diff --git a/.size-snapshot.json b/.size-snapshot.json index c9b0bf5e6..c7ccafb94 100644 --- a/.size-snapshot.json +++ b/.size-snapshot.json @@ -1,26 +1,26 @@ { "esm/history.js": { - "bundled": 28076, - "minified": 12353, - "gzipped": 3575, + "bundled": 29006, + "minified": 13074, + "gzipped": 3778, "treeshaked": { "rollup": { "code": 208, "import_statements": 132 }, "webpack": { - "code": 1324 + "code": 2207 } } }, "umd/history.js": { - "bundled": 33021, - "minified": 11943, - "gzipped": 3917 + "bundled": 33889, + "minified": 12474, + "gzipped": 4193 }, "umd/history.min.js": { - "bundled": 30384, - "minified": 9993, - "gzipped": 3501 + "bundled": 31154, + "minified": 10143, + "gzipped": 3541 } } diff --git a/modules/deprecate.js b/modules/deprecate.js new file mode 100644 index 000000000..9261bfcbc --- /dev/null +++ b/modules/deprecate.js @@ -0,0 +1,10 @@ +import warning from './warning.js'; + +export default function deprecate(fn, message) { + let alreadyWarned = false; + return function() { + warning(alreadyWarned, message); + alreadyWarned = true; + return fn.apply(this, arguments); + }; +} diff --git a/modules/index.js b/modules/index.js index b02317ddb..48ec4f1c3 100644 --- a/modules/index.js +++ b/modules/index.js @@ -1,5 +1,24 @@ -export { default as createBrowserHistory } from './createBrowserHistory'; -export { default as createHashHistory } from './createHashHistory'; -export { default as createMemoryHistory } from './createMemoryHistory'; -export { createLocation, locationsAreEqual } from './LocationUtils'; -export { parsePath, createPath } from './PathUtils'; +export { default as createBrowserHistory } from './createBrowserHistory.js'; +export { default as createHashHistory } from './createHashHistory.js'; +export { default as createMemoryHistory } from './createMemoryHistory.js'; +export { parsePath, createPath } from './PathUtils.js'; + +import deprecate from './deprecate.js'; +import { createLocation, locationsAreEqual } from './LocationUtils.js'; + +const deprecatedCreateLocation = deprecate( + createLocation, + 'createLocation is deprecated and will be removed in the next major release.' + + ' To create a location object from a URL string, use `location = parsePath(url)` instead.' +); + +const deprecatedLocationsAreEqual = deprecate( + locationsAreEqual, + 'locationsAreEqual is deprecated and will be removed in the next major release.' + + ' To check if two location objects represent the same location, compare `locationA.key === locationB.key` instead.' +); + +export { + deprecatedCreateLocation as createLocation, + deprecatedLocationsAreEqual as locationsAreEqual +};