From 2a62eb3f66cdcbc867b1f7e05d2b6bc683f28825 Mon Sep 17 00:00:00 2001 From: Daniel Garnier-Moiroux Date: Tue, 12 Nov 2019 07:56:49 +0100 Subject: [PATCH 1/2] Update doc: add known incompatible tools - Closes #81 --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index c23793c..ac5d471 100644 --- a/README.md +++ b/README.md @@ -143,6 +143,16 @@ module.exports = { } ``` +More details on the [official documentation](https://webpack.js.org/configuration/resolve). + +## Known incompatibilities + +This module does not play well with: + +- [Jest](https://jestjs.io), which discards node's module system entirely to use it's own module system, bypassing module-alias. +- All kinds of front-end frameworks (React, Vue, ...), as they tend to use Webpack. Use Webpack's [resolve.alias](https://webpack.js.org/configuration/resolve/#resolvealias) mechanism instead. +- The [NCC compiler](https://github.com/zeit/ncc), as it uses WebPack under the hood without exposing properties, such as resolve.alias. It is not [something they wish to do](https://github.com/zeit/ncc/pull/460). + ## How it works? In order to register an alias it modifies the internal `Module._resolveFilename` method so that when you use `require` or `import` it first checks whether the given string starts with one of the registered aliases, if so, it replaces the alias in the string with the target path of the alias. From 6cd3de326f20479198e25fc9b10bbff6a0a71cdf Mon Sep 17 00:00:00 2001 From: Daniel Garnier-Moiroux Date: Fri, 22 Nov 2019 11:52:37 +0100 Subject: [PATCH 2/2] Warn about front-end frameworks first in the list of incompatibilities --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ac5d471..a866d5b 100644 --- a/README.md +++ b/README.md @@ -149,8 +149,8 @@ More details on the [official documentation](https://webpack.js.org/configuratio This module does not play well with: +- Front-end JavaScript code. Module-alias is designed for server side so do not expect it to work with front-end frameworks (React, Vue, ...) as they tend to use Webpack. Use Webpack's [resolve.alias](https://webpack.js.org/configuration/resolve/#resolvealias) mechanism instead. - [Jest](https://jestjs.io), which discards node's module system entirely to use it's own module system, bypassing module-alias. -- All kinds of front-end frameworks (React, Vue, ...), as they tend to use Webpack. Use Webpack's [resolve.alias](https://webpack.js.org/configuration/resolve/#resolvealias) mechanism instead. - The [NCC compiler](https://github.com/zeit/ncc), as it uses WebPack under the hood without exposing properties, such as resolve.alias. It is not [something they wish to do](https://github.com/zeit/ncc/pull/460). ## How it works?