Skip to content

Commit

Permalink
Add an explicit warning if the path-to-regexp version is wrong
Browse files Browse the repository at this point in the history
  • Loading branch information
taion committed Jun 8, 2017
1 parent 8dcd841 commit 280b427
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
"dependencies": {
"babel-runtime": "^6.23.0",
"farce": "^0.2.1",
"invariant": "^2.2.2",
"is-promise": "^2.1.0",
"lodash": "^4.17.4",
"path-to-regexp": "^1.7.0",
Expand Down
10 changes: 10 additions & 0 deletions src/Matcher.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
import isEqual from 'lodash/isEqual';
import pathToRegexp from 'path-to-regexp';
import warning from 'warning';

export default class Matcher {
constructor(routeConfig) {
this.routeConfig = routeConfig;

// Overly-aggressive deduplication of packages can lead to the wrong
// version of path-to-regexp getting bundled. This is a common enough
// failure mode that it's worthwhile to add a dev-only warning here.
warning(
typeof pathToRegexp.compile === 'function',
'Incorrect version of path-to-regexp imported. If this is running ' +
'from a client bundle, check your bundler settings.',
);
}

match({ pathname }) {
Expand Down

0 comments on commit 280b427

Please sign in to comment.