KC's Workspace
    Preparing search index...
    interface InputOptions {
        checks?: ChecksOptions;
        context?: string;
        cwd?: string;
        debug?: { sessionId?: string };
        experimental?: {
            attachDebugInfo?: AttachDebugOptions;
            chunkImportMap?: boolean | { baseUrl?: string; fileName?: string };
            chunkModulesOrder?: ChunkModulesOrder;
            devMode?: DevModeOptions;
            disableLiveBindings?: boolean;
            incrementalBuild?: boolean;
            nativeMagicString?: boolean;
            onDemandWrapping?: boolean;
            resolveNewUrlToAsset?: boolean;
            strictExecutionOrder?: boolean;
            transformHiresSourcemap?: boolean | "boundary";
            viteMode?: boolean;
        };
        external?: ExternalOption;
        input?: InputOption;
        logLevel?: LogLevelOption;
        makeAbsoluteExternalsRelative?: MakeAbsoluteExternalsRelative;
        moduleTypes?: ModuleTypes;
        onLog?: OnLogFunction;
        onwarn?: OnwarnFunction;
        optimization?: OptimizationOptions;
        platform?: "neutral"
        | "node"
        | "browser";
        plugins?: RolldownPluginOption;
        preserveEntrySignatures?:
            | false
            | "strict"
            | "allow-extension"
            | "exports-only";
        resolve?: {
            alias?: Record<string, string | false | string[]>;
            aliasFields?: string[][];
            conditionNames?: string[];
            exportsFields?: string[][];
            extensionAlias?: Record<string, string[]>;
            extensions?: string[];
            mainFields?: string[];
            mainFiles?: string[];
            modules?: string[];
            symlinks?: boolean;
            tsconfigFilename?: string;
        };
        shimMissingExports?: boolean;
        transform?: TransformOptions;
        treeshake?: boolean
        | TreeshakingOptions;
        tsconfig?: string | true;
        watch?: false | WatcherOptions;
    }

    Hierarchy (View Summary)

    Index

    Properties

    checks?: ChecksOptions
    context?: string
    cwd?: string
    debug?: { sessionId?: string }
    experimental?: {
        attachDebugInfo?: AttachDebugOptions;
        chunkImportMap?: boolean | { baseUrl?: string; fileName?: string };
        chunkModulesOrder?: ChunkModulesOrder;
        devMode?: DevModeOptions;
        disableLiveBindings?: boolean;
        incrementalBuild?: boolean;
        nativeMagicString?: boolean;
        onDemandWrapping?: boolean;
        resolveNewUrlToAsset?: boolean;
        strictExecutionOrder?: boolean;
        transformHiresSourcemap?: boolean | "boundary";
        viteMode?: boolean;
    }

    Type Declaration

    • OptionalattachDebugInfo?: AttachDebugOptions

      Attach debug information to the output bundle.

      • Type: 'none' | 'simple' | 'full'

      • Default: 'simple'

      • none: No debug information is attached.

      • simple: Attach comments indicating which files the bundled code comes from. These comments could be removed by the minifier.

      • full: Attach detailed debug information to the output bundle. These comments are using legal comment syntax, so they won't be removed by the minifier.

      Warning

      You shouldn't use full in the production build.

    • OptionalchunkImportMap?: boolean | { baseUrl?: string; fileName?: string }

      Enables automatic generation of a chunk import map asset during build.

      This map only includes chunks with hashed filenames, where keys are derived from the facade module name or primary chunk name. It produces stable and unique hash-based filenames, effectively preventing cascading cache invalidation caused by content hashes and maximizing browser cache reuse.

      The output defaults to importmap.json unless overridden via fileName. A base URL prefix (default "/") can be applied to all paths. The resulting JSON is a valid import map and can be directly injected into HTML via <script type="importmap">.

      Example configuration snippet:

      {
      experimental: {
      chunkImportMap: {
      baseUrl: '/',
      fileName: 'importmap.json'
      }
      },
      plugins: [
      {
      name: 'inject-import-map',
      generateBundle(_, bundle) {
      const chunkImportMap = bundle['importmap.json'];
      if (chunkImportMap?.type === 'asset') {
      const htmlPath = path.resolve('index.html');
      let html = fs.readFileSync(htmlPath, 'utf-8');

      html = html.replace(
      /<script\s+type="importmap"[^>]*>[\s\S]*?</script>/i,
      `<script type="importmap">${chunkImportMap.source}</script>`
      );

      fs.writeFileSync(htmlPath, html);
      delete bundle['importmap.json'];
      }
      }
      }
      ]
      }
      Note

      If you want to learn more, you can check out the example here: examples/chunk-import-map

    • OptionalchunkModulesOrder?: ChunkModulesOrder

      Control which order should use when rendering modules in chunk

      • Type: `'exec-order' | 'module-id'

      • Default: 'exec-order'

      • exec-order: Almost equivalent to the topological order of the module graph, but specially handling when module graph has cycle.

      • module-id: This is more friendly for gzip compression, especially for some javascript static asset lib (e.g. icon library)

      Note

      Try to sort the modules by their module id if possible(Since rolldown scope hoist all modules in the chunk, we only try to sort those modules by module id if we could ensure runtime behavior is correct after sorting).

    • OptionaldevMode?: DevModeOptions
    • OptionaldisableLiveBindings?: boolean
    • OptionalincrementalBuild?: boolean

      Required to be used with watch mode.

    • OptionalnativeMagicString?: boolean

      Use native Rust implementation of MagicString for source map generation.

      • Type: boolean
      • Default: false

      MagicString is a JavaScript library commonly used by bundlers for string manipulation and source map generation. When enabled, rolldown will use a native Rust implementation of MagicString instead of the JavaScript version, providing significantly better performance during source map generation and code transformation.

      • Improved Performance: The native Rust implementation is typically faster than the JavaScript version, especially for large codebases with extensive source maps.
      • Background Processing: Source map generation is performed asynchronously in a background thread, allowing the main bundling process to continue without blocking. This parallel processing can significantly reduce overall build times when working with JavaScript transform hooks.
      • Better Integration: Seamless integration with rolldown's native Rust architecture.
      export default {
      experimental: {
      nativeMagicString: true
      },
      output: {
      sourcemap: true
      }
      }
      Note

      This is an experimental feature. While it aims to provide identical behavior to the JavaScript implementation, there may be edge cases. Please report any discrepancies you encounter. For a complete working example, see examples/native-magic-string

    • OptionalonDemandWrapping?: boolean
    • OptionalresolveNewUrlToAsset?: boolean
    • OptionalstrictExecutionOrder?: boolean

      Lets modules be executed in the order they are declared.

      • Type: boolean
      • Default: false

      This is done by injecting runtime helpers to ensure that modules are executed in the order they are imported. External modules won't be affected.

      Warning

      Enabling this option may negatively increase bundle size. It is recommended to use this option only when absolutely necessary.

    • OptionaltransformHiresSourcemap?: boolean | "boundary"
    • OptionalviteMode?: boolean
    external?: ExternalOption
    input?: InputOption
    logLevel?: LogLevelOption
    makeAbsoluteExternalsRelative?: MakeAbsoluteExternalsRelative
    moduleTypes?: ModuleTypes
    optimization?: OptimizationOptions
    platform?: "neutral" | "node" | "browser"

    Expected platform where the code run.

    When the platform is set to neutral:

    • When bundling is enabled the default output format is set to esm, which uses the export syntax introduced with ECMAScript 2015 (i.e. ES6). You can change the output format if this default is not appropriate.
    • The main fields setting is empty by default. If you want to use npm-style packages, you will likely have to configure this to be something else such as main for the standard main field used by node.
    • The conditions setting does not automatically include any platform-specific values.
    - 'node' if the format is 'cjs'
    - 'browser' for other formats
    preserveEntrySignatures?: false | "strict" | "allow-extension" | "exports-only"
    resolve?: {
        alias?: Record<string, string | false | string[]>;
        aliasFields?: string[][];
        conditionNames?: string[];
        exportsFields?: string[][];
        extensionAlias?: Record<string, string[]>;
        extensions?: string[];
        mainFields?: string[];
        mainFiles?: string[];
        modules?: string[];
        symlinks?: boolean;
        tsconfigFilename?: string;
    }

    Type Declaration

    • Optionalalias?: Record<string, string | false | string[]>
      Warning

      resolve.alias will not call resolveId hooks of other plugin. If you want to call resolveId hooks of other plugin, use viteAliasPlugin from rolldown/experimental instead. You could find more discussion in this issue

    • OptionalaliasFields?: string[][]
    • OptionalconditionNames?: string[]
    • OptionalexportsFields?: string[][]
    • OptionalextensionAlias?: Record<string, string[]>

      Map of extensions to alternative extensions.

      With writing import './foo.js' in a file, you want to resolve it to foo.ts instead of foo.js. You can achieve this by setting: extensionAlias: { '.js': ['.ts', '.js'] }.

    • Optionalextensions?: string[]
    • OptionalmainFields?: string[]
    • OptionalmainFiles?: string[]
    • Optionalmodules?: string[]
    • Optionalsymlinks?: boolean
    • OptionaltsconfigFilename?: string

      Use the top-level tsconfig option instead.

    shimMissingExports?: boolean
    transform?: TransformOptions

    Configure how the code is transformed. This process happens after the transform hook.

    To transpile legacy decorators, you could use

    export default defineConfig({
    transform: {
    decorator: {
    legacy: true,
    },
    },
    })

    For latest decorators proposal, rolldown is able to bundle them but doesn't support transpiling them yet.

    treeshake?: boolean | TreeshakingOptions
    tsconfig?: string | true

    Configures TypeScript configuration file resolution and usage.

    • true: Auto-discovery mode (similar to Vite). For each module, both resolver and transformer will find the nearest tsconfig.json. If the tsconfig has references, the file extension is allowed, and the tsconfig's include/exclude patterns don't match the file, the referenced tsconfigs will be searched for a match. Falls back to the original tsconfig if no match is found.
    • string: Path to a specific tsconfig.json file (relative to cwd or absolute path).
    • Resolver: Uses compilerOptions.paths and compilerOptions.baseUrl for path mapping
    • Transformer: Uses select compiler options (jsx, decorators, typescript, etc.)
    Note

    Priority: Top-level transform options always take precedence over tsconfig settings.

    undefined (no tsconfig resolution)
    
    watch?: false | WatcherOptions