-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Define process.env.NODE_ENV
in build process.
#10553
Conversation
@@ -31,6 +31,9 @@ export async function rscBuildClient(clientEntryFiles: Record<string, string>) { | |||
|
|||
const clientBuildOutput = await viteBuild({ | |||
envFile: false, | |||
define: { |
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.
Does having define
here, and in the other viteBuild
invocations, interfere with what we do in getMergedConfig.ts
where we set define: getEnvVarDefinitions()
?
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.
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.
It's used by every Redwood App (that has Vite setup, which they all do by default now)
If you look in the kitchen-sink test project inside web/vite.config.ts
it imports it as redwood
from @redwoodjs/vite
.
And then at least rscBuildAnalyze
uses that config file by doing configFile: rwPaths.web.viteConfig
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.
Oooh, ok! Let me look into that!
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.
I don't think it'll interfere; the only place where I modify, and we include the default config is here:
configFile: rwPaths.web.viteConfig, |
NODE_ENV
will be replaced appropriately as part of the build process.
…uth-store * 'main' of github.com:redwoodjs/redwood: chore(router): Add more code comments to analyzeRoutes (#10569) RSC: No need to use memo or useMemo in the server router (#10568) RSC: getViteConfig in rscWorker (#10567) Split RSC and RSA handling in rscWorker (#10565) RSC: Extract the fetchRSC function (#10564) RSC: Fix TODO regarding SSR in client.ts (#10562) Docs: QoL Updates to Contributing.md (#10561) Added warning note to not add WebAuthn (#10231) fix(rsc): Load all css links to support css with rsc (#10544) fix(cli): Add deprecation notice for edgio deployment (#10551) Define `process.env.NODE_ENV` in build process. (#10553) chore(docs): Update dbAuth and Supabase middleware READMEs (#10552) chore(deps): Upgrade React 19 to beta 20240508 (#10560) Revert "chore(deps): React beta 20240508 (#10558)" (#10559) chore(deps): React beta 20240508 (#10558) fix(functions): Fix context variable warning/error (#10556) fix(functions): Mock context in function test template (#10555) chore(middleware): Format code and comments and fix comment grammar (#10554)
This fixes a bug where RSC would complain about the Client using the development version of React whilst the server was using the production version. The reason for this is
that Vite's bundling process it replaces "process.env.NODE_ENV" with the values specified in the define configuration. Supplying this configuration option during the build
process ensures that we're using the same version of React.