@rolldown/browser 1.0.0-beta.7-commit.a0a7d95

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. package/LICENSE +25 -0
  2. package/bin/cli.mjs +2 -0
  3. package/dist/browser-bundler.mjs +3514 -0
  4. package/dist/browser.js +4626 -0
  5. package/dist/cli.cjs +1759 -0
  6. package/dist/cli.mjs +1828 -0
  7. package/dist/experimental-index.cjs +87 -0
  8. package/dist/experimental-index.mjs +67 -0
  9. package/dist/index.cjs +9 -0
  10. package/dist/index.mjs +5 -0
  11. package/dist/parallel-plugin-worker.cjs +43 -0
  12. package/dist/parallel-plugin-worker.mjs +48 -0
  13. package/dist/parallel-plugin.cjs +9 -0
  14. package/dist/parallel-plugin.mjs +8 -0
  15. package/dist/parse-ast-index.cjs +4 -0
  16. package/dist/parse-ast-index.mjs +4 -0
  17. package/dist/rolldown-binding.wasi-browser.js +102 -0
  18. package/dist/rolldown-binding.wasi.cjs +127 -0
  19. package/dist/rolldown-binding.wasm32-wasi.wasm +0 -0
  20. package/dist/shared/chunk-BuCFLigr.mjs +12 -0
  21. package/dist/shared/chunk-Dc32QXFI.cjs +31 -0
  22. package/dist/shared/parse-ast-index-C29iO6Jv.cjs +316 -0
  23. package/dist/shared/parse-ast-index-GcZLh6_d.mjs +273 -0
  24. package/dist/shared/prompt-B3VJLbs9.mjs +854 -0
  25. package/dist/shared/prompt-wpCBKCzA.cjs +855 -0
  26. package/dist/shared/src-6_rb-jCl.cjs +3147 -0
  27. package/dist/shared/src-QrPvO0Ec.mjs +4375 -0
  28. package/dist/types/api/build.d.ts +18 -0
  29. package/dist/types/api/experimental.d.ts +7 -0
  30. package/dist/types/api/rolldown/index.d.ts +3 -0
  31. package/dist/types/api/rolldown/rolldown-build.d.ts +15 -0
  32. package/dist/types/api/watch/index.d.ts +3 -0
  33. package/dist/types/api/watch/watch-emitter.d.ts +31 -0
  34. package/dist/types/api/watch/watcher.d.ts +13 -0
  35. package/dist/types/binding.d.ts +1504 -0
  36. package/dist/types/builtin-plugin/alias-plugin.d.ts +10 -0
  37. package/dist/types/builtin-plugin/constructors.d.ts +22 -0
  38. package/dist/types/builtin-plugin/replace-plugin.d.ts +27 -0
  39. package/dist/types/builtin-plugin/transform-plugin.d.ts +9 -0
  40. package/dist/types/builtin-plugin/utils.d.ts +8 -0
  41. package/dist/types/cli/arguments/alias.d.ts +16 -0
  42. package/dist/types/cli/arguments/index.d.ts +15 -0
  43. package/dist/types/cli/arguments/normalize.d.ts +16 -0
  44. package/dist/types/cli/arguments/utils.d.ts +8 -0
  45. package/dist/types/cli/commands/bundle.d.ts +3 -0
  46. package/dist/types/cli/commands/help.d.ts +1 -0
  47. package/dist/types/cli/index.d.ts +1 -0
  48. package/dist/types/cli/load-config.d.ts +5 -0
  49. package/dist/types/cli/logger.d.ts +5 -0
  50. package/dist/types/constants/plugin-context.d.ts +7 -0
  51. package/dist/types/constants/plugin.d.ts +45 -0
  52. package/dist/types/experimental-index.d.ts +9 -0
  53. package/dist/types/index.d.ts +31 -0
  54. package/dist/types/log/log-handler.d.ts +4 -0
  55. package/dist/types/log/logger.d.ts +6 -0
  56. package/dist/types/log/logging.d.ts +12 -0
  57. package/dist/types/log/logs.d.ts +18 -0
  58. package/dist/types/options/generated/checks-options.d.ts +57 -0
  59. package/dist/types/options/input-options.d.ts +185 -0
  60. package/dist/types/options/normalized-input-options.d.ts +18 -0
  61. package/dist/types/options/normalized-output-options.d.ts +70 -0
  62. package/dist/types/options/output-options.d.ts +182 -0
  63. package/dist/types/options/watch-options.d.ts +5 -0
  64. package/dist/types/parallel-plugin-worker.d.ts +1 -0
  65. package/dist/types/parallel-plugin.d.ts +1 -0
  66. package/dist/types/parse-ast-index.d.ts +5 -0
  67. package/dist/types/plugin/bindingify-build-hooks.d.ts +10 -0
  68. package/dist/types/plugin/bindingify-hook-filter.d.ts +7 -0
  69. package/dist/types/plugin/bindingify-output-hooks.d.ts +14 -0
  70. package/dist/types/plugin/bindingify-plugin-hook-meta.d.ts +8 -0
  71. package/dist/types/plugin/bindingify-plugin.d.ts +17 -0
  72. package/dist/types/plugin/bindingify-watch-hooks.d.ts +5 -0
  73. package/dist/types/plugin/hook-filter.d.ts +49 -0
  74. package/dist/types/plugin/index.d.ts +141 -0
  75. package/dist/types/plugin/minimal-plugin-context.d.ts +24 -0
  76. package/dist/types/plugin/parallel-plugin-implementation.d.ts +10 -0
  77. package/dist/types/plugin/parallel-plugin.d.ts +9 -0
  78. package/dist/types/plugin/plugin-context-data.d.ts +21 -0
  79. package/dist/types/plugin/plugin-context.d.ts +67 -0
  80. package/dist/types/plugin/plugin-driver.d.ts +10 -0
  81. package/dist/types/plugin/transform-plugin-context.d.ts +28 -0
  82. package/dist/types/plugin/with-filter.d.ts +10 -0
  83. package/dist/types/types/assert.d.ts +14 -0
  84. package/dist/types/types/config-export.d.ts +5 -0
  85. package/dist/types/types/misc.d.ts +40 -0
  86. package/dist/types/types/module-info.d.ts +15 -0
  87. package/dist/types/types/module-side-effects.d.ts +12 -0
  88. package/dist/types/types/output-bundle.d.ts +4 -0
  89. package/dist/types/types/rolldown-options.d.ts +5 -0
  90. package/dist/types/types/rolldown-output.d.ts +66 -0
  91. package/dist/types/types/schema.d.ts +33 -0
  92. package/dist/types/types/sourcemap.d.ts +14 -0
  93. package/dist/types/types/utils.d.ts +13 -0
  94. package/dist/types/types.d.ts +7 -0
  95. package/dist/types/utils/asset-source.d.ts +4 -0
  96. package/dist/types/utils/async-flatten.d.ts +1 -0
  97. package/dist/types/utils/bindingify-input-options.d.ts +7 -0
  98. package/dist/types/utils/bindingify-output-options.d.ts +5 -0
  99. package/dist/types/utils/code-frame.d.ts +1 -0
  100. package/dist/types/utils/compose-js-plugins.d.ts +2 -0
  101. package/dist/types/utils/create-bundler-option.d.ts +11 -0
  102. package/dist/types/utils/create-bundler.d.ts +9 -0
  103. package/dist/types/utils/define-config.d.ts +5 -0
  104. package/dist/types/utils/error.d.ts +2 -0
  105. package/dist/types/utils/initialize-parallel-plugins.d.ts +17 -0
  106. package/dist/types/utils/misc.d.ts +7 -0
  107. package/dist/types/utils/normalize-hook.d.ts +7 -0
  108. package/dist/types/utils/normalize-plugin-option.d.ts +13 -0
  109. package/dist/types/utils/normalize-string-or-regex.d.ts +2 -0
  110. package/dist/types/utils/plugin/index.d.ts +2 -0
  111. package/dist/types/utils/resolved-external.d.ts +4 -0
  112. package/dist/types/utils/transform-module-info.d.ts +4 -0
  113. package/dist/types/utils/transform-rendered-chunk.d.ts +4 -0
  114. package/dist/types/utils/transform-rendered-module.d.ts +3 -0
  115. package/dist/types/utils/transform-side-effects.d.ts +3 -0
  116. package/dist/types/utils/transform-sourcemap.d.ts +3 -0
  117. package/dist/types/utils/transform-to-rollup-output.d.ts +11 -0
  118. package/dist/types/utils/validator.d.ts +6 -0
  119. package/dist/wasi-worker-browser.mjs +39 -0
  120. package/dist/wasi-worker.mjs +63 -0
  121. package/package.json +85 -0
@@ -0,0 +1,10 @@
1
+ import { BuiltinPlugin } from './constructors';
2
+ type AliasPluginAlias = {
3
+ find: string | RegExp;
4
+ replacement: string;
5
+ };
6
+ type AliasPluginConfig = {
7
+ entries: AliasPluginAlias[];
8
+ };
9
+ export declare function aliasPlugin(config: AliasPluginConfig): BuiltinPlugin;
10
+ export {};
@@ -0,0 +1,22 @@
1
+ import { BindingBuildImportAnalysisPluginConfig, type BindingBuiltinPluginName, BindingGlobImportPluginConfig, BindingIsolatedDeclarationPluginConfig, BindingJsonPluginConfig, BindingManifestPluginConfig, BindingMfManifest, BindingModuleFederationPluginOption, BindingModulePreloadPolyfillPluginConfig, BindingRemote, type BindingViteResolvePluginConfig } from '../binding';
2
+ export declare class BuiltinPlugin {
3
+ name: BindingBuiltinPluginName;
4
+ _options?: unknown | undefined;
5
+ constructor(name: BindingBuiltinPluginName, _options?: unknown | undefined);
6
+ }
7
+ export declare function modulePreloadPolyfillPlugin(config?: BindingModulePreloadPolyfillPluginConfig): BuiltinPlugin;
8
+ export declare function dynamicImportVarsPlugin(): BuiltinPlugin;
9
+ export declare function importGlobPlugin(config?: BindingGlobImportPluginConfig): BuiltinPlugin;
10
+ export declare function manifestPlugin(config?: BindingManifestPluginConfig): BuiltinPlugin;
11
+ export declare function wasmHelperPlugin(): BuiltinPlugin;
12
+ export declare function wasmFallbackPlugin(): BuiltinPlugin;
13
+ export declare function loadFallbackPlugin(): BuiltinPlugin;
14
+ export declare function jsonPlugin(config?: BindingJsonPluginConfig): BuiltinPlugin;
15
+ export declare function buildImportAnalysisPlugin(config: BindingBuildImportAnalysisPluginConfig): BuiltinPlugin;
16
+ export declare function viteResolvePlugin(config: Omit<BindingViteResolvePluginConfig, 'runtime'>): BuiltinPlugin;
17
+ export type ModuleFederationPluginOption = Omit<BindingModuleFederationPluginOption, 'remotes'> & {
18
+ remotes?: Record<string, string | BindingRemote>;
19
+ manifest?: boolean | BindingMfManifest;
20
+ };
21
+ export declare function moduleFederationPlugin(config: ModuleFederationPluginOption): BuiltinPlugin;
22
+ export declare function isolatedDeclarationPlugin(config?: BindingIsolatedDeclarationPluginConfig): BuiltinPlugin;
@@ -0,0 +1,27 @@
1
+ import { BindingReplacePluginConfig } from '../binding';
2
+ import { BuiltinPlugin } from './constructors';
3
+ /**
4
+ * Replaces targeted strings in files while bundling.
5
+ *
6
+ * @example
7
+ * // Basic usage
8
+ * ```js
9
+ * replacePlugin({
10
+ * 'process.env.NODE_ENV': JSON.stringify('production'),
11
+ * __buildDate__: () => JSON.stringify(new Date()),
12
+ * __buildVersion: 15
13
+ * })
14
+ * ```
15
+ * @example
16
+ * // With options
17
+ * ```js
18
+ * replacePlugin({
19
+ * 'process.env.NODE_ENV': JSON.stringify('production'),
20
+ * __buildDate__: () => JSON.stringify(new Date()),
21
+ * __buildVersion: 15
22
+ * }, {
23
+ * preventAssignment: false,
24
+ * })
25
+ * ```
26
+ */
27
+ export declare function replacePlugin(values?: BindingReplacePluginConfig['values'], options?: Omit<BindingReplacePluginConfig, 'values'>): BuiltinPlugin;
@@ -0,0 +1,9 @@
1
+ import { BuiltinPlugin } from './constructors';
2
+ import { BindingTransformPluginConfig } from '../binding';
3
+ type TransformPattern = string | RegExp | (RegExp | string)[];
4
+ export type TransformPluginConfig = Omit<BindingTransformPluginConfig, 'include' | 'exclude'> & {
5
+ include?: TransformPattern;
6
+ exclude?: TransformPattern;
7
+ };
8
+ export declare function transformPlugin(config?: TransformPluginConfig): BuiltinPlugin;
9
+ export {};
@@ -0,0 +1,8 @@
1
+ import { BindingBuiltinPlugin, BindingCallableBuiltinPlugin } from '../binding';
2
+ import { BuiltinPlugin } from './constructors';
3
+ type BindingCallableBuiltinPluginLike = {
4
+ [K in keyof BindingCallableBuiltinPlugin]: BindingCallableBuiltinPlugin[K];
5
+ };
6
+ export declare function makeBuiltinPluginCallable(plugin: BuiltinPlugin): BuiltinPlugin & BindingCallableBuiltinPluginLike;
7
+ export declare function bindingifyBuiltInPlugin(plugin: BuiltinPlugin): BindingBuiltinPlugin;
8
+ export {};
@@ -0,0 +1,16 @@
1
+ import type { InputCliOptions } from '../../options/input-options';
2
+ import type { OutputCliOptions } from '../../options/output-options';
3
+ export interface CliOptions extends InputCliOptions, OutputCliOptions {
4
+ config?: string | boolean;
5
+ help?: boolean;
6
+ version?: boolean;
7
+ watch?: boolean;
8
+ }
9
+ export interface OptionConfig {
10
+ abbreviation?: string;
11
+ description?: string;
12
+ default?: string | boolean;
13
+ hint?: string;
14
+ reverse?: boolean;
15
+ }
16
+ export declare const alias: Partial<Record<keyof CliOptions, OptionConfig>>;
@@ -0,0 +1,15 @@
1
+ import type { Schema } from '../../types/schema';
2
+ import { type NormalizedCliOptions } from './normalize';
3
+ export declare const flattenedSchema: Record<string, Schema>;
4
+ export declare const options: {
5
+ [k: string]: {
6
+ type: 'boolean' | 'string';
7
+ multiple: boolean;
8
+ short?: string;
9
+ default?: boolean | string | string[];
10
+ hint?: string;
11
+ description: string;
12
+ };
13
+ };
14
+ export type ParseArgsOptions = typeof options;
15
+ export declare function parseCliArguments(): NormalizedCliOptions;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * @description This file is used for normalize the options.
3
+ * In CLI, the input options and output options are mixed together. We need to tell them apart.
4
+ */
5
+ import type { InputOptions } from '../../options/input-options';
6
+ import type { OutputOptions } from '../../options/output-options';
7
+ import type { CliOptions } from './alias';
8
+ export interface NormalizedCliOptions {
9
+ input: InputOptions;
10
+ output: OutputOptions;
11
+ help: boolean;
12
+ config: string;
13
+ version: boolean;
14
+ watch: boolean;
15
+ }
16
+ export declare function normalizeCliOptions(cliOptions: CliOptions, positionals: string[]): NormalizedCliOptions;
@@ -0,0 +1,8 @@
1
+ import type { Schema } from '../../types/schema';
2
+ type SchemaType = 'string' | 'boolean' | 'object' | 'number' | 'array';
3
+ export declare function getSchemaType(schema: Schema): SchemaType;
4
+ export declare function flattenSchema(schema: Record<string, Schema>, base?: Record<string, Schema>, parent?: string): Record<string, Schema>;
5
+ export declare function setNestedProperty<T extends object, K>(obj: T, path: string, value: K): void;
6
+ export declare function camelCaseToKebabCase(str: string): string;
7
+ export declare function kebabCaseToCamelCase(str: string): string;
8
+ export {};
@@ -0,0 +1,3 @@
1
+ import { NormalizedCliOptions } from '../arguments/normalize';
2
+ export declare function bundleWithConfig(configPath: string, cliOptions: NormalizedCliOptions): Promise<void>;
3
+ export declare function bundleWithCliOptions(cliOptions: NormalizedCliOptions): Promise<void>;
@@ -0,0 +1 @@
1
+ export declare function showHelp(): void;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ import type { ConfigExport } from '../types/config-export';
2
+ export declare function loadTsConfig(configFile: string): Promise<ConfigExport>;
3
+ export declare function isFilePathESM(filePath: string): boolean;
4
+ export declare function findNearestPackageData(basedir: string): any | null;
5
+ export declare function loadConfig(configPath: string): Promise<ConfigExport>;
@@ -0,0 +1,5 @@
1
+ import { type ConsolaInstance } from 'consola';
2
+ /**
3
+ * Console logger
4
+ */
5
+ export declare const logger: Record<string, any> | ConsolaInstance;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * If Composed plugins call `this.resolve` with `skipSelf: true`, the composed plugins will be skipped as a whole.
3
+ * To prevent that, we use this symbol to store the actual caller of `this.resolve` with `skipSelf: true`. And we
4
+ * will modify the skipSelf option to `false` and use this symbol to skip the caller itself in the composed plugins
5
+ * internally.
6
+ */
7
+ export declare const SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF: unique symbol;
@@ -0,0 +1,45 @@
1
+ import { Plugin } from '../plugin';
2
+ export declare const ENUMERATED_INPUT_PLUGIN_HOOK_NAMES: readonly ["options", "buildStart", "resolveId", "load", "transform", "moduleParsed", "buildEnd", "onLog", "resolveDynamicImport", "closeBundle", "closeWatcher", "watchChange"];
3
+ export declare const ENUMERATED_OUTPUT_PLUGIN_HOOK_NAMES: readonly ["augmentChunkHash", "outputOptions", "renderChunk", "renderStart", "renderError", "writeBundle", "generateBundle"];
4
+ export declare const ENUMERATED_PLUGIN_HOOK_NAMES: [
5
+ ...typeof ENUMERATED_INPUT_PLUGIN_HOOK_NAMES,
6
+ ...typeof ENUMERATED_OUTPUT_PLUGIN_HOOK_NAMES,
7
+ 'footer',
8
+ 'banner',
9
+ 'intro',
10
+ 'outro'
11
+ ];
12
+ /**
13
+ * Names of all properties in a `Plugin` object. Includes `name` and `api`.
14
+ */
15
+ export type PluginProps = keyof Plugin;
16
+ type EnumeratedPluginHookNames = typeof ENUMERATED_PLUGIN_HOOK_NAMES;
17
+ /**
18
+ * Names of all hooks in a `Plugin` object. Does not include `name` and `api`, since they are not hooks.
19
+ */
20
+ export type PluginHookNames = EnumeratedPluginHookNames[number];
21
+ /**
22
+ * Names of all defined hooks. It's like
23
+ * ```ts
24
+ * type DefinedHookNames = {
25
+ * options: 'options',
26
+ * buildStart: 'buildStart',
27
+ * ...
28
+ * }
29
+ * ```
30
+ */
31
+ export type DefinedHookNames = {
32
+ readonly [K in PluginHookNames]: K;
33
+ };
34
+ /**
35
+ * Names of all defined hooks. It's like
36
+ * ```js
37
+ * const DEFINED_HOOK_NAMES ={
38
+ * options: 'options',
39
+ * buildStart: 'buildStart',
40
+ * ...
41
+ * }
42
+ * ```
43
+ */
44
+ export declare const DEFINED_HOOK_NAMES: DefinedHookNames;
45
+ export {};
@@ -0,0 +1,9 @@
1
+ export { experimental_scan as scan } from './api/experimental';
2
+ export { moduleRunnerTransform, transform } from './binding';
3
+ export type { TransformOptions, TransformResult } from './binding';
4
+ export { defineParallelPlugin } from './plugin/parallel-plugin';
5
+ export { composeJsPlugins as composePlugins } from './utils/compose-js-plugins';
6
+ export { buildImportAnalysisPlugin, dynamicImportVarsPlugin, importGlobPlugin, isolatedDeclarationPlugin, jsonPlugin, loadFallbackPlugin, manifestPlugin, moduleFederationPlugin, modulePreloadPolyfillPlugin, viteResolvePlugin, wasmFallbackPlugin, wasmHelperPlugin, } from './builtin-plugin/constructors';
7
+ export { aliasPlugin } from './builtin-plugin/alias-plugin';
8
+ export { replacePlugin } from './builtin-plugin/replace-plugin';
9
+ export { transformPlugin } from './builtin-plugin/transform-plugin';
@@ -0,0 +1,31 @@
1
+ import { build, type BuildOptions } from './api/build';
2
+ import { rolldown } from './api/rolldown';
3
+ import { RolldownBuild } from './api/rolldown/rolldown-build';
4
+ import { watch } from './api/watch';
5
+ import { RolldownWatcher } from './api/watch/watch-emitter';
6
+ import { PreRenderedChunk } from './binding';
7
+ import type { LogOrStringHandler } from './log/logging';
8
+ import type { ExternalOption, InputOption, InputOptions, JsxOptions } from './options/input-options';
9
+ import { NormalizedInputOptions } from './options/normalized-input-options';
10
+ import { InternalModuleFormat, NormalizedOutputOptions } from './options/normalized-output-options';
11
+ import type { ModuleFormat, OutputOptions, PreRenderedAsset } from './options/output-options';
12
+ import { WatchOptions } from './options/watch-options';
13
+ import type { AsyncPluginHooks, CustomPluginOptions, FunctionPluginHooks, HookFilterExtension, ImportKind, LoadResult, ModuleOptions, ModuleType, ObjectHook, ParallelPluginHooks, PartialResolvedId, Plugin, ResolvedId, ResolveIdExtraOptions, ResolveIdResult, RolldownPlugin, RolldownPluginOption, SourceDescription, TransformResult } from './plugin';
14
+ export { withFilter } from './plugin';
15
+ import type { HookFilter, ModuleTypeFilter, StringFilter } from './plugin/hook-filter';
16
+ import { MinimalPluginContext, PluginContextMeta } from './plugin/minimal-plugin-context';
17
+ import { DefineParallelPluginResult } from './plugin/parallel-plugin';
18
+ import { EmittedAsset, EmittedFile, GetModuleInfo, PluginContext } from './plugin/plugin-context';
19
+ import { TransformPluginContext } from './plugin/transform-plugin-context';
20
+ import { ConfigExport } from './types/config-export';
21
+ import { ModuleInfo } from './types/module-info';
22
+ import { OutputBundle } from './types/output-bundle';
23
+ import type { RolldownOptions } from './types/rolldown-options';
24
+ import { OutputAsset, OutputChunk, RenderedChunk, RenderedModule, RolldownOutput, SourceMap } from './types/rolldown-output';
25
+ import { ExistingRawSourceMap, SourceMapInput } from './types/sourcemap';
26
+ import { PartialNull } from './types/utils';
27
+ import { defineConfig } from './utils/define-config';
28
+ export { build, defineConfig, rolldown, watch };
29
+ export declare const VERSION: string;
30
+ export type { AsyncPluginHooks, BuildOptions, ConfigExport, CustomPluginOptions, DefineParallelPluginResult, EmittedAsset, EmittedFile, ExistingRawSourceMap, ExternalOption, FunctionPluginHooks, GetModuleInfo, HookFilter, HookFilterExtension, ImportKind, InputOption, InputOptions, InternalModuleFormat, JsxOptions, LoadResult, LogOrStringHandler, MinimalPluginContext, ModuleFormat, ModuleInfo, ModuleOptions, ModuleType, ModuleTypeFilter, NormalizedInputOptions, NormalizedOutputOptions, ObjectHook, OutputAsset, OutputBundle, OutputChunk, OutputOptions, ParallelPluginHooks, PartialNull, PartialResolvedId, Plugin, PluginContext, PluginContextMeta, PreRenderedAsset, PreRenderedChunk, RenderedChunk, RenderedModule, ResolvedId, ResolveIdExtraOptions, ResolveIdResult, RolldownBuild, RolldownOptions, RolldownOutput, RolldownPlugin, RolldownPluginOption, RolldownWatcher, SourceDescription, SourceMap, SourceMapInput, StringFilter, TransformPluginContext, TransformResult, WatchOptions, };
31
+ export type { LoggingFunction, LogLevel, RollupError, RollupLog, WarningHandlerWithDefault, } from './types/misc';
@@ -0,0 +1,4 @@
1
+ import type { LoggingFunctionWithPosition, LogHandler, RollupLog } from '../types/misc';
2
+ import { type LogLevel, type LogLevelOption } from './logging';
3
+ export declare const normalizeLog: (log: RollupLog | string | (() => RollupLog | string)) => RollupLog;
4
+ export declare function getLogHandler(level: LogLevel, code: string, logger: LogHandler, pluginName: string, logLevel: LogLevelOption): LoggingFunctionWithPosition;
@@ -0,0 +1,6 @@
1
+ import type { InputOptions } from '../options/input-options';
2
+ import type { Plugin } from '../plugin';
3
+ import type { LogHandler } from '../types/misc';
4
+ import { type LogLevelOption } from './logging';
5
+ export declare function getLogger(plugins: Plugin[], onLog: LogHandler, logLevel: LogLevelOption, watchMode: boolean): LogHandler;
6
+ export declare const getOnLog: (config: InputOptions, logLevel: LogLevelOption, printLog?: LogHandler) => LogHandler;
@@ -0,0 +1,12 @@
1
+ export type LogLevel = 'info' | 'debug' | 'warn';
2
+ export type LogLevelOption = LogLevel | 'silent';
3
+ export type LogLevelWithError = LogLevel | 'error';
4
+ export type RollupLog = any;
5
+ export type RollupLogWithString = RollupLog | string;
6
+ export type LogOrStringHandler = (level: LogLevelWithError, log: RollupLogWithString) => void;
7
+ export declare const LOG_LEVEL_SILENT: LogLevelOption;
8
+ export declare const LOG_LEVEL_ERROR = "error";
9
+ export declare const LOG_LEVEL_WARN: LogLevel;
10
+ export declare const LOG_LEVEL_INFO: LogLevel;
11
+ export declare const LOG_LEVEL_DEBUG: LogLevel;
12
+ export declare const logLevelPriority: Record<LogLevelOption, number>;
@@ -0,0 +1,18 @@
1
+ import type { RollupLog } from '../types/misc';
2
+ export declare function logParseError(message: string): RollupLog;
3
+ export declare function logMinifyWarning(): RollupLog;
4
+ export declare function logInvalidLogPosition(pluginName: string): RollupLog;
5
+ export declare function logInputHookInOutputPlugin(pluginName: string, hookName: string): RollupLog;
6
+ export declare function logCycleLoading(pluginName: string, moduleId: string): RollupLog;
7
+ export declare function logMultiplyNotifyOption(): RollupLog;
8
+ export declare function logPluginError(error: Omit<RollupLog, 'code'> & {
9
+ code?: unknown;
10
+ }, plugin: string, { hook, id }?: {
11
+ hook?: string;
12
+ id?: string;
13
+ }): RollupLog;
14
+ export declare function error(base: Error | RollupLog): never;
15
+ export declare function augmentCodeLocation(properties: RollupLog, pos: number | {
16
+ column: number;
17
+ line: number;
18
+ }, source: string, id: string): void;
@@ -0,0 +1,57 @@
1
+ export interface ChecksOptions {
2
+ /**
3
+ * Whether to emit warning when detecting circular dependency
4
+ * @default false
5
+ */
6
+ circularDependency?: boolean;
7
+ /**
8
+ * Whether to emit warning when detecting eval
9
+ * @default true
10
+ */
11
+ eval?: boolean;
12
+ /**
13
+ * Whether to emit warning when detecting missing global name
14
+ * @default true
15
+ */
16
+ missingGlobalName?: boolean;
17
+ /**
18
+ * Whether to emit warning when detecting missing name option for iife export
19
+ * @default true
20
+ */
21
+ missingNameOptionForIifeExport?: boolean;
22
+ /**
23
+ * Whether to emit warning when detecting mixed export
24
+ * @default true
25
+ */
26
+ mixedExport?: boolean;
27
+ /**
28
+ * Whether to emit warning when detecting unresolved entry
29
+ * @default true
30
+ */
31
+ unresolvedEntry?: boolean;
32
+ /**
33
+ * Whether to emit warning when detecting unresolved import
34
+ * @default true
35
+ */
36
+ unresolvedImport?: boolean;
37
+ /**
38
+ * Whether to emit warning when detecting filename conflict
39
+ * @default true
40
+ */
41
+ filenameConflict?: boolean;
42
+ /**
43
+ * Whether to emit warning when detecting common js variable in esm
44
+ * @default true
45
+ */
46
+ commonJsVariableInEsm?: boolean;
47
+ /**
48
+ * Whether to emit warning when detecting import is undefined
49
+ * @default true
50
+ */
51
+ importIsUndefined?: boolean;
52
+ /**
53
+ * Whether to emit warning when detecting configuration field conflict
54
+ * @default true
55
+ */
56
+ configurationFieldConflict?: boolean;
57
+ }
@@ -0,0 +1,185 @@
1
+ import { TransformOptions } from '../binding';
2
+ import type { LogLevel, LogLevelOption, LogOrStringHandler, RollupLog, RollupLogWithString } from '../log/logging';
3
+ import type { RolldownPluginOption } from '../plugin';
4
+ import type { TreeshakingOptions } from '../types/module-side-effects';
5
+ import type { NullValue, StringOrRegExp } from '../types/utils';
6
+ import type { ChecksOptions } from './generated/checks-options';
7
+ export type InputOption = string | string[] | Record<string, string>;
8
+ type OxcTransformOption = Omit<TransformOptions, 'sourceType' | 'lang' | 'cwd' | 'sourcemap' | 'jsx' | 'define' | 'inject' | 'target'>;
9
+ export type ExternalOption = StringOrRegExp | StringOrRegExp[] | ((id: string, parentId: string | undefined, isResolved: boolean) => NullValue<boolean>);
10
+ export type ModuleTypes = Record<string, 'js' | 'jsx' | 'ts' | 'tsx' | 'json' | 'text' | 'base64' | 'dataurl' | 'binary' | 'empty' | 'css'>;
11
+ export interface JsxOptions {
12
+ mode?: 'classic' | 'automatic' | 'preserve';
13
+ factory?: string;
14
+ fragment?: string;
15
+ importSource?: string;
16
+ jsxImportSource?: string;
17
+ refresh?: boolean;
18
+ development?: boolean;
19
+ }
20
+ export interface WatchOptions {
21
+ skipWrite?: boolean;
22
+ buildDelay?: number;
23
+ notify?: {
24
+ pollInterval?: number;
25
+ compareContents?: boolean;
26
+ };
27
+ include?: StringOrRegExp | StringOrRegExp[];
28
+ exclude?: StringOrRegExp | StringOrRegExp[];
29
+ }
30
+ export type MakeAbsoluteExternalsRelative = boolean | 'ifRelativeSource';
31
+ export type HmrOptions = boolean | {
32
+ host?: string;
33
+ port?: number;
34
+ implement?: string;
35
+ };
36
+ export interface InputOptions {
37
+ input?: InputOption;
38
+ plugins?: RolldownPluginOption;
39
+ external?: ExternalOption;
40
+ resolve?: {
41
+ /**
42
+ * > [!WARNING]
43
+ * > `resolve.alias` will not call `resolveId` hooks of other plugin.
44
+ * > If you want to call `resolveId` hooks of other plugin, use `aliasPlugin` from `rolldown/experimental` instead.
45
+ * > You could find more discussion in [this issue](https://github.com/rolldown/rolldown/issues/3615)
46
+ */
47
+ alias?: Record<string, string[] | string>;
48
+ aliasFields?: string[][];
49
+ conditionNames?: string[];
50
+ /**
51
+ * Map of extensions to alternative extensions.
52
+ *
53
+ * With writing `import './foo.js'` in a file, you want to resolve it to `foo.ts` instead of `foo.js`.
54
+ * You can achieve this by setting: `extensionAlias: { '.js': ['.ts', '.js'] }`.
55
+ */
56
+ extensionAlias?: Record<string, string[]>;
57
+ exportsFields?: string[][];
58
+ extensions?: string[];
59
+ mainFields?: string[];
60
+ mainFiles?: string[];
61
+ modules?: string[];
62
+ symlinks?: boolean;
63
+ tsconfigFilename?: string;
64
+ };
65
+ cwd?: string;
66
+ /**
67
+ * Expected platform where the code run.
68
+ *
69
+ * @default
70
+ * - 'node' if the format is 'cjs'
71
+ * - 'browser' for other formats
72
+ */
73
+ platform?: 'node' | 'browser' | 'neutral';
74
+ shimMissingExports?: boolean;
75
+ treeshake?: boolean | TreeshakingOptions;
76
+ logLevel?: LogLevelOption;
77
+ onLog?: (level: LogLevel, log: RollupLog, defaultHandler: LogOrStringHandler) => void;
78
+ onwarn?: (warning: RollupLog, defaultHandler: (warning: RollupLogWithString | (() => RollupLogWithString)) => void) => void;
79
+ moduleTypes?: ModuleTypes;
80
+ experimental?: {
81
+ enableComposingJsPlugins?: boolean;
82
+ strictExecutionOrder?: boolean;
83
+ disableLiveBindings?: boolean;
84
+ viteMode?: boolean;
85
+ resolveNewUrlToAsset?: boolean;
86
+ hmr?: HmrOptions;
87
+ };
88
+ /**
89
+ * Replace global variables or [property accessors](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Property_accessors) with the provided values.
90
+ *
91
+ * # Examples
92
+ *
93
+ * - Replace the global variable `IS_PROD` with `true`
94
+ *
95
+ * ```js rolldown.config.js
96
+ * export default defineConfig({ define: { IS_PROD: 'true' // or JSON.stringify(true) } })
97
+ * ```
98
+ *
99
+ * Result:
100
+ *
101
+ * ```js
102
+ * // Input
103
+ * if (IS_PROD) {
104
+ * console.log('Production mode')
105
+ * }
106
+ *
107
+ * // After bundling
108
+ * if (true) {
109
+ * console.log('Production mode')
110
+ * }
111
+ * ```
112
+ *
113
+ * - Replace the property accessor `process.env.NODE_ENV` with `'production'`
114
+ *
115
+ * ```js rolldown.config.js
116
+ * export default defineConfig({ define: { 'process.env.NODE_ENV': "'production'" } })
117
+ * ```
118
+ *
119
+ * Result:
120
+ *
121
+ * ```js
122
+ * // Input
123
+ * if (process.env.NODE_ENV === 'production') {
124
+ * console.log('Production mode')
125
+ * }
126
+ *
127
+ * // After bundling
128
+ * if ('production' === 'production') {
129
+ * console.log('Production mode')
130
+ * }
131
+ *
132
+ * ```
133
+ */
134
+ define?: Record<string, string>;
135
+ /**
136
+ * Inject import statements on demand.
137
+ *
138
+ * ## Supported patterns
139
+ * ```js
140
+ * {
141
+ * // import { Promise } from 'es6-promise'
142
+ * Promise: ['es6-promise', 'Promise'],
143
+ *
144
+ * // import { Promise as P } from 'es6-promise'
145
+ * P: ['es6-promise', 'Promise'],
146
+ *
147
+ * // import $ from 'jquery'
148
+ * $: 'jquery',
149
+ *
150
+ * // import * as fs from 'node:fs'
151
+ * fs: ['node:fs', '*'],
152
+ *
153
+ * // Inject shims for property access pattern
154
+ * 'Object.assign': path.resolve( 'src/helpers/object-assign.js' ),
155
+ * }
156
+ * ```
157
+ */
158
+ inject?: Record<string, string | [string, string]>;
159
+ profilerNames?: boolean;
160
+ /**
161
+ * - `false` disables the JSX parser, resulting in a syntax error if JSX syntax is used.
162
+ * - `"preserve"` disables the JSX transformer, preserving the original JSX syntax in the output.
163
+ * - `"react"` enables the `classic` JSX transformer.
164
+ * - `"react-jsx"` enables the `automatic` JSX transformer.
165
+ *
166
+ * @default mode = "automatic"
167
+ */
168
+ jsx?: false | 'react' | 'react-jsx' | 'preserve' | JsxOptions;
169
+ transform?: OxcTransformOption;
170
+ watch?: WatchOptions | false;
171
+ dropLabels?: string[];
172
+ keepNames?: boolean;
173
+ checks?: ChecksOptions;
174
+ makeAbsoluteExternalsRelative?: MakeAbsoluteExternalsRelative;
175
+ debug?: {
176
+ buildId?: string;
177
+ };
178
+ }
179
+ interface OverwriteInputOptionsForCli {
180
+ external?: string[];
181
+ inject?: Record<string, string>;
182
+ treeshake?: boolean;
183
+ }
184
+ export type InputCliOptions = Omit<InputOptions, keyof OverwriteInputOptionsForCli | 'input' | 'plugins' | 'onwarn' | 'onLog' | 'resolve' | 'experimental' | 'profilerNames' | 'watch'> & OverwriteInputOptionsForCli;
185
+ export {};
@@ -0,0 +1,18 @@
1
+ import { InputOptions } from '..';
2
+ import { BindingNormalizedOptions } from '../binding';
3
+ import type { LogHandler } from '../types/misc';
4
+ export interface NormalizedInputOptions {
5
+ input: string[] | Record<string, string>;
6
+ cwd: string | undefined;
7
+ platform: InputOptions['platform'];
8
+ shimMissingExports: boolean;
9
+ }
10
+ export declare class NormalizedInputOptionsImpl implements NormalizedInputOptions {
11
+ onLog: LogHandler;
12
+ inner: BindingNormalizedOptions;
13
+ constructor(inner: BindingNormalizedOptions, onLog: LogHandler);
14
+ get shimMissingExports(): boolean;
15
+ get input(): string[] | Record<string, string>;
16
+ get cwd(): string | undefined;
17
+ get platform(): 'browser' | 'node' | 'neutral';
18
+ }
@@ -0,0 +1,70 @@
1
+ import { RolldownPlugin } from '..';
2
+ import type { BindingMinifyOptions, BindingNormalizedOptions } from '../binding';
3
+ import type { SourcemapIgnoreListOption, SourcemapPathTransformOption } from '../types/misc';
4
+ import type { AddonFunction, AssetFileNamesFunction, ChunkFileNamesFunction, GlobalsFunction, OutputOptions } from './output-options';
5
+ export type InternalModuleFormat = 'es' | 'cjs' | 'iife' | 'umd' | 'app';
6
+ export interface NormalizedOutputOptions {
7
+ name: string | undefined;
8
+ file: string | undefined;
9
+ dir: string | undefined;
10
+ entryFileNames: string | ChunkFileNamesFunction;
11
+ chunkFileNames: string | ChunkFileNamesFunction;
12
+ assetFileNames: string | AssetFileNamesFunction;
13
+ format: InternalModuleFormat;
14
+ exports: NonNullable<OutputOptions['exports']>;
15
+ sourcemap: boolean | 'inline' | 'hidden';
16
+ cssEntryFileNames: string | ChunkFileNamesFunction;
17
+ cssChunkFileNames: string | ChunkFileNamesFunction;
18
+ inlineDynamicImports: boolean;
19
+ externalLiveBindings: boolean;
20
+ banner: AddonFunction;
21
+ footer: AddonFunction;
22
+ intro: AddonFunction;
23
+ outro: AddonFunction;
24
+ esModule: boolean | 'if-default-prop';
25
+ extend: boolean;
26
+ globals: Record<string, string> | GlobalsFunction;
27
+ hashCharacters: 'base64' | 'base36' | 'hex';
28
+ sourcemapDebugIds: boolean;
29
+ sourcemapIgnoreList: SourcemapIgnoreListOption;
30
+ sourcemapPathTransform: SourcemapPathTransformOption | undefined;
31
+ minify: false | BindingMinifyOptions;
32
+ comments: 'none' | 'preserve-legal';
33
+ polyfillRequire: boolean;
34
+ plugins: RolldownPlugin[];
35
+ }
36
+ export declare class NormalizedOutputOptionsImpl implements NormalizedOutputOptions {
37
+ private inner;
38
+ private outputOptions;
39
+ private normalizedOutputPlugins;
40
+ constructor(inner: BindingNormalizedOptions, outputOptions: OutputOptions, normalizedOutputPlugins: RolldownPlugin[]);
41
+ get dir(): string | undefined;
42
+ get entryFileNames(): string | ChunkFileNamesFunction;
43
+ get chunkFileNames(): string | ChunkFileNamesFunction;
44
+ get assetFileNames(): string | AssetFileNamesFunction;
45
+ get format(): 'es' | 'cjs' | 'app' | 'iife' | 'umd';
46
+ get exports(): 'default' | 'named' | 'none' | 'auto';
47
+ get sourcemap(): boolean | 'inline' | 'hidden';
48
+ get cssEntryFileNames(): string | ChunkFileNamesFunction;
49
+ get cssChunkFileNames(): string | ChunkFileNamesFunction;
50
+ get shimMissingExports(): boolean;
51
+ get name(): string | undefined;
52
+ get file(): string | undefined;
53
+ get inlineDynamicImports(): boolean;
54
+ get externalLiveBindings(): boolean;
55
+ get banner(): AddonFunction;
56
+ get footer(): AddonFunction;
57
+ get intro(): AddonFunction;
58
+ get outro(): AddonFunction;
59
+ get esModule(): boolean | 'if-default-prop';
60
+ get extend(): boolean;
61
+ get globals(): Record<string, string> | GlobalsFunction;
62
+ get hashCharacters(): 'base64' | 'base36' | 'hex';
63
+ get sourcemapDebugIds(): boolean;
64
+ get sourcemapIgnoreList(): SourcemapIgnoreListOption;
65
+ get sourcemapPathTransform(): SourcemapPathTransformOption | undefined;
66
+ get minify(): false | BindingMinifyOptions;
67
+ get comments(): 'none' | 'preserve-legal';
68
+ get polyfillRequire(): boolean;
69
+ get plugins(): RolldownPlugin[];
70
+ }