@rolldown/browser 1.0.0-beta.9-commit.0ec9e7d → 1.0.0-rc.10
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/dist/cli.mjs +961 -1551
- package/dist/config.d.mts +9 -6
- package/dist/config.mjs +9 -11
- package/dist/constructors-DsfxKD6A.js +68 -0
- package/dist/error-BeZaDkS8.js +157 -0
- package/dist/experimental-index.browser.mjs +278 -44
- package/dist/experimental-index.d.mts +228 -68
- package/dist/experimental-index.mjs +274 -55
- package/dist/experimental-runtime-types.d.ts +98 -0
- package/dist/filter-index.d.mts +104 -2
- package/dist/filter-index.mjs +144 -5
- package/dist/get-log-filter.d.mts +3 -0
- package/dist/get-log-filter.mjs +68 -0
- package/dist/index.browser.mjs +238 -3
- package/dist/index.d.mts +4 -3
- package/dist/index.mjs +53 -6
- package/dist/{shared/parse-ast-index-BHaE0ECV.cjs → normalize-string-or-regex-TtAGUp42.js} +74 -147
- package/dist/parallel-plugin-worker.mjs +27 -35
- package/dist/parallel-plugin.d.mts +7 -7
- package/dist/parallel-plugin.mjs +1 -2
- package/dist/parse-ast-index.d.mts +28 -5
- package/dist/parse-ast-index.mjs +60 -4
- package/dist/plugins-index.browser.mjs +40 -0
- package/dist/plugins-index.d.mts +33 -0
- package/dist/plugins-index.mjs +40 -0
- package/dist/resolve-tsconfig-DThkUPSZ.js +112 -0
- package/dist/rolldown-binding.wasi-browser.js +46 -24
- package/dist/rolldown-binding.wasi.cjs +67 -24
- package/dist/rolldown-binding.wasm32-wasi.wasm +0 -0
- package/dist/rolldown-build-Chx5S-TB.js +5349 -0
- package/dist/shared/bindingify-input-options-Czbczr8Z.mjs +2168 -0
- package/dist/shared/composable-filters-B2ByPP8y.mjs +224 -0
- package/dist/shared/constructors-BVnf_fH1.d.mts +37 -0
- package/dist/shared/constructors-CemeNi29.mjs +68 -0
- package/dist/shared/define-config-DJOr6Iwt.mjs +6 -0
- package/dist/shared/define-config-i6TWE2hm.d.mts +3855 -0
- package/dist/shared/error-CQ6njWsV.mjs +86 -0
- package/dist/shared/get-log-filter-semyr3Lj.d.mts +35 -0
- package/dist/shared/{load-config-D7UduHRZ.mjs → load-config-CxvL5JxT.mjs} +32 -36
- package/dist/shared/logging-C6h4g8dA.d.mts +50 -0
- package/dist/shared/{parse-ast-index-vu376yZ1.mjs → logs-D80CXhvg.mjs} +25 -123
- package/dist/shared/normalize-string-or-regex-CF3Uz6aU.mjs +57 -0
- package/dist/shared/parse-CRhjbrcT.mjs +73 -0
- package/dist/shared/{prompt-CxjDC0Gn.cjs → prompt-BYQIwEjg.mjs} +301 -310
- package/dist/shared/resolve-tsconfig-Cwoo4h_o.mjs +112 -0
- package/dist/shared/rolldown-C3wFxOwq.mjs +40 -0
- package/dist/shared/rolldown-build-ChZOz6BP.mjs +3318 -0
- package/dist/shared/transform-DEgNAQOQ.d.mts +149 -0
- package/dist/shared/types-Cx3HYorz.d.mts +1302 -0
- package/dist/shared/utils-6wxe_LMG.d.mts +22 -0
- package/dist/shared/watch-C1jC1oFT.mjs +373 -0
- package/dist/utils-index.browser.mjs +2414 -0
- package/dist/utils-index.d.mts +374 -0
- package/dist/utils-index.mjs +2415 -0
- package/package.json +33 -38
- package/dist/cli.cjs +0 -1748
- package/dist/cli.d.cts +0 -1
- package/dist/config.cjs +0 -12
- package/dist/config.d.cts +0 -11
- package/dist/experimental-index.cjs +0 -129
- package/dist/experimental-index.d.cts +0 -96
- package/dist/filter-index.cjs +0 -53
- package/dist/filter-index.d.cts +0 -3
- package/dist/index.cjs +0 -9
- package/dist/index.d.cts +0 -3
- package/dist/parallel-plugin-worker.cjs +0 -33
- package/dist/parallel-plugin-worker.d.cts +0 -1
- package/dist/parallel-plugin.cjs +0 -8
- package/dist/parallel-plugin.d.cts +0 -14
- package/dist/parse-ast-index.cjs +0 -4
- package/dist/parse-ast-index.d.cts +0 -9
- package/dist/shared/chunk-DDkG_k5U.cjs +0 -39
- package/dist/shared/chunk-DSsiIF1Z.mjs +0 -30
- package/dist/shared/define-config.d-D4lKXE9V.d.cts +0 -1165
- package/dist/shared/define-config.d-Dm9iNdt9.d.mts +0 -1165
- package/dist/shared/dist-BMVjvV-v.cjs +0 -249
- package/dist/shared/dist-CAn6dxW6.mjs +0 -153
- package/dist/shared/load-config-CtKjQ8Mn.cjs +0 -125
- package/dist/shared/prompt-GFYxfPw7.mjs +0 -854
- package/dist/shared/src-D0nc44MQ.mjs +0 -4691
- package/dist/shared/src-s89s870G.cjs +0 -4647
- package/dist/src-CeWghjQt.js +0 -4329
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
const src_rolldown_binding_wasi_cjs = require_chunk.__toESM(require("../rolldown-binding.wasi.cjs"));
|
|
3
|
-
|
|
1
|
+
import { BindingCallableBuiltinPlugin } from "./rolldown-binding.wasi-browser.js";
|
|
4
2
|
//#region src/utils/code-frame.ts
|
|
5
3
|
function spaces(index) {
|
|
6
4
|
let result = "";
|
|
@@ -16,7 +14,7 @@ const ELLIPSIS = "...";
|
|
|
16
14
|
function getCodeFrame(source, line, column) {
|
|
17
15
|
let lines = source.split("\n");
|
|
18
16
|
if (line > lines.length) return "";
|
|
19
|
-
const maxLineLength = Math.max(tabsToSpaces(lines[line - 1].slice(0, column)).length + MIN_CHARACTERS_SHOWN_AFTER_LOCATION +
|
|
17
|
+
const maxLineLength = Math.max(tabsToSpaces(lines[line - 1].slice(0, column)).length + MIN_CHARACTERS_SHOWN_AFTER_LOCATION + 3, LINE_TRUNCATE_LENGTH);
|
|
20
18
|
const frameStart = Math.max(0, line - 3);
|
|
21
19
|
let frameEnd = Math.min(line + 2, lines.length);
|
|
22
20
|
lines = lines.slice(frameStart, frameEnd);
|
|
@@ -30,7 +28,7 @@ function getCodeFrame(source, line, column) {
|
|
|
30
28
|
let lineNumber = String(index + frameStart + 1);
|
|
31
29
|
while (lineNumber.length < digits) lineNumber = ` ${lineNumber}`;
|
|
32
30
|
let displayedLine = tabsToSpaces(sourceLine);
|
|
33
|
-
if (displayedLine.length > maxLineLength) displayedLine = `${displayedLine.slice(0, maxLineLength -
|
|
31
|
+
if (displayedLine.length > maxLineLength) displayedLine = `${displayedLine.slice(0, maxLineLength - 3)}${ELLIPSIS}`;
|
|
34
32
|
if (isErrorLine) {
|
|
35
33
|
const indicator = spaces(digits + 2 + tabsToSpaces(sourceLine.slice(0, column)).length) + "^";
|
|
36
34
|
return `${lineNumber}: ${displayedLine}\n${indicator}`;
|
|
@@ -38,7 +36,6 @@ function getCodeFrame(source, line, column) {
|
|
|
38
36
|
return `${lineNumber}: ${displayedLine}`;
|
|
39
37
|
}).join("\n");
|
|
40
38
|
}
|
|
41
|
-
|
|
42
39
|
//#endregion
|
|
43
40
|
//#region src/log/locate-character/index.js
|
|
44
41
|
/** @typedef {import('./types').Location} Location */
|
|
@@ -56,13 +53,13 @@ function rangeContains(range, index) {
|
|
|
56
53
|
function getLocator(source, options = {}) {
|
|
57
54
|
const { offsetLine = 0, offsetColumn = 0 } = options;
|
|
58
55
|
let start = 0;
|
|
59
|
-
const ranges = source.split("\n").map((line, i
|
|
56
|
+
const ranges = source.split("\n").map((line, i) => {
|
|
60
57
|
const end = start + line.length + 1;
|
|
61
58
|
/** @type {import('./types').Range} */
|
|
62
59
|
const range = {
|
|
63
60
|
start,
|
|
64
61
|
end,
|
|
65
|
-
line: i
|
|
62
|
+
line: i
|
|
66
63
|
};
|
|
67
64
|
start = end;
|
|
68
65
|
return range;
|
|
@@ -99,14 +96,15 @@ function getLocator(source, options = {}) {
|
|
|
99
96
|
function locate(source, search, options) {
|
|
100
97
|
return getLocator(source, options)(search, options && options.startIndex);
|
|
101
98
|
}
|
|
102
|
-
|
|
103
99
|
//#endregion
|
|
104
100
|
//#region src/log/logs.ts
|
|
105
|
-
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",
|
|
106
|
-
function logParseError(message) {
|
|
101
|
+
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", MULTIPLE_WATCHER_OPTION = "MULTIPLE_WATCHER_OPTION", PARSE_ERROR = "PARSE_ERROR", NO_FS_IN_BROWSER = "NO_FS_IN_BROWSER";
|
|
102
|
+
function logParseError(message, id, pos) {
|
|
107
103
|
return {
|
|
108
104
|
code: PARSE_ERROR,
|
|
109
|
-
|
|
105
|
+
id,
|
|
106
|
+
message,
|
|
107
|
+
pos
|
|
110
108
|
};
|
|
111
109
|
}
|
|
112
110
|
function logInvalidLogPosition(pluginName) {
|
|
@@ -127,29 +125,35 @@ function logCycleLoading(pluginName, moduleId) {
|
|
|
127
125
|
message: `Found the module "${moduleId}" cycle loading at ${pluginName} plugin, it maybe blocking fetching modules.`
|
|
128
126
|
};
|
|
129
127
|
}
|
|
130
|
-
function
|
|
128
|
+
function logMultipleWatcherOption() {
|
|
131
129
|
return {
|
|
132
|
-
code:
|
|
133
|
-
message: `Found
|
|
130
|
+
code: MULTIPLE_WATCHER_OPTION,
|
|
131
|
+
message: `Found multiple watcher options at watch options, using first one to start watcher.`
|
|
134
132
|
};
|
|
135
133
|
}
|
|
136
|
-
function
|
|
134
|
+
function logNoFileSystemInBrowser(method) {
|
|
135
|
+
return {
|
|
136
|
+
code: NO_FS_IN_BROWSER,
|
|
137
|
+
message: `Cannot access the file system (via "${method}") when using the browser build of Rolldown.`
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
function logPluginError(error, plugin, { hook, id } = {}) {
|
|
137
141
|
try {
|
|
138
|
-
const code = error
|
|
139
|
-
if (!error
|
|
140
|
-
error
|
|
141
|
-
error
|
|
142
|
-
if (hook) error
|
|
143
|
-
if (id) error
|
|
142
|
+
const code = error.code;
|
|
143
|
+
if (!error.pluginCode && code != null && (typeof code !== "string" || !code.startsWith("PLUGIN_"))) error.pluginCode = code;
|
|
144
|
+
error.code = PLUGIN_ERROR;
|
|
145
|
+
error.plugin = plugin;
|
|
146
|
+
if (hook) error.hook = hook;
|
|
147
|
+
if (id) error.id = id;
|
|
144
148
|
} catch (_) {} finally {
|
|
145
|
-
return error
|
|
149
|
+
return error;
|
|
146
150
|
}
|
|
147
151
|
}
|
|
148
152
|
function error(base) {
|
|
149
153
|
if (!(base instanceof Error)) {
|
|
150
154
|
base = Object.assign(new Error(base.message), base);
|
|
151
155
|
Object.defineProperty(base, "name", {
|
|
152
|
-
value: "
|
|
156
|
+
value: "RolldownError",
|
|
153
157
|
writable: true
|
|
154
158
|
});
|
|
155
159
|
}
|
|
@@ -179,136 +183,59 @@ function augmentCodeLocation(properties, pos, source, id) {
|
|
|
179
183
|
properties.frame = getCodeFrame(source, line, column);
|
|
180
184
|
}
|
|
181
185
|
}
|
|
182
|
-
|
|
183
186
|
//#endregion
|
|
184
|
-
//#region
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
return
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
187
|
+
//#region src/builtin-plugin/utils.ts
|
|
188
|
+
var BuiltinPlugin = class {
|
|
189
|
+
/** Vite-specific option to control plugin ordering */
|
|
190
|
+
enforce;
|
|
191
|
+
constructor(name, _options) {
|
|
192
|
+
this.name = name;
|
|
193
|
+
this._options = _options;
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
function makeBuiltinPluginCallable(plugin) {
|
|
197
|
+
let callablePlugin = new BindingCallableBuiltinPlugin(bindingifyBuiltInPlugin(plugin));
|
|
198
|
+
const wrappedPlugin = plugin;
|
|
199
|
+
for (const key in callablePlugin) wrappedPlugin[key] = async function(...args) {
|
|
200
|
+
try {
|
|
201
|
+
return await callablePlugin[key](...args);
|
|
202
|
+
} catch (e) {
|
|
203
|
+
if (e instanceof Error && !e.stack?.includes("at ")) Error.captureStackTrace(e, wrappedPlugin[key]);
|
|
204
|
+
return error(logPluginError(e, plugin.name, {
|
|
205
|
+
hook: key,
|
|
206
|
+
id: key === "transform" ? args[2] : void 0
|
|
207
|
+
}));
|
|
203
208
|
}
|
|
204
209
|
};
|
|
210
|
+
return wrappedPlugin;
|
|
205
211
|
}
|
|
206
|
-
function
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
}
|
|
211
|
-
function applyFix(program, fixPath) {
|
|
212
|
-
let node = program;
|
|
213
|
-
for (const key of fixPath) node = node[key];
|
|
214
|
-
if (node.bigint) node.value = BigInt(node.bigint);
|
|
215
|
-
else try {
|
|
216
|
-
node.value = RegExp(node.regex.pattern, node.regex.flags);
|
|
217
|
-
} catch (_err) {}
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
//#endregion
|
|
221
|
-
//#region src/parse-ast-index.ts
|
|
222
|
-
function wrap(result, sourceText) {
|
|
223
|
-
result = wrap$1(result);
|
|
224
|
-
if (result.errors.length > 0) return normalizeParseError(sourceText, result.errors);
|
|
225
|
-
return result.program;
|
|
212
|
+
function bindingifyBuiltInPlugin(plugin) {
|
|
213
|
+
return {
|
|
214
|
+
__name: plugin.name,
|
|
215
|
+
options: plugin._options
|
|
216
|
+
};
|
|
226
217
|
}
|
|
227
|
-
function
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
218
|
+
function bindingifyManifestPlugin(plugin, pluginContextData) {
|
|
219
|
+
const { isOutputOptionsForLegacyChunks, ...options } = plugin._options;
|
|
220
|
+
return {
|
|
221
|
+
__name: plugin.name,
|
|
222
|
+
options: {
|
|
223
|
+
...options,
|
|
224
|
+
isLegacy: isOutputOptionsForLegacyChunks ? (opts) => {
|
|
225
|
+
return isOutputOptionsForLegacyChunks(pluginContextData.getOutputOptions(opts));
|
|
226
|
+
} : void 0
|
|
233
227
|
}
|
|
234
|
-
|
|
235
|
-
message += e.message + "\n" + e.labels.map((label) => {
|
|
236
|
-
const location = locate(sourceText, label.start, { offsetLine: 1 });
|
|
237
|
-
if (!location) return;
|
|
238
|
-
return getCodeFrame(sourceText, location.line, location.column);
|
|
239
|
-
}).filter(Boolean).join("\n");
|
|
240
|
-
}
|
|
241
|
-
return error(logParseError(message));
|
|
228
|
+
};
|
|
242
229
|
}
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
return
|
|
249
|
-
...defaultParserOptions,
|
|
250
|
-
...options
|
|
251
|
-
}), sourceText);
|
|
230
|
+
//#endregion
|
|
231
|
+
//#region src/utils/normalize-string-or-regex.ts
|
|
232
|
+
function normalizedStringOrRegex(pattern) {
|
|
233
|
+
if (!pattern) return;
|
|
234
|
+
if (!isReadonlyArray(pattern)) return [pattern];
|
|
235
|
+
return pattern;
|
|
252
236
|
}
|
|
253
|
-
|
|
254
|
-
return
|
|
255
|
-
...defaultParserOptions,
|
|
256
|
-
...options
|
|
257
|
-
}), sourceText);
|
|
237
|
+
function isReadonlyArray(input) {
|
|
238
|
+
return Array.isArray(input);
|
|
258
239
|
}
|
|
259
|
-
|
|
260
240
|
//#endregion
|
|
261
|
-
|
|
262
|
-
enumerable: true,
|
|
263
|
-
get: function () {
|
|
264
|
-
return augmentCodeLocation;
|
|
265
|
-
}
|
|
266
|
-
});
|
|
267
|
-
Object.defineProperty(exports, 'error', {
|
|
268
|
-
enumerable: true,
|
|
269
|
-
get: function () {
|
|
270
|
-
return error;
|
|
271
|
-
}
|
|
272
|
-
});
|
|
273
|
-
Object.defineProperty(exports, 'logCycleLoading', {
|
|
274
|
-
enumerable: true,
|
|
275
|
-
get: function () {
|
|
276
|
-
return logCycleLoading;
|
|
277
|
-
}
|
|
278
|
-
});
|
|
279
|
-
Object.defineProperty(exports, 'logInputHookInOutputPlugin', {
|
|
280
|
-
enumerable: true,
|
|
281
|
-
get: function () {
|
|
282
|
-
return logInputHookInOutputPlugin;
|
|
283
|
-
}
|
|
284
|
-
});
|
|
285
|
-
Object.defineProperty(exports, 'logInvalidLogPosition', {
|
|
286
|
-
enumerable: true,
|
|
287
|
-
get: function () {
|
|
288
|
-
return logInvalidLogPosition;
|
|
289
|
-
}
|
|
290
|
-
});
|
|
291
|
-
Object.defineProperty(exports, 'logMultiplyNotifyOption', {
|
|
292
|
-
enumerable: true,
|
|
293
|
-
get: function () {
|
|
294
|
-
return logMultiplyNotifyOption;
|
|
295
|
-
}
|
|
296
|
-
});
|
|
297
|
-
Object.defineProperty(exports, 'logPluginError', {
|
|
298
|
-
enumerable: true,
|
|
299
|
-
get: function () {
|
|
300
|
-
return logPluginError;
|
|
301
|
-
}
|
|
302
|
-
});
|
|
303
|
-
Object.defineProperty(exports, 'parseAst', {
|
|
304
|
-
enumerable: true,
|
|
305
|
-
get: function () {
|
|
306
|
-
return parseAst;
|
|
307
|
-
}
|
|
308
|
-
});
|
|
309
|
-
Object.defineProperty(exports, 'parseAstAsync', {
|
|
310
|
-
enumerable: true,
|
|
311
|
-
get: function () {
|
|
312
|
-
return parseAstAsync;
|
|
313
|
-
}
|
|
314
|
-
});
|
|
241
|
+
export { makeBuiltinPluginCallable as a, logCycleLoading as c, logMultipleWatcherOption as d, logNoFileSystemInBrowser as f, getCodeFrame as g, locate as h, bindingifyManifestPlugin as i, logInputHookInOutputPlugin as l, logPluginError as m, BuiltinPlugin as n, augmentCodeLocation as o, logParseError as p, bindingifyBuiltInPlugin as r, error as s, normalizedStringOrRegex as t, logInvalidLogPosition as u };
|
|
@@ -1,38 +1,30 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { PluginContextData,
|
|
3
|
-
import "./shared/
|
|
4
|
-
import "./shared/parse-
|
|
5
|
-
import { registerPlugins } from "./rolldown-binding.wasi.cjs";
|
|
1
|
+
import "./shared/normalize-string-or-regex-CF3Uz6aU.mjs";
|
|
2
|
+
import { n as PluginContextData, r as bindingifyPlugin } from "./shared/bindingify-input-options-Czbczr8Z.mjs";
|
|
3
|
+
import "./shared/error-CQ6njWsV.mjs";
|
|
4
|
+
import "./shared/parse-CRhjbrcT.mjs";
|
|
6
5
|
import { parentPort, workerData } from "node:worker_threads";
|
|
7
|
-
|
|
6
|
+
import { registerPlugins } from "./rolldown-binding.wasi.cjs";
|
|
8
7
|
//#region src/parallel-plugin-worker.ts
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
});
|
|
31
|
-
} finally {
|
|
32
|
-
parentPort.unref();
|
|
33
|
-
}
|
|
34
|
-
})();
|
|
35
|
-
} });
|
|
36
|
-
|
|
8
|
+
const { registryId, pluginInfos, threadNumber } = workerData;
|
|
9
|
+
(async () => {
|
|
10
|
+
try {
|
|
11
|
+
registerPlugins(registryId, await Promise.all(pluginInfos.map(async (pluginInfo) => {
|
|
12
|
+
const definePluginImpl = (await import(pluginInfo.fileUrl)).default;
|
|
13
|
+
const plugin = await definePluginImpl(pluginInfo.options, { threadNumber });
|
|
14
|
+
return {
|
|
15
|
+
index: pluginInfo.index,
|
|
16
|
+
plugin: bindingifyPlugin(plugin, {}, {}, new PluginContextData(() => {}, {}, [], []), [], () => {}, "info", false)
|
|
17
|
+
};
|
|
18
|
+
})));
|
|
19
|
+
parentPort.postMessage({ type: "success" });
|
|
20
|
+
} catch (error) {
|
|
21
|
+
parentPort.postMessage({
|
|
22
|
+
type: "error",
|
|
23
|
+
error
|
|
24
|
+
});
|
|
25
|
+
} finally {
|
|
26
|
+
parentPort.unref();
|
|
27
|
+
}
|
|
28
|
+
})();
|
|
37
29
|
//#endregion
|
|
38
|
-
export
|
|
30
|
+
export {};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { w as Plugin } from "./shared/define-config-i6TWE2hm.mjs";
|
|
2
|
+
import { i as MaybePromise } from "./shared/utils-6wxe_LMG.mjs";
|
|
2
3
|
|
|
3
4
|
//#region src/plugin/parallel-plugin-implementation.d.ts
|
|
4
5
|
type ParallelPluginImplementation = Plugin;
|
|
5
6
|
type Context = {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Thread number
|
|
9
|
+
*/
|
|
10
|
+
threadNumber: number;
|
|
10
11
|
};
|
|
11
12
|
declare function defineParallelPluginImplementation<Options>(plugin: (Options: Options, context: Context) => MaybePromise<ParallelPluginImplementation>): (Options: Options, context: Context) => MaybePromise<ParallelPluginImplementation>;
|
|
12
|
-
|
|
13
13
|
//#endregion
|
|
14
|
-
export { Context, ParallelPluginImplementation, defineParallelPluginImplementation };
|
|
14
|
+
export { type Context, type ParallelPluginImplementation, defineParallelPluginImplementation };
|
package/dist/parallel-plugin.mjs
CHANGED
|
@@ -1,9 +1,32 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Dt as Program } from "./shared/types-Cx3HYorz.mjs";
|
|
2
|
+
import { ParseResult as ParseResult$1, ParserOptions as ParserOptions$1 } from "./binding.cjs";
|
|
3
3
|
|
|
4
4
|
//#region src/parse-ast-index.d.ts
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
/**
|
|
6
|
+
* @hidden
|
|
7
|
+
*/
|
|
8
|
+
type ParseResult = ParseResult$1;
|
|
9
|
+
/**
|
|
10
|
+
* @hidden
|
|
11
|
+
*/
|
|
12
|
+
type ParserOptions = ParserOptions$1;
|
|
13
|
+
/**
|
|
14
|
+
* Parse code synchronously and return the AST.
|
|
15
|
+
*
|
|
16
|
+
* This function is similar to Rollup's `parseAst` function.
|
|
17
|
+
* Prefer using {@linkcode parseSync} instead of this function as it has more information in the return value.
|
|
18
|
+
*
|
|
19
|
+
* @category Utilities
|
|
20
|
+
*/
|
|
21
|
+
declare function parseAst(sourceText: string, options?: ParserOptions | null, filename?: string): Program;
|
|
22
|
+
/**
|
|
23
|
+
* Parse code asynchronously and return the AST.
|
|
24
|
+
*
|
|
25
|
+
* This function is similar to Rollup's `parseAstAsync` function.
|
|
26
|
+
* Prefer using {@linkcode parseAsync} instead of this function as it has more information in the return value.
|
|
27
|
+
*
|
|
28
|
+
* @category Utilities
|
|
29
|
+
*/
|
|
30
|
+
declare function parseAstAsync(sourceText: string, options?: ParserOptions | null, filename?: string): Promise<Program>;
|
|
8
31
|
//#endregion
|
|
9
32
|
export { ParseResult, ParserOptions, parseAst, parseAstAsync };
|
package/dist/parse-ast-index.mjs
CHANGED
|
@@ -1,4 +1,60 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { l as locate, n as error, s as logParseError, t as augmentCodeLocation, u as getCodeFrame } from "./shared/logs-D80CXhvg.mjs";
|
|
2
|
+
import { n as parseSync, t as parse } from "./shared/parse-CRhjbrcT.mjs";
|
|
3
|
+
//#region src/parse-ast-index.ts
|
|
4
|
+
function wrap(result, filename, sourceText) {
|
|
5
|
+
if (result.errors.length > 0) return normalizeParseError(filename, sourceText, result.errors);
|
|
6
|
+
return result.program;
|
|
7
|
+
}
|
|
8
|
+
function normalizeParseError(filename, sourceText, errors) {
|
|
9
|
+
let message = `Parse failed with ${errors.length} error${errors.length < 2 ? "" : "s"}:\n`;
|
|
10
|
+
const pos = errors[0]?.labels?.[0]?.start;
|
|
11
|
+
for (let i = 0; i < errors.length; i++) {
|
|
12
|
+
if (i >= 5) {
|
|
13
|
+
message += "\n...";
|
|
14
|
+
break;
|
|
15
|
+
}
|
|
16
|
+
const e = errors[i];
|
|
17
|
+
message += e.message + "\n" + e.labels.map((label) => {
|
|
18
|
+
const location = locate(sourceText, label.start, { offsetLine: 1 });
|
|
19
|
+
if (!location) return;
|
|
20
|
+
return getCodeFrame(sourceText, location.line, location.column);
|
|
21
|
+
}).filter(Boolean).join("\n");
|
|
22
|
+
}
|
|
23
|
+
const log = logParseError(message, filename, pos);
|
|
24
|
+
if (pos !== void 0 && filename) augmentCodeLocation(log, pos, sourceText, filename);
|
|
25
|
+
return error(log);
|
|
26
|
+
}
|
|
27
|
+
const defaultParserOptions = {
|
|
28
|
+
lang: "js",
|
|
29
|
+
preserveParens: false
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Parse code synchronously and return the AST.
|
|
33
|
+
*
|
|
34
|
+
* This function is similar to Rollup's `parseAst` function.
|
|
35
|
+
* Prefer using {@linkcode parseSync} instead of this function as it has more information in the return value.
|
|
36
|
+
*
|
|
37
|
+
* @category Utilities
|
|
38
|
+
*/
|
|
39
|
+
function parseAst(sourceText, options, filename) {
|
|
40
|
+
return wrap(parseSync(filename ?? "file.js", sourceText, {
|
|
41
|
+
...defaultParserOptions,
|
|
42
|
+
...options
|
|
43
|
+
}), filename, sourceText);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Parse code asynchronously and return the AST.
|
|
47
|
+
*
|
|
48
|
+
* This function is similar to Rollup's `parseAstAsync` function.
|
|
49
|
+
* Prefer using {@linkcode parseAsync} instead of this function as it has more information in the return value.
|
|
50
|
+
*
|
|
51
|
+
* @category Utilities
|
|
52
|
+
*/
|
|
53
|
+
async function parseAstAsync(sourceText, options, filename) {
|
|
54
|
+
return wrap(await parse(filename ?? "file.js", sourceText, {
|
|
55
|
+
...defaultParserOptions,
|
|
56
|
+
...options
|
|
57
|
+
}), filename, sourceText);
|
|
58
|
+
}
|
|
59
|
+
//#endregion
|
|
60
|
+
export { parseAst, parseAstAsync };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { a as makeBuiltinPluginCallable, n as BuiltinPlugin } from "./normalize-string-or-regex-TtAGUp42.js";
|
|
2
|
+
import { t as esmExternalRequirePlugin } from "./constructors-DsfxKD6A.js";
|
|
3
|
+
//#region src/builtin-plugin/replace-plugin.ts
|
|
4
|
+
/**
|
|
5
|
+
* Replaces targeted strings in files while bundling.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* **Basic usage**
|
|
9
|
+
* ```js
|
|
10
|
+
* replacePlugin({
|
|
11
|
+
* 'process.env.NODE_ENV': JSON.stringify('production'),
|
|
12
|
+
* __buildVersion: 15
|
|
13
|
+
* })
|
|
14
|
+
* ```
|
|
15
|
+
* @example
|
|
16
|
+
* **With options**
|
|
17
|
+
* ```js
|
|
18
|
+
* replacePlugin({
|
|
19
|
+
* 'process.env.NODE_ENV': JSON.stringify('production'),
|
|
20
|
+
* __buildVersion: 15
|
|
21
|
+
* }, {
|
|
22
|
+
* preventAssignment: false,
|
|
23
|
+
* })
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @see https://rolldown.rs/builtin-plugins/replace
|
|
27
|
+
* @category Builtin Plugins
|
|
28
|
+
*/
|
|
29
|
+
function replacePlugin(values = {}, options = {}) {
|
|
30
|
+
Object.keys(values).forEach((key) => {
|
|
31
|
+
const value = values[key];
|
|
32
|
+
if (typeof value !== "string") values[key] = String(value);
|
|
33
|
+
});
|
|
34
|
+
return makeBuiltinPluginCallable(new BuiltinPlugin("builtin:replace", {
|
|
35
|
+
...options,
|
|
36
|
+
values
|
|
37
|
+
}));
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
export { esmExternalRequirePlugin, replacePlugin };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { t as BuiltinPlugin } from "./shared/utils-6wxe_LMG.mjs";
|
|
2
|
+
import { t as esmExternalRequirePlugin } from "./shared/constructors-BVnf_fH1.mjs";
|
|
3
|
+
import { BindingReplacePluginConfig } from "../binding.cjs";
|
|
4
|
+
|
|
5
|
+
//#region src/builtin-plugin/replace-plugin.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Replaces targeted strings in files while bundling.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* **Basic usage**
|
|
11
|
+
* ```js
|
|
12
|
+
* replacePlugin({
|
|
13
|
+
* 'process.env.NODE_ENV': JSON.stringify('production'),
|
|
14
|
+
* __buildVersion: 15
|
|
15
|
+
* })
|
|
16
|
+
* ```
|
|
17
|
+
* @example
|
|
18
|
+
* **With options**
|
|
19
|
+
* ```js
|
|
20
|
+
* replacePlugin({
|
|
21
|
+
* 'process.env.NODE_ENV': JSON.stringify('production'),
|
|
22
|
+
* __buildVersion: 15
|
|
23
|
+
* }, {
|
|
24
|
+
* preventAssignment: false,
|
|
25
|
+
* })
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* @see https://rolldown.rs/builtin-plugins/replace
|
|
29
|
+
* @category Builtin Plugins
|
|
30
|
+
*/
|
|
31
|
+
declare function replacePlugin(values?: BindingReplacePluginConfig["values"], options?: Omit<BindingReplacePluginConfig, "values">): BuiltinPlugin;
|
|
32
|
+
//#endregion
|
|
33
|
+
export { esmExternalRequirePlugin, replacePlugin };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { a as makeBuiltinPluginCallable, n as BuiltinPlugin } from "./shared/normalize-string-or-regex-CF3Uz6aU.mjs";
|
|
2
|
+
import { t as esmExternalRequirePlugin } from "./shared/constructors-CemeNi29.mjs";
|
|
3
|
+
//#region src/builtin-plugin/replace-plugin.ts
|
|
4
|
+
/**
|
|
5
|
+
* Replaces targeted strings in files while bundling.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* **Basic usage**
|
|
9
|
+
* ```js
|
|
10
|
+
* replacePlugin({
|
|
11
|
+
* 'process.env.NODE_ENV': JSON.stringify('production'),
|
|
12
|
+
* __buildVersion: 15
|
|
13
|
+
* })
|
|
14
|
+
* ```
|
|
15
|
+
* @example
|
|
16
|
+
* **With options**
|
|
17
|
+
* ```js
|
|
18
|
+
* replacePlugin({
|
|
19
|
+
* 'process.env.NODE_ENV': JSON.stringify('production'),
|
|
20
|
+
* __buildVersion: 15
|
|
21
|
+
* }, {
|
|
22
|
+
* preventAssignment: false,
|
|
23
|
+
* })
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @see https://rolldown.rs/builtin-plugins/replace
|
|
27
|
+
* @category Builtin Plugins
|
|
28
|
+
*/
|
|
29
|
+
function replacePlugin(values = {}, options = {}) {
|
|
30
|
+
Object.keys(values).forEach((key) => {
|
|
31
|
+
const value = values[key];
|
|
32
|
+
if (typeof value !== "string") values[key] = String(value);
|
|
33
|
+
});
|
|
34
|
+
return makeBuiltinPluginCallable(new BuiltinPlugin("builtin:replace", {
|
|
35
|
+
...options,
|
|
36
|
+
values
|
|
37
|
+
}));
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
export { esmExternalRequirePlugin, replacePlugin };
|