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

fix(DEV_SSR): set NODE_ENV to production for render-html worker process instead of pointing externals to production react #29620

Merged
merged 3 commits into from
Feb 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion packages/gatsby/src/utils/dev-ssr/render-dev-html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import JestWorker from "jest-worker"
import fs from "fs-extra"
import { joinPath } from "gatsby-core-utils"
import report from "gatsby-cli/lib/reporter"
import { isCI } from "gatsby-core-utils"

import { startListener } from "../../bootstrap/requires-writer"
import { findPageByPath } from "../find-page-by-path"
Expand All @@ -13,7 +14,15 @@ const startWorker = (): any => {
const newWorker = new JestWorker(require.resolve(`./render-dev-html-child`), {
exposedMethods: [`renderHTML`, `deleteModuleCache`, `warmup`],
numWorkers: 1,
forkOptions: { silent: false },
forkOptions: {
silent: false,
env: {
...process.env,
NODE_ENV: isCI() ? `production` : `development`,
forceColors: true,
GATSBY_EXPERIMENTAL_DEV_SSR: true,
},
},
})

// jest-worker is lazy with forking but we want to fork immediately so the user
Expand Down
14 changes: 1 addition & 13 deletions packages/gatsby/src/utils/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -692,20 +692,8 @@ module.exports = async (
// User modules that do not need to be part of the bundle
if (userExternalList.some(item => checkItem(item, request))) {
// TODO figure out to make preact work with this too
let modifiedRequest = request
if (
stage === `develop-html` &&
isCI() &&
process.env.GATSBY_EXPERIMENTAL_DEV_SSR
) {
if (request === `react`) {
modifiedRequest = `react/cjs/react.production.min.js`
} else if (request === `react-dom/server`) {
modifiedRequest = `react-dom/cjs/react-dom-server.node.production.min.js`
}
}

resolver(context, modifiedRequest, (err, newRequest) => {
resolver(context, request, (err, newRequest) => {
if (err) {
callback(err)
return
Expand Down