fix: inline CJS module/exports shims in client bundle for browser loader

This commit is contained in:
2026-09-04 14:59:11 +08:00
parent a14a8d9233
commit ef9508e597
3 changed files with 6 additions and 2 deletions
+2
View File
@@ -1,4 +1,6 @@
window.__ModuleLoader__.load({ id: "@gyxx/dsh-plugin-gyxx-workbench", factory: (require) => {
var module = { exports: {} };
var exports = module.exports;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
File diff suppressed because one or more lines are too long
+3 -1
View File
@@ -40,7 +40,9 @@ await build({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV ?? 'production'),
},
banner: {
js: `window.__ModuleLoader__.load({ id: ${JSON.stringify(PKG_ID)}, factory: (require) => {`,
// dsh 浏览器加载器只给 factoryrequire(返回值即模块导出),
// CJS 的 module/exports 垫片必须由包体自带(与官方 tsdown 产物一致)。
js: `window.__ModuleLoader__.load({ id: ${JSON.stringify(PKG_ID)}, factory: (require) => {\nvar module = { exports: {} };\nvar exports = module.exports;`,
},
footer: { js: 'return module.exports; } });' },
logLevel: 'info',