@rolldown/browser 1.0.0-beta.58 → 1.0.0-beta.60
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 +32 -32
- package/dist/config.d.mts +1 -1
- package/dist/config.mjs +7 -7
- package/dist/{constructors-BuqTjXTF.js → constructors-CPMzz58l.js} +2 -8
- package/dist/experimental-index.browser.mjs +18 -37
- package/dist/experimental-index.d.mts +17 -63
- package/dist/experimental-index.mjs +20 -39
- package/dist/experimental-runtime-types.d.ts +6 -2
- package/dist/filter-index.d.mts +1 -1
- package/dist/filter-index.mjs +1 -2
- package/dist/get-log-filter.d.mts +1 -1
- package/dist/index.browser.mjs +6 -6
- package/dist/index.d.mts +5 -5
- package/dist/index.mjs +11 -11
- package/dist/normalize-string-or-regex-DcX5TPjK.js +247 -0
- package/dist/parallel-plugin-worker.mjs +3 -3
- package/dist/parallel-plugin.d.mts +2 -2
- package/dist/parse-ast-index.d.mts +1 -1
- package/dist/parse-ast-index.mjs +1 -1
- package/dist/plugins-index.browser.mjs +2 -2
- package/dist/plugins-index.d.mts +3 -3
- package/dist/plugins-index.mjs +2 -2
- package/dist/rolldown-binding.wasi-browser.js +0 -1
- package/dist/rolldown-binding.wasi.cjs +0 -1
- package/dist/rolldown-binding.wasm32-wasi.wasm +0 -0
- package/dist/{rolldown-build-CRqas5jO.js → rolldown-build-Zb6e1FlF.js} +661 -80
- package/dist/shared/{binding-MAEzB4KA.d.mts → binding-CAB1xlCZ.d.mts} +58 -134
- package/dist/shared/{bindingify-input-options--qcSYuhh.mjs → bindingify-input-options-C4xVxTKf.mjs} +602 -51
- package/dist/shared/{composable-filters-C5qA4jo-.mjs → composable-filters-DmVadxLf.mjs} +41 -20
- package/dist/shared/{constructors-CQP6o3cR.d.mts → constructors-D_KDVVwY.d.mts} +3 -5
- package/dist/shared/{constructors-kOch67Sb.mjs → constructors-KqJrL3Ok.mjs} +2 -8
- package/dist/shared/{define-config-yInAJbA1.d.mts → define-config-CUEbSpq4.d.mts} +967 -408
- package/dist/shared/{load-config-BZhApFJg.mjs → load-config-DN8SQL2o.mjs} +1 -1
- package/dist/shared/{logging-B4x9qar8.d.mts → logging-DGAQcdLz.d.mts} +4 -0
- package/dist/shared/{logs-DEfpOy5A.mjs → logs-cXucB9vK.mjs} +8 -8
- package/dist/shared/normalize-string-or-regex-Bn5eoSii.mjs +60 -0
- package/dist/shared/{parse-ast-index-CgzK6cxG.mjs → parse-ast-index-B54CTqgh.mjs} +2 -2
- package/dist/shared/{prompt-CNt8OM9C.mjs → prompt-D80rO-gq.mjs} +220 -220
- package/dist/shared/{rolldown-Vl5SnJ_J.mjs → rolldown-BhEWsQWt.mjs} +1 -1
- package/dist/shared/{rolldown-build-7kWB1jqY.mjs → rolldown-build-PEQvqPGC.mjs} +48 -36
- package/dist/shared/{utils-BGxZdOXA.d.mts → utils-0UHbNgk4.d.mts} +2 -11
- package/dist/shared/{watch-CGYro6go.mjs → watch-avpeg13R.mjs} +11 -12
- package/package.json +1 -1
- package/dist/normalize-string-or-regex-3ql5-z8-.js +0 -872
- package/dist/shared/misc-BubmxcE3.mjs +0 -22
- package/dist/shared/normalize-string-or-regex-CIiT1lMg.mjs +0 -669
- /package/dist/shared/{define-config-BF4P-Pum.mjs → define-config-DrUTwApf.mjs} +0 -0
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import { BindingCallableBuiltinPlugin } from "./rolldown-binding.wasi-browser.js";
|
|
2
|
+
|
|
3
|
+
//#region src/utils/code-frame.ts
|
|
4
|
+
function spaces(index) {
|
|
5
|
+
let result = "";
|
|
6
|
+
while (index--) result += " ";
|
|
7
|
+
return result;
|
|
8
|
+
}
|
|
9
|
+
function tabsToSpaces(value) {
|
|
10
|
+
return value.replace(/^\t+/, (match) => match.split(" ").join(" "));
|
|
11
|
+
}
|
|
12
|
+
const LINE_TRUNCATE_LENGTH = 120;
|
|
13
|
+
const MIN_CHARACTERS_SHOWN_AFTER_LOCATION = 10;
|
|
14
|
+
const ELLIPSIS = "...";
|
|
15
|
+
function getCodeFrame(source, line, column) {
|
|
16
|
+
let lines = source.split("\n");
|
|
17
|
+
if (line > lines.length) return "";
|
|
18
|
+
const maxLineLength = Math.max(tabsToSpaces(lines[line - 1].slice(0, column)).length + MIN_CHARACTERS_SHOWN_AFTER_LOCATION + 3, LINE_TRUNCATE_LENGTH);
|
|
19
|
+
const frameStart = Math.max(0, line - 3);
|
|
20
|
+
let frameEnd = Math.min(line + 2, lines.length);
|
|
21
|
+
lines = lines.slice(frameStart, frameEnd);
|
|
22
|
+
while (!/\S/.test(lines[lines.length - 1])) {
|
|
23
|
+
lines.pop();
|
|
24
|
+
frameEnd -= 1;
|
|
25
|
+
}
|
|
26
|
+
const digits = String(frameEnd).length;
|
|
27
|
+
return lines.map((sourceLine, index) => {
|
|
28
|
+
const isErrorLine = frameStart + index + 1 === line;
|
|
29
|
+
let lineNumber = String(index + frameStart + 1);
|
|
30
|
+
while (lineNumber.length < digits) lineNumber = ` ${lineNumber}`;
|
|
31
|
+
let displayedLine = tabsToSpaces(sourceLine);
|
|
32
|
+
if (displayedLine.length > maxLineLength) displayedLine = `${displayedLine.slice(0, maxLineLength - 3)}${ELLIPSIS}`;
|
|
33
|
+
if (isErrorLine) {
|
|
34
|
+
const indicator = spaces(digits + 2 + tabsToSpaces(sourceLine.slice(0, column)).length) + "^";
|
|
35
|
+
return `${lineNumber}: ${displayedLine}\n${indicator}`;
|
|
36
|
+
}
|
|
37
|
+
return `${lineNumber}: ${displayedLine}`;
|
|
38
|
+
}).join("\n");
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region src/log/locate-character/index.js
|
|
43
|
+
/** @typedef {import('./types').Location} Location */
|
|
44
|
+
/**
|
|
45
|
+
* @param {import('./types').Range} range
|
|
46
|
+
* @param {number} index
|
|
47
|
+
*/
|
|
48
|
+
function rangeContains(range, index) {
|
|
49
|
+
return range.start <= index && index < range.end;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* @param {string} source
|
|
53
|
+
* @param {import('./types').Options} [options]
|
|
54
|
+
*/
|
|
55
|
+
function getLocator(source, options = {}) {
|
|
56
|
+
const { offsetLine = 0, offsetColumn = 0 } = options;
|
|
57
|
+
let start = 0;
|
|
58
|
+
const ranges = source.split("\n").map((line, i$1) => {
|
|
59
|
+
const end = start + line.length + 1;
|
|
60
|
+
/** @type {import('./types').Range} */
|
|
61
|
+
const range = {
|
|
62
|
+
start,
|
|
63
|
+
end,
|
|
64
|
+
line: i$1
|
|
65
|
+
};
|
|
66
|
+
start = end;
|
|
67
|
+
return range;
|
|
68
|
+
});
|
|
69
|
+
let i = 0;
|
|
70
|
+
/**
|
|
71
|
+
* @param {string | number} search
|
|
72
|
+
* @param {number} [index]
|
|
73
|
+
* @returns {Location | undefined}
|
|
74
|
+
*/
|
|
75
|
+
function locator(search, index) {
|
|
76
|
+
if (typeof search === "string") search = source.indexOf(search, index ?? 0);
|
|
77
|
+
if (search === -1) return void 0;
|
|
78
|
+
let range = ranges[i];
|
|
79
|
+
const d = search >= range.end ? 1 : -1;
|
|
80
|
+
while (range) {
|
|
81
|
+
if (rangeContains(range, search)) return {
|
|
82
|
+
line: offsetLine + range.line,
|
|
83
|
+
column: offsetColumn + search - range.start,
|
|
84
|
+
character: search
|
|
85
|
+
};
|
|
86
|
+
i += d;
|
|
87
|
+
range = ranges[i];
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return locator;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* @param {string} source
|
|
94
|
+
* @param {string | number} search
|
|
95
|
+
* @param {import('./types').Options} [options]
|
|
96
|
+
* @returns {Location | undefined}
|
|
97
|
+
*/
|
|
98
|
+
function locate(source, search, options) {
|
|
99
|
+
return getLocator(source, options)(search, options && options.startIndex);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
//#endregion
|
|
103
|
+
//#region src/log/logs.ts
|
|
104
|
+
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";
|
|
105
|
+
function logParseError(message, id, pos) {
|
|
106
|
+
return {
|
|
107
|
+
code: PARSE_ERROR,
|
|
108
|
+
id,
|
|
109
|
+
message,
|
|
110
|
+
pos
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
function logInvalidLogPosition(pluginName) {
|
|
114
|
+
return {
|
|
115
|
+
code: INVALID_LOG_POSITION,
|
|
116
|
+
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.`
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
function logInputHookInOutputPlugin(pluginName, hookName) {
|
|
120
|
+
return {
|
|
121
|
+
code: INPUT_HOOK_IN_OUTPUT_PLUGIN,
|
|
122
|
+
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.`
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
function logCycleLoading(pluginName, moduleId) {
|
|
126
|
+
return {
|
|
127
|
+
code: CYCLE_LOADING,
|
|
128
|
+
message: `Found the module "${moduleId}" cycle loading at ${pluginName} plugin, it maybe blocking fetching modules.`
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
function logMultiplyNotifyOption() {
|
|
132
|
+
return {
|
|
133
|
+
code: MULTIPLY_NOTIFY_OPTION,
|
|
134
|
+
message: `Found multiply notify option at watch options, using first one to start notify watcher.`
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
function logNoFileSystemInBrowser(method) {
|
|
138
|
+
return {
|
|
139
|
+
code: NO_FS_IN_BROWSER,
|
|
140
|
+
message: `Cannot access the file system (via "${method}") when using the browser build of Rolldown.`
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
function logPluginError(error, plugin, { hook, id } = {}) {
|
|
144
|
+
try {
|
|
145
|
+
const code = error.code;
|
|
146
|
+
if (!error.pluginCode && code != null && (typeof code !== "string" || !code.startsWith("PLUGIN_"))) error.pluginCode = code;
|
|
147
|
+
error.code = PLUGIN_ERROR;
|
|
148
|
+
error.plugin = plugin;
|
|
149
|
+
if (hook) error.hook = hook;
|
|
150
|
+
if (id) error.id = id;
|
|
151
|
+
} catch (_) {} finally {
|
|
152
|
+
return error;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
function error(base) {
|
|
156
|
+
if (!(base instanceof Error)) {
|
|
157
|
+
base = Object.assign(new Error(base.message), base);
|
|
158
|
+
Object.defineProperty(base, "name", {
|
|
159
|
+
value: "RollupError",
|
|
160
|
+
writable: true
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
throw base;
|
|
164
|
+
}
|
|
165
|
+
function augmentCodeLocation(properties, pos, source, id) {
|
|
166
|
+
if (typeof pos === "object") {
|
|
167
|
+
const { line, column } = pos;
|
|
168
|
+
properties.loc = {
|
|
169
|
+
column,
|
|
170
|
+
file: id,
|
|
171
|
+
line
|
|
172
|
+
};
|
|
173
|
+
} else {
|
|
174
|
+
properties.pos = pos;
|
|
175
|
+
const location = locate(source, pos, { offsetLine: 1 });
|
|
176
|
+
if (!location) return;
|
|
177
|
+
const { line, column } = location;
|
|
178
|
+
properties.loc = {
|
|
179
|
+
column,
|
|
180
|
+
file: id,
|
|
181
|
+
line
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
if (properties.frame === void 0) {
|
|
185
|
+
const { line, column } = properties.loc;
|
|
186
|
+
properties.frame = getCodeFrame(source, line, column);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
//#endregion
|
|
191
|
+
//#region src/builtin-plugin/utils.ts
|
|
192
|
+
var BuiltinPlugin = class {
|
|
193
|
+
/** Vite-specific option to control plugin ordering */
|
|
194
|
+
enforce;
|
|
195
|
+
constructor(name, _options) {
|
|
196
|
+
this.name = name;
|
|
197
|
+
this._options = _options;
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
function makeBuiltinPluginCallable(plugin) {
|
|
201
|
+
let callablePlugin = new BindingCallableBuiltinPlugin(bindingifyBuiltInPlugin(plugin));
|
|
202
|
+
const wrappedPlugin = plugin;
|
|
203
|
+
for (const key in callablePlugin) wrappedPlugin[key] = async function(...args) {
|
|
204
|
+
try {
|
|
205
|
+
return await callablePlugin[key](...args);
|
|
206
|
+
} catch (e) {
|
|
207
|
+
if (e instanceof Error && !e.stack?.includes("at ")) Error.captureStackTrace(e, wrappedPlugin[key]);
|
|
208
|
+
return error(logPluginError(e, plugin.name, {
|
|
209
|
+
hook: key,
|
|
210
|
+
id: key === "transform" ? args[2] : void 0
|
|
211
|
+
}));
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
return wrappedPlugin;
|
|
215
|
+
}
|
|
216
|
+
function bindingifyBuiltInPlugin(plugin) {
|
|
217
|
+
return {
|
|
218
|
+
__name: plugin.name,
|
|
219
|
+
options: plugin._options
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
function bindingifyManifestPlugin(plugin, pluginContextData) {
|
|
223
|
+
const { isOutputOptionsForLegacyChunks, ...options } = plugin._options;
|
|
224
|
+
return {
|
|
225
|
+
__name: plugin.name,
|
|
226
|
+
options: {
|
|
227
|
+
...options,
|
|
228
|
+
isLegacy: isOutputOptionsForLegacyChunks ? (opts) => {
|
|
229
|
+
return isOutputOptionsForLegacyChunks(pluginContextData.getOutputOptions(opts));
|
|
230
|
+
} : void 0
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
//#endregion
|
|
236
|
+
//#region src/utils/normalize-string-or-regex.ts
|
|
237
|
+
function normalizedStringOrRegex(pattern) {
|
|
238
|
+
if (!pattern) return;
|
|
239
|
+
if (!isReadonlyArray(pattern)) return [pattern];
|
|
240
|
+
return pattern;
|
|
241
|
+
}
|
|
242
|
+
function isReadonlyArray(input) {
|
|
243
|
+
return Array.isArray(input);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
//#endregion
|
|
247
|
+
export { makeBuiltinPluginCallable as a, logCycleLoading as c, logMultiplyNotifyOption 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,6 +1,6 @@
|
|
|
1
|
-
import "./shared/normalize-string-or-regex-
|
|
2
|
-
import { n as PluginContextData, r as bindingifyPlugin } from "./shared/bindingify-input-options
|
|
3
|
-
import "./shared/parse-ast-index-
|
|
1
|
+
import "./shared/normalize-string-or-regex-Bn5eoSii.mjs";
|
|
2
|
+
import { n as PluginContextData, r as bindingifyPlugin } from "./shared/bindingify-input-options-C4xVxTKf.mjs";
|
|
3
|
+
import "./shared/parse-ast-index-B54CTqgh.mjs";
|
|
4
4
|
import { parentPort, workerData } from "node:worker_threads";
|
|
5
5
|
import { registerPlugins } from "./rolldown-binding.wasi.cjs";
|
|
6
6
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { C as Plugin } from "./shared/define-config-CUEbSpq4.mjs";
|
|
2
|
+
import { i as MaybePromise } from "./shared/utils-0UHbNgk4.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/plugin/parallel-plugin-implementation.d.ts
|
|
5
5
|
type ParallelPluginImplementation = Plugin;
|
package/dist/parse-ast-index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as esmExternalRequirePlugin } from "./constructors-
|
|
1
|
+
import { a as makeBuiltinPluginCallable, n as BuiltinPlugin } from "./normalize-string-or-regex-DcX5TPjK.js";
|
|
2
|
+
import { t as esmExternalRequirePlugin } from "./constructors-CPMzz58l.js";
|
|
3
3
|
|
|
4
4
|
//#region src/builtin-plugin/replace-plugin.ts
|
|
5
5
|
/**
|
package/dist/plugins-index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { u as BindingReplacePluginConfig } from "./shared/binding-
|
|
2
|
-
import { t as BuiltinPlugin } from "./shared/utils-
|
|
3
|
-
import { t as esmExternalRequirePlugin } from "./shared/constructors-
|
|
1
|
+
import { u as BindingReplacePluginConfig } from "./shared/binding-CAB1xlCZ.mjs";
|
|
2
|
+
import { t as BuiltinPlugin } from "./shared/utils-0UHbNgk4.mjs";
|
|
3
|
+
import { t as esmExternalRequirePlugin } from "./shared/constructors-D_KDVVwY.mjs";
|
|
4
4
|
|
|
5
5
|
//#region src/builtin-plugin/replace-plugin.d.ts
|
|
6
6
|
|
package/dist/plugins-index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as esmExternalRequirePlugin } from "./shared/constructors-
|
|
1
|
+
import { a as makeBuiltinPluginCallable, n as BuiltinPlugin } from "./shared/normalize-string-or-regex-Bn5eoSii.mjs";
|
|
2
|
+
import { t as esmExternalRequirePlugin } from "./shared/constructors-KqJrL3Ok.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/builtin-plugin/replace-plugin.ts
|
|
5
5
|
/**
|
|
@@ -101,7 +101,6 @@ export const BindingRenderedChunk = __napiModule.exports.BindingRenderedChunk
|
|
|
101
101
|
export const BindingRenderedChunkMeta = __napiModule.exports.BindingRenderedChunkMeta
|
|
102
102
|
export const BindingRenderedModule = __napiModule.exports.BindingRenderedModule
|
|
103
103
|
export const BindingTransformPluginContext = __napiModule.exports.BindingTransformPluginContext
|
|
104
|
-
export const BindingUrlResolver = __napiModule.exports.BindingUrlResolver
|
|
105
104
|
export const BindingWatcher = __napiModule.exports.BindingWatcher
|
|
106
105
|
export const BindingWatcherBundler = __napiModule.exports.BindingWatcherBundler
|
|
107
106
|
export const BindingWatcherChangeData = __napiModule.exports.BindingWatcherChangeData
|
|
@@ -146,7 +146,6 @@ module.exports.BindingRenderedChunk = __napiModule.exports.BindingRenderedChunk
|
|
|
146
146
|
module.exports.BindingRenderedChunkMeta = __napiModule.exports.BindingRenderedChunkMeta
|
|
147
147
|
module.exports.BindingRenderedModule = __napiModule.exports.BindingRenderedModule
|
|
148
148
|
module.exports.BindingTransformPluginContext = __napiModule.exports.BindingTransformPluginContext
|
|
149
|
-
module.exports.BindingUrlResolver = __napiModule.exports.BindingUrlResolver
|
|
150
149
|
module.exports.BindingWatcher = __napiModule.exports.BindingWatcher
|
|
151
150
|
module.exports.BindingWatcherBundler = __napiModule.exports.BindingWatcherBundler
|
|
152
151
|
module.exports.BindingWatcherChangeData = __napiModule.exports.BindingWatcherChangeData
|
|
Binary file
|