Skip to content

Type Alias: OptimizationOptions

ts
type OptimizationOptions = object

Defined in: node_modules/.pnpm/rolldown@1.0.0-beta.53/node_modules/rolldown/dist/shared/define-config-BS8Bt-r8.d.mts:1366

Properties

inlineConst?

ts
optional inlineConst:
  | boolean
  | {
  mode?: "all" | "smart";
  pass?: number;
};

Defined in: node_modules/.pnpm/rolldown@1.0.0-beta.53/node_modules/rolldown/dist/shared/define-config-BS8Bt-r8.d.mts:1406

Inline imported constant values during bundling instead of preserving variable references.

When enabled, constant values from imported modules will be inlined at their usage sites, potentially reducing bundle size and improving runtime performance by eliminating variable lookups. options:

  • true: equivalent to { mode: 'all', pass: 1 }, enabling constant inlining for all eligible constants with a single pass.
  • false: Disable constant inlining
  • { mode: 'smart' | 'all', pass?: number }:
    • mode: 'smart': Only inline constants in specific scenarios where it is likely to reduce bundle size and improve performance. Smart mode inlines constants in these specific scenarios:
      1. if (test) {} else {} - condition expressions in if statements
      2. test ? a : b - condition expressions in ternary operators
      3. test1 || test2 - logical OR expressions
      4. test1 && test2 - logical AND expressions
      5. test1 ?? test2 - nullish coalescing expressions
  • mode: 'all': Inline all imported constants wherever they are used.
  • pass: Number of passes to perform for inlining constants.

example

js
// Input files:
// constants.js
export const API_URL = 'https://api.example.com'

// main.js
import { API_URL } from './constants.js'
console.log(API_URL)

// With inlineConst: true, the bundled output becomes:
console.log('https://api.example.com')

// Instead of:
const API_URL = 'https://api.example.com'
console.log(API_URL)

Default

ts
false

pifeForModuleWrappers?

ts
optional pifeForModuleWrappers: boolean;

Defined in: node_modules/.pnpm/rolldown@1.0.0-beta.53/node_modules/rolldown/dist/shared/define-config-BS8Bt-r8.d.mts:1413

Use PIFE pattern for module wrappers

Released under the MIT License.