-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
fix(remix-dev/vite): fix react-refresh/babel
plugin resolution
#7904
fix(remix-dev/vite): fix react-refresh/babel
plugin resolution
#7904
Conversation
🦋 Changeset detectedLatest commit: 7f803e0 The changes in this PR will be included in the next version bump. This PR includes changesets to release 16 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
react-refresh/babel
plugin resolution error when custom server with pnpmreact-refresh/babel
plugin resolution error when custom server with pnpm during development
I see firefox integration test failed on CI, but I cannot reproduce it locally:
EDIT: It seems CI passed after re-run. |
react-refresh/babel
plugin resolution error when custom server with pnpm during developmentreact-refresh/babel
plugin resolution
b1248ab
to
0e96075
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hi-ogawa thanks, looks great!
🤖 Hello there, We just published version Thanks! |
🤖 Hello there, We just published version Thanks! |
Closes: #7905
I think this error is caused by the combination of:
plugins
option is passed as a string (not sure what rule exactly...)node ./server.mjs
), the base of such resolution becomes user's root directory.react-refresh
package (transitive dependency of@remix-run/dev
) is not visible from root directory when using pnpm's non-flatnode_modules
,Looking at
vite-plugin-react
, they indeed resolve plugin library on its own then pass toplugins
option ofbabel.transformAsync
(see "additional notes" below).So this PR align with it in a similar way by directly calling
require("react-refresh/babel")
within@remix-run/dev
.I think the reason why this issue doesn't manifest when running a server via
remix
cli is that, in that case, the babel plugin resolution starts from@remix-run/dev
package directory andnode_modules/react-refresh
dependency is visible from that directory.(Additional notes)
vite-plugin-react
currently does dynamicimport
with own caching to resolve babel plugin https://github.com/vitejs/vite-plugin-react/blob/b255776f75ced38e9ae8d0ba2f9113e697159a73/packages/plugin-react/src/index.ts#L197, but they were also usingrequire("react-refresh/babel")
before package migration done in vitejs/vite-plugin-react@e999b23 (see the deleted filepackages/plugin-react/src/index.js
).Testing Strategy:
I verified this fix the issue on pnpm by applying a patch in the reproduction example via
pnpm patch / patch-commit
: