Skip to content

Commit e9d854c

Browse files
committed
add 'polyfill' for node: protocol in e2e/prod
1 parent edce092 commit e9d854c

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

e2e-tests/production-runtime/gatsby-config.js

+17
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,23 @@ const {
22
data: headFunctionExportData,
33
} = require(`./shared-data/head-function-export.js`)
44

5+
try {
6+
require(`node:path`)
7+
} catch (e) {
8+
console.warn(
9+
`Used node version doesn't support "node:" imports protocol, adding polyfill`
10+
)
11+
12+
const mod = require("module")
13+
const originalModuleLoad = mod._load
14+
mod._load = (request, parent, isMain) => {
15+
if (request.startsWith(`node:`)) {
16+
request = request.replace(`node:`, ``)
17+
}
18+
return originalModuleLoad(request, parent, isMain)
19+
}
20+
}
21+
522
module.exports = {
623
siteMetadata: {
724
title: `Gatsby Default Starter`,

0 commit comments

Comments
 (0)