From 09b5f5ff1310f813ef9331b84649cc83eb981e53 Mon Sep 17 00:00:00 2001 From: Nytelife26 Date: Sun, 21 Feb 2021 16:48:36 +0000 Subject: [PATCH 1/2] docs: suggest import mapping for newer versions --- README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.md b/README.md index 056571e..c5f9d5f 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,21 @@ import module from 'my_private_module' **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. +## IMPORTANT - Node v14.6.0+ + +**WARNING:** If you are using Node v14.6.0 or above, you do not need this +package. A feature was added in Node v14.6.0 called import mapping - you can +find more at the [documentation]. This enables you to map from both import paths +AND dependencies, for both `require` and ESM `import` statements, without +potentially breaking the module resolution order for other packages in a project +(which makes it fully suitable for libraries and a better alternative to this +package). + +We will not be deprecating this package so people can still use it for older +versions of Node. + +[documentation]: https://nodejs.org/api/packages.html#packages_imports + ## Install ``` @@ -169,6 +184,8 @@ You can use `module-alias` within another NPM package, however there are a few t Here is an [example project](https://github.com/Kehrlann/module-alias-library). +See [the aforementioned section](#important---node-v1460) for more information +and if you wish to avoid this behaviour (Node 14.6.0+ only). ## Known incompatibilities From 76681ff777e992156feebd09f1fa840d5f328b37 Mon Sep 17 00:00:00 2001 From: Nytelife26 Date: Mon, 22 Feb 2021 13:43:12 +0000 Subject: [PATCH 2/2] docs: format & more examples --- README.md | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index c5f9d5f..38dd481 100644 --- a/README.md +++ b/README.md @@ -33,16 +33,20 @@ import module from 'my_private_module' **WARNING:** If you are using Node v14.6.0 or above, you do not need this package. A feature was added in Node v14.6.0 called import mapping - you can -find more at the [documentation]. This enables you to map from both import paths -AND dependencies, for both `require` and ESM `import` statements, without -potentially breaking the module resolution order for other packages in a project -(which makes it fully suitable for libraries and a better alternative to this -package). +find more at the official [documentation] site. This enables you to map from +both import paths AND dependencies, for both `require` and ESM `import` +statements, without potentially breaking the module resolution order for other +packages in a project (which makes it fully suitable for libraries and a better +alternative to this package). + +For further explanation on how to use this to replace `module-alias`, there +are [more examples] in the documentation specifically focused on path imports. We will not be deprecating this package so people can still use it for older versions of Node. [documentation]: https://nodejs.org/api/packages.html#packages_imports +[more examples]: https://nodejs.org/api/packages.html#packages_subpath_imports ## Install