You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Background: Create React App comes with a ModuleScopePlugin which ensures that relative imports from app's source directories don't reach outside of it, meaning whatever you're importing has to be either in src/ or node_modules.
But our plugin node-polyfill-webpack-plugin uses webpack require.resolve, which returns the absolute path of packages
If we trying to use console or path polyfill with CRA
This issue is relevant for Linux or Unix platforms (e.g. Ubuntu, Mac OS), on Windows everything works properly. This is not node-polyfill-webpack-pluginor ModuleScopePlugin problem.
There is open issue on the topic in enhanced-resolve library repo - webpack/enhanced-resolve#308 Fallback node module been resolved with absolute path which starts with / (filesystem root) on Linux/Unix. On Windows it also resolves with absolute path, but it starts with drive letter, and so there everything works properly.
Edit: Actually it may be ModuleScopePlugin problem, because webpack documentation states that On non-Windows systems these requests are resolved as an absolute path first, so enhanced-resolve works as intended which means that ModuleScopePlugin just does not handle properly this case as it was written before roots option was introduced in webpack 4.44.
Background:
Create React App
comes with a ModuleScopePlugin which ensures that relative imports from app's source directories don't reach outside of it, meaning whatever you're importing has to be either insrc/
ornode_modules
.But our plugin
node-polyfill-webpack-plugin
uses webpackrequire.resolve
, which returns the absolute path of packagesIf we trying to use
console
orpath
polyfill with CRACRA would report error
I created a reproduce repository here node-polyfill-webpack-plugin-cra-reproduce
Some other info
The text was updated successfully, but these errors were encountered: