Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incompatible with React 18 #621

Closed
bradenmitchell opened this issue Mar 31, 2022 · 11 comments
Closed

Incompatible with React 18 #621

bradenmitchell opened this issue Mar 31, 2022 · 11 comments

Comments

@bradenmitchell
Copy link

The react and react-dom libraries have been updated to version 18. Using version 18 with the react-refresh and this webpack plugin throws the following error when running webpack dev server:

ERROR in ./src/index.tsx
Module build failed (from ./node_modules/@pmmmwh/react-refresh-webpack-plugin/loader/index.js):
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './runtime.js' is not defined by "exports" in /Users/Braden/Projects/test-app/node_modules/react-refresh/package.json
    at new NodeError (node:internal/errors:371:5)
    at throwExportsNotFound (node:internal/modules/esm/resolve:453:9)
    at packageExportsResolve (node:internal/modules/esm/resolve:729:3)
    at resolveExports (node:internal/modules/cjs/loader:482:36)
    at Function.Module._findPath (node:internal/modules/cjs/loader:522:31)
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:27)
    at Function.resolve (node:internal/modules/cjs/helpers:108:19)
    at Object.<anonymous> (/Users/Braden/Projects/test-app/node_modules/@pmmmwh/react-refresh-webpack-plugin/loader/index.js:20:4)
    at Module._compile (node:internal/modules/cjs/loader:1103:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10)

ERROR in ./node_modules/@pmmmwh/react-refresh-webpack-plugin/client/ReactRefreshEntry.js 4:23-58
Module not found: Error: Package path ./runtime.js is not exported from package /Users/Braden/Projects/test-app/node_modules/react-refresh (see exports field in /Users/Braden/Projects/test-app/node_modules/react-refresh/package.json)

Versions
node: 16.14.0
react: 18.0.0
react-dom: 18.0.0
webpack: 5.70.0
webpack-dev-server: 4.7.4
react-refresh: 0.12.0
react-refresh-webpack-plugin: 0.5.4

Current work around is to disable react-refresh & react-refresh-webpack-plugin or downgrade to react/react-dom 17

@1111mp
Copy link

1111mp commented Mar 31, 2022

+1

@jussikinnula
Copy link

I tested, and apparently the master version works well. There has been changes this year to change imports from react-refresh/runtime.js to react-refresh' (in loader.js) and to react-refresh/runtime(inclient/ReactRefreshEntry.js`).

I tested with React 18 and changing my package.json dependency from:

"@pmmmwh/react-refresh-webpack-plugin": "^0.5.4",

to:

"@pmmmwh/react-refresh-webpack-plugin": "github:pmmmwh/react-refresh-webpack-plugin",

Works without issues.

@pmmmwh, could we have a new release from master? :-)

@ntucker
Copy link

ntucker commented Mar 31, 2022

This is fixed in #576 but we are all waiting on a version with this fix to be published.

Important to note that this is still compatible with React 18, just not react-refresh 0.12. react-refresh 0.11 still works with React 18.

@kimbaudi
Copy link

i agree that these errors are related to react-refresh 0.12.0 and not react 18. you should be able to use react 18 as long as you don't upgrade from react-refresh 0.11.0 to 0.12.0. we just need to wait for a newer release of react-refresh w/ the fix.

@moquette
Copy link

moquette commented Apr 1, 2022

I tested, and apparently the master version works well. There has been changes this year to change imports from react-refresh/runtime.js to react-refresh' (in loader.js) and to react-refresh/runtime(inclient/ReactRefreshEntry.js`).

I tested with React 18 and changing my package.json dependency from:

"@pmmmwh/react-refresh-webpack-plugin": "^0.5.4",

to:

"@pmmmwh/react-refresh-webpack-plugin": "github:pmmmwh/react-refresh-webpack-plugin",

Works without issues.

@pmmmwh, could we have a new release from master? :-)

I can confirm updating package.json with following changes fixes the issue.

"@pmmmwh/react-refresh-webpack-plugin": "github:pmmmwh/react-refresh-webpack-plugin",

@luckymore
Copy link

are you ok?

@luckymore

This comment was marked as off-topic.

@jussikinnula
Copy link

Thanks for noting this. Slava Ukraini.

I can take action and publish an npm package Tomorrow which could be used until we hear back from @pmmmwh.

@pmmmwh
Copy link
Owner

pmmmwh commented Apr 4, 2022

@jussikinnula I know the reason...

Hi, I really do not appreciate the attempt to misinterpret what I write on my PERSONAL Twitter account. The fixes just have not been released simply because I did not have the time and effort to go through more planned work.

Thanks for noting this. Slava Ukraini.

I can take action and publish an npm package Tomorrow which could be used until we hear back from @pmmmwh.

If you haven't done it, I would strongly advise against doing so to reduce fragmentation.

Fix is published in 0.5.5.

@pmmmwh pmmmwh closed this as completed Apr 4, 2022
@jussikinnula
Copy link

@pmmmwh, I agree that reducing fragmentation is very important.

I haven't published anything and of course I will not publish anything.

And I'm very sorry for the misinterpretation from my behalf.

@justin808
Copy link

justin808 commented May 3, 2022

If React 18 is supported, does the home page need updating?

BTW, thanks @pmmmwh for your excellent work! I'm maintaining https://github.com/shakacode/react_on_rails and https://github.com/shakacode/shakapacker, and this is a crucial part of the puzzle.

image

CC: @tomdracz.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants