diff --git a/.changeset/six-berries-dream.md b/.changeset/six-berries-dream.md new file mode 100644 index 000000000000..e33c90cb7d97 --- /dev/null +++ b/.changeset/six-berries-dream.md @@ -0,0 +1,6 @@ +--- +'@modern-js/module-tools': patch +--- + +feat(module-tools): update umd global code +feat(module-tools): 更新 umd 全局代码 diff --git a/packages/solutions/module-tools/src/builder/esbuild/adapter.ts b/packages/solutions/module-tools/src/builder/esbuild/adapter.ts index 0077e9a91d12..352978dfb240 100644 --- a/packages/solutions/module-tools/src/builder/esbuild/adapter.ts +++ b/packages/solutions/module-tools/src/builder/esbuild/adapter.ts @@ -214,7 +214,7 @@ export const adapterPlugin = (compiler: ICompiler): Plugin => { if (args.namespace === globalNamespace) { const value = config.umdGlobals[args.path]; return { - contents: `module.exports = (typeof globalThis !== "undefined" ? globalThis : Function('return this')() || global || self)[${JSON.stringify( + contents: `module.exports = (typeof globalThis !== "undefined" ? globalThis : (typeof global !== "undefined" ? global : self || Function('return this')()))[${JSON.stringify( value, )}]`, };