Skip to content

Commit 9a9819c

Browse files
committed
Fix webpack config
1 parent 7412e66 commit 9a9819c

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

webpack.config.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import TerserPlugin from "terser-webpack-plugin";
22
import { fileURLToPath } from "url";
33
import path from "path";
44
import fs from "fs";
5+
import webpack from "webpack";
56

67
const __dirname = path.dirname(fileURLToPath(import.meta.url));
78

@@ -142,8 +143,8 @@ const NODE_EXTERNAL_MODULES = [
142143
"node:url",
143144
];
144145

145-
// Do not bundle onnxruntime-node when packaging for the web.
146-
const WEB_IGNORE_MODULES = ["onnxruntime-node"];
146+
// Do not bundle onnxruntime-node or sharp when packaging for the web.
147+
const WEB_IGNORE_MODULES = ["onnxruntime-node", "sharp"];
147148

148149
// Do not bundle the following modules with webpack (mark as external)
149150
const WEB_EXTERNAL_MODULES = [
@@ -157,12 +158,23 @@ const WEB_BUILD = buildConfig({
157158
type: "module",
158159
ignoreModules: WEB_IGNORE_MODULES,
159160
externalModules: WEB_EXTERNAL_MODULES,
161+
plugins: [
162+
new webpack.IgnorePlugin({
163+
resourceRegExp: /^node:/,
164+
}),
165+
]
160166
});
161167

162168
// Web-only build, bundled with onnxruntime-web
163169
const BUNDLE_BUILD = buildConfig({
164170
type: "module",
165-
plugins: [new PostBuildPlugin()],
171+
ignoreModules: WEB_IGNORE_MODULES,
172+
plugins: [
173+
new webpack.IgnorePlugin({
174+
resourceRegExp: /^node:/,
175+
}),
176+
new PostBuildPlugin(),
177+
],
166178
});
167179

168180
// Node-compatible builds

0 commit comments

Comments
 (0)