rolldown 1.0.0-beta.43 → 1.0.0-beta.44
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.
- package/bin/cli.mjs +1 -0
- package/dist/cli-setup.d.mts +1 -0
- package/dist/cli-setup.mjs +16 -0
- package/dist/cli.mjs +1049 -75
- package/dist/config.d.mts +2 -2
- package/dist/config.mjs +5 -4
- package/dist/experimental-index.d.mts +20 -5
- package/dist/experimental-index.mjs +39 -15
- package/dist/filter-index.d.mts +2 -2
- package/dist/filter-index.mjs +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +4 -3
- package/dist/parallel-plugin-worker.mjs +4 -3
- package/dist/parallel-plugin.d.mts +2 -2
- package/dist/parse-ast-index.d.mts +1 -1
- package/dist/parse-ast-index.mjs +2 -1
- package/dist/shared/{parse-ast-index-DkUtf7vl.mjs → binding-DkR1uPxc.mjs} +97 -360
- package/dist/shared/{binding-BkaKdpud.d.mts → binding-QBosa6N8.d.mts} +89 -14
- package/dist/shared/{define-config-BGtNx9V_.d.mts → define-config-D9LwN_tW.d.mts} +193 -87
- package/dist/shared/{load-config-CLB1MN5j.mjs → load-config-BwIN-FIB.mjs} +2 -2
- package/dist/shared/{misc-CQeo-AFx.mjs → misc-usdOVIou.mjs} +1 -1
- package/dist/shared/parse-ast-index-Dee9Dv5S.mjs +297 -0
- package/dist/shared/{prompt-B4e-jZUR.mjs → prompt-YGfbLmz5.mjs} +1 -1
- package/dist/shared/{src-DucjDcdj.mjs → src-DY4_vVWu.mjs} +85 -88
- package/package.json +19 -20
- package/dist/shared/logger-B83ocDok.mjs +0 -985
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
import { b as parseSync, y as parseAsync } from "./binding-DkR1uPxc.mjs";
|
|
2
|
+
import { styleText } from "node:util";
|
|
3
|
+
|
|
4
|
+
//#region src/utils/code-frame.ts
|
|
5
|
+
function spaces(index) {
|
|
6
|
+
let result = "";
|
|
7
|
+
while (index--) result += " ";
|
|
8
|
+
return result;
|
|
9
|
+
}
|
|
10
|
+
function tabsToSpaces(value) {
|
|
11
|
+
return value.replace(/^\t+/, (match) => match.split(" ").join(" "));
|
|
12
|
+
}
|
|
13
|
+
const LINE_TRUNCATE_LENGTH = 120;
|
|
14
|
+
const MIN_CHARACTERS_SHOWN_AFTER_LOCATION = 10;
|
|
15
|
+
const ELLIPSIS = "...";
|
|
16
|
+
function getCodeFrame(source, line, column) {
|
|
17
|
+
let lines = source.split("\n");
|
|
18
|
+
if (line > lines.length) return "";
|
|
19
|
+
const maxLineLength = Math.max(tabsToSpaces(lines[line - 1].slice(0, column)).length + MIN_CHARACTERS_SHOWN_AFTER_LOCATION + 3, LINE_TRUNCATE_LENGTH);
|
|
20
|
+
const frameStart = Math.max(0, line - 3);
|
|
21
|
+
let frameEnd = Math.min(line + 2, lines.length);
|
|
22
|
+
lines = lines.slice(frameStart, frameEnd);
|
|
23
|
+
while (!/\S/.test(lines[lines.length - 1])) {
|
|
24
|
+
lines.pop();
|
|
25
|
+
frameEnd -= 1;
|
|
26
|
+
}
|
|
27
|
+
const digits = String(frameEnd).length;
|
|
28
|
+
return lines.map((sourceLine, index) => {
|
|
29
|
+
const isErrorLine = frameStart + index + 1 === line;
|
|
30
|
+
let lineNumber = String(index + frameStart + 1);
|
|
31
|
+
while (lineNumber.length < digits) lineNumber = ` ${lineNumber}`;
|
|
32
|
+
let displayedLine = tabsToSpaces(sourceLine);
|
|
33
|
+
if (displayedLine.length > maxLineLength) displayedLine = `${displayedLine.slice(0, maxLineLength - 3)}${ELLIPSIS}`;
|
|
34
|
+
if (isErrorLine) {
|
|
35
|
+
const indicator = spaces(digits + 2 + tabsToSpaces(sourceLine.slice(0, column)).length) + "^";
|
|
36
|
+
return `${lineNumber}: ${displayedLine}\n${indicator}`;
|
|
37
|
+
}
|
|
38
|
+
return `${lineNumber}: ${displayedLine}`;
|
|
39
|
+
}).join("\n");
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
//#endregion
|
|
43
|
+
//#region src/utils/style-text.ts
|
|
44
|
+
function styleText$1(...args) {
|
|
45
|
+
return styleText(...args);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
//#endregion
|
|
49
|
+
//#region src/log/locate-character/index.js
|
|
50
|
+
/** @typedef {import('./types').Location} Location */
|
|
51
|
+
/**
|
|
52
|
+
* @param {import('./types').Range} range
|
|
53
|
+
* @param {number} index
|
|
54
|
+
*/
|
|
55
|
+
function rangeContains(range, index) {
|
|
56
|
+
return range.start <= index && index < range.end;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* @param {string} source
|
|
60
|
+
* @param {import('./types').Options} [options]
|
|
61
|
+
*/
|
|
62
|
+
function getLocator(source, options = {}) {
|
|
63
|
+
const { offsetLine = 0, offsetColumn = 0 } = options;
|
|
64
|
+
let start = 0;
|
|
65
|
+
const ranges = source.split("\n").map((line, i$1) => {
|
|
66
|
+
const end = start + line.length + 1;
|
|
67
|
+
/** @type {import('./types').Range} */
|
|
68
|
+
const range = {
|
|
69
|
+
start,
|
|
70
|
+
end,
|
|
71
|
+
line: i$1
|
|
72
|
+
};
|
|
73
|
+
start = end;
|
|
74
|
+
return range;
|
|
75
|
+
});
|
|
76
|
+
let i = 0;
|
|
77
|
+
/**
|
|
78
|
+
* @param {string | number} search
|
|
79
|
+
* @param {number} [index]
|
|
80
|
+
* @returns {Location | undefined}
|
|
81
|
+
*/
|
|
82
|
+
function locator(search, index) {
|
|
83
|
+
if (typeof search === "string") search = source.indexOf(search, index ?? 0);
|
|
84
|
+
if (search === -1) return void 0;
|
|
85
|
+
let range = ranges[i];
|
|
86
|
+
const d = search >= range.end ? 1 : -1;
|
|
87
|
+
while (range) {
|
|
88
|
+
if (rangeContains(range, search)) return {
|
|
89
|
+
line: offsetLine + range.line,
|
|
90
|
+
column: offsetColumn + search - range.start,
|
|
91
|
+
character: search
|
|
92
|
+
};
|
|
93
|
+
i += d;
|
|
94
|
+
range = ranges[i];
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return locator;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* @param {string} source
|
|
101
|
+
* @param {string | number} search
|
|
102
|
+
* @param {import('./types').Options} [options]
|
|
103
|
+
* @returns {Location | undefined}
|
|
104
|
+
*/
|
|
105
|
+
function locate(source, search, options) {
|
|
106
|
+
return getLocator(source, options)(search, options && options.startIndex);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
//#endregion
|
|
110
|
+
//#region src/log/logs.ts
|
|
111
|
+
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", PARSE_ERROR = "PARSE_ERROR", NO_FS_IN_BROWSER = "NO_FS_IN_BROWSER", DEPRECATED_DEFINE = "DEPRECATED_DEFINE", DEPRECATED_INJECT = "DEPRECATED_INJECT", DEPRECATED_PROFILER_NAMES = "DEPRECATED_PROFILER_NAMES", DEPRECATED_KEEP_NAMES = "DEPRECATED_KEEP_NAMES", DEPRECATED_DROP_LABELS = "DEPRECATED_DROP_LABELS";
|
|
112
|
+
function logParseError(message) {
|
|
113
|
+
return {
|
|
114
|
+
code: PARSE_ERROR,
|
|
115
|
+
message
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
function logInvalidLogPosition(pluginName) {
|
|
119
|
+
return {
|
|
120
|
+
code: INVALID_LOG_POSITION,
|
|
121
|
+
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.`
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
function logInputHookInOutputPlugin(pluginName, hookName) {
|
|
125
|
+
return {
|
|
126
|
+
code: INPUT_HOOK_IN_OUTPUT_PLUGIN,
|
|
127
|
+
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.`
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
function logCycleLoading(pluginName, moduleId) {
|
|
131
|
+
return {
|
|
132
|
+
code: CYCLE_LOADING,
|
|
133
|
+
message: `Found the module "${moduleId}" cycle loading at ${pluginName} plugin, it maybe blocking fetching modules.`
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
function logMultiplyNotifyOption() {
|
|
137
|
+
return {
|
|
138
|
+
code: MULTIPLY_NOTIFY_OPTION,
|
|
139
|
+
message: `Found multiply notify option at watch options, using first one to start notify watcher.`
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
function logDeprecatedDefine() {
|
|
143
|
+
return {
|
|
144
|
+
code: DEPRECATED_DEFINE,
|
|
145
|
+
message: `${styleText$1(["yellow", "bold"], "⚠ Deprecation Warning:")} The top-level "define" option is deprecated. Use "transform.define" instead.`
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
function logDeprecatedInject() {
|
|
149
|
+
return {
|
|
150
|
+
code: DEPRECATED_INJECT,
|
|
151
|
+
message: `${styleText$1(["yellow", "bold"], "⚠ Deprecation Warning:")} The top-level "inject" option is deprecated. Use "transform.inject" instead.`
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
function logDeprecatedProfilerNames() {
|
|
155
|
+
return {
|
|
156
|
+
code: DEPRECATED_PROFILER_NAMES,
|
|
157
|
+
message: "The top-level \"profilerNames\" option is deprecated. Use \"output.generatedCode.profilerNames\" instead."
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
function logDeprecatedKeepNames() {
|
|
161
|
+
return {
|
|
162
|
+
code: DEPRECATED_KEEP_NAMES,
|
|
163
|
+
message: "The top-level \"keepNames\" option is deprecated. Use \"output.keepNames\" instead."
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
function logDeprecatedDropLabels() {
|
|
167
|
+
return {
|
|
168
|
+
code: DEPRECATED_DROP_LABELS,
|
|
169
|
+
message: `${styleText$1(["yellow", "bold"], "⚠ Deprecation Warning:")} The top-level "dropLabels" option is deprecated. Use "transform.dropLabels" instead.`
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
function logPluginError(error$1, plugin, { hook, id } = {}) {
|
|
173
|
+
try {
|
|
174
|
+
const code = error$1.code;
|
|
175
|
+
if (!error$1.pluginCode && code != null && (typeof code !== "string" || !code.startsWith("PLUGIN_"))) error$1.pluginCode = code;
|
|
176
|
+
error$1.code = PLUGIN_ERROR;
|
|
177
|
+
error$1.plugin = plugin;
|
|
178
|
+
if (hook) error$1.hook = hook;
|
|
179
|
+
if (id) error$1.id = id;
|
|
180
|
+
} catch (_) {} finally {
|
|
181
|
+
return error$1;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
function error(base) {
|
|
185
|
+
if (!(base instanceof Error)) {
|
|
186
|
+
base = Object.assign(new Error(base.message), base);
|
|
187
|
+
Object.defineProperty(base, "name", {
|
|
188
|
+
value: "RollupError",
|
|
189
|
+
writable: true
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
throw base;
|
|
193
|
+
}
|
|
194
|
+
function augmentCodeLocation(properties, pos, source, id) {
|
|
195
|
+
if (typeof pos === "object") {
|
|
196
|
+
const { line, column } = pos;
|
|
197
|
+
properties.loc = {
|
|
198
|
+
column,
|
|
199
|
+
file: id,
|
|
200
|
+
line
|
|
201
|
+
};
|
|
202
|
+
} else {
|
|
203
|
+
properties.pos = pos;
|
|
204
|
+
const location = locate(source, pos, { offsetLine: 1 });
|
|
205
|
+
if (!location) return;
|
|
206
|
+
const { line, column } = location;
|
|
207
|
+
properties.loc = {
|
|
208
|
+
column,
|
|
209
|
+
file: id,
|
|
210
|
+
line
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
if (properties.frame === void 0) {
|
|
214
|
+
const { line, column } = properties.loc;
|
|
215
|
+
properties.frame = getCodeFrame(source, line, column);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
//#endregion
|
|
220
|
+
//#region ../../node_modules/.pnpm/oxc-parser@0.95.0/node_modules/oxc-parser/src-js/wrap.js
|
|
221
|
+
function wrap$1(result) {
|
|
222
|
+
let program, module, comments, errors;
|
|
223
|
+
return {
|
|
224
|
+
get program() {
|
|
225
|
+
if (!program) program = jsonParseAst(result.program);
|
|
226
|
+
return program;
|
|
227
|
+
},
|
|
228
|
+
get module() {
|
|
229
|
+
if (!module) module = result.module;
|
|
230
|
+
return module;
|
|
231
|
+
},
|
|
232
|
+
get comments() {
|
|
233
|
+
if (!comments) comments = result.comments;
|
|
234
|
+
return comments;
|
|
235
|
+
},
|
|
236
|
+
get errors() {
|
|
237
|
+
if (!errors) errors = result.errors;
|
|
238
|
+
return errors;
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
function jsonParseAst(programJson) {
|
|
243
|
+
const { node: program, fixes } = JSON.parse(programJson);
|
|
244
|
+
for (const fixPath of fixes) applyFix(program, fixPath);
|
|
245
|
+
return program;
|
|
246
|
+
}
|
|
247
|
+
function applyFix(program, fixPath) {
|
|
248
|
+
let node = program;
|
|
249
|
+
for (const key of fixPath) node = node[key];
|
|
250
|
+
if (node.bigint) node.value = BigInt(node.bigint);
|
|
251
|
+
else try {
|
|
252
|
+
node.value = RegExp(node.regex.pattern, node.regex.flags);
|
|
253
|
+
} catch (_err) {}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
//#endregion
|
|
257
|
+
//#region src/parse-ast-index.ts
|
|
258
|
+
function wrap(result, sourceText) {
|
|
259
|
+
result = wrap$1(result);
|
|
260
|
+
if (result.errors.length > 0) return normalizeParseError(sourceText, result.errors);
|
|
261
|
+
return result.program;
|
|
262
|
+
}
|
|
263
|
+
function normalizeParseError(sourceText, errors) {
|
|
264
|
+
let message = `Parse failed with ${errors.length} error${errors.length < 2 ? "" : "s"}:\n`;
|
|
265
|
+
for (let i = 0; i < errors.length; i++) {
|
|
266
|
+
if (i >= 5) {
|
|
267
|
+
message += "\n...";
|
|
268
|
+
break;
|
|
269
|
+
}
|
|
270
|
+
const e = errors[i];
|
|
271
|
+
message += e.message + "\n" + e.labels.map((label) => {
|
|
272
|
+
const location = locate(sourceText, label.start, { offsetLine: 1 });
|
|
273
|
+
if (!location) return;
|
|
274
|
+
return getCodeFrame(sourceText, location.line, location.column);
|
|
275
|
+
}).filter(Boolean).join("\n");
|
|
276
|
+
}
|
|
277
|
+
return error(logParseError(message));
|
|
278
|
+
}
|
|
279
|
+
const defaultParserOptions = {
|
|
280
|
+
lang: "js",
|
|
281
|
+
preserveParens: false
|
|
282
|
+
};
|
|
283
|
+
function parseAst(sourceText, options, filename) {
|
|
284
|
+
return wrap(parseSync(filename ?? "file.js", sourceText, {
|
|
285
|
+
...defaultParserOptions,
|
|
286
|
+
...options
|
|
287
|
+
}), sourceText);
|
|
288
|
+
}
|
|
289
|
+
async function parseAstAsync(sourceText, options, filename) {
|
|
290
|
+
return wrap(await parseAsync(filename ?? "file.js", sourceText, {
|
|
291
|
+
...defaultParserOptions,
|
|
292
|
+
...options
|
|
293
|
+
}), sourceText);
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
//#endregion
|
|
297
|
+
export { logCycleLoading as a, logDeprecatedInject as c, logInputHookInOutputPlugin as d, logInvalidLogPosition as f, styleText$1 as h, error as i, logDeprecatedKeepNames as l, logPluginError as m, parseAstAsync as n, logDeprecatedDefine as o, logMultiplyNotifyOption as p, augmentCodeLocation as r, logDeprecatedDropLabels as s, parseAst as t, logDeprecatedProfilerNames as u };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { C as startAsyncRuntime, S as shutdownAsyncRuntime, c as BindingPluginOrder, f as BindingWatcher, g as initTraceSubscriber, i as BindingChunkModuleOrderBy, l as BindingPropertyReadSideEffects, n as BindingBundler, o as BindingLogLevel, p as ParallelJsPluginRegistry, r as BindingCallableBuiltinPlugin, s as BindingMagicString, t as BindingAttachDebugInfo, u as BindingPropertyWriteSideEffects } from "./binding-DkR1uPxc.mjs";
|
|
2
|
+
import { a as logCycleLoading, c as logDeprecatedInject, d as logInputHookInOutputPlugin, f as logInvalidLogPosition, h as styleText, i as error, l as logDeprecatedKeepNames, m as logPluginError, o as logDeprecatedDefine, p as logMultiplyNotifyOption, r as augmentCodeLocation, s as logDeprecatedDropLabels, t as parseAst, u as logDeprecatedProfilerNames } from "./parse-ast-index-Dee9Dv5S.mjs";
|
|
3
|
+
import { a as unreachable, i as unimplemented, o as unsupported, r as noop, t as arraify } from "./misc-usdOVIou.mjs";
|
|
3
4
|
import { Worker, isMainThread } from "node:worker_threads";
|
|
4
5
|
import path from "node:path";
|
|
5
|
-
import colors from "ansis";
|
|
6
6
|
import * as filter from "@rolldown/pluginutils";
|
|
7
7
|
import fsp from "node:fs/promises";
|
|
8
8
|
import os from "node:os";
|
|
@@ -218,7 +218,7 @@ if (isMainThread) {
|
|
|
218
218
|
|
|
219
219
|
//#endregion
|
|
220
220
|
//#region package.json
|
|
221
|
-
var version = "1.0.0-beta.
|
|
221
|
+
var version = "1.0.0-beta.44";
|
|
222
222
|
var description$1 = "Fast JavaScript/TypeScript bundler in Rust with Rollup-compatible API.";
|
|
223
223
|
|
|
224
224
|
//#endregion
|
|
@@ -1679,17 +1679,6 @@ const JsxOptionsSchema = strictObject({
|
|
|
1679
1679
|
pragmaFrag: pipe(optional(string()), description("Jsx fragment transformation")),
|
|
1680
1680
|
refresh: pipe(optional(boolean()), description("Enable react fast refresh"))
|
|
1681
1681
|
});
|
|
1682
|
-
const RollupJsxOptionsSchema = strictObject({
|
|
1683
|
-
mode: optional(union([
|
|
1684
|
-
literal("classic"),
|
|
1685
|
-
literal("automatic"),
|
|
1686
|
-
literal("preserve")
|
|
1687
|
-
])),
|
|
1688
|
-
factory: optional(string()),
|
|
1689
|
-
fragment: optional(string()),
|
|
1690
|
-
importSource: optional(string()),
|
|
1691
|
-
jsxImportSource: optional(string())
|
|
1692
|
-
});
|
|
1693
1682
|
const HelperModeSchema = union([literal("Runtime"), literal("External")]);
|
|
1694
1683
|
const DecoratorOptionSchema = object({
|
|
1695
1684
|
legacy: optional(boolean()),
|
|
@@ -1726,7 +1715,10 @@ const TransformOptionsSchema = object({
|
|
|
1726
1715
|
helpers: optional(HelpersSchema),
|
|
1727
1716
|
decorators: optional(DecoratorOptionSchema),
|
|
1728
1717
|
jsx: optional(union([literal("preserve"), JsxOptionsSchema])),
|
|
1729
|
-
target: pipe(optional(union([string(), array(string())])), description("The JavaScript target environment"))
|
|
1718
|
+
target: pipe(optional(union([string(), array(string())])), description("The JavaScript target environment")),
|
|
1719
|
+
define: optional(record(string(), string())),
|
|
1720
|
+
inject: optional(record(string(), union([string(), tuple([string(), string()])]))),
|
|
1721
|
+
dropLabels: pipe(optional(array(string())), description("Remove labeled statements with these label names"))
|
|
1730
1722
|
});
|
|
1731
1723
|
const WatchOptionsSchema = strictObject({
|
|
1732
1724
|
chokidar: optional(never(`The "watch.chokidar" option is deprecated, please use "watch.notify" instead of it`)),
|
|
@@ -1853,11 +1845,11 @@ const InputOptionsSchema = strictObject({
|
|
|
1853
1845
|
literal("browser"),
|
|
1854
1846
|
literal("neutral"),
|
|
1855
1847
|
literal("node")
|
|
1856
|
-
])), description(`Platform for which the code should be generated (node, ${
|
|
1848
|
+
])), description(`Platform for which the code should be generated (node, ${styleText("underline", "browser")}, neutral)`)),
|
|
1857
1849
|
shimMissingExports: pipe(optional(boolean()), description("Create shim variables for missing exports")),
|
|
1858
1850
|
treeshake: optional(TreeshakingOptionsSchema),
|
|
1859
1851
|
optimization: optional(OptimizationOptionsSchema),
|
|
1860
|
-
logLevel: pipe(optional(LogLevelOptionSchema), description(`Log level (${
|
|
1852
|
+
logLevel: pipe(optional(LogLevelOptionSchema), description(`Log level (${styleText("dim", "silent")}, ${styleText(["underline", "gray"], "info")}, debug, ${styleText("yellow", "warn")})`)),
|
|
1861
1853
|
onLog: optional(OnLogSchema),
|
|
1862
1854
|
onwarn: optional(OnwarnSchema),
|
|
1863
1855
|
moduleTypes: pipe(optional(ModuleTypesSchema), description("Module types for customized extensions")),
|
|
@@ -1885,13 +1877,6 @@ const InputOptionsSchema = strictObject({
|
|
|
1885
1877
|
define: pipe(optional(record(string(), string())), description("Define global variables")),
|
|
1886
1878
|
inject: optional(record(string(), union([string(), tuple([string(), string()])]))),
|
|
1887
1879
|
profilerNames: optional(boolean()),
|
|
1888
|
-
jsx: optional(union([
|
|
1889
|
-
literal(false),
|
|
1890
|
-
literal("react"),
|
|
1891
|
-
literal("react-jsx"),
|
|
1892
|
-
literal("preserve"),
|
|
1893
|
-
RollupJsxOptionsSchema
|
|
1894
|
-
])),
|
|
1895
1880
|
transform: optional(TransformOptionsSchema),
|
|
1896
1881
|
watch: optional(union([WatchOptionsSchema, literal(false)])),
|
|
1897
1882
|
dropLabels: pipe(optional(array(string())), description("Remove labeled statements with these label names")),
|
|
@@ -1912,12 +1897,6 @@ const InputCliOverrideSchema = strictObject({
|
|
|
1912
1897
|
inject: pipe(optional(record(string(), string())), description("Inject import statements on demand")),
|
|
1913
1898
|
treeshake: pipe(optional(boolean()), description("enable treeshaking")),
|
|
1914
1899
|
makeAbsoluteExternalsRelative: pipe(optional(boolean()), description("Prevent normalization of external imports")),
|
|
1915
|
-
jsx: pipe(optional(union([
|
|
1916
|
-
literal(false),
|
|
1917
|
-
literal("react"),
|
|
1918
|
-
literal("react-jsx"),
|
|
1919
|
-
literal("preserve")
|
|
1920
|
-
])), description("Jsx options preset")),
|
|
1921
1900
|
preserveEntrySignatures: pipe(optional(literal(false)), description("Avoid facade chunks for entry points")),
|
|
1922
1901
|
context: pipe(optional(string()), description("The entity top-level `this` represents."))
|
|
1923
1902
|
});
|
|
@@ -1973,7 +1952,8 @@ const AdvancedChunksSchema = strictObject({
|
|
|
1973
1952
|
const GeneratedCodePresetSchema = union([literal("es5"), literal("es2015")]);
|
|
1974
1953
|
const GeneratedCodeOptionsSchema = strictObject({
|
|
1975
1954
|
symbols: pipe(optional(boolean()), description("Whether to use Symbol.toStringTag for namespace objects")),
|
|
1976
|
-
preset: GeneratedCodePresetSchema
|
|
1955
|
+
preset: GeneratedCodePresetSchema,
|
|
1956
|
+
profilerNames: pipe(optional(boolean()), description("Whether to add readable names to internal variables for profiling purposes"))
|
|
1977
1957
|
});
|
|
1978
1958
|
const OutputOptionsSchema = strictObject({
|
|
1979
1959
|
dir: pipe(optional(string()), description("Output directory, defaults to `dist` if `file` is not set")),
|
|
@@ -1983,18 +1963,18 @@ const OutputOptionsSchema = strictObject({
|
|
|
1983
1963
|
literal("named"),
|
|
1984
1964
|
literal("default"),
|
|
1985
1965
|
literal("none")
|
|
1986
|
-
])), description(`Specify a export mode (${
|
|
1966
|
+
])), description(`Specify a export mode (${styleText("underline", "auto")}, named, default, none)`)),
|
|
1987
1967
|
hashCharacters: pipe(optional(union([
|
|
1988
1968
|
literal("base64"),
|
|
1989
1969
|
literal("base36"),
|
|
1990
1970
|
literal("hex")
|
|
1991
1971
|
])), description("Use the specified character set for file hashes")),
|
|
1992
|
-
format: pipe(optional(ModuleFormatSchema), description(`Output format of the generated bundle (supports ${
|
|
1972
|
+
format: pipe(optional(ModuleFormatSchema), description(`Output format of the generated bundle (supports ${styleText("underline", "esm")}, cjs, and iife)`)),
|
|
1993
1973
|
sourcemap: pipe(optional(union([
|
|
1994
1974
|
boolean(),
|
|
1995
1975
|
literal("inline"),
|
|
1996
1976
|
literal("hidden")
|
|
1997
|
-
])), description(`Generate sourcemap (\`-s inline\` for inline, or ${
|
|
1977
|
+
])), description(`Generate sourcemap (\`-s inline\` for inline, or ${styleText("bold", "pass the `-s` on the last argument if you want to generate `.map` file")})`)),
|
|
1998
1978
|
sourcemapBaseUrl: pipe(optional(string()), description("Base URL used to prefix sourcemap paths")),
|
|
1999
1979
|
sourcemapDebugIds: pipe(optional(boolean()), description("Inject sourcemap debug IDs")),
|
|
2000
1980
|
sourcemapIgnoreList: optional(union([
|
|
@@ -2039,10 +2019,12 @@ const OutputOptionsSchema = strictObject({
|
|
|
2039
2019
|
preserveModulesRoot: pipe(optional(string()), description("Put preserved modules under this path at root level")),
|
|
2040
2020
|
virtualDirname: optional(string()),
|
|
2041
2021
|
minifyInternalExports: pipe(optional(boolean()), description("Minify internal exports")),
|
|
2042
|
-
topLevelVar: pipe(optional(boolean()), description("Rewrite top-level declarations to use `var`."))
|
|
2022
|
+
topLevelVar: pipe(optional(boolean()), description("Rewrite top-level declarations to use `var`.")),
|
|
2023
|
+
cleanDir: pipe(optional(boolean()), description("Clean output directory before emitting output")),
|
|
2024
|
+
keepNames: pipe(optional(boolean()), description("Keep function and class names after bundling"))
|
|
2043
2025
|
});
|
|
2044
2026
|
const getAddonDescription = (placement, wrapper) => {
|
|
2045
|
-
return `Code to insert the ${
|
|
2027
|
+
return `Code to insert the ${styleText("bold", placement)} of the bundled file (${styleText("bold", wrapper)} the wrapper function)`;
|
|
2046
2028
|
};
|
|
2047
2029
|
const OutputCliOverrideSchema = strictObject({
|
|
2048
2030
|
assetFileNames: pipe(optional(string()), description("Name pattern for asset files")),
|
|
@@ -3610,6 +3592,49 @@ function isReadonlyArray(input) {
|
|
|
3610
3592
|
return Array.isArray(input);
|
|
3611
3593
|
}
|
|
3612
3594
|
|
|
3595
|
+
//#endregion
|
|
3596
|
+
//#region src/utils/normalize-transform-options.ts
|
|
3597
|
+
/**
|
|
3598
|
+
* Normalizes transform options by extracting `define`, `inject`, and `dropLabels` separately from OXC transform options.
|
|
3599
|
+
*
|
|
3600
|
+
* Prioritizes values from `transform.define`, `transform.inject`, and `transform.dropLabels` over deprecated top-level options.
|
|
3601
|
+
*/
|
|
3602
|
+
function normalizeTransformOptions(inputOptions, onLog) {
|
|
3603
|
+
const transform = inputOptions.transform;
|
|
3604
|
+
let define;
|
|
3605
|
+
if (transform?.define) define = Object.entries(transform.define);
|
|
3606
|
+
else if (inputOptions.define) {
|
|
3607
|
+
onLog(LOG_LEVEL_WARN, logDeprecatedDefine());
|
|
3608
|
+
define = Object.entries(inputOptions.define);
|
|
3609
|
+
}
|
|
3610
|
+
let inject;
|
|
3611
|
+
if (transform?.inject) inject = transform.inject;
|
|
3612
|
+
else if (inputOptions.inject) {
|
|
3613
|
+
onLog(LOG_LEVEL_WARN, logDeprecatedInject());
|
|
3614
|
+
inject = inputOptions.inject;
|
|
3615
|
+
}
|
|
3616
|
+
let dropLabels;
|
|
3617
|
+
if (transform?.dropLabels) dropLabels = transform.dropLabels;
|
|
3618
|
+
else if (inputOptions.dropLabels) {
|
|
3619
|
+
onLog(LOG_LEVEL_WARN, logDeprecatedDropLabels());
|
|
3620
|
+
dropLabels = inputOptions.dropLabels;
|
|
3621
|
+
}
|
|
3622
|
+
let oxcTransformOptions;
|
|
3623
|
+
if (transform) {
|
|
3624
|
+
const { define: _define, inject: _inject, dropLabels: _dropLabels,...rest } = transform;
|
|
3625
|
+
if (Object.keys(rest).length > 0) {
|
|
3626
|
+
if (rest.jsx === false) rest.jsx = "disable";
|
|
3627
|
+
oxcTransformOptions = rest;
|
|
3628
|
+
}
|
|
3629
|
+
}
|
|
3630
|
+
return {
|
|
3631
|
+
define,
|
|
3632
|
+
inject,
|
|
3633
|
+
dropLabels,
|
|
3634
|
+
oxcTransformOptions
|
|
3635
|
+
};
|
|
3636
|
+
}
|
|
3637
|
+
|
|
3613
3638
|
//#endregion
|
|
3614
3639
|
//#region src/utils/bindingify-input-options.ts
|
|
3615
3640
|
function bindingifyInputOptions(rawPlugins, inputOptions, outputOptions, normalizedOutputPlugins, onLog, logLevel, watchMode) {
|
|
@@ -3619,7 +3644,19 @@ function bindingifyInputOptions(rawPlugins, inputOptions, outputOptions, normali
|
|
|
3619
3644
|
if (plugin instanceof BuiltinPlugin) return bindingifyBuiltInPlugin(plugin);
|
|
3620
3645
|
return bindingifyPlugin(plugin, inputOptions, outputOptions, pluginContextData, normalizedOutputPlugins, onLog, logLevel, watchMode);
|
|
3621
3646
|
});
|
|
3622
|
-
const
|
|
3647
|
+
const normalizedTransform = normalizeTransformOptions(inputOptions, onLog);
|
|
3648
|
+
let profilerNames;
|
|
3649
|
+
if (outputOptions.generatedCode?.profilerNames !== void 0) profilerNames = outputOptions.generatedCode.profilerNames;
|
|
3650
|
+
else if (inputOptions.profilerNames !== void 0) {
|
|
3651
|
+
onLog(LOG_LEVEL_WARN, logDeprecatedProfilerNames());
|
|
3652
|
+
profilerNames = inputOptions.profilerNames;
|
|
3653
|
+
}
|
|
3654
|
+
let keepNames;
|
|
3655
|
+
if (outputOptions.keepNames !== void 0) keepNames = outputOptions.keepNames;
|
|
3656
|
+
else if (inputOptions.keepNames !== void 0) {
|
|
3657
|
+
onLog(LOG_LEVEL_WARN, logDeprecatedKeepNames());
|
|
3658
|
+
keepNames = inputOptions.keepNames;
|
|
3659
|
+
}
|
|
3623
3660
|
return {
|
|
3624
3661
|
input: bindingifyInput(inputOptions.input),
|
|
3625
3662
|
plugins,
|
|
@@ -3632,15 +3669,14 @@ function bindingifyInputOptions(rawPlugins, inputOptions, outputOptions, normali
|
|
|
3632
3669
|
onLog: async (level, log) => onLog(level, log),
|
|
3633
3670
|
treeshake: bindingifyTreeshakeOptions(inputOptions.treeshake),
|
|
3634
3671
|
moduleTypes: inputOptions.moduleTypes,
|
|
3635
|
-
define:
|
|
3636
|
-
inject: bindingifyInject(
|
|
3672
|
+
define: normalizedTransform.define,
|
|
3673
|
+
inject: bindingifyInject(normalizedTransform.inject),
|
|
3637
3674
|
experimental: bindingifyExperimental(inputOptions.experimental),
|
|
3638
|
-
profilerNames
|
|
3639
|
-
|
|
3640
|
-
transform,
|
|
3675
|
+
profilerNames,
|
|
3676
|
+
transform: normalizedTransform.oxcTransformOptions,
|
|
3641
3677
|
watch: bindingifyWatch(inputOptions.watch),
|
|
3642
|
-
dropLabels:
|
|
3643
|
-
keepNames
|
|
3678
|
+
dropLabels: normalizedTransform.dropLabels,
|
|
3679
|
+
keepNames,
|
|
3644
3680
|
checks: inputOptions.checks,
|
|
3645
3681
|
deferSyncScanData: () => {
|
|
3646
3682
|
let ret = [];
|
|
@@ -3769,46 +3805,6 @@ function bindingifyInput(input) {
|
|
|
3769
3805
|
};
|
|
3770
3806
|
});
|
|
3771
3807
|
}
|
|
3772
|
-
function bindingifyJsx(onLog, input, transform) {
|
|
3773
|
-
if (transform?.jsx) {
|
|
3774
|
-
if (input !== void 0) onLog(LOG_LEVEL_WARN, logDuplicateJsxConfig());
|
|
3775
|
-
return { transform };
|
|
3776
|
-
}
|
|
3777
|
-
if (typeof input === "object") {
|
|
3778
|
-
if (input.mode === "preserve") return {
|
|
3779
|
-
jsx: BindingJsx.Preserve,
|
|
3780
|
-
transform
|
|
3781
|
-
};
|
|
3782
|
-
const mode = input.mode ?? "automatic";
|
|
3783
|
-
transform ??= {};
|
|
3784
|
-
transform.jsx = {
|
|
3785
|
-
runtime: mode,
|
|
3786
|
-
pragma: input.factory,
|
|
3787
|
-
pragmaFrag: input.fragment,
|
|
3788
|
-
importSource: mode === "classic" ? input.importSource : mode === "automatic" ? input.jsxImportSource : void 0
|
|
3789
|
-
};
|
|
3790
|
-
return { transform };
|
|
3791
|
-
}
|
|
3792
|
-
let jsx;
|
|
3793
|
-
switch (input) {
|
|
3794
|
-
case false:
|
|
3795
|
-
jsx = BindingJsx.Disable;
|
|
3796
|
-
break;
|
|
3797
|
-
case "react":
|
|
3798
|
-
jsx = BindingJsx.React;
|
|
3799
|
-
break;
|
|
3800
|
-
case "react-jsx":
|
|
3801
|
-
jsx = BindingJsx.ReactJsx;
|
|
3802
|
-
break;
|
|
3803
|
-
case "preserve":
|
|
3804
|
-
jsx = BindingJsx.Preserve;
|
|
3805
|
-
break;
|
|
3806
|
-
}
|
|
3807
|
-
return {
|
|
3808
|
-
jsx,
|
|
3809
|
-
transform
|
|
3810
|
-
};
|
|
3811
|
-
}
|
|
3812
3808
|
function bindingifyWatch(watch$1) {
|
|
3813
3809
|
if (watch$1) return {
|
|
3814
3810
|
buildDelay: watch$1.buildDelay,
|
|
@@ -3895,7 +3891,7 @@ var ChunkingContextImpl = class {
|
|
|
3895
3891
|
//#endregion
|
|
3896
3892
|
//#region src/utils/bindingify-output-options.ts
|
|
3897
3893
|
function bindingifyOutputOptions(outputOptions) {
|
|
3898
|
-
const { dir, format, exports, hashCharacters, sourcemap, sourcemapBaseUrl, sourcemapDebugIds, sourcemapIgnoreList, sourcemapPathTransform, name, assetFileNames, entryFileNames, chunkFileNames, cssEntryFileNames, cssChunkFileNames, banner, footer, intro, outro, esModule, globals, paths, generatedCode, file, sanitizeFileName, preserveModules, virtualDirname, legalComments, preserveModulesRoot, manualChunks, topLevelVar } = outputOptions;
|
|
3894
|
+
const { dir, format, exports, hashCharacters, sourcemap, sourcemapBaseUrl, sourcemapDebugIds, sourcemapIgnoreList, sourcemapPathTransform, name, assetFileNames, entryFileNames, chunkFileNames, cssEntryFileNames, cssChunkFileNames, banner, footer, intro, outro, esModule, globals, paths, generatedCode, file, sanitizeFileName, preserveModules, virtualDirname, legalComments, preserveModulesRoot, manualChunks, topLevelVar, cleanDir } = outputOptions;
|
|
3899
3895
|
const advancedChunks = bindingifyAdvancedChunks(outputOptions.advancedChunks, manualChunks);
|
|
3900
3896
|
return {
|
|
3901
3897
|
dir,
|
|
@@ -3935,7 +3931,8 @@ function bindingifyOutputOptions(outputOptions) {
|
|
|
3935
3931
|
legalComments,
|
|
3936
3932
|
preserveModulesRoot,
|
|
3937
3933
|
topLevelVar,
|
|
3938
|
-
minifyInternalExports: outputOptions.minifyInternalExports
|
|
3934
|
+
minifyInternalExports: outputOptions.minifyInternalExports,
|
|
3935
|
+
cleanDir
|
|
3939
3936
|
};
|
|
3940
3937
|
}
|
|
3941
3938
|
function bindingifyAddon(configAddon) {
|
|
@@ -4315,4 +4312,4 @@ function defineConfig(config) {
|
|
|
4315
4312
|
const VERSION = version;
|
|
4316
4313
|
|
|
4317
4314
|
//#endregion
|
|
4318
|
-
export {
|
|
4315
|
+
export { onExit as C, version as S, validateCliOptions as _, rolldown as a, makeBuiltinPluginCallable as b, normalizedStringOrRegex as c, transformToRollupOutput as d, normalizeBindingResult as f, getOutputCliKeys as g, getInputCliKeys as h, build as i, PluginContextData as l, getCliSchemaInfo as m, defineConfig as n, RolldownBuild as o, bindingifySourcemap$1 as p, watch as r, createBundlerOptions as s, VERSION as t, bindingifyPlugin as u, PluginDriver as v, description$1 as x, BuiltinPlugin as y };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rolldown",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.44",
|
|
4
4
|
"description": "Fast JavaScript/TypeScript bundler in Rust with Rollup-compatible API.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"homepage": "https://rolldown.rs/",
|
|
@@ -75,9 +75,8 @@
|
|
|
75
75
|
"dtsHeader": "type MaybePromise<T> = T | Promise<T>\ntype Nullable<T> = T | null | undefined\ntype VoidNullable<T = void> = T | null | undefined | void\nexport type BindingStringOrRegex = string | RegExp\ntype BindingResult<T> = { errors: BindingError[], isBindingErrors: boolean } | T\n\n"
|
|
76
76
|
},
|
|
77
77
|
"dependencies": {
|
|
78
|
-
"@oxc-project/types": "=0.
|
|
79
|
-
"
|
|
80
|
-
"@rolldown/pluginutils": "1.0.0-beta.43"
|
|
78
|
+
"@oxc-project/types": "=0.95.0",
|
|
79
|
+
"@rolldown/pluginutils": "1.0.0-beta.44"
|
|
81
80
|
},
|
|
82
81
|
"devDependencies": {
|
|
83
82
|
"@napi-rs/cli": "^3.2.0",
|
|
@@ -88,7 +87,7 @@
|
|
|
88
87
|
"consola": "^3.4.2",
|
|
89
88
|
"execa": "^9.2.0",
|
|
90
89
|
"glob": "^11.0.0",
|
|
91
|
-
"oxc-parser": "=0.
|
|
90
|
+
"oxc-parser": "=0.95.0",
|
|
92
91
|
"pathe": "^2.0.3",
|
|
93
92
|
"remeda": "^2.10.0",
|
|
94
93
|
"rolldown-plugin-dts": "^0.16.0",
|
|
@@ -99,26 +98,26 @@
|
|
|
99
98
|
"typedoc": "^0.28.0",
|
|
100
99
|
"typescript": "^5.8.3",
|
|
101
100
|
"valibot": "1.1.0",
|
|
102
|
-
"rolldown": "1.0.0-beta.
|
|
101
|
+
"rolldown": "1.0.0-beta.44"
|
|
103
102
|
},
|
|
104
103
|
"engines": {
|
|
105
104
|
"node": "^20.19.0 || >=22.12.0"
|
|
106
105
|
},
|
|
107
106
|
"optionalDependencies": {
|
|
108
|
-
"@rolldown/binding-darwin-x64": "1.0.0-beta.
|
|
109
|
-
"@rolldown/binding-win32-x64-msvc": "1.0.0-beta.
|
|
110
|
-
"@rolldown/binding-linux-x64-gnu": "1.0.0-beta.
|
|
111
|
-
"@rolldown/binding-linux-x64-musl": "1.0.0-beta.
|
|
112
|
-
"@rolldown/binding-freebsd-x64": "1.0.0-beta.
|
|
113
|
-
"@rolldown/binding-win32-ia32-msvc": "1.0.0-beta.
|
|
114
|
-
"@rolldown/binding-linux-arm-gnueabihf": "1.0.0-beta.
|
|
115
|
-
"@rolldown/binding-linux-arm64-gnu": "1.0.0-beta.
|
|
116
|
-
"@rolldown/binding-darwin-arm64": "1.0.0-beta.
|
|
117
|
-
"@rolldown/binding-linux-arm64-musl": "1.0.0-beta.
|
|
118
|
-
"@rolldown/binding-openharmony-arm64": "1.0.0-beta.
|
|
119
|
-
"@rolldown/binding-win32-arm64-msvc": "1.0.0-beta.
|
|
120
|
-
"@rolldown/binding-android-arm64": "1.0.0-beta.
|
|
121
|
-
"@rolldown/binding-wasm32-wasi": "1.0.0-beta.
|
|
107
|
+
"@rolldown/binding-darwin-x64": "1.0.0-beta.44",
|
|
108
|
+
"@rolldown/binding-win32-x64-msvc": "1.0.0-beta.44",
|
|
109
|
+
"@rolldown/binding-linux-x64-gnu": "1.0.0-beta.44",
|
|
110
|
+
"@rolldown/binding-linux-x64-musl": "1.0.0-beta.44",
|
|
111
|
+
"@rolldown/binding-freebsd-x64": "1.0.0-beta.44",
|
|
112
|
+
"@rolldown/binding-win32-ia32-msvc": "1.0.0-beta.44",
|
|
113
|
+
"@rolldown/binding-linux-arm-gnueabihf": "1.0.0-beta.44",
|
|
114
|
+
"@rolldown/binding-linux-arm64-gnu": "1.0.0-beta.44",
|
|
115
|
+
"@rolldown/binding-darwin-arm64": "1.0.0-beta.44",
|
|
116
|
+
"@rolldown/binding-linux-arm64-musl": "1.0.0-beta.44",
|
|
117
|
+
"@rolldown/binding-openharmony-arm64": "1.0.0-beta.44",
|
|
118
|
+
"@rolldown/binding-win32-arm64-msvc": "1.0.0-beta.44",
|
|
119
|
+
"@rolldown/binding-android-arm64": "1.0.0-beta.44",
|
|
120
|
+
"@rolldown/binding-wasm32-wasi": "1.0.0-beta.44"
|
|
122
121
|
},
|
|
123
122
|
"scripts": {
|
|
124
123
|
"# Scrips for binding #": "_",
|