File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed
packages/webpack5/src/configuration Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -267,6 +267,15 @@ export default function (config: Config, env: IWebpackEnv = _env): Config {
267267 if ( env === null || env === void 0 ? void 0 : env . uniqueBundle ) {
268268 config . output . filename ( `[name].${ env . uniqueBundle } .mjs` ) ;
269269 }
270+ // Prevent webpack from generating Node-style ESM shims for __dirname/__filename.
271+ // For output modules, webpack defaults these to a fileURLToPath(import.meta.url) helper
272+ // imported from bare "url", which does not match the NativeScript iOS runtime contract.
273+ // The runtime already provides import.meta.dirname and initializes global.__dirname,
274+ // so webpack's helper is redundant and can misresolve in bundle/worker contexts.
275+ // ESM app or dependency code should use import.meta.dirname/import.meta.url instead
276+ // of expecting webpack to synthesize __dirname/__filename.
277+ config . node . set ( '__dirname' , false ) ;
278+ config . node . set ( '__filename' , false ) ;
270279 }
271280
272281 config . watchOptions ( {
You can’t perform that action at this time.
0 commit comments