From e91793b934b467763c1a7cecd917f9787827d65d Mon Sep 17 00:00:00 2001 From: Oliver Eyton-Williams Date: Sat, 27 Mar 2021 14:49:30 +0100 Subject: [PATCH] fix(client): polyfill path with path-browserify (#41615) path is being used by webpack to transform imports into requires. Since some challenges rely on this transformation, path has to exist in the browser. --- client/gatsby-node.js | 2 +- client/package-lock.json | 5 +++++ client/package.json | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/client/gatsby-node.js b/client/gatsby-node.js index 7a2618593f..f6cf66bf89 100644 --- a/client/gatsby-node.js +++ b/client/gatsby-node.js @@ -204,7 +204,7 @@ exports.onCreateWebpackConfig = ({ stage, plugins, actions }) => { resolve: { fallback: { fs: false, - path: false, + path: require.resolve('path-browserify'), assert: require.resolve('assert'), crypto: require.resolve('crypto-browserify'), util: false, diff --git a/client/package-lock.json b/client/package-lock.json index d44c0722be..d8ab8f6052 100644 --- a/client/package-lock.json +++ b/client/package-lock.json @@ -18989,6 +18989,11 @@ "cross-spawn": "^6.0.5" } }, + "path-browserify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-1.0.1.tgz", + "integrity": "sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g==" + }, "path-dirname": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/path-dirname/-/path-dirname-1.0.2.tgz", diff --git a/client/package.json b/client/package.json index d88b5d1fc9..ec6b089315 100644 --- a/client/package.json +++ b/client/package.json @@ -50,6 +50,7 @@ "lodash": "^4.17.21", "monaco-editor": "^0.22.3", "nanoid": "^3.1.22", + "path-browserify": "^1.0.1", "prismjs": "^1.23.0", "process": "^0.11.10", "query-string": "^6.14.1",