@@ -2,6 +2,7 @@ import TerserPlugin from "terser-webpack-plugin";
22import { fileURLToPath } from "url" ;
33import path from "path" ;
44import fs from "fs" ;
5+ import webpack from "webpack" ;
56
67const __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)
149150const 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 : / ^ n o d e : / ,
164+ } ) ,
165+ ]
160166} ) ;
161167
162168// Web-only build, bundled with onnxruntime-web
163169const BUNDLE_BUILD = buildConfig ( {
164170 type : "module" ,
165- plugins : [ new PostBuildPlugin ( ) ] ,
171+ ignoreModules : WEB_IGNORE_MODULES ,
172+ plugins : [
173+ new webpack . IgnorePlugin ( {
174+ resourceRegExp : / ^ n o d e : / ,
175+ } ) ,
176+ new PostBuildPlugin ( ) ,
177+ ] ,
166178} ) ;
167179
168180// Node-compatible builds
0 commit comments