diff --git a/benchmark/index.js b/benchmark/index.js index 35b3d8e..b6e3783 100644 --- a/benchmark/index.js +++ b/benchmark/index.js @@ -1,6 +1,6 @@ 'use strict'; -/* eslint import/no-unresolved: 0*/ +/* eslint import/no-unresolved: 0 */ const Benchmark = require('benchmark'); const Route = require('route-parser'); const FnRoute = require('../src'); diff --git a/package.json b/package.json index 82a29d0..23bd1e3 100644 --- a/package.json +++ b/package.json @@ -45,6 +45,7 @@ "chai": "^3.5.0", "codecov": "^2.1.0", "commitizen": "^2.9.6", + "copy-webpack-plugin": "^4.6.0", "cross-env": "^4.0.0", "cz-conventional-changelog": "^2.0.0", "eslint": "^3.16.1", diff --git a/src/index.d.ts b/src/index.d.ts new file mode 100644 index 0000000..c0ad052 --- /dev/null +++ b/src/index.d.ts @@ -0,0 +1,13 @@ +export type RouteNamedSegments = { [key: string]: string }; + +export interface RouteMatcher { + route: string; + match(route?: string): RouteNamedSegments | false; +} + +export interface RouterOptions { + delimiter?: string; + namedSegment?: string; +} + +export default function Router(route?: string, options?: RouterOptions): RouteMatcher; diff --git a/webpack.config.js b/webpack.config.js index 71819f9..28465d5 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,9 +1,11 @@ 'use strict'; const BabiliPlugin = require('babili-webpack-plugin'); - +const CopyWebpackPlugin = require('copy-webpack-plugin'); const { join } = require('path'); +const copyTypings = new CopyWebpackPlugin(['src/index.d.ts']); + const isProduction = process.env.NODE_ENV === 'production'; const include = join(__dirname, 'src'); @@ -20,5 +22,7 @@ module.exports = { { test: /\.js$/, loader: 'babel-loader', include } ] }, - plugins: isProduction ? [new BabiliPlugin({}, { comments: false })] : [] + plugins: isProduction + ? [new BabiliPlugin({}, { comments: false }), copyTypings] + : [copyTypings] };