From b81f6d65f3621bde6ffd411fe05f68712247e52c Mon Sep 17 00:00:00 2001 From: Victor Lin <13424970+victorlin@users.noreply.github.com> Date: Tue, 22 Nov 2022 14:53:26 -0800 Subject: [PATCH] =?UTF-8?q?webpack=20v4=20=E2=86=92=20v5=20polyfill=20conf?= =?UTF-8?q?iguration?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Install buffer and add a fallback to retain original behavior. Note that this increases the overall bundle size, so increase the bundlesize check by an additional 1kB. Original error message that showed before these changes: webpack < 5 used to include polyfills for node.js core modules by default. This is no longer the case. Verify if you need this module and configure a polyfill for it. If you want to include a polyfill, you need to: - add a fallback 'resolve.fallback: { "buffer": require.resolve("buffer/") }' - install 'buffer' If you don't want to include a polyfill, you can use an empty module like this: resolve.fallback: { "buffer": false } --- bundlesize.config.json | 2 +- package-lock.json | 15 +++++++++++---- package.json | 1 + webpack.config.js | 1 + 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/bundlesize.config.json b/bundlesize.config.json index 0b5d9cea7..9019fb86c 100644 --- a/bundlesize.config.json +++ b/bundlesize.config.json @@ -2,7 +2,7 @@ "files": [ { "path": "./dist/auspice.bundle.*.js", - "maxSize": "2 kB" + "maxSize": "3 kB" }, { "path": "./dist/auspice.chunk.+([0-9]).bundle.*.js", diff --git a/package-lock.json b/package-lock.json index b5ea5eadc..9b7f58d90 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3302,8 +3302,7 @@ "base64-js": { "version": "1.5.1", "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", - "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", - "dev": true + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==" }, "bcrypt-pbkdf": { "version": "1.0.2", @@ -3508,6 +3507,15 @@ "node-int64": "^0.4.0" } }, + "buffer": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", + "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", + "requires": { + "base64-js": "^1.3.1", + "ieee754": "^1.2.1" + } + }, "buffer-crc32": { "version": "0.2.13", "resolved": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.13.tgz", @@ -6706,8 +6714,7 @@ "ieee754": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", - "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", - "dev": true + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==" }, "iferr": { "version": "0.1.5", diff --git a/package.json b/package.json index 107615f49..60a5166c2 100644 --- a/package.json +++ b/package.json @@ -52,6 +52,7 @@ "babel-plugin-strip-function-call": "^1.0.2", "babel-plugin-styled-components": "^1.10.0", "binomial": "^0.2.0", + "buffer": "^6.0.3", "chalk": "^2.4.1", "clean-webpack-plugin": "^4.0.0", "compression": "^1.7.3", diff --git a/webpack.config.js b/webpack.config.js index a66102dd7..5f760b60a 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -192,6 +192,7 @@ const generateConfig = ({extensionPath, devMode=false, customOutputPath, analyze resolve: { alias: aliasesToResolve, fallback: { + buffer: require.resolve("buffer/"), fs: false } },