浏览代码

fix: update target and platform settings

daiwei 5 月之前
父节点
当前提交
08b1447560
共有 1 个文件被更改,包括 7 次插入1 次删除
  1. 7 1
      scripts/create-rolldown-config.js

+ 7 - 1
scripts/create-rolldown-config.js

@@ -334,8 +334,14 @@ export function createConfigsForPackage({
       external: resolveExternal(),
       transform: {
         define: resolveDefine(),
+        target: isServerRenderer || isCJSBuild ? 'es2019' : 'es2016',
       },
-      platform: format === 'cjs' ? 'node' : 'browser',
+      tsconfig: path.resolve(__dirname, '../tsconfig.json'),
+      // esm-bundler outputs are meant to be consumed by bundlers (Vite/Rspack/etc)
+      // and should preserve `process.env.NODE_ENV` checks for downstream replacement.
+      // Using `browser` here may cause the bundler to inline/fold env checks too early.
+      platform:
+        format === 'cjs' ? 'node' : isBundlerESMBuild ? 'neutral' : 'browser',
       resolve: {
         alias: entries,
       },