Skip to content

生成的代码选项

¥Generated Code Options

  • 类型:Partial<GeneratedCodeOptions>

    ¥Type: Partial<GeneratedCodeOptions>

  • 默认值:查看各个选项

    ¥Default: See individual options

生成的代码输出的配置。

¥Configuration for the generated code output.

示例

¥Examples

js
export default {
  output: {
    generatedCode: {
      preset: 'es2015',
      symbols: false,
      profilerNames: true,
    },
  },
};

symbols

  • 类型:boolean

    ¥Type: boolean

  • 默认值:false

    ¥Default: false

  • 路径:output.generatedCode.symbols

    ¥Path: output.generatedCode.symbols

是否对命名空间对象使用 Symbol.toStringTag

¥Whether to use Symbol.toStringTag for namespace objects.

preset

  • 类型:'es5' | 'es2015'

    ¥Type: 'es5' | 'es2015'

  • 默认值:'es2015'

    ¥Default: 'es2015'

  • 路径:output.generatedCode.preset

    ¥Path: output.generatedCode.preset

允许选择其中一个预设,同时覆盖某些选项。预设值决定了 Rolldown 生成的辅助代码所使用的 ECMAScript 版本。

¥Allows choosing one of the presets while overriding some options. The preset determines the ECMAScript version used for helper code generated by Rolldown.

profilerNames

  • 类型:boolean

    ¥Type: boolean

  • 默认值:禁用压缩时使用 true,启用压缩时使用 false

    ¥Default: true when minification is disabled, false when minification is enabled

  • 路径:output.generatedCode.profilerNames

    ¥Path: output.generatedCode.profilerNames

是否为内部变量添加可读名称以便进行性能分析。

¥Whether to add readable names to internal variables for profiling purposes.

示例

¥Examples

js
export default {
  output: {
    generatedCode: {
      profilerNames: true,
    },
  },
};

深入探讨

¥In-depth

启用后,生成的代码将使用与原始模块名称对应的描述性变量名称,从而更轻松地对打包后的代码进行分析和调试。这在使用浏览器分析工具识别函数执行时间时很有用,因为匿名函数将具有描述性名称。

¥When enabled, generated code will use descriptive variable names that correspond to the original module names, making it easier to profile and debug the bundled code. This can be helpful when using browser profiling tools to identify function execution times, as anonymous functions will have descriptive names.