-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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): allow custom NODE_ENV
for vite dev
#7980
fix(remix-dev/vite): allow custom NODE_ENV
for vite dev
#7980
Conversation
🦋 Changeset detectedLatest commit: 0269019 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 |
skipEnvCheck
for react-refresh/babel
pluginskipEnvCheck
for react-refresh/babel
plugin
skipEnvCheck
for react-refresh/babel
pluginskipEnvCheck
for react-refresh/babel
plugin to allow any NODE_ENV
skipEnvCheck
for react-refresh/babel
plugin to allow any NODE_ENV
NODE_ENV
for vite dev
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.
Thanks for the PR!
🤖 Hello there, We just published version Thanks! |
🤖 Hello there, We just published version Thanks! |
Closes: #7918
This can be achieved by
skipEnvCheck: true
forreact-refresh/babel
plugin, andLiveReload
to checkviteCommand = "serve"
instead ofNODE_ENV = "development"
I initially thought the error
"React Refresh Babel transform should only be enabled in development environment."
only manifests when remix plugin is (unintentionally) loaded on vitest, but I found that this can also happen, for example, when doingNODE_ENV=test vite dev
.So, I think it makes sense to disable this check (and also allow HMR) for other NODE_ENV as well since it looks like too-opinionated restriction. Also remix itself applies this transform only on
"serve"
command, so such warning is irrelevant.Also note that this is yet-another compatibility with
@vitejs/plugin-react
, which also usesskipEnvCheck: true
:https://github.com/vitejs/vite-plugin-react/blob/38b3cece51644f3d4ba78e2352717b5077bd4637/packages/plugin-react/src/index.ts#L196-L199
Testing Strategy:
I didn't add a test case since it felt a little redundant. But, to verify the behavior, I locally checked
vite-dev-test.ts
still passes after manually modifyingNODE_ENV: "test"
here:remix/integration/vite-dev-test.ts
Lines 205 to 209 in 25181c6