Make sure is all builds.
This commit is contained in:
parent
2704eb8180
commit
ad2aa40d47
@ -37,6 +37,10 @@
|
||||
"eslint": "3.2.0",
|
||||
"rimraf": "2.5.4",
|
||||
"rollup-plugin-json": "2.1.0",
|
||||
"rollup-plugin-babel": "^2.7.1",
|
||||
"uglifyjs": "2.4.10"
|
||||
},
|
||||
"dependencies": {
|
||||
"trimkit": "^1.0.2"
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,15 @@
|
||||
import json from 'rollup-plugin-json';
|
||||
import babel from 'rollup-plugin-babel';
|
||||
|
||||
const babelConfig = {
|
||||
env: {
|
||||
es6: true,
|
||||
browser: true
|
||||
},
|
||||
plugins: [],
|
||||
presets: ['stage-0', 'es2015-rollup']
|
||||
};
|
||||
|
||||
export default {
|
||||
entry: 'src/index.js',
|
||||
format: 'umd',
|
||||
|
||||
@ -2,11 +2,7 @@ import { isFunction, isUndefined, Null, ObjectKeys } from 'trimkit';
|
||||
|
||||
function nop() {}
|
||||
|
||||
export function Router(
|
||||
baseUrl: string,
|
||||
routes: RouteSpecType,
|
||||
unmatched: UnmatchedFunctionType
|
||||
): RouterApiType {
|
||||
export function Router(baseUrl, routes, unmatched) {
|
||||
let listening = false;
|
||||
let currentRoute = 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);
|
||||
|
||||
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];
|
||||
if (!route) {
|
||||
throw new Error(`Invalid route ${routeName}.`);
|
||||
@ -111,11 +107,11 @@ export function Router(
|
||||
return `${baseUrl}${path}`;
|
||||
}
|
||||
|
||||
function _location(): string {
|
||||
function _location() {
|
||||
return location.hash;
|
||||
}
|
||||
|
||||
function listen(initialRoute: string): void {
|
||||
function listen(initialRoute) {
|
||||
if (listening) {
|
||||
return;
|
||||
}
|
||||
@ -125,7 +121,7 @@ export function Router(
|
||||
goto(_location() || initialRoute);
|
||||
}
|
||||
|
||||
function current(): RouteInfoType | null {
|
||||
function current() {
|
||||
return currentRoute;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user