@@ -2,10 +2,9 @@ use std::{collections::HashMap, fmt::Debug};
22
33use napi_derive:: napi;
44use rspack_core:: {
5- BoxPlugin , CompilerOptions , DevServerOptions , Devtool , EntryItem , Experiments , ExternalItem ,
6- ModuleOptions , OutputOptions , PluginExt , TargetPlatform ,
5+ BoxPlugin , CompilerOptions , DevServerOptions , Devtool , EntryItem , Experiments , ModuleOptions ,
6+ OutputOptions , PluginExt , TargetPlatform ,
77} ;
8- use rspack_regex:: RspackRegex ;
98use serde:: Deserialize ;
109
1110mod raw_builtins;
@@ -145,7 +144,7 @@ impl RawOptionsApply for RawOptions {
145144 ) ;
146145 }
147146 if self . externals_presets . node {
148- plugins. push ( node_target_plugin ( ) ) ;
147+ plugins. push ( rspack_plugin_externals :: node_target_plugin ( ) ) ;
149148 }
150149 plugins. push ( rspack_plugin_javascript:: JsPlugin :: new ( ) . boxed ( ) ) ;
151150 plugins. push (
@@ -185,66 +184,3 @@ impl RawOptionsApply for RawOptions {
185184 } )
186185 }
187186}
188-
189- fn node_target_plugin ( ) -> BoxPlugin {
190- rspack_plugin_externals:: ExternalPlugin :: new (
191- "commonjs" . to_string ( ) , // TODO: should be "node-commonjs"
192- vec ! [
193- ExternalItem :: from( "assert" . to_string( ) ) ,
194- ExternalItem :: from( "assert/strict" . to_string( ) ) ,
195- ExternalItem :: from( "async_hooks" . to_string( ) ) ,
196- ExternalItem :: from( "buffer" . to_string( ) ) ,
197- ExternalItem :: from( "child_process" . to_string( ) ) ,
198- ExternalItem :: from( "cluster" . to_string( ) ) ,
199- ExternalItem :: from( "console" . to_string( ) ) ,
200- ExternalItem :: from( "constants" . to_string( ) ) ,
201- ExternalItem :: from( "crypto" . to_string( ) ) ,
202- ExternalItem :: from( "dgram" . to_string( ) ) ,
203- ExternalItem :: from( "diagnostics_channel" . to_string( ) ) ,
204- ExternalItem :: from( "dns" . to_string( ) ) ,
205- ExternalItem :: from( "dns/promises" . to_string( ) ) ,
206- ExternalItem :: from( "domain" . to_string( ) ) ,
207- ExternalItem :: from( "events" . to_string( ) ) ,
208- ExternalItem :: from( "fs" . to_string( ) ) ,
209- ExternalItem :: from( "fs/promises" . to_string( ) ) ,
210- ExternalItem :: from( "http" . to_string( ) ) ,
211- ExternalItem :: from( "http2" . to_string( ) ) ,
212- ExternalItem :: from( "https" . to_string( ) ) ,
213- ExternalItem :: from( "inspector" . to_string( ) ) ,
214- ExternalItem :: from( "module" . to_string( ) ) ,
215- ExternalItem :: from( "net" . to_string( ) ) ,
216- ExternalItem :: from( "os" . to_string( ) ) ,
217- ExternalItem :: from( "path" . to_string( ) ) ,
218- ExternalItem :: from( "path/posix" . to_string( ) ) ,
219- ExternalItem :: from( "path/win32" . to_string( ) ) ,
220- ExternalItem :: from( "perf_hooks" . to_string( ) ) ,
221- ExternalItem :: from( "process" . to_string( ) ) ,
222- ExternalItem :: from( "punycode" . to_string( ) ) ,
223- ExternalItem :: from( "querystring" . to_string( ) ) ,
224- ExternalItem :: from( "readline" . to_string( ) ) ,
225- ExternalItem :: from( "repl" . to_string( ) ) ,
226- ExternalItem :: from( "stream" . to_string( ) ) ,
227- ExternalItem :: from( "stream/promises" . to_string( ) ) ,
228- ExternalItem :: from( "stream/web" . to_string( ) ) ,
229- ExternalItem :: from( "string_decoder" . to_string( ) ) ,
230- ExternalItem :: from( "sys" . to_string( ) ) ,
231- ExternalItem :: from( "timers" . to_string( ) ) ,
232- ExternalItem :: from( "timers/promises" . to_string( ) ) ,
233- ExternalItem :: from( "tls" . to_string( ) ) ,
234- ExternalItem :: from( "trace_events" . to_string( ) ) ,
235- ExternalItem :: from( "tty" . to_string( ) ) ,
236- ExternalItem :: from( "url" . to_string( ) ) ,
237- ExternalItem :: from( "util" . to_string( ) ) ,
238- ExternalItem :: from( "util/types" . to_string( ) ) ,
239- ExternalItem :: from( "v8" . to_string( ) ) ,
240- ExternalItem :: from( "vm" . to_string( ) ) ,
241- ExternalItem :: from( "wasi" . to_string( ) ) ,
242- ExternalItem :: from( "worker_threads" . to_string( ) ) ,
243- ExternalItem :: from( "zlib" . to_string( ) ) ,
244- ExternalItem :: from( RspackRegex :: new( "^node:" ) . expect( "Invalid regexp" ) ) ,
245- // Yarn PnP adds pnpapi as "builtin"
246- ExternalItem :: from( "pnpapi" . to_string( ) ) ,
247- ] ,
248- )
249- . boxed ( )
250- }
0 commit comments