@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,182 @@
1
+ import type { PreRenderedChunk } from '../binding';
2
+ import { RolldownOutputPluginOption } from '../plugin';
3
+ import { SourcemapIgnoreListOption, SourcemapPathTransformOption } from '../types/misc';
4
+ import { RenderedChunk } from '../types/rolldown-output';
5
+ import type { StringOrRegExp } from '../types/utils';
6
+ export type ModuleFormat = 'es' | 'cjs' | 'esm' | 'module' | 'commonjs' | 'iife' | 'umd' | 'experimental-app';
7
+ export type AddonFunction = (chunk: RenderedChunk) => string | Promise<string>;
8
+ export type ChunkFileNamesFunction = (chunkInfo: PreRenderedChunk) => string;
9
+ export interface MinifyOptions {
10
+ mangle: boolean;
11
+ compress: boolean;
12
+ removeWhitespace: boolean;
13
+ }
14
+ export interface PreRenderedAsset {
15
+ names: string[];
16
+ originalFileNames: string[];
17
+ source: string | Uint8Array;
18
+ type: 'asset';
19
+ }
20
+ export type AssetFileNamesFunction = (chunkInfo: PreRenderedAsset) => string;
21
+ export type GlobalsFunction = (name: string) => string;
22
+ export type ESTarget = 'es6' | 'es2015' | 'es2016' | 'es2017' | 'es2018' | 'es2019' | 'es2020' | 'es2021' | 'es2022' | 'es2023' | 'es2024' | 'esnext';
23
+ export interface OutputOptions {
24
+ dir?: string;
25
+ file?: string;
26
+ exports?: 'auto' | 'named' | 'default' | 'none';
27
+ hashCharacters?: 'base64' | 'base36' | 'hex';
28
+ /**
29
+ * Expected format of generated code.
30
+ * - `'es'`, `'esm'` and `'module'` are the same format, all stand for ES module.
31
+ * - `'cjs'` and `'commonjs'` are the same format, all stand for CommonJS module.
32
+ * - `'iife'` stands for [Immediately Invoked Function Expression](https://developer.mozilla.org/en-US/docs/Glossary/IIFE).
33
+ * - `'umd'` stands for [Universal Module Definition](https://github.com/umdjs/umd).
34
+ *
35
+ * @default 'esm'
36
+ */
37
+ format?: ModuleFormat;
38
+ sourcemap?: boolean | 'inline' | 'hidden';
39
+ sourcemapDebugIds?: boolean;
40
+ sourcemapIgnoreList?: boolean | SourcemapIgnoreListOption;
41
+ sourcemapPathTransform?: SourcemapPathTransformOption;
42
+ banner?: string | AddonFunction;
43
+ footer?: string | AddonFunction;
44
+ intro?: string | AddonFunction;
45
+ outro?: string | AddonFunction;
46
+ extend?: boolean;
47
+ esModule?: boolean | 'if-default-prop';
48
+ assetFileNames?: string | AssetFileNamesFunction;
49
+ entryFileNames?: string | ChunkFileNamesFunction;
50
+ chunkFileNames?: string | ChunkFileNamesFunction;
51
+ cssEntryFileNames?: string | ChunkFileNamesFunction;
52
+ cssChunkFileNames?: string | ChunkFileNamesFunction;
53
+ sanitizeFileName?: boolean | ((name: string) => string);
54
+ minify?: boolean | 'dce-only' | MinifyOptions;
55
+ name?: string;
56
+ globals?: Record<string, string> | GlobalsFunction;
57
+ externalLiveBindings?: boolean;
58
+ inlineDynamicImports?: boolean;
59
+ /**
60
+ * Allows you to do advanced chunking. Use it to reduce the number of common chunks or split out a chunk that hardly changes to obtain better caching.
61
+ */
62
+ advancedChunks?: {
63
+ /**
64
+ * - Type: `number`
65
+ *
66
+ * Global fallback of [`{group}.minSize`](#advancedchunks-groups-minsize), if it's not specified in the group.
67
+ */
68
+ minSize?: number;
69
+ /**
70
+ * - Type: `number`
71
+ *
72
+ * Global fallback of [`{group}.maxSize`](#advancedchunks-groups-maxsize), if it's not specified in the group.
73
+ */
74
+ maxSize?: number;
75
+ /**
76
+ * - Type: `number`
77
+ *
78
+ * Global fallback of [`{group}.maxModuleSize`](#advancedchunks-groups-maxmodulesize), if it's not specified in the group.
79
+ */
80
+ maxModuleSize?: number;
81
+ /**
82
+ * - Type: `number`
83
+ *
84
+ * Global fallback of [`{group}.minModuleSize`](#advancedchunks-groups-minmodulesize), if it's not specified in the group.
85
+ */
86
+ minModuleSize?: number;
87
+ /**
88
+ * - Type: `number`
89
+ *
90
+ * Global fallback of [`{group}.minShareCount`](#advancedchunks-groups-minsharecount), if it's not specified in the group.
91
+ */
92
+ minShareCount?: number;
93
+ /**
94
+ * Groups to be used for advanced chunking.
95
+ */
96
+ groups?: {
97
+ /**
98
+ * - Type: `string`
99
+ *
100
+ * Name of the group. It will be also used as the name of the chunk and replaced the `[name]` placeholder in the `chunkFileNames` option.
101
+ */
102
+ name: string;
103
+ /**
104
+ * - Type: `string | RegExp`
105
+ *
106
+ * Controls which modules are captured in this group.
107
+ *
108
+ * If `test` is a string, the module whose id contains the string will be captured.
109
+ * If `test` is a regular expression, the module whose id matches the regular expression will be captured.
110
+ * if `test` is empty, any module will be considered as matched.
111
+ */
112
+ test?: StringOrRegExp;
113
+ /**
114
+ * - Type: `number`
115
+ *
116
+ * Priority of the group. Group with higher priority will be chosen first to match modules and create chunks. When converting the group to a chunk, modules of that group will be removed from other groups.
117
+ *
118
+ * If two groups have the same priority, the group whose index is smaller will be chosen.
119
+ */
120
+ priority?: number;
121
+ /**
122
+ * - Type: `number`
123
+ * - Default: `0`
124
+ *
125
+ * Minimum size of the desired chunk. If accumulated size of captured modules is smaller than this value, this group will be ignored.s
126
+ */
127
+ minSize?: number;
128
+ /**
129
+ * - Type: `number`
130
+ * - Default: `1`
131
+ *
132
+ * Controls if a module should be captured based on how many entry chunks reference it.
133
+ */
134
+ minShareCount?: number;
135
+ /**
136
+ * - Type: `number`
137
+ * - Default: `Infinity`
138
+ *
139
+ * If final size of this group is larger than this value, this group will be spit into multiple groups that each has size closed to this value.
140
+ */
141
+ maxSize?: number;
142
+ /**
143
+ * - Type: `number`
144
+ * - Default: `Infinity`
145
+ *
146
+ * Controls a module could only be captured if its size is smaller or equal than this value.
147
+ */
148
+ maxModuleSize?: number;
149
+ /**
150
+ * - Type: `number`
151
+ * - Default: `0`
152
+ *
153
+ * Controls a module could only be captured if its size is larger or equal than this value.
154
+ */
155
+ minModuleSize?: number;
156
+ }[];
157
+ };
158
+ /**
159
+ * Control comments in the output.
160
+ *
161
+ * - `none`: no comments
162
+ * - `preserve-legal`: preserve comments that contain `@license`, `@preserve` or starts with `//!` `/*!`
163
+ */
164
+ comments?: 'none' | 'preserve-legal';
165
+ plugins?: RolldownOutputPluginOption;
166
+ polyfillRequire?: boolean;
167
+ target?: ESTarget;
168
+ }
169
+ interface OverwriteOutputOptionsForCli {
170
+ banner?: string;
171
+ footer?: string;
172
+ intro?: string;
173
+ outro?: string;
174
+ esModule?: boolean;
175
+ globals?: Record<string, string>;
176
+ advancedChunks?: {
177
+ minSize?: number;
178
+ minShareCount?: number;
179
+ };
180
+ }
181
+ export type OutputCliOptions = Omit<OutputOptions, keyof OverwriteOutputOptionsForCli | 'sourcemapIgnoreList' | 'sourcemapPathTransform'> & OverwriteOutputOptionsForCli;
182
+ export {};
@@ -0,0 +1,5 @@
1
+ import { InputOptions } from '../options/input-options';
2
+ import { OutputOptions } from '../options/output-options';
3
+ export interface WatchOptions extends InputOptions {
4
+ output?: OutputOptions | OutputOptions[];
5
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export { type Context, defineParallelPluginImplementation, type ParallelPluginImplementation, } from './plugin/parallel-plugin-implementation';
@@ -0,0 +1,5 @@
1
+ import { Program } from '@oxc-project/types';
2
+ import type { ParseResult, ParserOptions } from './binding';
3
+ export declare function parseAst(sourceText: string, options?: ParserOptions | undefined | null, filename?: string): Program;
4
+ export declare function parseAstAsync(sourceText: string, options?: ParserOptions | undefined | null, filename?: string): Promise<Program>;
5
+ export type { ParseResult, ParserOptions };
@@ -0,0 +1,10 @@
1
+ import type { BindingGeneralHookFilter, BindingPluginOptions, BindingTransformHookFilter } from '../binding';
2
+ import type { BindingifyPluginArgs } from './bindingify-plugin';
3
+ import { PluginHookWithBindingExt } from './bindingify-plugin-hook-meta';
4
+ export declare function bindingifyBuildStart(args: BindingifyPluginArgs): PluginHookWithBindingExt<BindingPluginOptions['buildStart']>;
5
+ export declare function bindingifyBuildEnd(args: BindingifyPluginArgs): PluginHookWithBindingExt<BindingPluginOptions['buildEnd']>;
6
+ export declare function bindingifyResolveId(args: BindingifyPluginArgs): PluginHookWithBindingExt<BindingPluginOptions['resolveId'], BindingGeneralHookFilter | undefined>;
7
+ export declare function bindingifyResolveDynamicImport(args: BindingifyPluginArgs): PluginHookWithBindingExt<BindingPluginOptions['resolveDynamicImport']>;
8
+ export declare function bindingifyTransform(args: BindingifyPluginArgs): PluginHookWithBindingExt<BindingPluginOptions['transform'], BindingTransformHookFilter | undefined>;
9
+ export declare function bindingifyLoad(args: BindingifyPluginArgs): PluginHookWithBindingExt<BindingPluginOptions['load'], BindingGeneralHookFilter | undefined>;
10
+ export declare function bindingifyModuleParsed(args: BindingifyPluginArgs): PluginHookWithBindingExt<BindingPluginOptions['moduleParsed']>;
@@ -0,0 +1,7 @@
1
+ import type { BindingGeneralHookFilter, BindingTransformHookFilter } from '../binding.d';
2
+ import type { HookFilterExtension } from '.';
3
+ import type { StringFilter } from './hook-filter';
4
+ export declare function bindingifyStringFilter(matcher: StringFilter): BindingGeneralHookFilter;
5
+ export declare function bindingifyResolveIdFilter(filterOption?: HookFilterExtension<'resolveId'>['filter']): BindingGeneralHookFilter | undefined;
6
+ export declare function bindingifyLoadFilter(filterOption?: HookFilterExtension<'load'>['filter']): BindingGeneralHookFilter | undefined;
7
+ export declare function bindingifyTransformFilter(filterOption?: HookFilterExtension<'transform'>['filter']): BindingTransformHookFilter | undefined;
@@ -0,0 +1,14 @@
1
+ import type { BindingPluginOptions } from '../binding';
2
+ import type { BindingifyPluginArgs } from './bindingify-plugin';
3
+ import { PluginHookWithBindingExt } from './bindingify-plugin-hook-meta';
4
+ export declare function bindingifyRenderStart(args: BindingifyPluginArgs): PluginHookWithBindingExt<BindingPluginOptions['renderStart']>;
5
+ export declare function bindingifyRenderChunk(args: BindingifyPluginArgs): PluginHookWithBindingExt<BindingPluginOptions['renderChunk']>;
6
+ export declare function bindingifyAugmentChunkHash(args: BindingifyPluginArgs): PluginHookWithBindingExt<BindingPluginOptions['augmentChunkHash']>;
7
+ export declare function bindingifyRenderError(args: BindingifyPluginArgs): PluginHookWithBindingExt<BindingPluginOptions['renderError']>;
8
+ export declare function bindingifyGenerateBundle(args: BindingifyPluginArgs): PluginHookWithBindingExt<BindingPluginOptions['generateBundle']>;
9
+ export declare function bindingifyWriteBundle(args: BindingifyPluginArgs): PluginHookWithBindingExt<BindingPluginOptions['writeBundle']>;
10
+ export declare function bindingifyCloseBundle(args: BindingifyPluginArgs): PluginHookWithBindingExt<BindingPluginOptions['closeBundle']>;
11
+ export declare function bindingifyBanner(args: BindingifyPluginArgs): PluginHookWithBindingExt<BindingPluginOptions['banner']>;
12
+ export declare function bindingifyFooter(args: BindingifyPluginArgs): PluginHookWithBindingExt<BindingPluginOptions['footer']>;
13
+ export declare function bindingifyIntro(args: BindingifyPluginArgs): PluginHookWithBindingExt<BindingPluginOptions['intro']>;
14
+ export declare function bindingifyOutro(args: BindingifyPluginArgs): PluginHookWithBindingExt<BindingPluginOptions['outro']>;
@@ -0,0 +1,8 @@
1
+ import { BindingPluginHookMeta } from '../binding';
2
+ import { ObjectHookMeta } from '.';
3
+ export declare function bindingifyPluginHookMeta(options: ObjectHookMeta): BindingPluginHookMeta;
4
+ export type PluginHookWithBindingExt<T, F = undefined> = {
5
+ plugin?: T;
6
+ meta?: BindingPluginHookMeta;
7
+ filter?: F;
8
+ };
@@ -0,0 +1,17 @@
1
+ import type { BindingPluginOptions } from '../binding';
2
+ import type { InputOptions } from '../options/input-options';
3
+ import type { OutputOptions } from '../options/output-options';
4
+ import type { LogHandler, LogLevelOption } from '../types/misc';
5
+ import type { Plugin, RolldownPlugin } from './index';
6
+ import { PluginContextData } from './plugin-context-data';
7
+ export interface BindingifyPluginArgs {
8
+ plugin: Plugin;
9
+ options: InputOptions;
10
+ outputOptions: OutputOptions;
11
+ pluginContextData: PluginContextData;
12
+ onLog: LogHandler;
13
+ logLevel: LogLevelOption;
14
+ watchMode: boolean;
15
+ normalizedOutputPlugins: RolldownPlugin[];
16
+ }
17
+ export declare function bindingifyPlugin(plugin: Plugin, options: InputOptions, outputOptions: OutputOptions, pluginContextData: PluginContextData, normalizedOutputPlugins: RolldownPlugin[], onLog: LogHandler, logLevel: LogLevelOption, watchMode: boolean): BindingPluginOptions;
@@ -0,0 +1,5 @@
1
+ import type { BindingPluginOptions } from '../binding';
2
+ import { BindingifyPluginArgs } from './bindingify-plugin';
3
+ import { PluginHookWithBindingExt } from './bindingify-plugin-hook-meta';
4
+ export declare function bindingifyWatchChange(args: BindingifyPluginArgs): PluginHookWithBindingExt<BindingPluginOptions['watchChange']>;
5
+ export declare function bindingifyCloseWatcher(args: BindingifyPluginArgs): PluginHookWithBindingExt<BindingPluginOptions['closeWatcher']>;
@@ -0,0 +1,49 @@
1
+ import type { ModuleType } from '../index';
2
+ import type { MaybeArray } from '../types/utils';
3
+ import type { StringOrRegExp } from '../types/utils';
4
+ export type StringFilter<Value = StringOrRegExp> = MaybeArray<Value> | {
5
+ include?: MaybeArray<Value>;
6
+ exclude?: MaybeArray<Value>;
7
+ };
8
+ interface FormalModuleTypeFilter {
9
+ include?: ModuleType[];
10
+ }
11
+ export type ModuleTypeFilter = ModuleType[] | FormalModuleTypeFilter;
12
+ export interface HookFilter {
13
+ /**
14
+ * This filter is used to do a pre-test to determine whether the hook should be called.
15
+ *
16
+ * @example
17
+ * Include all `id`s that contain `node_modules` in the path.
18
+ * ```js
19
+ * { id: 'node_modules' }
20
+ * ```
21
+ * @example
22
+ * Include all `id`s that contain `node_modules` or `src` in the path.
23
+ * ```js
24
+ * { id: ['node_modules', 'src'] }
25
+ * ```
26
+ * @example
27
+ * Include all `id`s that start with `http`
28
+ * ```js
29
+ * { id: /^http/ }
30
+ * ```
31
+ * @example
32
+ * Exclude all `id`s that contain `node_modules` in the path.
33
+ * ```js
34
+ * { id: { exclude: 'node_modules' } }
35
+ * ```
36
+ * @example
37
+ * Formal pattern to define includes and excludes.
38
+ * ```
39
+ * { id : {
40
+ * include: ["foo", /bar/],
41
+ * exclude: ["baz", /qux/]
42
+ * }}
43
+ * ```
44
+ */
45
+ id?: StringFilter;
46
+ moduleType?: ModuleTypeFilter;
47
+ code?: StringFilter;
48
+ }
49
+ export {};
@@ -0,0 +1,141 @@
1
+ import type { InputOptions, OutputOptions } from '..';
2
+ import type { BindingHookResolveIdExtraArgs, BindingTransformHookExtraArgs } from '../binding';
3
+ import type { BuiltinPlugin } from '../builtin-plugin/constructors';
4
+ import type { DefinedHookNames } from '../constants/plugin';
5
+ import type { DEFINED_HOOK_NAMES } from '../constants/plugin';
6
+ import type { SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF } from '../constants/plugin-context';
7
+ import type { LogLevel } from '../log/logging';
8
+ import type { NormalizedInputOptions } from '../options/normalized-input-options';
9
+ import type { NormalizedOutputOptions } from '../options/normalized-output-options';
10
+ import type { RollupLog } from '../types/misc';
11
+ import type { ModuleInfo } from '../types/module-info';
12
+ import type { OutputBundle } from '../types/output-bundle';
13
+ import { RenderedChunk } from '../types/rolldown-output';
14
+ import type { SourceMapInput } from '../types/sourcemap';
15
+ import type { MakeAsync, MaybePromise, NullValue, PartialNull } from '../types/utils';
16
+ import type { HookFilter, StringFilter } from './hook-filter';
17
+ import type { MinimalPluginContext } from './minimal-plugin-context';
18
+ import type { ParallelPlugin } from './parallel-plugin';
19
+ import type { PluginContext } from './plugin-context';
20
+ import type { TransformPluginContext } from './transform-plugin-context';
21
+ export type ModuleSideEffects = boolean | 'no-treeshake' | null;
22
+ export { withFilter } from './with-filter';
23
+ export type ModuleType = 'js' | 'jsx' | 'ts' | 'tsx' | 'json' | 'text' | 'base64' | 'dataurl' | 'binary' | 'empty' | (string & {});
24
+ export type ImportKind = BindingHookResolveIdExtraArgs['kind'];
25
+ export interface CustomPluginOptions {
26
+ [plugin: string]: any;
27
+ }
28
+ export interface ModuleOptions {
29
+ moduleSideEffects: ModuleSideEffects;
30
+ meta: CustomPluginOptions;
31
+ invalidate?: boolean;
32
+ }
33
+ export interface ResolvedId extends ModuleOptions {
34
+ external: boolean | 'absolute';
35
+ id: string;
36
+ }
37
+ export interface PartialResolvedId extends Partial<PartialNull<ModuleOptions>> {
38
+ external?: boolean | 'absolute' | 'relative';
39
+ id: string;
40
+ }
41
+ export interface SourceDescription extends Partial<PartialNull<ModuleOptions>> {
42
+ code: string;
43
+ map?: SourceMapInput;
44
+ moduleType?: ModuleType;
45
+ }
46
+ export interface ResolveIdExtraOptions {
47
+ custom?: CustomPluginOptions;
48
+ isEntry: boolean;
49
+ kind: 'import' | 'dynamic-import' | 'require-call';
50
+ }
51
+ export interface PrivateResolveIdExtraOptions extends ResolveIdExtraOptions {
52
+ [SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF]?: symbol;
53
+ }
54
+ export type ResolveIdResult = string | NullValue | false | PartialResolvedId;
55
+ export type LoadResult = NullValue | string | SourceDescription;
56
+ export type TransformResult = NullValue | string | Partial<SourceDescription>;
57
+ export type RenderedChunkMeta = {
58
+ chunks: Record<string, RenderedChunk>;
59
+ };
60
+ export interface FunctionPluginHooks {
61
+ [DEFINED_HOOK_NAMES.onLog]: (this: MinimalPluginContext, level: LogLevel, log: RollupLog) => NullValue | boolean;
62
+ [DEFINED_HOOK_NAMES.options]: (this: MinimalPluginContext, options: InputOptions) => NullValue | InputOptions;
63
+ [DEFINED_HOOK_NAMES.outputOptions]: (this: MinimalPluginContext, options: OutputOptions) => NullValue | OutputOptions;
64
+ [DEFINED_HOOK_NAMES.buildStart]: (this: PluginContext, options: NormalizedInputOptions) => void;
65
+ [DEFINED_HOOK_NAMES.resolveId]: (this: PluginContext, source: string, importer: string | undefined, extraOptions: ResolveIdExtraOptions) => ResolveIdResult;
66
+ /**
67
+ * @deprecated
68
+ * This hook is only for rollup plugin compatibility. Please use `resolveId` instead.
69
+ */
70
+ [DEFINED_HOOK_NAMES.resolveDynamicImport]: (this: PluginContext, source: string, importer: string | undefined) => ResolveIdResult;
71
+ [DEFINED_HOOK_NAMES.load]: (this: PluginContext, id: string) => MaybePromise<LoadResult>;
72
+ [DEFINED_HOOK_NAMES.transform]: (this: TransformPluginContext, code: string, id: string, meta: BindingTransformHookExtraArgs & {
73
+ moduleType: ModuleType;
74
+ }) => TransformResult;
75
+ [DEFINED_HOOK_NAMES.moduleParsed]: (this: PluginContext, moduleInfo: ModuleInfo) => void;
76
+ [DEFINED_HOOK_NAMES.buildEnd]: (this: PluginContext, err?: Error) => void;
77
+ [DEFINED_HOOK_NAMES.renderStart]: (this: PluginContext, outputOptions: NormalizedOutputOptions, inputOptions: NormalizedInputOptions) => void;
78
+ [DEFINED_HOOK_NAMES.renderChunk]: (this: PluginContext, code: string, chunk: RenderedChunk, outputOptions: NormalizedOutputOptions, meta: RenderedChunkMeta) => NullValue | string | {
79
+ code: string;
80
+ map?: SourceMapInput;
81
+ };
82
+ [DEFINED_HOOK_NAMES.augmentChunkHash]: (this: PluginContext, chunk: RenderedChunk) => string | void;
83
+ [DEFINED_HOOK_NAMES.renderError]: (this: PluginContext, error: Error) => void;
84
+ [DEFINED_HOOK_NAMES.generateBundle]: (this: PluginContext, outputOptions: NormalizedOutputOptions, bundle: OutputBundle, isWrite: boolean) => void;
85
+ [DEFINED_HOOK_NAMES.writeBundle]: (this: PluginContext, outputOptions: NormalizedOutputOptions, bundle: OutputBundle) => void;
86
+ [DEFINED_HOOK_NAMES.closeBundle]: (this: PluginContext) => void;
87
+ [DEFINED_HOOK_NAMES.watchChange]: (this: PluginContext, id: string, event: {
88
+ event: ChangeEvent;
89
+ }) => void;
90
+ [DEFINED_HOOK_NAMES.closeWatcher]: (this: PluginContext) => void;
91
+ }
92
+ export type ChangeEvent = 'create' | 'update' | 'delete';
93
+ export type PluginOrder = 'pre' | 'post' | null;
94
+ export type ObjectHookMeta = {
95
+ order?: PluginOrder;
96
+ };
97
+ export type ObjectHook<T, O = {}> = T | ({
98
+ handler: T;
99
+ } & ObjectHookMeta & O);
100
+ export type SyncPluginHooks = DefinedHookNames['augmentChunkHash' | 'onLog' | 'outputOptions'];
101
+ export type AsyncPluginHooks = Exclude<keyof FunctionPluginHooks, SyncPluginHooks>;
102
+ export type FirstPluginHooks = DefinedHookNames['load' | 'resolveDynamicImport' | 'resolveId'];
103
+ export type SequentialPluginHooks = DefinedHookNames['augmentChunkHash' | 'generateBundle' | 'onLog' | 'options' | 'outputOptions' | 'renderChunk' | 'transform'];
104
+ export type AddonHooks = DefinedHookNames['banner' | 'footer' | 'intro' | 'outro'];
105
+ export type OutputPluginHooks = DefinedHookNames['augmentChunkHash' | 'generateBundle' | 'outputOptions' | 'renderChunk' | 'renderError' | 'renderStart' | 'writeBundle'];
106
+ export type ParallelPluginHooks = Exclude<keyof FunctionPluginHooks | AddonHooks, FirstPluginHooks | SequentialPluginHooks>;
107
+ export type HookFilterExtension<K extends keyof FunctionPluginHooks> = K extends 'transform' ? {
108
+ filter?: HookFilter;
109
+ } : K extends 'load' ? {
110
+ filter?: Pick<HookFilter, 'id'>;
111
+ } : K extends 'resolveId' ? {
112
+ filter?: {
113
+ id?: StringFilter<RegExp>;
114
+ };
115
+ } : {};
116
+ export type PluginHooks = {
117
+ [K in keyof FunctionPluginHooks]: ObjectHook<K extends AsyncPluginHooks ? MakeAsync<FunctionPluginHooks[K]> : FunctionPluginHooks[K], HookFilterExtension<K> & (K extends ParallelPluginHooks ? {
118
+ /**
119
+ * @deprecated
120
+ * this is only for rollup Plugin type compatibility.
121
+ * hooks always work as `sequential: true`.
122
+ */
123
+ sequential?: boolean;
124
+ } : {})>;
125
+ };
126
+ export type AddonHookFunction = (this: PluginContext, chunk: RenderedChunk) => string | Promise<string>;
127
+ export type AddonHook = string | AddonHookFunction;
128
+ export interface OutputPlugin extends Partial<{
129
+ [K in OutputPluginHooks]: PluginHooks[K];
130
+ }>, Partial<{
131
+ [K in AddonHooks]: ObjectHook<AddonHook>;
132
+ }> {
133
+ name: string;
134
+ }
135
+ export interface Plugin<A = any> extends OutputPlugin, Partial<PluginHooks> {
136
+ api?: A;
137
+ }
138
+ export type RolldownPlugin<A = any> = Plugin<A> | BuiltinPlugin | ParallelPlugin;
139
+ export type RolldownPluginOption<A = any> = MaybePromise<NullValue<RolldownPlugin<A>> | false | RolldownPluginOption[]>;
140
+ export type RolldownOutputPlugin = OutputPlugin | BuiltinPlugin;
141
+ export type RolldownOutputPluginOption = MaybePromise<NullValue<RolldownOutputPlugin> | false | RolldownOutputPluginOption[]>;
@@ -0,0 +1,24 @@
1
+ import type { LoggingFunction, LogHandler, LogLevelOption, RollupError } from '../types/misc';
2
+ export interface PluginContextMeta {
3
+ rollupVersion: string;
4
+ rolldownVersion: string;
5
+ watchMode: boolean;
6
+ }
7
+ export interface MinimalPluginContext {
8
+ readonly pluginName: string;
9
+ error: (e: RollupError | string) => never;
10
+ info: LoggingFunction;
11
+ warn: LoggingFunction;
12
+ debug: LoggingFunction;
13
+ meta: PluginContextMeta;
14
+ }
15
+ export declare class MinimalPluginContextImpl {
16
+ readonly pluginName: string;
17
+ private readonly hookName?;
18
+ info: LoggingFunction;
19
+ warn: LoggingFunction;
20
+ debug: LoggingFunction;
21
+ meta: PluginContextMeta;
22
+ constructor(onLog: LogHandler, logLevel: LogLevelOption, pluginName: string, watchMode: boolean, hookName?: string | undefined);
23
+ error(e: RollupError | string): never;
24
+ }
@@ -0,0 +1,10 @@
1
+ import type { MaybePromise } from '../types/utils';
2
+ import type { Plugin } from './index';
3
+ export type ParallelPluginImplementation = Plugin;
4
+ export type Context = {
5
+ /**
6
+ * Thread number
7
+ */
8
+ threadNumber: number;
9
+ };
10
+ export declare function defineParallelPluginImplementation<Options>(plugin: (Options: Options, context: Context) => MaybePromise<ParallelPluginImplementation>): (Options: Options, context: Context) => MaybePromise<ParallelPluginImplementation>;
@@ -0,0 +1,9 @@
1
+ export type ParallelPlugin = {
2
+ /** @internal */
3
+ _parallel: {
4
+ fileUrl: string;
5
+ options: unknown;
6
+ };
7
+ };
8
+ export type DefineParallelPluginResult<Options> = (options: Options) => ParallelPlugin;
9
+ export declare function defineParallelPlugin<Options>(pluginPath: string): DefineParallelPluginResult<Options>;
@@ -0,0 +1,21 @@
1
+ import { ModuleOptions } from '..';
2
+ import { BindingPluginContext } from '../binding';
3
+ import type { ModuleInfo } from '../types/module-info';
4
+ import { RenderedChunkMeta } from '.';
5
+ import { PluginContextResolveOptions } from './plugin-context';
6
+ export declare class PluginContextData {
7
+ moduleOptionMap: Map<string, ModuleOptions>;
8
+ resolveOptionsMap: Map<number, PluginContextResolveOptions>;
9
+ loadModulePromiseMap: Map<string, Promise<void>>;
10
+ meta: RenderedChunkMeta | null;
11
+ updateModuleOption(id: string, option: ModuleOptions): ModuleOptions;
12
+ getModuleOption(id: string): ModuleOptions;
13
+ getModuleInfo(id: string, context: BindingPluginContext): ModuleInfo | null;
14
+ proxyModuleInfo(id: string, info: ModuleInfo): ModuleInfo;
15
+ getModuleIds(context: BindingPluginContext): ArrayIterator<string>;
16
+ saveResolveOptions(options: PluginContextResolveOptions): number;
17
+ getSavedResolveOptions(receipt: number): PluginContextResolveOptions | undefined;
18
+ removeSavedResolveOptions(receipt: number): void;
19
+ setRenderChunkMeta(meta: RenderedChunkMeta): void;
20
+ getRenderChunkMeta(): RenderedChunkMeta | null;
21
+ }
@@ -0,0 +1,67 @@
1
+ import { Program } from '@oxc-project/types';
2
+ import type { BindingPluginContext, ParserOptions } from '../binding';
3
+ import { SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF } from '../constants/plugin-context';
4
+ import { OutputOptions } from '../options/output-options';
5
+ import { MinimalPluginContext, MinimalPluginContextImpl } from '../plugin/minimal-plugin-context';
6
+ import type { LogHandler, LogLevelOption } from '../types/misc';
7
+ import { ModuleInfo } from '../types/module-info';
8
+ import { PartialNull } from '../types/utils';
9
+ import { AssetSource } from '../utils/asset-source';
10
+ import type { CustomPluginOptions, ModuleOptions, Plugin, ResolvedId } from './index';
11
+ import { PluginContextData } from './plugin-context-data';
12
+ export interface EmittedAsset {
13
+ type: 'asset';
14
+ name?: string;
15
+ fileName?: string;
16
+ originalFileName?: string | null;
17
+ source: AssetSource;
18
+ }
19
+ export interface EmittedChunk {
20
+ type: 'chunk';
21
+ name?: string;
22
+ fileName?: string;
23
+ id: string;
24
+ importer?: string;
25
+ }
26
+ export type EmittedFile = EmittedAsset | EmittedChunk;
27
+ export interface PluginContextResolveOptions {
28
+ skipSelf?: boolean;
29
+ custom?: CustomPluginOptions;
30
+ }
31
+ export interface PrivatePluginContextResolveOptions extends PluginContextResolveOptions {
32
+ [SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF]?: symbol;
33
+ }
34
+ export type GetModuleInfo = (moduleId: string) => ModuleInfo | null;
35
+ export interface PluginContext extends MinimalPluginContext {
36
+ emitFile(file: EmittedFile): string;
37
+ getFileName(referenceId: string): string;
38
+ getModuleIds(): IterableIterator<string>;
39
+ getModuleInfo: GetModuleInfo;
40
+ addWatchFile(id: string): void;
41
+ load(options: {
42
+ id: string;
43
+ resolveDependencies?: boolean;
44
+ } & Partial<PartialNull<ModuleOptions>>): Promise<ModuleInfo>;
45
+ parse(input: string, options?: ParserOptions | undefined | null): Program;
46
+ resolve(source: string, importer?: string, options?: PluginContextResolveOptions): Promise<ResolvedId | null>;
47
+ }
48
+ export declare class PluginContextImpl extends MinimalPluginContextImpl {
49
+ private outputOptions;
50
+ private context;
51
+ private data;
52
+ private onLog;
53
+ private currentLoadingModule?;
54
+ getModuleInfo: GetModuleInfo;
55
+ constructor(outputOptions: OutputOptions, context: BindingPluginContext, plugin: Plugin, data: PluginContextData, onLog: LogHandler, logLevel: LogLevelOption, watchMode: boolean, currentLoadingModule?: string | undefined);
56
+ load(options: {
57
+ id: string;
58
+ resolveDependencies?: boolean;
59
+ } & Partial<PartialNull<ModuleOptions>>): Promise<ModuleInfo>;
60
+ resolve(source: string, importer?: string, options?: PluginContextResolveOptions): Promise<ResolvedId | null>;
61
+ emitFile: PluginContext['emitFile'];
62
+ private getAssetFileNames;
63
+ getFileName(referenceId: string): string;
64
+ getModuleIds(): IterableIterator<string>;
65
+ addWatchFile(id: string): void;
66
+ parse(input: string, options?: ParserOptions | undefined | null): Program;
67
+ }
@@ -0,0 +1,10 @@
1
+ import { InputOptions, OutputOptions, RolldownPlugin } from '..';
2
+ import { type LogLevelOption } from '../log/logging';
3
+ import type { LogHandler } from '../types/misc';
4
+ import { Plugin } from './';
5
+ export declare class PluginDriver {
6
+ static callOptionsHook(inputOptions: InputOptions, watchMode?: boolean): Promise<InputOptions>;
7
+ static callOutputOptionsHook(rawPlugins: RolldownPlugin[], outputOptions: OutputOptions, onLog: LogHandler, logLevel: LogLevelOption, watchMode: boolean): OutputOptions;
8
+ }
9
+ export declare function getObjectPlugins(plugins: RolldownPlugin[]): Plugin[];
10
+ export declare function getSortedPlugins(hookName: 'options' | 'outputOptions' | 'onLog', plugins: readonly Plugin[]): Plugin[];
@@ -0,0 +1,28 @@
1
+ import type { BindingPluginContext, BindingTransformPluginContext } from '../binding';
2
+ import { OutputOptions } from '../options/output-options';
3
+ import type { LoggingFunctionWithPosition, LogHandler, LogLevelOption, RollupError } from '../types/misc';
4
+ import { SourceMap } from '../types/rolldown-output';
5
+ import type { Plugin } from './index';
6
+ import { type PluginContext, PluginContextImpl } from './plugin-context';
7
+ import { PluginContextData } from './plugin-context-data';
8
+ export interface TransformPluginContext extends PluginContext {
9
+ debug: LoggingFunctionWithPosition;
10
+ info: LoggingFunctionWithPosition;
11
+ warn: LoggingFunctionWithPosition;
12
+ error(e: RollupError | string, pos?: number | {
13
+ column: number;
14
+ line: number;
15
+ }): never;
16
+ getCombinedSourcemap(): SourceMap;
17
+ }
18
+ export declare class TransformPluginContextImpl extends PluginContextImpl {
19
+ private inner;
20
+ private moduleId;
21
+ private moduleSource;
22
+ constructor(outputOptions: OutputOptions, context: BindingPluginContext, plugin: Plugin, data: PluginContextData, inner: BindingTransformPluginContext, moduleId: string, moduleSource: string, onLog: LogHandler, LogLevelOption: LogLevelOption, watchMode: boolean);
23
+ error(e: RollupError | string, pos?: number | {
24
+ column: number;
25
+ line: number;
26
+ }): never;
27
+ getCombinedSourcemap(): SourceMap;
28
+ }