Skip to content

Commit 5cb550b

Browse files
committed
fix: add Node.js polyfills for webpack UMD build
Resolves webpack 5 build errors by adding polyfills for Node.js core modules that are no longer included by default. This fixes the GitHub workflow failure where the UMD build was failing with 'stream' module resolution errors. Changes: - Added webpack resolve.fallback configuration for Node.js modules - Installed stream-browserify, buffer, util, and url polyfill packages - Added ESLint directives for webpack.config.js CommonJS usage - UMD build now compiles successfully for browser environments Fixes the error: "Module not found: Error: Can't resolve 'stream' in helpers.ts" The stream module import is needed for Node.js Readable stream detection in helpers.ts but requires polyfills for browser compatibility.
1 parent bdfa175 commit 5cb550b

3 files changed

Lines changed: 120 additions & 0 deletions

File tree

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
"@types/ws": "^8.5.10",
7777
"@typescript-eslint/eslint-plugin": "^8.7.0",
7878
"@typescript-eslint/parser": "^8.7.0",
79+
"buffer": "^6.0.3",
7980
"cross-env": "^7.0.3",
8081
"dotenv": "^16.5.0",
8182
"eslint": "^8.57.1",
@@ -90,11 +91,14 @@
9091
"pretty-quick": "^3.1.3",
9192
"rimraf": "^3.0.2",
9293
"semantic-release-plugin-update-version-in-files": "^1.1.0",
94+
"stream-browserify": "^3.0.0",
9395
"ts-jest": "^29.1.2",
9496
"ts-loader": "^8.0.11",
9597
"ts-node": "^10.9.1",
9698
"typedoc": "^0.22.16",
9799
"typescript": "^4.5.5",
100+
"url": "^0.11.4",
101+
"util": "^0.12.5",
98102
"webpack": "^5.69.1",
99103
"webpack-cli": "^4.9.2",
100104
"yaml-lint": "^1.7.0"

pnpm-lock.yaml

Lines changed: 107 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webpack.config.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
/* eslint-env node */
2+
/* eslint-disable @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports */
3+
14
const path = require("path");
25

36
module.exports = {
@@ -23,5 +26,11 @@ module.exports = {
2326
},
2427
resolve: {
2528
extensions: [".ts", ".js", ".json"],
29+
fallback: {
30+
stream: require.resolve("stream-browserify"),
31+
buffer: require.resolve("buffer"),
32+
util: require.resolve("util"),
33+
url: require.resolve("url"),
34+
},
2635
},
2736
};

0 commit comments

Comments
 (0)