Make sure is all builds.

This commit is contained in:
Timothy Farrell 2017-01-21 15:55:06 -06:00
parent e6e44beeee
commit 70e426fc20
3 changed files with 19 additions and 10 deletions

View File

@ -37,6 +37,10 @@
"eslint": "3.2.0", "eslint": "3.2.0",
"rimraf": "2.5.4", "rimraf": "2.5.4",
"rollup-plugin-json": "2.1.0", "rollup-plugin-json": "2.1.0",
"rollup-plugin-babel": "^2.7.1",
"uglifyjs": "2.4.10" "uglifyjs": "2.4.10"
},
"dependencies": {
"trimkit": "^1.0.2"
} }
} }

View File

@ -1,6 +1,15 @@
import json from 'rollup-plugin-json'; import json from 'rollup-plugin-json';
import babel from 'rollup-plugin-babel'; import babel from 'rollup-plugin-babel';
const babelConfig = {
env: {
es6: true,
browser: true
},
plugins: [],
presets: ['stage-0', 'es2015-rollup']
};
export default { export default {
entry: 'src/index.js', entry: 'src/index.js',
format: 'umd', format: 'umd',

View File

@ -2,11 +2,7 @@ import { isFunction, isUndefined, Null, ObjectKeys } from 'trimkit';
function nop() {} function nop() {}
export function Router( export function Router(baseUrl, routes, unmatched) {
baseUrl: string,
routes: RouteSpecType,
unmatched: UnmatchedFunctionType
): RouterApiType {
let listening = false; let listening = false;
let currentRoute = Null; let currentRoute = Null;
let reEnterHook = Null; let reEnterHook = Null;
@ -29,7 +25,7 @@ export function Router(
}; };
}); });
function goto(urlOrName: string, vars?: RouteVarsType) { function goto(urlOrName, vars) {
const url = urlOrName.startsWith(baseUrl) ? urlOrName : href(urlOrName, vars); const url = urlOrName.startsWith(baseUrl) ? urlOrName : href(urlOrName, vars);
if (listening && _location() !== url) { if (listening && _location() !== url) {
@ -89,7 +85,7 @@ export function Router(
} }
} }
function href(routeName: string, vars: RouteVarsType = {}): string { function href(routeName, vars) {
const route = routes[routeName]; const route = routes[routeName];
if (!route) { if (!route) {
throw new Error(`Invalid route ${routeName}.`); throw new Error(`Invalid route ${routeName}.`);
@ -111,11 +107,11 @@ export function Router(
return `${baseUrl}${path}`; return `${baseUrl}${path}`;
} }
function _location(): string { function _location() {
return location.hash; return location.hash;
} }
function listen(initialRoute: string): void { function listen(initialRoute) {
if (listening) { if (listening) {
return; return;
} }
@ -125,7 +121,7 @@ export function Router(
goto(_location() || initialRoute); goto(_location() || initialRoute);
} }
function current(): RouteInfoType | null { function current() {
return currentRoute; return currentRoute;
} }