From a08c8a0424da388bc4b2d5c77265ff7970ab8160 Mon Sep 17 00:00:00 2001 From: Chitoku Date: Thu, 4 Jan 2024 00:36:56 +0900 Subject: [PATCH] fix(gatsby): support builtin modules prefixed with `node:` on `build-html` (#38516) --- packages/gatsby/src/utils/webpack.config.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/gatsby/src/utils/webpack.config.js b/packages/gatsby/src/utils/webpack.config.js index 1be2b316ddbff..5938b1adad3fc 100644 --- a/packages/gatsby/src/utils/webpack.config.js +++ b/packages/gatsby/src/utils/webpack.config.js @@ -872,14 +872,17 @@ module.exports = async ( const builtinsExternalsDictionary = builtinModules.reduce( (acc, builtinModule) => { if (builtinModulesToTrack.includes(builtinModule)) { - acc[builtinModule] = `commonjs ${path.join( + const builtinModuleTracked = path.join( program.directory, `.cache`, `ssr-builtin-trackers`, builtinModule - )}` + ) + acc[builtinModule] = `commonjs ${builtinModuleTracked}` + acc[`node:${builtinModule}`] = `commonjs ${builtinModuleTracked}` } else { acc[builtinModule] = `commonjs ${builtinModule}` + acc[`node:${builtinModule}`] = `commonjs ${builtinModule}` } return acc },