react-refresh-webpack-plugin
react-refresh-webpack-plugin copied to clipboard
On pure ESM project this plugin cause some weird error
Sorry that I'm not able to clearly state what happened in the issue title.
Reproduce
- Clonse https://github.com/otakustay/issues/tree/react-refresh-plugin-esm branch
-
git checkout react-refresh-plugin-esm branch
-
pnpm install
, you need to have pnpm installed withnpm i -g pnpm
-
cd packages/app
-
$(npm bin)/webpack-dev-server
Issue
You will see an error in terminal:
ERROR in ./src/index.js 6:45-50
export 'value' (imported as 'value') was not found in '@me/lib' (module has no exports)
Also there is an error in browser's console:
Uncaught ReferenceError: exports is not defined
Expected
You can get rid of this error by either:
- Remove
"type": "module"
frompackage.json
- Or remove
ReactRefreshWebpackPlugin
fromwebpack.config.cjs
So this issue is raised when an app is "type": "module"
and also having @pmmmwh/react-refresh-webpack-plugin
configured
Run $(npm bin)/webpack
also encounters this issue, not sure how this plugin affects the resolve and build of webpack.
I just ran afoul of this, as well. @otakustay did you ever find a solution?
I've managed to figure out that this is specifically an issue with the resolver not following symlinks when ReactRefreshWebpackPlugin is in use.
I'm running into this as well.