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): [rendering engines] use results of exports removal if sourceMap was not generated alongside transformed code (#37282) #37296

Merged
merged 1 commit into from
Dec 20, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ node node_modules/gatsby/dist/schema/graphql-engine/standalone-regenerate.js
*/

import { createGraphqlEngineBundle } from "./bundle-webpack"
import { createPageSSRBundle } from "./../../utils/page-ssr-module/bundle-webpack"
import reporter from "gatsby-cli/lib/reporter"
import { loadConfigAndPlugins } from "../../utils/worker/child/load-config-and-plugins"
import * as fs from "fs-extra"
import { store } from "../../redux"
import { validateEngines } from "../../utils/validate-engines"

async function run(): Promise<void> {
Expand All @@ -34,17 +36,30 @@ async function run(): Promise<void> {
console.log(`clearing webpack cache\n\n`)
// get rid of cache if it exist
await fs.remove(process.cwd() + `/.cache/webpack/query-engine`)
await fs.remove(process.cwd() + `/.cache/webpack/page-ssr`)
} catch (e) {
// eslint-disable no-empty
}

const state = store.getState()

// recompile
const buildActivityTimer = reporter.activityTimer(
`Building Rendering Engines`
)
try {
buildActivityTimer.start()
await createGraphqlEngineBundle(process.cwd(), reporter, true)
await Promise.all([
createGraphqlEngineBundle(process.cwd(), reporter, true),
createPageSSRBundle({
rootDir: process.cwd(),
components: store.getState().components,
staticQueriesByTemplate: state.staticQueriesByTemplate,
webpackCompilationHash: state.webpackCompilationHash, // we set webpackCompilationHash above
reporter,
isVerbose: state.program.verbose,
}),
])
} catch (err) {
buildActivityTimer.panic(err)
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ const webpackRemoveExportsLoader: LoaderDefinitionFunction<IOptions> =
(err, result) => {
if (err) {
callback(err)
} else if (result && result.code && result.map) {
callback(null, result?.code, result?.map)
} else if (result && result.code) {
callback(null, result?.code, result?.map ?? undefined)
} else {
callback(null, source, sourceMap)
}
Expand Down