rolldown 1.0.0-beta.2-commit.2666b23 → 1.0.0-beta.20

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-5O9lFYtz.d.mts +1215 -0
  36. package/dist/shared/binding-BvKFOCZr.d.cts +1215 -0
  37. package/dist/shared/{chunk-qZFfknuJ.cjs → chunk-DDkG_k5U.cjs} +0 -1
  38. package/dist/shared/define-config-BOD4oRSZ.d.cts +1204 -0
  39. package/dist/shared/define-config-DdVYel_V.d.mts +1204 -0
  40. package/dist/shared/load-config-B_hPIyxu.mjs +119 -0
  41. package/dist/shared/load-config-BdY850xq.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-CZ0tgOug.cjs +4851 -0
  49. package/dist/shared/src-DHXNdTPA.mjs +4647 -0
  50. package/package.json +63 -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-BC6S-BmL.cjs +0 -2828
  61. package/dist/shared/src-mupmacNC.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,7 +0,0 @@
1
- import { AnyFn } from '../types/utils';
2
- import type { ObjectHook, ObjectHookMeta } from '../plugin';
3
- export declare function normalizeHook<Hook extends ObjectHook<AnyFn | string>>(hook: Hook): Hook extends ObjectHook<infer RawHook, infer CustomOptions> ? Hook extends RawHook ? never : {
4
- handler: RawHook;
5
- options: CustomOptions;
6
- meta: ObjectHookMeta;
7
- } : never;
@@ -1,21 +0,0 @@
1
- import { unreachable } from './misc';
2
- export function normalizeHook(hook) {
3
- if (typeof hook === 'function' || typeof hook === 'string') {
4
- return {
5
- handler: hook,
6
- options: {},
7
- meta: {},
8
- };
9
- }
10
- if (typeof hook === 'object' && hook !== null) {
11
- const { handler, order, ...options } = hook;
12
- return {
13
- handler,
14
- options,
15
- meta: {
16
- order,
17
- },
18
- };
19
- }
20
- unreachable('Invalid hook type');
21
- }
@@ -1,13 +0,0 @@
1
- import type { RolldownPlugin, RolldownOutputPlugin } from '../plugin';
2
- import type { InputOptions } from '../options/input-options';
3
- import type { OutputOptions } from '../options/output-options';
4
- import { LogHandler } from '../types/misc';
5
- export declare const normalizePluginOption: {
6
- (plugins: InputOptions['plugins']): Promise<RolldownPlugin[]>;
7
- (plugins: OutputOptions['plugins']): Promise<RolldownOutputPlugin[]>;
8
- (plugins: unknown): Promise<any[]>;
9
- };
10
- export declare function checkOutputPluginOption(plugins: RolldownOutputPlugin[], onLog: LogHandler): RolldownOutputPlugin[];
11
- export declare function normalizePlugins<T extends RolldownPlugin>(plugins: T[], anonymousPrefix: string): T[];
12
- export declare const ANONYMOUS_PLUGIN_PREFIX = "at position ";
13
- export declare const ANONYMOUS_OUTPUT_PLUGIN_PREFIX = "at output position ";
@@ -1,35 +0,0 @@
1
- import { asyncFlatten } from './async-flatten';
2
- import { ENUMERATED_INPUT_PLUGIN_HOOK_NAMES } from '../constants/plugin';
3
- import { logInputHookInOutputPlugin } from '../log/logs';
4
- import { LOG_LEVEL_WARN } from '../log/logging';
5
- import { BuiltinPlugin } from '../builtin-plugin/constructors';
6
- export const normalizePluginOption = async (plugins) => (await asyncFlatten([plugins])).filter(Boolean);
7
- export function checkOutputPluginOption(plugins, onLog) {
8
- for (const plugin of plugins) {
9
- for (const hook of ENUMERATED_INPUT_PLUGIN_HOOK_NAMES) {
10
- if (hook in plugin) {
11
- // remove the hook from the plugin if it is not an output plugin hook, avoid the plugin to be called
12
- // @ts-expect-error Here the plugin typing should be RolldownPlugin
13
- delete plugin[hook];
14
- onLog(LOG_LEVEL_WARN, logInputHookInOutputPlugin(plugin.name, hook));
15
- }
16
- }
17
- }
18
- return plugins;
19
- }
20
- export function normalizePlugins(plugins, anonymousPrefix) {
21
- for (const [index, plugin] of plugins.entries()) {
22
- if ('_parallel' in plugin) {
23
- continue;
24
- }
25
- if (plugin instanceof BuiltinPlugin) {
26
- continue;
27
- }
28
- if (!plugin.name) {
29
- plugin.name = `${anonymousPrefix}${index + 1}`;
30
- }
31
- }
32
- return plugins;
33
- }
34
- export const ANONYMOUS_PLUGIN_PREFIX = 'at position ';
35
- export const ANONYMOUS_OUTPUT_PLUGIN_PREFIX = 'at output position ';
@@ -1,2 +0,0 @@
1
- import type { BindingStringOrRegex } from '../binding';
2
- export declare function normalizedStringOrRegex(pattern?: Array<string | RegExp> | (string | RegExp)): BindingStringOrRegex[] | undefined;
@@ -1,14 +0,0 @@
1
- /*
2
- * Normalize single or multiple string or regex patterns to an array of BindingStringOrRegex
3
- * convert a type that is dx friendly to a type that is friendly for binding usage
4
- *
5
- * */
6
- export function normalizedStringOrRegex(pattern) {
7
- if (!pattern) {
8
- return undefined;
9
- }
10
- if (!Array.isArray(pattern)) {
11
- pattern = [pattern];
12
- }
13
- return pattern;
14
- }
@@ -1,2 +0,0 @@
1
- import { PluginHookNames } from '../../constants/plugin';
2
- export declare const isPluginHookName: (hookName: string) => hookName is PluginHookNames;
@@ -1,7 +0,0 @@
1
- import { ENUMERATED_PLUGIN_HOOK_NAMES, } from '../../constants/plugin';
2
- export const isPluginHookName = (function () {
3
- const PLUGIN_HOOK_NAMES_SET = new Set(ENUMERATED_PLUGIN_HOOK_NAMES);
4
- return function isPluginHookName(hookName) {
5
- return PLUGIN_HOOK_NAMES_SET.has(hookName);
6
- };
7
- })();
@@ -1,4 +0,0 @@
1
- import type { ModuleInfo } from '../types/module-info';
2
- import type { BindingModuleInfo } from '../binding';
3
- import { ModuleOptions } from '..';
4
- export declare function transformModuleInfo(info: BindingModuleInfo, option: ModuleOptions): ModuleInfo;
@@ -1,19 +0,0 @@
1
- import { unsupported } from './misc';
2
- export function transformModuleInfo(info, option) {
3
- return {
4
- get ast() {
5
- return unsupported('ModuleInfo#ast');
6
- },
7
- get code() {
8
- return info.code;
9
- },
10
- id: info.id,
11
- importers: info.importers,
12
- dynamicImporters: info.dynamicImporters,
13
- importedIds: info.importedIds,
14
- dynamicallyImportedIds: info.dynamicallyImportedIds,
15
- exports: info.exports,
16
- isEntry: info.isEntry,
17
- ...option,
18
- };
19
- }
@@ -1,4 +0,0 @@
1
- import { RenderedChunk as BindingRenderedChunk } from '../binding';
2
- import { RenderedChunk } from '../types/rolldown-output';
3
- export declare function transformRenderedChunk(chunk: BindingRenderedChunk): RenderedChunk;
4
- export declare function transformChunkModules(modules: BindingRenderedChunk['modules']): RenderedChunk['modules'];
@@ -1,43 +0,0 @@
1
- import { transformToRenderedModule } from './transform-rendered-module';
2
- export function transformRenderedChunk(chunk) {
3
- return {
4
- get name() {
5
- return chunk.name;
6
- },
7
- get isEntry() {
8
- return chunk.isEntry;
9
- },
10
- get isDynamicEntry() {
11
- return chunk.isDynamicEntry;
12
- },
13
- get facadeModuleId() {
14
- return chunk.facadeModuleId;
15
- },
16
- get moduleIds() {
17
- return chunk.moduleIds;
18
- },
19
- get exports() {
20
- return chunk.exports;
21
- },
22
- get fileName() {
23
- return chunk.fileName;
24
- },
25
- get imports() {
26
- return chunk.imports;
27
- },
28
- get dynamicImports() {
29
- return chunk.dynamicImports;
30
- },
31
- get modules() {
32
- return transformChunkModules(chunk.modules);
33
- },
34
- };
35
- }
36
- export function transformChunkModules(modules) {
37
- const result = {};
38
- for (const [id, index] of Object.entries(modules.idToIndex)) {
39
- let mod = modules.value[index];
40
- result[id] = transformToRenderedModule(mod);
41
- }
42
- return result;
43
- }
@@ -1,3 +0,0 @@
1
- import { BindingRenderedModule } from '../binding';
2
- import { RenderedModule } from '../types/rolldown-output';
3
- export declare function transformToRenderedModule(bindingRenderedModule: BindingRenderedModule): RenderedModule;
@@ -1,10 +0,0 @@
1
- export function transformToRenderedModule(bindingRenderedModule) {
2
- return {
3
- get code() {
4
- return bindingRenderedModule.code;
5
- },
6
- get renderedLength() {
7
- return bindingRenderedModule.code?.length || 0;
8
- },
9
- };
10
- }
@@ -1,3 +0,0 @@
1
- import { BindingHookSideEffects } from '../binding';
2
- import { ModuleSideEffects } from '../plugin';
3
- export declare function bindingifySideEffects(sideEffects?: ModuleSideEffects): BindingHookSideEffects | undefined;
@@ -1,16 +0,0 @@
1
- import { BindingHookSideEffects } from '../binding';
2
- export function bindingifySideEffects(sideEffects) {
3
- switch (sideEffects) {
4
- case true:
5
- return BindingHookSideEffects.True;
6
- case false:
7
- return BindingHookSideEffects.False;
8
- case 'no-treeshake':
9
- return BindingHookSideEffects.NoTreeshake;
10
- case null:
11
- case undefined:
12
- return undefined;
13
- default:
14
- throw new Error(`Unexpected side effects: ${sideEffects}`);
15
- }
16
- }
@@ -1,3 +0,0 @@
1
- import { type ExistingRawSourceMap, SourceMapInput } from '../types/sourcemap';
2
- export declare function isEmptySourcemapFiled(array: undefined | (string | null)[]): boolean;
3
- export declare function normalizeTransformHookSourcemap(id: string, originalCode: string, rawMap?: SourceMapInput): ExistingRawSourceMap | undefined;
@@ -1,29 +0,0 @@
1
- export function isEmptySourcemapFiled(array) {
2
- if (!array) {
3
- return true;
4
- }
5
- if (array.length === 0 || !array[0] /* null or '' */) {
6
- return true;
7
- }
8
- return false;
9
- }
10
- export function normalizeTransformHookSourcemap(id, originalCode, rawMap) {
11
- if (!rawMap) {
12
- return;
13
- }
14
- // If sourcemap hasn't `sourcesContent` and `sources`, using original code to fill it.
15
- // The rust side already has the feature at `crates/rolldown_plugin/src/plugin_driver/build_hooks.rs#transform`.
16
- // but it could be failed at `rolldown_sourcemap::SourceMap::from_json`, because the map is invalid.
17
- let map = typeof rawMap === 'object'
18
- ? rawMap
19
- : JSON.parse(rawMap);
20
- if (isEmptySourcemapFiled(map.sourcesContent)) {
21
- map.sourcesContent = [originalCode];
22
- }
23
- if (isEmptySourcemapFiled(map.sources) ||
24
- (map.sources && map.sources.length === 1 && map.sources[0] !== id) // the transform sourcemaps maybe contain multiple sources
25
- ) {
26
- map.sources = [id];
27
- }
28
- return map;
29
- }
@@ -1,11 +0,0 @@
1
- import type { RolldownOutput } from '../types/rolldown-output';
2
- import type { OutputBundle } from '../types/output-bundle';
3
- import type { BindingOutputs, JsChangedOutputs } from '../binding';
4
- export declare function transformToRollupOutput(output: BindingOutputs, changed?: ChangedOutputs): RolldownOutput;
5
- export declare function handleOutputErrors(output: BindingOutputs): void;
6
- export declare function transformToOutputBundle(output: BindingOutputs, changed: ChangedOutputs): OutputBundle;
7
- export interface ChangedOutputs {
8
- updated: Set<string>;
9
- deleted: Set<string>;
10
- }
11
- export declare function collectChangedBundle(changed: ChangedOutputs, bundle: OutputBundle): JsChangedOutputs;
@@ -1,165 +0,0 @@
1
- import { bindingAssetSource, transformAssetSource, } from './asset-source';
2
- import { bindingifySourcemap } from '../types/sourcemap';
3
- import { normalizeErrors } from './error';
4
- import { transformChunkModules } from './transform-rendered-chunk';
5
- import { Buffer } from 'node:buffer';
6
- function transformToRollupSourceMap(map) {
7
- const parsed = JSON.parse(map);
8
- const obj = {
9
- ...parsed,
10
- toString() {
11
- return JSON.stringify(obj);
12
- },
13
- toUrl() {
14
- return `data:application/json;charset=utf-8;base64,${Buffer.from(obj.toString(), 'utf-8').toString('base64')}`;
15
- },
16
- };
17
- return obj;
18
- }
19
- function transformToRollupOutputChunk(bindingChunk, changed) {
20
- const chunk = {
21
- type: 'chunk',
22
- get code() {
23
- return bindingChunk.code;
24
- },
25
- fileName: bindingChunk.fileName,
26
- name: bindingChunk.name,
27
- get modules() {
28
- return transformChunkModules(bindingChunk.modules);
29
- },
30
- get imports() {
31
- return bindingChunk.imports;
32
- },
33
- get dynamicImports() {
34
- return bindingChunk.dynamicImports;
35
- },
36
- exports: bindingChunk.exports,
37
- isEntry: bindingChunk.isEntry,
38
- facadeModuleId: bindingChunk.facadeModuleId || null,
39
- isDynamicEntry: bindingChunk.isDynamicEntry,
40
- get moduleIds() {
41
- return bindingChunk.moduleIds;
42
- },
43
- get map() {
44
- return bindingChunk.map
45
- ? transformToRollupSourceMap(bindingChunk.map)
46
- : null;
47
- },
48
- sourcemapFileName: bindingChunk.sourcemapFileName || null,
49
- preliminaryFileName: bindingChunk.preliminaryFileName,
50
- };
51
- const cache = {};
52
- return new Proxy(chunk, {
53
- get(target, p) {
54
- if (p in cache) {
55
- return cache[p];
56
- }
57
- return target[p];
58
- },
59
- set(target, p, newValue) {
60
- cache[p] = newValue;
61
- changed?.updated.add(bindingChunk.fileName);
62
- return true;
63
- },
64
- });
65
- }
66
- function transformToRollupOutputAsset(bindingAsset, changed) {
67
- const asset = {
68
- type: 'asset',
69
- fileName: bindingAsset.fileName,
70
- originalFileName: bindingAsset.originalFileName || null,
71
- originalFileNames: bindingAsset.originalFileNames,
72
- get source() {
73
- return transformAssetSource(bindingAsset.source);
74
- },
75
- name: bindingAsset.name ?? undefined,
76
- names: bindingAsset.names,
77
- };
78
- const cache = {};
79
- return new Proxy(asset, {
80
- get(target, p) {
81
- if (p in cache) {
82
- return cache[p];
83
- }
84
- return target[p];
85
- },
86
- set(target, p, newValue) {
87
- cache[p] = newValue;
88
- changed?.updated.add(bindingAsset.fileName);
89
- return true;
90
- },
91
- });
92
- }
93
- export function transformToRollupOutput(output, changed) {
94
- handleOutputErrors(output);
95
- const { chunks, assets } = output;
96
- return {
97
- output: [
98
- ...chunks.map((chunk) => transformToRollupOutputChunk(chunk, changed)),
99
- ...assets.map((asset) => transformToRollupOutputAsset(asset, changed)),
100
- ],
101
- };
102
- }
103
- export function handleOutputErrors(output) {
104
- const rawErrors = output.errors;
105
- if (rawErrors.length > 0) {
106
- throw normalizeErrors(rawErrors);
107
- }
108
- }
109
- export function transformToOutputBundle(output, changed) {
110
- const bundle = Object.fromEntries(transformToRollupOutput(output, changed).output.map((item) => [
111
- item.fileName,
112
- item,
113
- ]));
114
- return new Proxy(bundle, {
115
- deleteProperty(target, property) {
116
- if (typeof property === 'string') {
117
- changed.deleted.add(property);
118
- }
119
- return true;
120
- },
121
- });
122
- }
123
- // TODO find a way only transfer the changed part to rust side.
124
- export function collectChangedBundle(changed, bundle) {
125
- const assets = [];
126
- const chunks = [];
127
- for (const key in bundle) {
128
- if (changed.deleted.has(key) || !changed.updated.has(key)) {
129
- continue;
130
- }
131
- const item = bundle[key];
132
- if (item.type === 'asset') {
133
- assets.push({
134
- filename: item.fileName,
135
- originalFileNames: item.originalFileNames,
136
- source: bindingAssetSource(item.source),
137
- names: item.names,
138
- });
139
- }
140
- else {
141
- // not all properties modifications are reflected to rust side
142
- chunks.push({
143
- code: item.code,
144
- filename: item.fileName,
145
- name: item.name,
146
- isEntry: item.isEntry,
147
- exports: item.exports,
148
- modules: {},
149
- imports: item.imports,
150
- dynamicImports: item.dynamicImports,
151
- facadeModuleId: item.facadeModuleId || undefined,
152
- isDynamicEntry: item.isDynamicEntry,
153
- moduleIds: item.moduleIds,
154
- map: bindingifySourcemap(item.map),
155
- sourcemapFilename: item.sourcemapFileName || undefined,
156
- preliminaryFilename: item.preliminaryFileName,
157
- });
158
- }
159
- }
160
- return {
161
- assets,
162
- chunks,
163
- deleted: Array.from(changed.deleted),
164
- };
165
- }
@@ -1,7 +0,0 @@
1
- import type { ObjectSchema } from '../types/schema';
2
- import type { TreeshakingOptions } from '../types/module-side-effects';
3
- export declare function validateTreeShakingOptions(options: TreeshakingOptions): void;
4
- export declare function validateCliOptions<T>(options: T): [T, string[]?];
5
- export declare function getInputCliKeys(): string[];
6
- export declare function getOutputCliKeys(): string[];
7
- export declare function getJsonSchema(): ObjectSchema;