pmmmwh / react-refresh-webpack-plugin

A Webpack plugin to enable "Fast Refresh" (also previously known as Hot Reloading) for React components.
MIT License
3.13k stars 194 forks source link

Relative imports outside of src/ are not supported. #770

Closed auxon closed 3 months ago

auxon commented 1 year ago

I get this error on MacOS but not Windows:

Module not found: Error: You attempted to import /Users/rah/repos/web/ReaderCore/WebInterpreter/v3/node_modules/@pmmmwh/react-refresh-webpack-plugin/overlay/index.js which falls outside of the project src/ directory. Relative imports outside of src/ are not supported. You can either move it inside src/, or add a symlink to it from project's node_modules/.

This is the only module causing this issue. Any ideas?

I updated to the latest version today to see if it would be fixed but it's still a problem.

pmmmwh commented 1 year ago

This is an error from react-scripts I believe?

auxon commented 1 year ago

@pmmmwh I think so; I'm really confused by this one.

pmmmwh commented 1 year ago

Can you show more of your setup? Webpack, package.json, or however you are running your app?

auxon commented 1 year ago

@pmmmwh I made a new create-react-app with typescript installed after the fact, then eject it, and compared my webpack.config.js to the new one and just changed a few lines to put back my required customizations, and suddently it works again. It's very odd. I am trying to track down the difference that broke it.

auxon commented 1 year ago

Ah, it's the overlay set to true that causes the issue. The default for create-react-app is false, but I switched it to true. I guess there's an issue with this on Macs.

      new ReactRefreshWebpackPlugin({
        overlay: true,
      }),
auxon commented 1 year ago

@pmmmwh Confirmed ... you can duplicate the issue with a default create-react-app, ejected, and set the overlay to false in the webpack.config.js, but it doesn't seem to be an issue on Windows. I'm running on a Macbook Air M1 2020, with Ventura 13.4.1 (c) (22F770820d).

pmmmwh commented 3 months ago

This is a restriction from react-scripts - nothing to do with this plugin / it's compatibility.