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(gatsby): more reliable way to use prod versions of react/react-dom #29683

Merged
merged 4 commits into from
Feb 23, 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
17 changes: 0 additions & 17 deletions packages/gatsby/src/utils/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -697,23 +697,6 @@ module.exports = async (

config.externals = [
function (context, request, callback) {
if (
stage === `develop-html` &&
isCI() &&
process.env.GATSBY_EXPERIMENTAL_DEV_SSR
) {
if (request === `react`) {
callback(null, `react/cjs/react.production.min.js`)
return
} else if (request === `react-dom/server`) {
callback(
null,
`react-dom/cjs/react-dom-server.node.production.min.js`
)
return
}
}

const external = isExternal(request)
if (external !== null) {
callback(null, external)
Expand Down