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,4 +0,0 @@
1
- import { BindingAssetSource } from '../binding';
2
- export type AssetSource = string | Uint8Array;
3
- export declare function transformAssetSource(bindingAssetSource: BindingAssetSource): AssetSource;
4
- export declare function bindingAssetSource(source: AssetSource): BindingAssetSource;
@@ -1,8 +0,0 @@
1
- export function transformAssetSource(bindingAssetSource) {
2
- return bindingAssetSource.inner;
3
- }
4
- export function bindingAssetSource(source) {
5
- return {
6
- inner: source,
7
- };
8
- }
@@ -1 +0,0 @@
1
- export declare function asyncFlatten<T>(array: T[]): Promise<T[]>;
@@ -1,7 +0,0 @@
1
- // Copied from https://github.com/rollup/rollup/blob/3b560f7c889a63968dabc9b6970aabf52a77d3fd/src/utils/asyncFlatten.ts
2
- export async function asyncFlatten(array) {
3
- do {
4
- array = (await Promise.all(array)).flat(Infinity);
5
- } while (array.some((v) => v?.then));
6
- return array;
7
- }
@@ -1,7 +0,0 @@
1
- import type { RolldownPlugin } from '../plugin';
2
- import type { InputOptions } from '../options/input-options';
3
- import type { OutputOptions } from '../options/output-options';
4
- import type { BindingInputOptions } from '../binding';
5
- import { LogHandler } from '../types/misc';
6
- import { LogLevelOption } from '../log/logging';
7
- export declare function bindingifyInputOptions(rawPlugins: RolldownPlugin[], inputOptions: InputOptions, outputOptions: OutputOptions, onLog: LogHandler, logLevel: LogLevelOption): BindingInputOptions;
@@ -1,225 +0,0 @@
1
- import { BindingLogLevel } from '../binding';
2
- import { bindingifyPlugin } from '../plugin/bindingify-plugin';
3
- import { PluginContextData } from '../plugin/plugin-context-data';
4
- import { bindingifyBuiltInPlugin } from '../builtin-plugin/utils';
5
- import { BuiltinPlugin } from '../builtin-plugin/constructors';
6
- import { arraify, unsupported } from './misc';
7
- import { normalizedStringOrRegex } from './normalize-string-or-regex';
8
- export function bindingifyInputOptions(rawPlugins, inputOptions, outputOptions, onLog, logLevel) {
9
- const pluginContextData = new PluginContextData();
10
- const plugins = rawPlugins.map((plugin) => {
11
- if ('_parallel' in plugin) {
12
- return undefined;
13
- }
14
- if (plugin instanceof BuiltinPlugin) {
15
- return bindingifyBuiltInPlugin(plugin);
16
- }
17
- return bindingifyPlugin(plugin, inputOptions, outputOptions, pluginContextData, onLog, logLevel);
18
- });
19
- return {
20
- input: bindingifyInput(inputOptions.input),
21
- plugins,
22
- cwd: inputOptions.cwd ?? process.cwd(),
23
- external: bindingifyExternal(inputOptions.external),
24
- resolve: bindingifyResolve(inputOptions.resolve),
25
- platform: inputOptions.platform,
26
- shimMissingExports: inputOptions.shimMissingExports,
27
- logLevel: bindingifyLogLevel(logLevel),
28
- onLog,
29
- // After normalized, `false` will be converted to `undefined`, otherwise, default value will be assigned
30
- // Because it is hard to represent Enum in napi, ref: https://github.com/napi-rs/napi-rs/issues/507
31
- // So we use `undefined | NormalizedTreeshakingOptions` (or Option<NormalizedTreeshakingOptions> in rust side), to represent `false | NormalizedTreeshakingOptions`
32
- treeshake: bindingifyTreeshakeOptions(inputOptions.treeshake),
33
- moduleTypes: inputOptions.moduleTypes,
34
- define: inputOptions.define
35
- ? Object.entries(inputOptions.define)
36
- : undefined,
37
- inject: bindingifyInject(inputOptions.inject),
38
- experimental: {
39
- strictExecutionOrder: inputOptions.experimental?.strictExecutionOrder,
40
- disableLiveBindings: inputOptions.experimental?.disableLiveBindings,
41
- viteMode: inputOptions.experimental?.viteMode,
42
- resolveNewUrlToAsset: inputOptions.experimental?.resolveNewUrlToAsset,
43
- },
44
- profilerNames: inputOptions?.profilerNames,
45
- jsx: bindingifyJsx(inputOptions.jsx),
46
- watch: bindingifyWatch(inputOptions.watch),
47
- dropLabels: inputOptions.dropLabels,
48
- keepNames: inputOptions.keepNames,
49
- checks: inputOptions.checks,
50
- };
51
- }
52
- function bindingifyExternal(external) {
53
- if (external) {
54
- if (typeof external === 'function') {
55
- return (id, importer, isResolved) => {
56
- if (id.startsWith('\0'))
57
- return false;
58
- return external(id, importer, isResolved) ?? false;
59
- };
60
- }
61
- const externalArr = arraify(external);
62
- return (id, _importer, _isResolved) => {
63
- return externalArr.some((pat) => {
64
- if (pat instanceof RegExp) {
65
- return pat.test(id);
66
- }
67
- return id === pat;
68
- });
69
- };
70
- }
71
- }
72
- function bindingifyResolve(resolve) {
73
- if (resolve) {
74
- const { alias, extensionAlias, ...rest } = resolve;
75
- return {
76
- alias: alias
77
- ? Object.entries(alias).map(([name, replacement]) => ({
78
- find: name,
79
- replacements: arraify(replacement),
80
- }))
81
- : undefined,
82
- extensionAlias: extensionAlias
83
- ? Object.entries(extensionAlias).map(([name, value]) => ({
84
- target: name,
85
- replacements: value,
86
- }))
87
- : undefined,
88
- ...rest,
89
- };
90
- }
91
- }
92
- function bindingifyInject(inject) {
93
- if (inject) {
94
- return Object.entries(inject).map(([alias, item]) => {
95
- if (Array.isArray(item)) {
96
- // import * as fs from 'node:fs'
97
- // fs: ['node:fs', '*' ],
98
- if (item[1] === '*') {
99
- return {
100
- tagNamespace: true,
101
- alias,
102
- from: item[0],
103
- };
104
- }
105
- // import { Promise } from 'es6-promise'
106
- // Promise: [ 'es6-promise', 'Promise' ],
107
- // import { Promise as P } from 'es6-promise'
108
- // P: [ 'es6-promise', 'Promise' ],
109
- return {
110
- tagNamed: true,
111
- alias,
112
- from: item[0],
113
- imported: item[1],
114
- };
115
- }
116
- else {
117
- // import $ from 'jquery'
118
- // $: 'jquery',
119
- // 'Object.assign': path.resolve( 'src/helpers/object-assign.js' ),
120
- return {
121
- tagNamed: true,
122
- imported: 'default',
123
- alias,
124
- from: item,
125
- };
126
- }
127
- });
128
- }
129
- }
130
- function bindingifyLogLevel(logLevel) {
131
- switch (logLevel) {
132
- case 'silent':
133
- return BindingLogLevel.Silent;
134
- case 'debug':
135
- return BindingLogLevel.Debug;
136
- case 'warn':
137
- return BindingLogLevel.Warn;
138
- case 'info':
139
- return BindingLogLevel.Info;
140
- default:
141
- throw new Error(`Unexpected log level: ${logLevel}`);
142
- }
143
- }
144
- function bindingifyInput(input) {
145
- if (input === undefined) {
146
- return [];
147
- }
148
- if (typeof input === 'string') {
149
- return [{ import: input }];
150
- }
151
- if (Array.isArray(input)) {
152
- return input.map((src) => ({ import: src }));
153
- }
154
- return Object.entries(input).map((value) => {
155
- return { name: value[0], import: value[1] };
156
- });
157
- }
158
- // The `automatic` is most user usages, so it is different rollup's default value `false`
159
- function bindingifyJsx(input) {
160
- if (input === false) {
161
- return { type: 'Disable' };
162
- }
163
- if (input) {
164
- if (input.mode === 'preserve') {
165
- return { type: 'Preserve' };
166
- }
167
- const mode = input.mode ?? 'automatic';
168
- return {
169
- type: 'Enable',
170
- field0: {
171
- runtime: mode,
172
- importSource: mode === 'classic'
173
- ? input.importSource
174
- : mode === 'automatic'
175
- ? input.jsxImportSource
176
- : undefined,
177
- pragma: input.factory,
178
- pragmaFrag: input.fragment,
179
- development: input.development,
180
- refresh: input.refresh,
181
- },
182
- };
183
- }
184
- }
185
- function bindingifyWatch(watch) {
186
- if (watch) {
187
- let value = {
188
- skipWrite: watch.skipWrite,
189
- include: normalizedStringOrRegex(watch.include),
190
- exclude: normalizedStringOrRegex(watch.exclude),
191
- };
192
- if (watch.chokidar) {
193
- unsupported('The watch chokidar option is deprecated, please use notify options instead of it.');
194
- }
195
- return value;
196
- }
197
- }
198
- function bindingifyTreeshakeOptions(config) {
199
- if (config === false) {
200
- return undefined;
201
- }
202
- if (config === true || config === undefined) {
203
- return {
204
- moduleSideEffects: true,
205
- annotations: true,
206
- };
207
- }
208
- let normalizedConfig = {
209
- moduleSideEffects: true,
210
- };
211
- if (config.moduleSideEffects === undefined) {
212
- normalizedConfig.moduleSideEffects = true;
213
- }
214
- else if (config.moduleSideEffects === 'no-external') {
215
- normalizedConfig.moduleSideEffects = [
216
- { external: true, sideEffects: false },
217
- { external: false, sideEffects: true },
218
- ];
219
- }
220
- else {
221
- normalizedConfig.moduleSideEffects = config.moduleSideEffects;
222
- }
223
- normalizedConfig.annotations = config.annotations ?? true;
224
- return normalizedConfig;
225
- }
@@ -1,3 +0,0 @@
1
- import type { BindingOutputOptions } from '../binding';
2
- import type { OutputOptions } from '../options/output-options';
3
- export declare function bindingifyOutputOptions(outputOptions: OutputOptions): BindingOutputOptions;
@@ -1,92 +0,0 @@
1
- import { unimplemented } from './misc';
2
- import { transformRenderedChunk } from './transform-rendered-chunk';
3
- export function bindingifyOutputOptions(outputOptions) {
4
- const { dir, format, exports, hashCharacters, sourcemap, sourcemapIgnoreList, sourcemapPathTransform, name, assetFileNames, entryFileNames, chunkFileNames, cssEntryFileNames, cssChunkFileNames, banner, footer, intro, outro, esModule, globals, file, } = outputOptions;
5
- return {
6
- dir,
7
- // Handle case: rollup/test/sourcemaps/samples/sourcemap-file-hashed/_config.js
8
- file: file == null ? undefined : file,
9
- format: bindingifyFormat(format),
10
- exports,
11
- hashCharacters,
12
- sourcemap: bindingifySourcemap(sourcemap),
13
- sourcemapIgnoreList: bindingifySourcemapIgnoreList(sourcemapIgnoreList),
14
- sourcemapPathTransform,
15
- banner: bindingifyAddon(banner),
16
- footer: bindingifyAddon(footer),
17
- intro: bindingifyAddon(intro),
18
- outro: bindingifyAddon(outro),
19
- extend: outputOptions.extend,
20
- globals,
21
- esModule,
22
- name,
23
- assetFileNames,
24
- entryFileNames,
25
- chunkFileNames,
26
- cssEntryFileNames,
27
- cssChunkFileNames,
28
- // TODO(sapphi-red): support parallel plugins
29
- plugins: [],
30
- minify: outputOptions.minify,
31
- externalLiveBindings: outputOptions.externalLiveBindings,
32
- inlineDynamicImports: outputOptions.inlineDynamicImports,
33
- advancedChunks: outputOptions.advancedChunks,
34
- polyfillRequire: outputOptions.polyfillRequire,
35
- target: outputOptions.target,
36
- };
37
- }
38
- function bindingifyAddon(configAddon) {
39
- return async (chunk) => {
40
- if (typeof configAddon === 'function') {
41
- return configAddon(transformRenderedChunk(chunk));
42
- }
43
- return configAddon || '';
44
- };
45
- }
46
- function bindingifyFormat(format) {
47
- switch (format) {
48
- case undefined:
49
- case 'es':
50
- case 'esm':
51
- case 'module': {
52
- return 'es';
53
- }
54
- case 'cjs':
55
- case 'commonjs': {
56
- return 'cjs';
57
- }
58
- case 'iife': {
59
- return 'iife';
60
- }
61
- case 'umd': {
62
- return 'umd';
63
- }
64
- case 'experimental-app': {
65
- return 'app';
66
- }
67
- default:
68
- unimplemented(`output.format: ${format}`);
69
- }
70
- }
71
- function bindingifySourcemap(sourcemap) {
72
- switch (sourcemap) {
73
- case true:
74
- return 'file';
75
- case 'inline':
76
- return 'inline';
77
- case false:
78
- case undefined:
79
- return undefined;
80
- case 'hidden':
81
- return 'hidden';
82
- default:
83
- throw new Error(`unknown sourcemap: ${sourcemap}`);
84
- }
85
- }
86
- function bindingifySourcemapIgnoreList(sourcemapIgnoreList) {
87
- return typeof sourcemapIgnoreList === 'function'
88
- ? sourcemapIgnoreList
89
- : sourcemapIgnoreList === false
90
- ? () => false
91
- : (relativeSourcePath, _sourcemapPath) => relativeSourcePath.includes('node_modules');
92
- }
@@ -1 +0,0 @@
1
- export declare function getCodeFrame(source: string, line: number, column: number): string;
@@ -1,46 +0,0 @@
1
- function spaces(index) {
2
- let result = '';
3
- while (index--)
4
- result += ' ';
5
- return result;
6
- }
7
- function tabsToSpaces(value) {
8
- return value.replace(/^\t+/, (match) => match.split('\t').join(' '));
9
- }
10
- const LINE_TRUNCATE_LENGTH = 120;
11
- const MIN_CHARACTERS_SHOWN_AFTER_LOCATION = 10;
12
- const ELLIPSIS = '...';
13
- export function getCodeFrame(source, line, column) {
14
- let lines = source.split('\n');
15
- // Needed if a plugin did not generate correct sourcemaps
16
- if (line > lines.length)
17
- return '';
18
- const maxLineLength = Math.max(tabsToSpaces(lines[line - 1].slice(0, column)).length +
19
- MIN_CHARACTERS_SHOWN_AFTER_LOCATION +
20
- ELLIPSIS.length, LINE_TRUNCATE_LENGTH);
21
- const frameStart = Math.max(0, line - 3);
22
- let frameEnd = Math.min(line + 2, lines.length);
23
- lines = lines.slice(frameStart, frameEnd);
24
- while (!/\S/.test(lines[lines.length - 1])) {
25
- lines.pop();
26
- frameEnd -= 1;
27
- }
28
- const digits = String(frameEnd).length;
29
- return lines
30
- .map((sourceLine, index) => {
31
- const isErrorLine = frameStart + index + 1 === line;
32
- let lineNumber = String(index + frameStart + 1);
33
- while (lineNumber.length < digits)
34
- lineNumber = ` ${lineNumber}`;
35
- let displayedLine = tabsToSpaces(sourceLine);
36
- if (displayedLine.length > maxLineLength) {
37
- displayedLine = `${displayedLine.slice(0, maxLineLength - ELLIPSIS.length)}${ELLIPSIS}`;
38
- }
39
- if (isErrorLine) {
40
- const indicator = spaces(digits + 2 + tabsToSpaces(sourceLine.slice(0, column)).length) + '^';
41
- return `${lineNumber}: ${displayedLine}\n${indicator}`;
42
- }
43
- return `${lineNumber}: ${displayedLine}`;
44
- })
45
- .join('\n');
46
- }
@@ -1,2 +0,0 @@
1
- import { RolldownPlugin } from '../plugin';
2
- export declare function composeJsPlugins(plugins: RolldownPlugin[]): RolldownPlugin[];