Skip to content

Commit d92f3de

Browse files
authored
docs: suggest import mapping for newer versions (#114)
1 parent 86b3f73 commit d92f3de

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,25 @@ import module from 'my_private_module'
3636

3737
**WARNING:** If you are going to use this package within another NPM package, please read [Using within another NPM package](#using-within-another-npm-package) first to be aware of potential caveats.
3838

39+
## IMPORTANT - Node v14.6.0+
40+
41+
**WARNING:** If you are using Node v14.6.0 or above, you do not need this
42+
package. A feature was added in Node v14.6.0 called import mapping - you can
43+
find more at the official [documentation] site. This enables you to map from
44+
both import paths AND dependencies, for both `require` and ESM `import`
45+
statements, without potentially breaking the module resolution order for other
46+
packages in a project (which makes it fully suitable for libraries and a better
47+
alternative to this package).
48+
49+
For further explanation on how to use this to replace `module-alias`, there
50+
are [more examples] in the documentation specifically focused on path imports.
51+
52+
We will not be deprecating this package so people can still use it for older
53+
versions of Node.
54+
55+
[documentation]: https://nodejs.org/api/packages.html#packages_imports
56+
[more examples]: https://nodejs.org/api/packages.html#packages_subpath_imports
57+
3958
## Install
4059

4160
```
@@ -176,6 +195,8 @@ You can use `module-alias` within another NPM package, however there are a few t
176195

177196
Here is an [example project](https://github.com/Kehrlann/module-alias-library).
178197

198+
See [the aforementioned section](#important---node-v1460) for more information
199+
and if you wish to avoid this behaviour (Node 14.6.0+ only).
179200

180201
## Known incompatibilities
181202

0 commit comments

Comments
 (0)