rolldown 1.0.0-beta.2-commit.5deb279 → 1.0.0-beta.21

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 (236) hide show
  1. package/bin/cli.mjs +2 -0
  2. package/dist/{cjs/cli.cjs → cli.cjs} +630 -603
  3. package/dist/cli.d.cts +1 -0
  4. package/dist/cli.d.mts +1 -0
  5. package/dist/{esm/cli.mjs → cli.mjs} +605 -575
  6. package/dist/config.cjs +12 -0
  7. package/dist/config.d.cts +10 -0
  8. package/dist/config.d.mts +10 -0
  9. package/dist/config.mjs +10 -0
  10. package/dist/experimental-index.cjs +107 -0
  11. package/dist/experimental-index.d.cts +63 -0
  12. package/dist/experimental-index.d.mts +63 -0
  13. package/dist/experimental-index.mjs +82 -0
  14. package/dist/experimental-runtime-types.d.ts +52 -0
  15. package/dist/filter-index.cjs +105 -0
  16. package/dist/filter-index.d.cts +4 -0
  17. package/dist/filter-index.d.mts +4 -0
  18. package/dist/filter-index.mjs +44 -0
  19. package/dist/index.cjs +9 -0
  20. package/dist/index.d.cts +3 -0
  21. package/dist/index.d.mts +3 -0
  22. package/dist/index.mjs +5 -0
  23. package/dist/{cjs/parallel-plugin-worker.cjs → parallel-plugin-worker.cjs} +6 -14
  24. package/dist/parallel-plugin-worker.d.cts +1 -0
  25. package/dist/parallel-plugin-worker.d.mts +1 -0
  26. package/dist/{esm/parallel-plugin-worker.mjs → parallel-plugin-worker.mjs} +5 -12
  27. package/dist/{cjs/parallel-plugin.cjs → parallel-plugin.cjs} +1 -2
  28. package/dist/parallel-plugin.d.cts +14 -0
  29. package/dist/parallel-plugin.d.mts +14 -0
  30. package/dist/{esm/parallel-plugin.mjs → parallel-plugin.mjs} +0 -1
  31. package/dist/parse-ast-index.cjs +4 -0
  32. package/dist/parse-ast-index.d.cts +9 -0
  33. package/dist/parse-ast-index.d.mts +9 -0
  34. package/dist/parse-ast-index.mjs +3 -0
  35. package/dist/shared/binding--Ro_HG7S.d.mts +1246 -0
  36. package/dist/shared/binding-DBnJxycu.d.cts +1246 -0
  37. package/dist/shared/{chunk-qZFfknuJ.cjs → chunk-DDkG_k5U.cjs} +0 -1
  38. package/dist/shared/define-config-LuFmoc43.d.cts +1204 -0
  39. package/dist/shared/define-config-WLh0sQOM.d.mts +1204 -0
  40. package/dist/shared/load-config-DUa6Uqtc.mjs +119 -0
  41. package/dist/shared/load-config-juy1xxPU.cjs +125 -0
  42. package/dist/shared/misc-BKp5iIef.cjs +67 -0
  43. package/dist/shared/misc-BN0nse6C.mjs +25 -0
  44. package/dist/shared/parse-ast-index-CVVmsBjK.cjs +738 -0
  45. package/dist/shared/parse-ast-index-DW8kbzjr.mjs +616 -0
  46. package/dist/shared/{prompt-Nfm4Xz36.mjs → prompt-C5jz26Zn.mjs} +247 -246
  47. package/dist/shared/{prompt-B7tq3GL9.cjs → prompt-QNI93ne7.cjs} +250 -250
  48. package/dist/shared/src-LzfUVOSn.mjs +4647 -0
  49. package/dist/shared/src-ajsKFM6g.cjs +4851 -0
  50. package/package.json +65 -67
  51. package/bin/cli.js +0 -2
  52. package/dist/cjs/experimental-index.cjs +0 -79
  53. package/dist/cjs/index.cjs +0 -8
  54. package/dist/cjs/parse-ast-index.cjs +0 -57
  55. package/dist/esm/experimental-index.mjs +0 -56
  56. package/dist/esm/index.mjs +0 -4
  57. package/dist/esm/parse-ast-index.mjs +0 -55
  58. package/dist/shared/binding-l7VLSKnB.mjs +0 -610
  59. package/dist/shared/binding-orkvONpS.cjs +0 -661
  60. package/dist/shared/src-CV5Vk_cS.cjs +0 -2828
  61. package/dist/shared/src-CwOjWVUb.mjs +0 -2647
  62. package/dist/types/api/build.d.ts +0 -18
  63. package/dist/types/api/build.js +0 -22
  64. package/dist/types/api/experimental.d.ts +0 -7
  65. package/dist/types/api/experimental.js +0 -13
  66. package/dist/types/api/rolldown/index.d.ts +0 -3
  67. package/dist/types/api/rolldown/index.js +0 -7
  68. package/dist/types/api/rolldown/rolldown-build.d.ts +0 -12
  69. package/dist/types/api/rolldown/rolldown-build.js +0 -43
  70. package/dist/types/api/watch/index.d.ts +0 -3
  71. package/dist/types/api/watch/index.js +0 -8
  72. package/dist/types/api/watch/watch-emitter.d.ts +0 -31
  73. package/dist/types/api/watch/watch-emitter.js +0 -69
  74. package/dist/types/api/watch/watcher.d.ts +0 -13
  75. package/dist/types/api/watch/watcher.js +0 -66
  76. package/dist/types/binding.d.ts +0 -1327
  77. package/dist/types/builtin-plugin/alias-plugin.d.ts +0 -10
  78. package/dist/types/builtin-plugin/alias-plugin.js +0 -4
  79. package/dist/types/builtin-plugin/constructors.d.ts +0 -20
  80. package/dist/types/builtin-plugin/constructors.js +0 -68
  81. package/dist/types/builtin-plugin/replace-plugin.d.ts +0 -28
  82. package/dist/types/builtin-plugin/replace-plugin.js +0 -29
  83. package/dist/types/builtin-plugin/transform-plugin.d.ts +0 -9
  84. package/dist/types/builtin-plugin/transform-plugin.js +0 -16
  85. package/dist/types/builtin-plugin/utils.d.ts +0 -8
  86. package/dist/types/builtin-plugin/utils.js +0 -19
  87. package/dist/types/cli/arguments/alias.d.ts +0 -16
  88. package/dist/types/cli/arguments/alias.js +0 -63
  89. package/dist/types/cli/arguments/index.d.ts +0 -15
  90. package/dist/types/cli/arguments/index.js +0 -127
  91. package/dist/types/cli/arguments/normalize.d.ts +0 -12
  92. package/dist/types/cli/arguments/normalize.js +0 -48
  93. package/dist/types/cli/arguments/utils.d.ts +0 -8
  94. package/dist/types/cli/arguments/utils.js +0 -67
  95. package/dist/types/cli/colors.d.ts +0 -11
  96. package/dist/types/cli/colors.js +0 -17
  97. package/dist/types/cli/commands/bundle.d.ts +0 -3
  98. package/dist/types/cli/commands/bundle.js +0 -203
  99. package/dist/types/cli/commands/help.d.ts +0 -1
  100. package/dist/types/cli/commands/help.js +0 -88
  101. package/dist/types/cli/index.d.ts +0 -1
  102. package/dist/types/cli/index.js +0 -27
  103. package/dist/types/cli/load-config.d.ts +0 -3
  104. package/dist/types/cli/load-config.js +0 -95
  105. package/dist/types/cli/logger.d.ts +0 -5
  106. package/dist/types/cli/logger.js +0 -35
  107. package/dist/types/constants/plugin-context.d.ts +0 -7
  108. package/dist/types/constants/plugin-context.js +0 -7
  109. package/dist/types/constants/plugin.d.ts +0 -45
  110. package/dist/types/constants/plugin.js +0 -69
  111. package/dist/types/experimental-index.d.ts +0 -9
  112. package/dist/types/experimental-index.js +0 -9
  113. package/dist/types/index.d.ts +0 -28
  114. package/dist/types/index.js +0 -7
  115. package/dist/types/log/logHandler.d.ts +0 -4
  116. package/dist/types/log/logHandler.js +0 -25
  117. package/dist/types/log/logger.d.ts +0 -6
  118. package/dist/types/log/logger.js +0 -107
  119. package/dist/types/log/logging.d.ts +0 -11
  120. package/dist/types/log/logging.js +0 -11
  121. package/dist/types/log/logs.d.ts +0 -18
  122. package/dist/types/log/logs.js +0 -86
  123. package/dist/types/options/input-options.d.ts +0 -170
  124. package/dist/types/options/input-options.js +0 -1
  125. package/dist/types/options/normalized-input-options.d.ts +0 -18
  126. package/dist/types/options/normalized-input-options.js +0 -21
  127. package/dist/types/options/normalized-output-options.d.ts +0 -67
  128. package/dist/types/options/normalized-output-options.js +0 -99
  129. package/dist/types/options/output-options.d.ts +0 -86
  130. package/dist/types/options/output-options.js +0 -1
  131. package/dist/types/options/watch-options.d.ts +0 -5
  132. package/dist/types/options/watch-options.js +0 -1
  133. package/dist/types/parallel-plugin-worker.d.ts +0 -1
  134. package/dist/types/parallel-plugin-worker.js +0 -31
  135. package/dist/types/parallel-plugin.d.ts +0 -1
  136. package/dist/types/parallel-plugin.js +0 -1
  137. package/dist/types/parse-ast-index.d.ts +0 -4
  138. package/dist/types/parse-ast-index.js +0 -73
  139. package/dist/types/plugin/bindingify-build-hooks.d.ts +0 -10
  140. package/dist/types/plugin/bindingify-build-hooks.js +0 -213
  141. package/dist/types/plugin/bindingify-hook-filter.d.ts +0 -7
  142. package/dist/types/plugin/bindingify-hook-filter.js +0 -39
  143. package/dist/types/plugin/bindingify-output-hooks.d.ts +0 -14
  144. package/dist/types/plugin/bindingify-output-hooks.js +0 -189
  145. package/dist/types/plugin/bindingify-plugin-hook-meta.d.ts +0 -8
  146. package/dist/types/plugin/bindingify-plugin-hook-meta.js +0 -19
  147. package/dist/types/plugin/bindingify-plugin.d.ts +0 -15
  148. package/dist/types/plugin/bindingify-plugin.js +0 -124
  149. package/dist/types/plugin/bindingify-watch-hooks.d.ts +0 -5
  150. package/dist/types/plugin/bindingify-watch-hooks.js +0 -29
  151. package/dist/types/plugin/hook-filter.d.ts +0 -48
  152. package/dist/types/plugin/hook-filter.js +0 -1
  153. package/dist/types/plugin/index.d.ts +0 -126
  154. package/dist/types/plugin/index.js +0 -1
  155. package/dist/types/plugin/minimal-plugin-context.d.ts +0 -15
  156. package/dist/types/plugin/minimal-plugin-context.js +0 -25
  157. package/dist/types/plugin/parallel-plugin-implementation.d.ts +0 -10
  158. package/dist/types/plugin/parallel-plugin-implementation.js +0 -3
  159. package/dist/types/plugin/parallel-plugin.d.ts +0 -9
  160. package/dist/types/plugin/parallel-plugin.js +0 -6
  161. package/dist/types/plugin/plugin-context-data.d.ts +0 -16
  162. package/dist/types/plugin/plugin-context-data.js +0 -55
  163. package/dist/types/plugin/plugin-context.d.ts +0 -52
  164. package/dist/types/plugin/plugin-context.js +0 -108
  165. package/dist/types/plugin/plugin-driver.d.ts +0 -8
  166. package/dist/types/plugin/plugin-driver.js +0 -88
  167. package/dist/types/plugin/transform-plugin-context.d.ts +0 -17
  168. package/dist/types/plugin/transform-plugin-context.js +0 -37
  169. package/dist/types/types/assert.d.ts +0 -13
  170. package/dist/types/types/assert.js +0 -1
  171. package/dist/types/types/config-export.d.ts +0 -5
  172. package/dist/types/types/config-export.js +0 -1
  173. package/dist/types/types/misc.d.ts +0 -40
  174. package/dist/types/types/misc.js +0 -1
  175. package/dist/types/types/module-info.d.ts +0 -15
  176. package/dist/types/types/module-info.js +0 -1
  177. package/dist/types/types/module-side-effects.d.ts +0 -10
  178. package/dist/types/types/module-side-effects.js +0 -1
  179. package/dist/types/types/output-bundle.d.ts +0 -4
  180. package/dist/types/types/output-bundle.js +0 -1
  181. package/dist/types/types/rolldown-options.d.ts +0 -5
  182. package/dist/types/types/rolldown-options.js +0 -1
  183. package/dist/types/types/rolldown-output.d.ts +0 -63
  184. package/dist/types/types/rolldown-output.js +0 -1
  185. package/dist/types/types/schema.d.ts +0 -33
  186. package/dist/types/types/schema.js +0 -1
  187. package/dist/types/types/sourcemap.d.ts +0 -13
  188. package/dist/types/types/sourcemap.js +0 -16
  189. package/dist/types/types/utils.d.ts +0 -13
  190. package/dist/types/types/utils.js +0 -1
  191. package/dist/types/utils/asset-source.d.ts +0 -4
  192. package/dist/types/utils/asset-source.js +0 -8
  193. package/dist/types/utils/async-flatten.d.ts +0 -1
  194. package/dist/types/utils/async-flatten.js +0 -7
  195. package/dist/types/utils/bindingify-input-options.d.ts +0 -7
  196. package/dist/types/utils/bindingify-input-options.js +0 -225
  197. package/dist/types/utils/bindingify-output-options.d.ts +0 -3
  198. package/dist/types/utils/bindingify-output-options.js +0 -92
  199. package/dist/types/utils/code-frame.d.ts +0 -1
  200. package/dist/types/utils/code-frame.js +0 -46
  201. package/dist/types/utils/compose-js-plugins.d.ts +0 -2
  202. package/dist/types/utils/compose-js-plugins.js +0 -400
  203. package/dist/types/utils/create-bundler-option.d.ts +0 -11
  204. package/dist/types/utils/create-bundler-option.js +0 -53
  205. package/dist/types/utils/create-bundler.d.ts +0 -8
  206. package/dist/types/utils/create-bundler.js +0 -15
  207. package/dist/types/utils/define-config.d.ts +0 -5
  208. package/dist/types/utils/define-config.js +0 -3
  209. package/dist/types/utils/error.d.ts +0 -2
  210. package/dist/types/utils/error.js +0 -65
  211. package/dist/types/utils/initialize-parallel-plugins.d.ts +0 -19
  212. package/dist/types/utils/initialize-parallel-plugins.js +0 -54
  213. package/dist/types/utils/misc.d.ts +0 -6
  214. package/dist/types/utils/misc.js +0 -22
  215. package/dist/types/utils/normalize-hook.d.ts +0 -7
  216. package/dist/types/utils/normalize-hook.js +0 -21
  217. package/dist/types/utils/normalize-plugin-option.d.ts +0 -13
  218. package/dist/types/utils/normalize-plugin-option.js +0 -35
  219. package/dist/types/utils/normalize-string-or-regex.d.ts +0 -2
  220. package/dist/types/utils/normalize-string-or-regex.js +0 -14
  221. package/dist/types/utils/plugin/index.d.ts +0 -2
  222. package/dist/types/utils/plugin/index.js +0 -7
  223. package/dist/types/utils/transform-module-info.d.ts +0 -4
  224. package/dist/types/utils/transform-module-info.js +0 -19
  225. package/dist/types/utils/transform-rendered-chunk.d.ts +0 -4
  226. package/dist/types/utils/transform-rendered-chunk.js +0 -43
  227. package/dist/types/utils/transform-rendered-module.d.ts +0 -3
  228. package/dist/types/utils/transform-rendered-module.js +0 -10
  229. package/dist/types/utils/transform-side-effects.d.ts +0 -3
  230. package/dist/types/utils/transform-side-effects.js +0 -16
  231. package/dist/types/utils/transform-sourcemap.d.ts +0 -3
  232. package/dist/types/utils/transform-sourcemap.js +0 -29
  233. package/dist/types/utils/transform-to-rollup-output.d.ts +0 -11
  234. package/dist/types/utils/transform-to-rollup-output.js +0 -165
  235. package/dist/types/utils/validator.d.ts +0 -7
  236. package/dist/types/utils/validator.js +0 -275
@@ -1,16 +0,0 @@
1
- import { BindingPluginContext } from '../binding';
2
- import { ModuleOptions } from '..';
3
- import { PluginContextResolveOptions } from './plugin-context';
4
- import type { ModuleInfo } from '../types/module-info';
5
- export declare class PluginContextData {
6
- moduleOptionMap: Map<string, ModuleOptions>;
7
- resolveOptionsMap: Map<number, PluginContextResolveOptions>;
8
- loadModulePromiseMap: Map<string, Promise<void>>;
9
- updateModuleOption(id: string, option: ModuleOptions): void;
10
- getModuleOption(id: string): ModuleOptions;
11
- getModuleInfo(id: string, context: BindingPluginContext): ModuleInfo | null;
12
- getModuleIds(context: BindingPluginContext): ArrayIterator<string>;
13
- saveResolveOptions(options: PluginContextResolveOptions): number;
14
- getSavedResolveOptions(receipt: number): PluginContextResolveOptions | undefined;
15
- removeSavedResolveOptions(receipt: number): void;
16
- }
@@ -1,55 +0,0 @@
1
- import { transformModuleInfo } from '../utils/transform-module-info';
2
- export class PluginContextData {
3
- moduleOptionMap = new Map();
4
- resolveOptionsMap = new Map();
5
- loadModulePromiseMap = new Map();
6
- updateModuleOption(id, option) {
7
- const existing = this.moduleOptionMap.get(id);
8
- if (existing) {
9
- if (option.moduleSideEffects != null) {
10
- existing.moduleSideEffects = option.moduleSideEffects;
11
- }
12
- if (option.meta != null) {
13
- Object.assign(existing.meta, option.meta);
14
- }
15
- }
16
- else {
17
- this.moduleOptionMap.set(id, option);
18
- }
19
- }
20
- getModuleOption(id) {
21
- const option = this.moduleOptionMap.get(id);
22
- if (!option) {
23
- const raw = {
24
- moduleSideEffects: null,
25
- meta: {},
26
- };
27
- this.moduleOptionMap.set(id, raw);
28
- return raw;
29
- }
30
- return option;
31
- }
32
- getModuleInfo(id, context) {
33
- const bindingInfo = context.getModuleInfo(id);
34
- if (bindingInfo) {
35
- const info = transformModuleInfo(bindingInfo, this.getModuleOption(id));
36
- return info;
37
- }
38
- return null;
39
- }
40
- getModuleIds(context) {
41
- const moduleIds = context.getModuleIds();
42
- return moduleIds.values();
43
- }
44
- saveResolveOptions(options) {
45
- const index = this.resolveOptionsMap.size;
46
- this.resolveOptionsMap.set(index, options);
47
- return index;
48
- }
49
- getSavedResolveOptions(receipt) {
50
- return this.resolveOptionsMap.get(receipt);
51
- }
52
- removeSavedResolveOptions(receipt) {
53
- this.resolveOptionsMap.delete(receipt);
54
- }
55
- }
@@ -1,52 +0,0 @@
1
- import type { BindingPluginContext } from '../binding';
2
- import type { CustomPluginOptions, ModuleOptions, Plugin, ResolvedId } from './index';
3
- import { MinimalPluginContext } from '../plugin/minimal-plugin-context';
4
- import { AssetSource } from '../utils/asset-source';
5
- import { ModuleInfo } from '../types/module-info';
6
- import { PluginContextData } from './plugin-context-data';
7
- import { SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF } from '../constants/plugin-context';
8
- import { PartialNull } from '../types/utils';
9
- import type { LogHandler, LogLevelOption } from '../types/misc';
10
- export interface EmittedAsset {
11
- type: 'asset';
12
- name?: string;
13
- fileName?: string;
14
- originalFileName?: string | null;
15
- source: AssetSource;
16
- }
17
- export interface EmittedChunk {
18
- type: 'chunk';
19
- name?: string;
20
- fileName?: string;
21
- id: string;
22
- importer?: string;
23
- }
24
- export type EmittedFile = EmittedAsset;
25
- export interface PluginContextResolveOptions {
26
- skipSelf?: boolean;
27
- custom?: CustomPluginOptions;
28
- }
29
- export interface PrivatePluginContextResolveOptions extends PluginContextResolveOptions {
30
- [SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF]?: symbol;
31
- }
32
- export declare class PluginContext extends MinimalPluginContext {
33
- private context;
34
- private data;
35
- private onLog;
36
- private currentLoadingModule?;
37
- constructor(context: BindingPluginContext, plugin: Plugin, data: PluginContextData, onLog: LogHandler, logLevel: LogLevelOption, currentLoadingModule?: string | undefined);
38
- load(options: {
39
- id: string;
40
- resolveDependencies?: boolean;
41
- } & Partial<PartialNull<ModuleOptions>>): Promise<ModuleInfo>;
42
- resolve(source: string, importer?: string, options?: PluginContextResolveOptions): Promise<ResolvedId | null>;
43
- emitFile(file: EmittedAsset | EmittedChunk): string;
44
- getFileName(referenceId: string): string;
45
- getModuleInfo(id: string): ModuleInfo | null;
46
- getModuleIds(): IterableIterator<string>;
47
- addWatchFile(id: string): void;
48
- /**
49
- * @deprecated This rollup API won't be supported by rolldown. Using this API will cause runtime error.
50
- */
51
- parse(_input: string, _options?: any): any;
52
- }
@@ -1,108 +0,0 @@
1
- import { MinimalPluginContext } from '../plugin/minimal-plugin-context';
2
- import { bindingAssetSource } from '../utils/asset-source';
3
- import { unimplemented, unsupported } from '../utils/misc';
4
- import { SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF } from '../constants/plugin-context';
5
- import { bindingifySideEffects } from '../utils/transform-side-effects';
6
- import { LOG_LEVEL_WARN } from '../log/logging';
7
- import { logCycleLoading } from '../log/logs';
8
- export class PluginContext extends MinimalPluginContext {
9
- context;
10
- data;
11
- onLog;
12
- currentLoadingModule;
13
- constructor(context, plugin, data, onLog, logLevel, currentLoadingModule) {
14
- super(onLog, logLevel, plugin.name);
15
- this.context = context;
16
- this.data = data;
17
- this.onLog = onLog;
18
- this.currentLoadingModule = currentLoadingModule;
19
- }
20
- async load(options) {
21
- const id = options.id;
22
- if (id === this.currentLoadingModule) {
23
- this.onLog(LOG_LEVEL_WARN, logCycleLoading(this.pluginName, this.currentLoadingModule));
24
- }
25
- // resolveDependencies always true at rolldown
26
- const moduleInfo = this.data.getModuleInfo(id, this.context);
27
- if (moduleInfo && moduleInfo.code !== null /* module already parsed */) {
28
- return moduleInfo;
29
- }
30
- const rawOptions = {
31
- meta: options.meta || {},
32
- moduleSideEffects: options.moduleSideEffects || null,
33
- };
34
- this.data.updateModuleOption(id, rawOptions);
35
- async function createLoadModulePromise(context, data) {
36
- const loadPromise = data.loadModulePromiseMap.get(id);
37
- if (loadPromise) {
38
- return loadPromise;
39
- }
40
- let resolveFn;
41
- // TODO: If is not resolved, we need to set a time to avoid waiting.
42
- const promise = new Promise((resolve, _) => {
43
- resolveFn = resolve;
44
- });
45
- data.loadModulePromiseMap.set(id, promise);
46
- try {
47
- await context.load(id, bindingifySideEffects(options.moduleSideEffects), resolveFn);
48
- }
49
- finally {
50
- // If the load module has failed, avoid it re-load using unresolved promise.
51
- data.loadModulePromiseMap.delete(id);
52
- }
53
- return promise;
54
- }
55
- // Here using one promise to avoid pass more callback to rust side, it only accept one callback, other will be ignored.
56
- await createLoadModulePromise(this.context, this.data);
57
- return this.data.getModuleInfo(id, this.context);
58
- }
59
- async resolve(source, importer, options) {
60
- let receipt = undefined;
61
- if (options != null) {
62
- receipt = this.data.saveResolveOptions(options);
63
- }
64
- const res = await this.context.resolve(source, importer, {
65
- custom: receipt,
66
- skipSelf: options?.skipSelf,
67
- });
68
- if (receipt != null) {
69
- this.data.removeSavedResolveOptions(receipt);
70
- }
71
- if (res == null)
72
- return null;
73
- const info = this.data.getModuleOption(res.id) || {};
74
- return { ...res, ...info };
75
- }
76
- emitFile(file) {
77
- // @ts-expect-error
78
- if (file.type === 'prebuilt-chunk') {
79
- return unimplemented('PluginContext.emitFile with type prebuilt-chunk');
80
- }
81
- if (file.type === 'chunk') {
82
- return this.context.emitChunk(file);
83
- }
84
- return this.context.emitFile({
85
- ...file,
86
- originalFileName: file.originalFileName || undefined,
87
- source: bindingAssetSource(file.source),
88
- });
89
- }
90
- getFileName(referenceId) {
91
- return this.context.getFileName(referenceId);
92
- }
93
- getModuleInfo(id) {
94
- return this.data.getModuleInfo(id, this.context);
95
- }
96
- getModuleIds() {
97
- return this.data.getModuleIds(this.context);
98
- }
99
- addWatchFile(id) {
100
- this.context.addWatchFile(id);
101
- }
102
- /**
103
- * @deprecated This rollup API won't be supported by rolldown. Using this API will cause runtime error.
104
- */
105
- parse(_input, _options) {
106
- unsupported('`PluginContext#parse` is not supported by rolldown.');
107
- }
108
- }
@@ -1,8 +0,0 @@
1
- import { Plugin } from './';
2
- import { InputOptions, OutputOptions, RolldownPlugin } from '..';
3
- export declare class PluginDriver {
4
- static callOptionsHook(inputOptions: InputOptions): Promise<InputOptions>;
5
- static callOutputOptionsHook(rawPlugins: RolldownPlugin[], outputOptions: OutputOptions): OutputOptions;
6
- }
7
- export declare function getObjectPlugins(plugins: RolldownPlugin[]): Plugin[];
8
- export declare function getSortedPlugins(hookName: 'options' | 'outputOptions' | 'onLog', plugins: readonly Plugin[]): Plugin[];
@@ -1,88 +0,0 @@
1
- import { getLogHandler, normalizeLog } from '../log/logHandler';
2
- import { LOG_LEVEL_DEBUG, LOG_LEVEL_INFO, LOG_LEVEL_WARN } from '../log/logging';
3
- import { error, logPluginError } from '../log/logs';
4
- import { normalizeHook } from '../utils/normalize-hook';
5
- import { VERSION } from '..';
6
- import { getLogger, getOnLog } from '../log/logger';
7
- import { BuiltinPlugin } from '../builtin-plugin/constructors';
8
- import { normalizePluginOption } from '../utils/normalize-plugin-option';
9
- export class PluginDriver {
10
- static async callOptionsHook(inputOptions) {
11
- const logLevel = inputOptions.logLevel || LOG_LEVEL_INFO;
12
- const plugins = getSortedPlugins('options', getObjectPlugins(await normalizePluginOption(inputOptions.plugins)));
13
- const logger = getLogger(plugins, getOnLog(inputOptions, logLevel), logLevel);
14
- for (const plugin of plugins) {
15
- const name = plugin.name || 'unknown';
16
- const options = plugin.options;
17
- if (options) {
18
- const { handler } = normalizeHook(options);
19
- const result = await handler.call({
20
- debug: getLogHandler(LOG_LEVEL_DEBUG, 'PLUGIN_LOG', logger, name, logLevel),
21
- error: (e) => error(logPluginError(normalizeLog(e), name, { hook: 'onLog' })),
22
- info: getLogHandler(LOG_LEVEL_INFO, 'PLUGIN_LOG', logger, name, logLevel),
23
- meta: {
24
- rollupVersion: '4.23.0',
25
- rolldownVersion: VERSION,
26
- watchMode: false,
27
- },
28
- warn: getLogHandler(LOG_LEVEL_WARN, 'PLUGIN_WARNING', logger, name, logLevel),
29
- pluginName: name,
30
- }, inputOptions);
31
- if (result) {
32
- inputOptions = result;
33
- }
34
- }
35
- }
36
- return inputOptions;
37
- }
38
- static callOutputOptionsHook(rawPlugins, outputOptions) {
39
- const sortedPlugins = getSortedPlugins('outputOptions', getObjectPlugins(rawPlugins));
40
- for (const plugin of sortedPlugins) {
41
- const options = plugin.outputOptions;
42
- if (options) {
43
- const { handler } = normalizeHook(options);
44
- const result = handler.call(null, outputOptions);
45
- if (result) {
46
- outputOptions = result;
47
- }
48
- }
49
- }
50
- return outputOptions;
51
- }
52
- }
53
- export function getObjectPlugins(plugins) {
54
- return plugins.filter((plugin) => {
55
- if (!plugin) {
56
- return undefined;
57
- }
58
- if ('_parallel' in plugin) {
59
- return undefined;
60
- }
61
- if (plugin instanceof BuiltinPlugin) {
62
- return undefined;
63
- }
64
- return plugin;
65
- });
66
- }
67
- export function getSortedPlugins(hookName, plugins) {
68
- const pre = [];
69
- const normal = [];
70
- const post = [];
71
- for (const plugin of plugins) {
72
- const hook = plugin[hookName];
73
- if (hook) {
74
- if (typeof hook === 'object') {
75
- if (hook.order === 'pre') {
76
- pre.push(plugin);
77
- continue;
78
- }
79
- if (hook.order === 'post') {
80
- post.push(plugin);
81
- continue;
82
- }
83
- }
84
- normal.push(plugin);
85
- }
86
- }
87
- return [...pre, ...normal, ...post];
88
- }
@@ -1,17 +0,0 @@
1
- import type { BindingPluginContext, BindingTransformPluginContext } from '../binding';
2
- import type { LogHandler, LogLevelOption, RollupError } from '../types/misc';
3
- import { PluginContext } from './plugin-context';
4
- import { PluginContextData } from './plugin-context-data';
5
- import type { Plugin } from './index';
6
- import { SourceMap } from '../types/rolldown-output';
7
- export declare class TransformPluginContext extends PluginContext {
8
- private inner;
9
- private moduleId;
10
- private moduleSource;
11
- constructor(context: BindingPluginContext, plugin: Plugin, data: PluginContextData, inner: BindingTransformPluginContext, moduleId: string, moduleSource: string, onLog: LogHandler, LogLevelOption: LogLevelOption);
12
- error(e: RollupError | string, pos?: number | {
13
- column: number;
14
- line: number;
15
- }): never;
16
- getCombinedSourcemap(): SourceMap;
17
- }
@@ -1,37 +0,0 @@
1
- import { normalizeLog } from '../log/logHandler';
2
- import { PluginContext } from './plugin-context';
3
- import { augmentCodeLocation, error, logPluginError } from '../log/logs';
4
- export class TransformPluginContext extends PluginContext {
5
- inner;
6
- moduleId;
7
- moduleSource;
8
- constructor(context, plugin, data, inner, moduleId, moduleSource, onLog, LogLevelOption) {
9
- super(context, plugin, data, onLog, LogLevelOption, moduleId);
10
- this.inner = inner;
11
- this.moduleId = moduleId;
12
- this.moduleSource = moduleSource;
13
- const getLogHandler = (handler) => (log, pos) => {
14
- log = normalizeLog(log);
15
- if (pos)
16
- augmentCodeLocation(log, pos, moduleSource, moduleId);
17
- log.id = moduleId;
18
- log.hook = 'transform';
19
- handler(log);
20
- };
21
- this.debug = getLogHandler(this.debug);
22
- this.warn = getLogHandler(this.warn);
23
- this.info = getLogHandler(this.info);
24
- }
25
- error(e, pos) {
26
- if (typeof e === 'string')
27
- e = { message: e };
28
- if (pos)
29
- augmentCodeLocation(e, pos, this.moduleSource, this.moduleId);
30
- e.id = this.moduleId;
31
- e.hook = 'transform';
32
- return error(logPluginError(normalizeLog(e), this.pluginName));
33
- }
34
- getCombinedSourcemap() {
35
- return JSON.parse(this.inner.getCombinedSourcemap());
36
- }
37
- }
@@ -1,13 +0,0 @@
1
- import type { IsEqual } from 'type-fest';
2
- export type TypeAssert<T extends true> = T;
3
- export type HasProperty<T, K extends string> = K extends keyof T ? true : false;
4
- export type IsPropertyEqual<A, B, Key extends keyof A & keyof B> = IsEqual<A[Key], B[Key]>;
5
- type IsValuesOfObjectAllTrue<T> = {
6
- [K in keyof T]: T[K] extends true ? true : false;
7
- }[keyof T] extends true ? true : false;
8
- export type ShowPropertiesEqualStatus<A, B> = {
9
- [K in keyof A]: K extends keyof B ? IsEqual<A[K], B[K]> : true;
10
- };
11
- export type IsPropertiesEqual<A, B> = IsValuesOfObjectAllTrue<ShowPropertiesEqualStatus<A, B>>;
12
- export type AssertNever<T extends never> = T;
13
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,5 +0,0 @@
1
- import type { RolldownOptions } from './rolldown-options';
2
- /**
3
- * Type for `default export` of `rolldown.config.js` file.
4
- */
5
- export type ConfigExport = RolldownOptions | RolldownOptions[];
@@ -1 +0,0 @@
1
- export {};
@@ -1,40 +0,0 @@
1
- export interface RollupLog {
2
- binding?: string;
3
- cause?: unknown;
4
- code?: string;
5
- exporter?: string;
6
- frame?: string;
7
- hook?: string;
8
- id?: string;
9
- ids?: string[];
10
- loc?: {
11
- column: number;
12
- file?: string;
13
- line: number;
14
- };
15
- message: string;
16
- meta?: any;
17
- names?: string[];
18
- plugin?: string;
19
- pluginCode?: unknown;
20
- pos?: number;
21
- reexporter?: string;
22
- stack?: string;
23
- url?: string;
24
- }
25
- export interface RollupError extends RollupLog {
26
- name?: string;
27
- stack?: string;
28
- watchFiles?: string[];
29
- }
30
- export type LogLevel = 'warn' | 'info' | 'debug';
31
- export type LogLevelOption = LogLevel | 'silent';
32
- export type LoggingFunction = (log: RollupLog | string | (() => RollupLog | string)) => void;
33
- export type LoggingFunctionWithPosition = (log: RollupLog | string | (() => RollupLog | string), pos?: number | {
34
- column: number;
35
- line: number;
36
- }) => void;
37
- export type LogHandler = (level: LogLevel, log: RollupLog) => void;
38
- export type SourcemapPathTransformOption = (relativeSourcePath: string, sourcemapPath: string) => string;
39
- export type SourcemapIgnoreListOption = (relativeSourcePath: string, sourcemapPath: string) => boolean;
40
- export type WarningHandlerWithDefault = (warning: RollupLog, defaultHandler: LoggingFunction) => void;
@@ -1 +0,0 @@
1
- export {};
@@ -1,15 +0,0 @@
1
- import { ModuleOptions } from '..';
2
- export interface ModuleInfo extends ModuleOptions {
3
- /**
4
- * Unsupported at rolldown
5
- */
6
- ast: any;
7
- code: string | null;
8
- id: string;
9
- importers: string[];
10
- dynamicImporters: string[];
11
- importedIds: string[];
12
- dynamicallyImportedIds: string[];
13
- exports: string[];
14
- isEntry: boolean;
15
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,10 +0,0 @@
1
- export interface ModuleSideEffectsRule {
2
- test?: RegExp;
3
- external?: boolean;
4
- sideEffects: boolean;
5
- }
6
- export type ModuleSideEffectsOption = boolean | ModuleSideEffectsRule[] | ((id: string, isResolved: boolean) => boolean | undefined) | 'no-external';
7
- export type TreeshakingOptions = {
8
- moduleSideEffects?: ModuleSideEffectsOption;
9
- annotations?: boolean;
10
- } | boolean;
@@ -1 +0,0 @@
1
- export {};
@@ -1,4 +0,0 @@
1
- import type { OutputAsset, OutputChunk } from './rolldown-output';
2
- export interface OutputBundle {
3
- [fileName: string]: OutputAsset | OutputChunk;
4
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,5 +0,0 @@
1
- import type { InputOptions } from '../options/input-options';
2
- import type { OutputOptions } from '../options/output-options';
3
- export interface RolldownOptions extends InputOptions {
4
- output?: OutputOptions | OutputOptions[];
5
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,63 +0,0 @@
1
- import { AssetSource } from '../utils/asset-source';
2
- import type { RenderedChunk as BindingRenderedChunk } from '../binding';
3
- export interface OutputAsset {
4
- type: 'asset';
5
- fileName: string;
6
- /** @deprecated Use "originalFileNames" instead. */
7
- originalFileName: string | null;
8
- originalFileNames: string[];
9
- source: AssetSource;
10
- /** @deprecated Use "names" instead. */
11
- name: string | undefined;
12
- names: string[];
13
- }
14
- export interface SourceMap {
15
- file: string;
16
- mappings: string;
17
- names: string[];
18
- sources: string[];
19
- sourcesContent: string[];
20
- version: number;
21
- toString(): string;
22
- toUrl(): string;
23
- }
24
- export interface RenderedModule {
25
- readonly code: string | null;
26
- renderedLength: number;
27
- }
28
- export interface RenderedChunk extends Omit<BindingRenderedChunk, 'modules'> {
29
- modules: {
30
- [id: string]: RenderedModule;
31
- };
32
- name: string;
33
- isEntry: boolean;
34
- isDynamicEntry: boolean;
35
- facadeModuleId: string | null;
36
- moduleIds: Array<string>;
37
- exports: Array<string>;
38
- fileName: string;
39
- imports: Array<string>;
40
- dynamicImports: Array<string>;
41
- }
42
- export interface OutputChunk {
43
- type: 'chunk';
44
- code: string;
45
- name: string;
46
- isEntry: boolean;
47
- exports: string[];
48
- fileName: string;
49
- modules: {
50
- [id: string]: RenderedModule;
51
- };
52
- imports: string[];
53
- dynamicImports: string[];
54
- facadeModuleId: string | null;
55
- isDynamicEntry: boolean;
56
- moduleIds: string[];
57
- map: SourceMap | null;
58
- sourcemapFileName: string | null;
59
- preliminaryFileName: string;
60
- }
61
- export interface RolldownOutput {
62
- output: [OutputChunk, ...(OutputChunk | OutputAsset)[]];
63
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,33 +0,0 @@
1
- export interface JsonSchema {
2
- type: string;
3
- description?: string;
4
- }
5
- export interface ObjectSchema extends JsonSchema {
6
- type: 'object';
7
- properties: Record<string, Schema>;
8
- required?: string[];
9
- additionalProperties?: boolean | {
10
- type: 'string';
11
- };
12
- }
13
- export interface ArraySchema extends JsonSchema {
14
- type: 'array';
15
- items: Schema;
16
- }
17
- export interface StringConstantSchema extends JsonSchema {
18
- type: 'string';
19
- const: string;
20
- }
21
- export interface StringEnumSchema extends JsonSchema {
22
- type: 'string';
23
- enum: string[];
24
- }
25
- export interface BooleanSchema extends JsonSchema {
26
- type: 'boolean';
27
- }
28
- export type StringSchema = StringConstantSchema | StringEnumSchema;
29
- export interface AnyOfSchema {
30
- anyOf: (StringSchema | ObjectSchema | BooleanSchema | ArraySchema)[];
31
- description?: string;
32
- }
33
- export type Schema = StringSchema | ObjectSchema | ArraySchema | BooleanSchema | AnyOfSchema | JsonSchema;
@@ -1 +0,0 @@
1
- export {};
@@ -1,13 +0,0 @@
1
- import { BindingSourcemap } from '../binding';
2
- export interface ExistingRawSourceMap {
3
- file?: string | null;
4
- mappings: string;
5
- names?: string[];
6
- sources?: (string | null)[];
7
- sourcesContent?: (string | null)[];
8
- sourceRoot?: string;
9
- version?: number;
10
- x_google_ignoreList?: number[];
11
- }
12
- export type SourceMapInput = ExistingRawSourceMap | string | null;
13
- export declare function bindingifySourcemap(map?: SourceMapInput): undefined | BindingSourcemap;
@@ -1,16 +0,0 @@
1
- export function bindingifySourcemap(map) {
2
- if (map == null)
3
- return;
4
- return {
5
- inner: typeof map === 'string'
6
- ? map
7
- : {
8
- file: map.file ?? undefined,
9
- mappings: map.mappings,
10
- sourceRoot: map.sourceRoot,
11
- sources: map.sources?.map((s) => s ?? undefined),
12
- sourcesContent: map.sourcesContent?.map((s) => s ?? undefined),
13
- names: map.names,
14
- },
15
- };
16
- }
@@ -1,13 +0,0 @@
1
- export type MaybePromise<T> = T | Promise<T>;
2
- export interface AnyFn {
3
- (...args: any[]): any;
4
- }
5
- export interface AnyObj {
6
- }
7
- export type NullValue<T = void> = T | undefined | null | void;
8
- export type PartialNull<T> = {
9
- [P in keyof T]: T[P] | null;
10
- };
11
- export type MakeAsync<Function_> = Function_ extends (this: infer This, ...parameters: infer Arguments) => infer Return ? (this: This, ...parameters: Arguments) => Return | Promise<Return> : never;
12
- export type MaybeArray<T> = T | T[];
13
- export type StringOrRegExp = string | RegExp;
@@ -1 +0,0 @@
1
- export {};