File tree Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Original file line number Diff line number Diff line change 11const webpack = require ( 'webpack' ) ;
2+
23module . exports = class WasiExtPlugin {
34 constructor ( ) {
45 this . fallbacks = {
56 process : require . resolve ( '../lib/process' ) ,
67 fs : require . resolve ( '../lib/fs' ) ,
78 path : require . resolve ( 'path-browserify' ) ,
89 } ;
10+
911 }
1012
1113 apply ( compiler ) {
1214 const providePlugin = new webpack . ProvidePlugin ( {
1315 Buffer : [ 'buffer' , 'Buffer' ] ,
14- process : [ require . resolve ( '../lib/process' ) , 'default' ]
16+ process : [ require . resolve ( '../lib/process' ) , 'default' ] ,
1517 } ) ;
1618
19+ // Add a NormalModuleReplacementPlugin to handle `node:` imports
20+ const normalModuleReplacements = [
21+ [ 'node:fs' , 'fs' ] ,
22+ [ 'node:process' , 'process' ] ,
23+ [ 'node:path' , 'path' ] ,
24+ ] . map ( ( [ from , to ] ) => new webpack . NormalModuleReplacementPlugin (
25+ new RegExp ( `^${ from } $` ) ,
26+ to
27+ ) ) ;
28+
1729 compiler . options . resolve . fallback = {
1830 ...compiler . options . resolve . fallback ,
1931 ...this . fallbacks ,
2032 } ;
2133
22- compiler . options . plugins . push ( providePlugin ) ;
34+
35+ compiler . options . plugins = compiler . options . plugins || [ ] ;
36+ compiler . options . plugins . push ( providePlugin , ...normalModuleReplacements ) ;
2337 }
24- } ;
38+ } ;
Original file line number Diff line number Diff line change 11import fs from "fs" ;
22import { setupExt } from "@spinframework/wasi-ext" ;
3- import process from "process"
3+ import process from "node: process"
44
55//@ts -ignore
66addEventListener ( 'fetch' , ( event : FetchEvent ) => {
You can’t perform that action at this time.
0 commit comments