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,25 +0,0 @@
1
- import { noop } from '../utils/misc';
2
- import { LOG_LEVEL_WARN, logLevelPriority, } from './logging';
3
- import { logInvalidLogPosition } from './logs';
4
- export const normalizeLog = (log) => typeof log === 'string'
5
- ? { message: log }
6
- : typeof log === 'function'
7
- ? normalizeLog(log())
8
- : log;
9
- export function getLogHandler(level, code, logger, pluginName, logLevel) {
10
- if (logLevelPriority[level] < logLevelPriority[logLevel]) {
11
- return noop;
12
- }
13
- return (log, pos) => {
14
- if (pos != null) {
15
- logger(LOG_LEVEL_WARN, logInvalidLogPosition(pluginName));
16
- }
17
- log = normalizeLog(log);
18
- if (log.code && !log.pluginCode) {
19
- log.pluginCode = log.code;
20
- }
21
- log.code = code;
22
- log.plugin = pluginName;
23
- logger(level, log);
24
- };
25
- }
@@ -1,6 +0,0 @@
1
- import type { LogHandler } from '../types/misc';
2
- import type { Plugin } from '../plugin';
3
- import { type LogLevelOption } from './logging';
4
- import type { InputOptions } from '../options/input-options';
5
- export declare function getLogger(plugins: Plugin[], onLog: LogHandler, logLevel: LogLevelOption): LogHandler;
6
- export declare const getOnLog: (config: InputOptions, logLevel: LogLevelOption, printLog?: LogHandler) => LogHandler;
@@ -1,107 +0,0 @@
1
- import { LOG_LEVEL_DEBUG, LOG_LEVEL_INFO, LOG_LEVEL_WARN, LOG_LEVEL_ERROR, logLevelPriority, } from './logging';
2
- import { error } from './logs';
3
- import { normalizeLog } from './logHandler';
4
- import path from 'node:path';
5
- import { VERSION } from '..';
6
- import { getSortedPlugins } from '../plugin/plugin-driver';
7
- export function getLogger(plugins, onLog, logLevel) {
8
- const minimalPriority = logLevelPriority[logLevel];
9
- const logger = (level, log, skipped = new Set()) => {
10
- const logPriority = logLevelPriority[level];
11
- if (logPriority < minimalPriority) {
12
- return;
13
- }
14
- for (const plugin of getSortedPlugins('onLog', plugins)) {
15
- if (skipped.has(plugin))
16
- continue;
17
- const { onLog: pluginOnLog } = plugin;
18
- if (pluginOnLog) {
19
- const getLogHandler = (level) => {
20
- if (logLevelPriority[level] < minimalPriority) {
21
- return () => { };
22
- }
23
- return (log) => logger(level, normalizeLog(log), new Set(skipped).add(plugin));
24
- };
25
- const handler = 'handler' in pluginOnLog ? pluginOnLog.handler : pluginOnLog;
26
- if (handler.call({
27
- debug: getLogHandler(LOG_LEVEL_DEBUG),
28
- error: (log) => error(normalizeLog(log)),
29
- info: getLogHandler(LOG_LEVEL_INFO),
30
- meta: {
31
- rollupVersion: '4.23.0',
32
- rolldownVersion: VERSION,
33
- watchMode: false,
34
- },
35
- warn: getLogHandler(LOG_LEVEL_WARN),
36
- pluginName: plugin.name || 'unknown',
37
- }, level, log) === false) {
38
- return;
39
- }
40
- }
41
- }
42
- onLog(level, log);
43
- };
44
- return logger;
45
- }
46
- export const getOnLog = (config, logLevel, printLog = defaultPrintLog) => {
47
- const { onwarn, onLog } = config;
48
- const defaultOnLog = getDefaultOnLog(printLog, onwarn);
49
- if (onLog) {
50
- const minimalPriority = logLevelPriority[logLevel];
51
- return (level, log) => onLog(level, addLogToString(log), (level, handledLog) => {
52
- if (level === LOG_LEVEL_ERROR) {
53
- return error(normalizeLog(handledLog));
54
- }
55
- if (logLevelPriority[level] >= minimalPriority) {
56
- defaultOnLog(level, normalizeLog(handledLog));
57
- }
58
- });
59
- }
60
- return defaultOnLog;
61
- };
62
- const getDefaultOnLog = (printLog, onwarn) => onwarn
63
- ? (level, log) => {
64
- if (level === LOG_LEVEL_WARN) {
65
- onwarn(addLogToString(log), (warning) => printLog(LOG_LEVEL_WARN, normalizeLog(warning)));
66
- }
67
- else {
68
- printLog(level, log);
69
- }
70
- }
71
- : printLog;
72
- const addLogToString = (log) => {
73
- Object.defineProperty(log, 'toString', {
74
- value: () => getExtendedLogMessage(log),
75
- writable: true,
76
- });
77
- return log;
78
- };
79
- const defaultPrintLog = (level, log) => {
80
- const message = getExtendedLogMessage(log);
81
- switch (level) {
82
- case LOG_LEVEL_WARN: {
83
- return console.warn(message);
84
- }
85
- case LOG_LEVEL_DEBUG: {
86
- return console.debug(message);
87
- }
88
- default: {
89
- return console.info(message);
90
- }
91
- }
92
- };
93
- const getExtendedLogMessage = (log) => {
94
- let prefix = '';
95
- if (log.plugin) {
96
- prefix += `(${log.plugin} plugin) `;
97
- }
98
- if (log.loc) {
99
- prefix += `${relativeId(log.loc.file)} (${log.loc.line}:${log.loc.column}) `;
100
- }
101
- return prefix + log.message;
102
- };
103
- function relativeId(id) {
104
- if (!path.isAbsolute(id))
105
- return id;
106
- return path.relative(path.resolve(), id);
107
- }
@@ -1,11 +0,0 @@
1
- export type LogLevel = 'info' | 'debug' | 'warn';
2
- export type LogLevelOption = LogLevel | 'silent';
3
- export type LogLevelWithError = LogLevel | 'error';
4
- export type RollupLog = any;
5
- export type RollupLogWithString = RollupLog | string;
6
- export declare const LOG_LEVEL_SILENT: LogLevelOption;
7
- export declare const LOG_LEVEL_ERROR = "error";
8
- export declare const LOG_LEVEL_WARN: LogLevel;
9
- export declare const LOG_LEVEL_INFO: LogLevel;
10
- export declare const LOG_LEVEL_DEBUG: LogLevel;
11
- export declare const logLevelPriority: Record<LogLevelOption, number>;
@@ -1,11 +0,0 @@
1
- export const LOG_LEVEL_SILENT = 'silent';
2
- export const LOG_LEVEL_ERROR = 'error';
3
- export const LOG_LEVEL_WARN = 'warn';
4
- export const LOG_LEVEL_INFO = 'info';
5
- export const LOG_LEVEL_DEBUG = 'debug';
6
- export const logLevelPriority = {
7
- [LOG_LEVEL_DEBUG]: 0,
8
- [LOG_LEVEL_INFO]: 1,
9
- [LOG_LEVEL_WARN]: 2,
10
- [LOG_LEVEL_SILENT]: 3,
11
- };
@@ -1,18 +0,0 @@
1
- import type { RollupLog } from '../types/misc';
2
- export declare function logParseError(message: string): RollupLog;
3
- export declare function logMinifyWarning(): RollupLog;
4
- export declare function logInvalidLogPosition(pluginName: string): RollupLog;
5
- export declare function logInputHookInOutputPlugin(pluginName: string, hookName: string): RollupLog;
6
- export declare function logCycleLoading(pluginName: string, moduleId: string): RollupLog;
7
- export declare function logMultiplyNotifyOption(): RollupLog;
8
- export declare function logPluginError(error: Omit<RollupLog, 'code'> & {
9
- code?: unknown;
10
- }, plugin: string, { hook, id }?: {
11
- hook?: string;
12
- id?: string;
13
- }): RollupLog;
14
- export declare function error(base: Error | RollupLog): never;
15
- export declare function augmentCodeLocation(properties: RollupLog, pos: number | {
16
- column: number;
17
- line: number;
18
- }, source: string, id: string): void;
@@ -1,86 +0,0 @@
1
- import { getCodeFrame } from '../utils/code-frame';
2
- import { locate } from './locate-character';
3
- import { colors } from '../cli/colors';
4
- const INVALID_LOG_POSITION = 'INVALID_LOG_POSITION', PLUGIN_ERROR = 'PLUGIN_ERROR', INPUT_HOOK_IN_OUTPUT_PLUGIN = 'INPUT_HOOK_IN_OUTPUT_PLUGIN', CYCLE_LOADING = 'CYCLE_LOADING', MULTIPLY_NOTIFY_OPTION = 'MULTIPLY_NOTIFY_OPTION', MINIFY_WARNING = 'MINIFY_WARNING', PARSE_ERROR = 'PARSE_ERROR';
5
- export function logParseError(message) {
6
- return {
7
- code: PARSE_ERROR,
8
- message,
9
- };
10
- }
11
- export function logMinifyWarning() {
12
- return {
13
- code: MINIFY_WARNING,
14
- message: colors.yellow('The built-in minifier is still under development. Setting "minify: true" is not recommended for production use.'),
15
- };
16
- }
17
- export function logInvalidLogPosition(pluginName) {
18
- return {
19
- code: INVALID_LOG_POSITION,
20
- message: `Plugin "${pluginName}" tried to add a file position to a log or warning. This is only supported in the "transform" hook at the moment and will be ignored.`,
21
- };
22
- }
23
- export function logInputHookInOutputPlugin(pluginName, hookName) {
24
- return {
25
- code: INPUT_HOOK_IN_OUTPUT_PLUGIN,
26
- message: `The "${hookName}" hook used by the output plugin ${pluginName} is a build time hook and will not be run for that plugin. Either this plugin cannot be used as an output plugin, or it should have an option to configure it as an output plugin.`,
27
- };
28
- }
29
- export function logCycleLoading(pluginName, moduleId) {
30
- return {
31
- code: CYCLE_LOADING,
32
- message: `Found the module "${moduleId}" cycle loading at ${pluginName} plugin, it maybe blocking fetching modules.`,
33
- };
34
- }
35
- export function logMultiplyNotifyOption() {
36
- return {
37
- code: MULTIPLY_NOTIFY_OPTION,
38
- message: `Found multiply notify option at watch options, using first one to start notify watcher.`,
39
- };
40
- }
41
- export function logPluginError(error, plugin, { hook, id } = {}) {
42
- const code = error.code;
43
- if (!error.pluginCode &&
44
- code != null &&
45
- (typeof code !== 'string' || !code.startsWith('PLUGIN_'))) {
46
- error.pluginCode = code;
47
- }
48
- error.code = PLUGIN_ERROR;
49
- error.plugin = plugin;
50
- if (hook) {
51
- error.hook = hook;
52
- }
53
- if (id) {
54
- error.id = id;
55
- }
56
- return error;
57
- }
58
- export function error(base) {
59
- if (!(base instanceof Error)) {
60
- base = Object.assign(new Error(base.message), base);
61
- Object.defineProperty(base, 'name', {
62
- value: 'RollupError',
63
- writable: true,
64
- });
65
- }
66
- throw base;
67
- }
68
- export function augmentCodeLocation(properties, pos, source, id) {
69
- if (typeof pos === 'object') {
70
- const { line, column } = pos;
71
- properties.loc = { column, file: id, line };
72
- }
73
- else {
74
- properties.pos = pos;
75
- const location = locate(source, pos, { offsetLine: 1 });
76
- if (!location) {
77
- return;
78
- }
79
- const { line, column } = location;
80
- properties.loc = { column, file: id, line };
81
- }
82
- if (properties.frame === undefined) {
83
- const { line, column } = properties.loc;
84
- properties.frame = getCodeFrame(source, line, column);
85
- }
86
- }
@@ -1,170 +0,0 @@
1
- import type { RolldownPluginOption } from '../plugin';
2
- import type { LogLevel, LogLevelOption, LogLevelWithError, RollupLog, RollupLogWithString } from '../log/logging';
3
- import type { NullValue, StringOrRegExp } from '../types/utils';
4
- import type { TreeshakingOptions } from '../types/module-side-effects';
5
- export type InputOption = string | string[] | Record<string, string>;
6
- export type ExternalOption = StringOrRegExp | StringOrRegExp[] | ((id: string, parentId: string | undefined, isResolved: boolean) => NullValue<boolean>);
7
- export type ModuleTypes = Record<string, 'js' | 'jsx' | 'ts' | 'tsx' | 'json' | 'text' | 'base64' | 'dataurl' | 'binary' | 'empty' | 'css'>;
8
- export interface JsxOptions {
9
- mode?: 'classic' | 'automatic' | 'preserve';
10
- factory?: string;
11
- fragment?: string;
12
- importSource?: string;
13
- jsxImportSource?: string;
14
- refresh?: boolean;
15
- development?: boolean;
16
- }
17
- export interface WatchOptions {
18
- skipWrite?: boolean;
19
- notify?: {
20
- pollInterval?: number;
21
- compareContents?: boolean;
22
- };
23
- include?: StringOrRegExp | StringOrRegExp[];
24
- exclude?: StringOrRegExp | StringOrRegExp[];
25
- chokidar?: any;
26
- }
27
- export interface ChecksOptions {
28
- /**
29
- * Whether to emit warnings when detecting circular dependencies.
30
- * @default false
31
- */
32
- circularDependency?: boolean;
33
- }
34
- export interface InputOptions {
35
- input?: InputOption;
36
- plugins?: RolldownPluginOption;
37
- external?: ExternalOption;
38
- resolve?: {
39
- alias?: Record<string, string[] | string>;
40
- aliasFields?: string[][];
41
- conditionNames?: string[];
42
- /**
43
- * Map of extensions to alternative extensions.
44
- *
45
- * With writing `import './foo.js'` in a file, you want to resolve it to `foo.ts` instead of `foo.js`.
46
- * You can achieve this by setting: `extensionAlias: { '.js': ['.ts', '.js'] }`.
47
- */
48
- extensionAlias?: Record<string, string[]>;
49
- exportsFields?: string[][];
50
- extensions?: string[];
51
- mainFields?: string[];
52
- mainFiles?: string[];
53
- modules?: string[];
54
- symlinks?: boolean;
55
- tsconfigFilename?: string;
56
- };
57
- cwd?: string;
58
- /**
59
- * Expected platform where the code run.
60
- *
61
- * @default
62
- * - 'node' if the format is 'cjs'
63
- * - 'browser' for other formats
64
- */
65
- platform?: 'node' | 'browser' | 'neutral';
66
- shimMissingExports?: boolean;
67
- treeshake?: boolean | TreeshakingOptions;
68
- logLevel?: LogLevelOption;
69
- onLog?: (level: LogLevel, log: RollupLog, defaultHandler: (level: LogLevelWithError, log: RollupLogWithString) => void) => void;
70
- onwarn?: (warning: RollupLog, defaultHandler: (warning: RollupLogWithString | (() => RollupLogWithString)) => void) => void;
71
- moduleTypes?: ModuleTypes;
72
- experimental?: {
73
- enableComposingJsPlugins?: boolean;
74
- strictExecutionOrder?: boolean;
75
- disableLiveBindings?: boolean;
76
- viteMode?: boolean;
77
- resolveNewUrlToAsset?: boolean;
78
- };
79
- /**
80
- * Replace global variables or [property accessors](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Property_accessors) with the provided values.
81
- *
82
- * # Examples
83
- *
84
- * - Replace the global variable `IS_PROD` with `true`
85
- *
86
- * ```js rolldown.config.js
87
- * export default defineConfig({ define: { IS_PROD: 'true' // or JSON.stringify(true) } })
88
- * ```
89
- *
90
- * Result:
91
- *
92
- * ```js
93
- * // Input
94
- * if (IS_PROD) {
95
- * console.log('Production mode')
96
- * }
97
- *
98
- * // After bundling
99
- * if (true) {
100
- * console.log('Production mode')
101
- * }
102
- *```
103
- *
104
- * - Replace the property accessor `process.env.NODE_ENV` with `'production'`
105
- *
106
- * ```js rolldown.config.js
107
- * export default defineConfig({ define: { 'process.env.NODE_ENV': "'production'" } })
108
- * ```
109
- *
110
- * Result:
111
- *
112
- * ```js
113
- * // Input
114
- * if (process.env.NODE_ENV === 'production') {
115
- * console.log('Production mode')
116
- * }
117
- *
118
- * // After bundling
119
- * if ('production' === 'production') {
120
- * console.log('Production mode')
121
- * }
122
- *
123
- * ```
124
- */
125
- define?: Record<string, string>;
126
- /**
127
- * Inject import statements on demand.
128
- *
129
- * ## Supported patterns
130
- * ```js
131
- * {
132
- * // import { Promise } from 'es6-promise'
133
- * Promise: ['es6-promise', 'Promise'],
134
- *
135
- * // import { Promise as P } from 'es6-promise'
136
- * P: ['es6-promise', 'Promise'],
137
- *
138
- * // import $ from 'jquery'
139
- * $: 'jquery',
140
- *
141
- * // import * as fs from 'node:fs'
142
- * fs: ['node:fs', '*'],
143
- *
144
- * // Inject shims for property access pattern
145
- * 'Object.assign': path.resolve( 'src/helpers/object-assign.js' ),
146
- * }
147
- * ```
148
- */
149
- inject?: Record<string, string | [string, string]>;
150
- profilerNames?: boolean;
151
- /**
152
- * The `false` is disabled jsx parser, it will give you a syntax error if you use jsx syntax
153
- * The `mode: preserve` is disabled jsx transformer, it perverse original jsx syntax in the output.
154
- * The `mode: classic` is enabled jsx `classic` transformer.
155
- * The `mode: automatic` is enabled jsx `automatic` transformer.
156
- * @default mode = 'automatic'
157
- */
158
- jsx?: false | JsxOptions;
159
- watch?: WatchOptions | false;
160
- dropLabels?: string[];
161
- keepNames?: boolean;
162
- checks?: ChecksOptions;
163
- }
164
- interface OverwriteInputOptionsForCli {
165
- external?: string[];
166
- inject?: Record<string, string>;
167
- treeshake?: boolean;
168
- }
169
- export type InputCliOptions = Omit<InputOptions, keyof OverwriteInputOptionsForCli | 'input' | 'plugins' | 'onwarn' | 'onLog' | 'resolve' | 'experimental' | 'profilerNames' | 'watch'> & OverwriteInputOptionsForCli;
170
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,18 +0,0 @@
1
- import type { LogHandler } from '../types/misc';
2
- import { BindingNormalizedOptions } from '../binding';
3
- import { InputOptions } from '..';
4
- export interface NormalizedInputOptions {
5
- input: string[] | Record<string, string>;
6
- cwd: string | undefined;
7
- platform: InputOptions['platform'];
8
- shimMissingExports: boolean;
9
- }
10
- export declare class NormalizedInputOptionsImpl implements NormalizedInputOptions {
11
- onLog: LogHandler;
12
- inner: BindingNormalizedOptions;
13
- constructor(inner: BindingNormalizedOptions, onLog: LogHandler);
14
- get shimMissingExports(): boolean;
15
- get input(): string[] | Record<string, string>;
16
- get cwd(): string | undefined;
17
- get platform(): 'browser' | 'node' | 'neutral';
18
- }
@@ -1,21 +0,0 @@
1
- // TODO: I guess we make these getters enumerable so it act more like a plain object
2
- export class NormalizedInputOptionsImpl {
3
- onLog;
4
- inner;
5
- constructor(inner, onLog) {
6
- this.onLog = onLog;
7
- this.inner = inner;
8
- }
9
- get shimMissingExports() {
10
- return this.inner.shimMissingExports;
11
- }
12
- get input() {
13
- return this.inner.input;
14
- }
15
- get cwd() {
16
- return this.inner.cwd ?? undefined;
17
- }
18
- get platform() {
19
- return this.inner.platform;
20
- }
21
- }
@@ -1,67 +0,0 @@
1
- import type { BindingNormalizedOptions } from '../binding';
2
- import type { SourcemapIgnoreListOption, SourcemapPathTransformOption } from '../types/misc';
3
- import type { ChunkFileNamesFunction, GlobalsFunction, OutputOptions } from './output-options';
4
- export type InternalModuleFormat = 'es' | 'cjs' | 'iife' | 'umd' | 'app';
5
- export interface NormalizedOutputOptions {
6
- name: string | undefined;
7
- file: string | undefined;
8
- dir: string | undefined;
9
- entryFileNames: string | ChunkFileNamesFunction;
10
- chunkFileNames: string | ChunkFileNamesFunction;
11
- assetFileNames: string;
12
- format: InternalModuleFormat;
13
- exports: NonNullable<OutputOptions['exports']>;
14
- sourcemap: boolean | 'inline' | 'hidden';
15
- cssEntryFileNames: string | ChunkFileNamesFunction;
16
- cssChunkFileNames: string | ChunkFileNamesFunction;
17
- inlineDynamicImports: boolean;
18
- externalLiveBindings: boolean;
19
- banner: OutputOptions['banner'];
20
- footer: OutputOptions['footer'];
21
- intro: OutputOptions['intro'];
22
- outro: OutputOptions['outro'];
23
- esModule: boolean | 'if-default-prop';
24
- extend: boolean;
25
- globals: Record<string, string> | GlobalsFunction;
26
- hashCharacters: 'base64' | 'base36' | 'hex';
27
- sourcemapDebugIds: boolean;
28
- sourcemapIgnoreList: SourcemapIgnoreListOption | undefined;
29
- sourcemapPathTransform: SourcemapPathTransformOption | undefined;
30
- minify: boolean;
31
- comments: 'none' | 'preserve-legal';
32
- polyfillRequire: boolean;
33
- }
34
- type UnsupportedFnRet = () => never;
35
- export declare class NormalizedOutputOptionsImpl implements NormalizedOutputOptions {
36
- inner: BindingNormalizedOptions;
37
- constructor(inner: BindingNormalizedOptions);
38
- get dir(): string | undefined;
39
- get entryFileNames(): string | UnsupportedFnRet;
40
- get chunkFileNames(): string | UnsupportedFnRet;
41
- get assetFileNames(): string;
42
- get format(): 'es' | 'cjs' | 'app' | 'iife' | 'umd';
43
- get exports(): 'default' | 'named' | 'none' | 'auto';
44
- get sourcemap(): boolean | 'inline' | 'hidden';
45
- get cssEntryFileNames(): string | UnsupportedFnRet;
46
- get cssChunkFileNames(): string | UnsupportedFnRet;
47
- get shimMissingExports(): boolean;
48
- get name(): string | undefined;
49
- get file(): string | undefined;
50
- get inlineDynamicImports(): boolean;
51
- get externalLiveBindings(): boolean;
52
- get banner(): string | UnsupportedFnRet | undefined;
53
- get footer(): string | UnsupportedFnRet | undefined;
54
- get intro(): string | UnsupportedFnRet | undefined;
55
- get outro(): string | UnsupportedFnRet | undefined;
56
- get esModule(): boolean | 'if-default-prop';
57
- get extend(): boolean;
58
- get globals(): Record<string, string> | UnsupportedFnRet;
59
- get hashCharacters(): 'base64' | 'base36' | 'hex';
60
- get sourcemapDebugIds(): boolean;
61
- get sourcemapIgnoreList(): UnsupportedFnRet | undefined;
62
- get sourcemapPathTransform(): UnsupportedFnRet | undefined;
63
- get minify(): boolean;
64
- get comments(): 'none' | 'preserve-legal';
65
- get polyfillRequire(): boolean;
66
- }
67
- export {};
@@ -1,99 +0,0 @@
1
- import { unsupported } from '../utils/misc';
2
- function mapFunctionOption(option, name) {
3
- return typeof option === 'undefined'
4
- ? () => {
5
- unsupported(`You should not take \`NormalizedOutputOptions#${name}\` and call it directly`);
6
- }
7
- : option;
8
- }
9
- // TODO: I guess we make these getters enumerable so it act more like a plain object
10
- export class NormalizedOutputOptionsImpl {
11
- inner;
12
- constructor(inner) {
13
- this.inner = inner;
14
- }
15
- get dir() {
16
- return this.inner.dir ?? undefined;
17
- }
18
- get entryFileNames() {
19
- return mapFunctionOption(this.inner.entryFilenames, 'entryFileNames');
20
- }
21
- get chunkFileNames() {
22
- return mapFunctionOption(this.inner.chunkFilenames, 'chunkFileNames');
23
- }
24
- get assetFileNames() {
25
- return this.inner.assetFilenames;
26
- }
27
- get format() {
28
- return this.inner.format;
29
- }
30
- get exports() {
31
- return this.inner.exports;
32
- }
33
- get sourcemap() {
34
- return this.inner.sourcemap;
35
- }
36
- get cssEntryFileNames() {
37
- return mapFunctionOption(this.inner.cssEntryFilenames, 'cssEntryFileNames');
38
- }
39
- get cssChunkFileNames() {
40
- return mapFunctionOption(this.inner.cssChunkFilenames, 'cssChunkFileNames');
41
- }
42
- get shimMissingExports() {
43
- return this.inner.shimMissingExports;
44
- }
45
- get name() {
46
- return this.inner.name ?? undefined;
47
- }
48
- get file() {
49
- return this.inner.file ?? undefined;
50
- }
51
- get inlineDynamicImports() {
52
- return this.inner.inlineDynamicImports;
53
- }
54
- get externalLiveBindings() {
55
- return this.inner.externalLiveBindings;
56
- }
57
- get banner() {
58
- return mapFunctionOption(this.inner.banner, 'banner') ?? undefined;
59
- }
60
- get footer() {
61
- return mapFunctionOption(this.inner.footer, 'footer') ?? undefined;
62
- }
63
- get intro() {
64
- return mapFunctionOption(this.inner.intro, 'intro') ?? undefined;
65
- }
66
- get outro() {
67
- return mapFunctionOption(this.inner.outro, 'outro') ?? undefined;
68
- }
69
- get esModule() {
70
- return this.inner.esModule;
71
- }
72
- get extend() {
73
- return this.inner.extend;
74
- }
75
- get globals() {
76
- return mapFunctionOption(this.inner.globals, 'globals');
77
- }
78
- get hashCharacters() {
79
- return this.inner.hashCharacters;
80
- }
81
- get sourcemapDebugIds() {
82
- return this.inner.sourcemapDebugIds;
83
- }
84
- get sourcemapIgnoreList() {
85
- return mapFunctionOption(void 0, 'sourcemapIgnoreList');
86
- }
87
- get sourcemapPathTransform() {
88
- return mapFunctionOption(void 0, 'sourcemapPathTransform');
89
- }
90
- get minify() {
91
- return this.inner.minify;
92
- }
93
- get comments() {
94
- return this.inner.comments;
95
- }
96
- get polyfillRequire() {
97
- return this.inner.polyfillRequire;
98
- }
99
- }