react-refresh-webpack-plugin icon indicating copy to clipboard operation
react-refresh-webpack-plugin copied to clipboard

On pure ESM project this plugin cause some weird error

Open otakustay opened this issue 2 years ago • 3 comments

Sorry that I'm not able to clearly state what happened in the issue title.

Reproduce

  1. Clonse https://github.com/otakustay/issues/tree/react-refresh-plugin-esm branch
  2. git checkout react-refresh-plugin-esm branch
  3. pnpm install, you need to have pnpm installed with npm i -g pnpm
  4. cd packages/app
  5. $(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:

  1. Remove "type": "module" from package.json
  2. Or remove ReactRefreshWebpackPlugin from webpack.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.

otakustay avatar Dec 29 '21 10:12 otakustay

I just ran afoul of this, as well. @otakustay did you ever find a solution?

Twipped avatar Jun 02 '22 22:06 Twipped

I've managed to figure out that this is specifically an issue with the resolver not following symlinks when ReactRefreshWebpackPlugin is in use.

Twipped avatar Jun 02 '22 23:06 Twipped

I'm running into this as well.

jacob-ebey avatar Jun 04 '22 20:06 jacob-ebey