@rolldown/browser 1.0.0-beta.59 → 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-c0HHH7Qq.js → constructors-CPMzz58l.js} +2 -8
- package/dist/experimental-index.browser.mjs +4 -37
- package/dist/experimental-index.d.mts +5 -63
- package/dist/experimental-index.mjs +6 -39
- 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-Bfw5c2c3.js → rolldown-build-Zb6e1FlF.js} +657 -78
- package/dist/shared/{binding-MAEzB4KA.d.mts → binding-CAB1xlCZ.d.mts} +58 -134
- package/dist/shared/{bindingify-input-options-BTd8uAdf.mjs → bindingify-input-options-C4xVxTKf.mjs} +600 -50
- 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-C8tBnLHP.mjs → constructors-KqJrL3Ok.mjs} +2 -8
- package/dist/shared/{define-config-CpZLzJD0.d.mts → define-config-CUEbSpq4.d.mts} +954 -408
- package/dist/shared/{load-config-cKGxDu4K.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-BLdgtc2B.mjs → parse-ast-index-B54CTqgh.mjs} +2 -2
- package/dist/shared/{prompt-CNt8OM9C.mjs → prompt-D80rO-gq.mjs} +220 -220
- package/dist/shared/{rolldown-8m9pjMU2.mjs → rolldown-BhEWsQWt.mjs} +1 -1
- package/dist/shared/{rolldown-build-DKF_S8hw.mjs → rolldown-build-PEQvqPGC.mjs} +46 -35
- package/dist/shared/{utils-BGxZdOXA.d.mts → utils-0UHbNgk4.d.mts} +2 -11
- package/dist/shared/{watch-BEzOq0zm.mjs → watch-avpeg13R.mjs} +11 -12
- package/package.json +1 -1
- package/dist/normalize-string-or-regex-BB1FWNyl.js +0 -872
- package/dist/shared/misc-BubmxcE3.mjs +0 -22
- package/dist/shared/normalize-string-or-regex-DJ5EwPtg.mjs +0 -669
- /package/dist/shared/{define-config-BF4P-Pum.mjs → define-config-DrUTwApf.mjs} +0 -0
|
@@ -1,872 +0,0 @@
|
|
|
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$1, plugin, { hook, id } = {}) {
|
|
144
|
-
try {
|
|
145
|
-
const code = error$1.code;
|
|
146
|
-
if (!error$1.pluginCode && code != null && (typeof code !== "string" || !code.startsWith("PLUGIN_"))) error$1.pluginCode = code;
|
|
147
|
-
error$1.code = PLUGIN_ERROR;
|
|
148
|
-
error$1.plugin = plugin;
|
|
149
|
-
if (hook) error$1.hook = hook;
|
|
150
|
-
if (id) error$1.id = id;
|
|
151
|
-
} catch (_) {} finally {
|
|
152
|
-
return error$1;
|
|
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/utils/misc.ts
|
|
192
|
-
function arraify(value) {
|
|
193
|
-
return Array.isArray(value) ? value : [value];
|
|
194
|
-
}
|
|
195
|
-
function unimplemented(info) {
|
|
196
|
-
if (info) throw new Error(`unimplemented: ${info}`);
|
|
197
|
-
throw new Error("unimplemented");
|
|
198
|
-
}
|
|
199
|
-
function unreachable(info) {
|
|
200
|
-
if (info) throw new Error(`unreachable: ${info}`);
|
|
201
|
-
throw new Error("unreachable");
|
|
202
|
-
}
|
|
203
|
-
function unsupported(info) {
|
|
204
|
-
throw new Error(`UNSUPPORTED: ${info}`);
|
|
205
|
-
}
|
|
206
|
-
function noop(..._args) {}
|
|
207
|
-
|
|
208
|
-
//#endregion
|
|
209
|
-
//#region src/log/logging.ts
|
|
210
|
-
const LOG_LEVEL_SILENT = "silent";
|
|
211
|
-
const LOG_LEVEL_ERROR = "error";
|
|
212
|
-
const LOG_LEVEL_WARN = "warn";
|
|
213
|
-
const LOG_LEVEL_INFO = "info";
|
|
214
|
-
const LOG_LEVEL_DEBUG = "debug";
|
|
215
|
-
const logLevelPriority = {
|
|
216
|
-
[LOG_LEVEL_DEBUG]: 0,
|
|
217
|
-
[LOG_LEVEL_INFO]: 1,
|
|
218
|
-
[LOG_LEVEL_WARN]: 2,
|
|
219
|
-
[LOG_LEVEL_SILENT]: 3
|
|
220
|
-
};
|
|
221
|
-
|
|
222
|
-
//#endregion
|
|
223
|
-
//#region src/log/log-handler.ts
|
|
224
|
-
const normalizeLog = (log) => typeof log === "string" ? { message: log } : typeof log === "function" ? normalizeLog(log()) : log;
|
|
225
|
-
function getLogHandler(level, code, logger, pluginName, logLevel) {
|
|
226
|
-
if (logLevelPriority[level] < logLevelPriority[logLevel]) return noop;
|
|
227
|
-
return (log, pos) => {
|
|
228
|
-
if (pos != null) logger(LOG_LEVEL_WARN, logInvalidLogPosition(pluginName));
|
|
229
|
-
log = normalizeLog(log);
|
|
230
|
-
if (log.code && !log.pluginCode) log.pluginCode = log.code;
|
|
231
|
-
log.code = code;
|
|
232
|
-
log.plugin = pluginName;
|
|
233
|
-
logger(level, log);
|
|
234
|
-
};
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
//#endregion
|
|
238
|
-
//#region package.json
|
|
239
|
-
var version = "1.0.0-beta.59";
|
|
240
|
-
|
|
241
|
-
//#endregion
|
|
242
|
-
//#region src/version.ts
|
|
243
|
-
/** @category Plugin APIs */
|
|
244
|
-
const VERSION = version;
|
|
245
|
-
|
|
246
|
-
//#endregion
|
|
247
|
-
//#region src/plugin/minimal-plugin-context.ts
|
|
248
|
-
var MinimalPluginContextImpl = class {
|
|
249
|
-
info;
|
|
250
|
-
warn;
|
|
251
|
-
debug;
|
|
252
|
-
meta;
|
|
253
|
-
constructor(onLog, logLevel, pluginName, watchMode, hookName) {
|
|
254
|
-
this.pluginName = pluginName;
|
|
255
|
-
this.hookName = hookName;
|
|
256
|
-
this.debug = getLogHandler(LOG_LEVEL_DEBUG, "PLUGIN_LOG", onLog, pluginName, logLevel);
|
|
257
|
-
this.info = getLogHandler(LOG_LEVEL_INFO, "PLUGIN_LOG", onLog, pluginName, logLevel);
|
|
258
|
-
this.warn = getLogHandler(LOG_LEVEL_WARN, "PLUGIN_WARNING", onLog, pluginName, logLevel);
|
|
259
|
-
this.meta = {
|
|
260
|
-
rollupVersion: "4.23.0",
|
|
261
|
-
rolldownVersion: VERSION,
|
|
262
|
-
watchMode
|
|
263
|
-
};
|
|
264
|
-
}
|
|
265
|
-
error(e) {
|
|
266
|
-
return error(logPluginError(normalizeLog(e), this.pluginName, { hook: this.hookName }));
|
|
267
|
-
}
|
|
268
|
-
};
|
|
269
|
-
|
|
270
|
-
//#endregion
|
|
271
|
-
//#region src/types/plain-object-like.ts
|
|
272
|
-
const LAZY_FIELDS_KEY = Symbol("__lazy_fields__");
|
|
273
|
-
/**
|
|
274
|
-
* Base class for classes that use `@lazyProp` decorated properties.
|
|
275
|
-
*
|
|
276
|
-
* **Design Pattern in Rolldown:**
|
|
277
|
-
* This is a common pattern in Rolldown due to its three-layer architecture:
|
|
278
|
-
* TypeScript API → NAPI Bindings → Rust Core
|
|
279
|
-
*
|
|
280
|
-
* **Why we use getters:**
|
|
281
|
-
* For performance - to lazily fetch data from Rust bindings only when needed,
|
|
282
|
-
* rather than eagerly fetching all data during object construction.
|
|
283
|
-
*
|
|
284
|
-
* **The problem:**
|
|
285
|
-
* Getters defined on class prototypes are non-enumerable by default, which breaks:
|
|
286
|
-
* - Object spread operators ({...obj})
|
|
287
|
-
* - Object.keys() and similar methods
|
|
288
|
-
* - Standard JavaScript object semantics
|
|
289
|
-
*
|
|
290
|
-
* **The solution:**
|
|
291
|
-
* This base class automatically converts `@lazyProp` decorated getters into
|
|
292
|
-
* own enumerable getters on each instance during construction.
|
|
293
|
-
*
|
|
294
|
-
* **Result:**
|
|
295
|
-
* Objects get both lazy-loading performance benefits AND plain JavaScript object behavior.
|
|
296
|
-
*
|
|
297
|
-
* @example
|
|
298
|
-
* ```typescript
|
|
299
|
-
* class MyClass extends PlainObjectLike {
|
|
300
|
-
* @lazyProp
|
|
301
|
-
* get myProp() {
|
|
302
|
-
* return fetchFromRustBinding();
|
|
303
|
-
* }
|
|
304
|
-
* }
|
|
305
|
-
* ```
|
|
306
|
-
*/
|
|
307
|
-
var PlainObjectLike = class {
|
|
308
|
-
constructor() {
|
|
309
|
-
setupLazyProperties(this);
|
|
310
|
-
}
|
|
311
|
-
};
|
|
312
|
-
/**
|
|
313
|
-
* Set up lazy properties as own getters on an instance.
|
|
314
|
-
* This is called automatically by the `PlainObjectLike` base class constructor.
|
|
315
|
-
*
|
|
316
|
-
* @param instance - The instance to set up lazy properties on
|
|
317
|
-
* @internal
|
|
318
|
-
*/
|
|
319
|
-
function setupLazyProperties(instance) {
|
|
320
|
-
const lazyFields = instance.constructor[LAZY_FIELDS_KEY];
|
|
321
|
-
if (!lazyFields) return;
|
|
322
|
-
for (const [propertyKey, originalGetter] of lazyFields.entries()) {
|
|
323
|
-
let cachedValue;
|
|
324
|
-
let hasValue = false;
|
|
325
|
-
Object.defineProperty(instance, propertyKey, {
|
|
326
|
-
get() {
|
|
327
|
-
if (!hasValue) {
|
|
328
|
-
cachedValue = originalGetter.call(this);
|
|
329
|
-
hasValue = true;
|
|
330
|
-
}
|
|
331
|
-
return cachedValue;
|
|
332
|
-
},
|
|
333
|
-
enumerable: true,
|
|
334
|
-
configurable: true
|
|
335
|
-
});
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
/**
|
|
339
|
-
* Get all lazy field names from a class instance.
|
|
340
|
-
*
|
|
341
|
-
* @param instance - Instance to inspect
|
|
342
|
-
* @returns Set of lazy property names
|
|
343
|
-
*/
|
|
344
|
-
function getLazyFields(instance) {
|
|
345
|
-
const lazyFields = instance.constructor[LAZY_FIELDS_KEY];
|
|
346
|
-
return lazyFields ? new Set(lazyFields.keys()) : /* @__PURE__ */ new Set();
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
//#endregion
|
|
350
|
-
//#region src/decorators/lazy.ts
|
|
351
|
-
/**
|
|
352
|
-
* Decorator that marks a getter as lazy-evaluated and cached.
|
|
353
|
-
*
|
|
354
|
-
* **What "lazy" means here:**
|
|
355
|
-
* 1. Data is lazily fetched from Rust bindings only when the property is accessed (not eagerly on construction)
|
|
356
|
-
* 2. Once fetched, the data is cached for subsequent accesses (performance optimization)
|
|
357
|
-
* 3. Despite being a getter, it behaves like a plain object property (enumerable, appears in Object.keys())
|
|
358
|
-
*
|
|
359
|
-
* **Important**: Properties decorated with `@lazyProp` are defined as own enumerable
|
|
360
|
-
* properties on each instance (not on the prototype). This ensures they:
|
|
361
|
-
* - Appear in Object.keys() and Object.getOwnPropertyNames()
|
|
362
|
-
* - Are included in object spreads ({...obj})
|
|
363
|
-
* - Are enumerable in for...in loops
|
|
364
|
-
*
|
|
365
|
-
* Classes using this decorator must extend `PlainObjectLike` base class.
|
|
366
|
-
*
|
|
367
|
-
* @example
|
|
368
|
-
* ```typescript
|
|
369
|
-
* class MyClass extends PlainObjectLike {
|
|
370
|
-
* @lazyProp
|
|
371
|
-
* get expensiveValue() {
|
|
372
|
-
* return someExpensiveComputation();
|
|
373
|
-
* }
|
|
374
|
-
* }
|
|
375
|
-
* ```
|
|
376
|
-
*/
|
|
377
|
-
function lazyProp(target, propertyKey, descriptor) {
|
|
378
|
-
if (!target.constructor[LAZY_FIELDS_KEY]) target.constructor[LAZY_FIELDS_KEY] = /* @__PURE__ */ new Map();
|
|
379
|
-
const originalGetter = descriptor.get;
|
|
380
|
-
target.constructor[LAZY_FIELDS_KEY].set(propertyKey, originalGetter);
|
|
381
|
-
return {
|
|
382
|
-
enumerable: false,
|
|
383
|
-
configurable: true
|
|
384
|
-
};
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
//#endregion
|
|
388
|
-
//#region src/utils/asset-source.ts
|
|
389
|
-
function transformAssetSource(bindingAssetSource$1) {
|
|
390
|
-
return bindingAssetSource$1.inner;
|
|
391
|
-
}
|
|
392
|
-
function bindingAssetSource(source) {
|
|
393
|
-
return { inner: source };
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
//#endregion
|
|
397
|
-
//#region \0@oxc-project+runtime@0.107.0/helpers/decorate.js
|
|
398
|
-
function __decorate(decorators, target, key, desc) {
|
|
399
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
400
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
401
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
402
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
//#endregion
|
|
406
|
-
//#region src/types/output-asset-impl.ts
|
|
407
|
-
var OutputAssetImpl = class extends PlainObjectLike {
|
|
408
|
-
type = "asset";
|
|
409
|
-
constructor(bindingAsset) {
|
|
410
|
-
super();
|
|
411
|
-
this.bindingAsset = bindingAsset;
|
|
412
|
-
}
|
|
413
|
-
get fileName() {
|
|
414
|
-
return this.bindingAsset.getFileName();
|
|
415
|
-
}
|
|
416
|
-
get originalFileName() {
|
|
417
|
-
return this.bindingAsset.getOriginalFileName() || null;
|
|
418
|
-
}
|
|
419
|
-
get originalFileNames() {
|
|
420
|
-
return this.bindingAsset.getOriginalFileNames();
|
|
421
|
-
}
|
|
422
|
-
get name() {
|
|
423
|
-
return this.bindingAsset.getName() ?? void 0;
|
|
424
|
-
}
|
|
425
|
-
get names() {
|
|
426
|
-
return this.bindingAsset.getNames();
|
|
427
|
-
}
|
|
428
|
-
get source() {
|
|
429
|
-
return transformAssetSource(this.bindingAsset.getSource());
|
|
430
|
-
}
|
|
431
|
-
__rolldown_external_memory_handle__(keepDataAlive) {
|
|
432
|
-
if (keepDataAlive) this.#evaluateAllLazyFields();
|
|
433
|
-
return this.bindingAsset.dropInner();
|
|
434
|
-
}
|
|
435
|
-
#evaluateAllLazyFields() {
|
|
436
|
-
for (const field of getLazyFields(this)) this[field];
|
|
437
|
-
}
|
|
438
|
-
};
|
|
439
|
-
__decorate([lazyProp], OutputAssetImpl.prototype, "fileName", null);
|
|
440
|
-
__decorate([lazyProp], OutputAssetImpl.prototype, "originalFileName", null);
|
|
441
|
-
__decorate([lazyProp], OutputAssetImpl.prototype, "originalFileNames", null);
|
|
442
|
-
__decorate([lazyProp], OutputAssetImpl.prototype, "name", null);
|
|
443
|
-
__decorate([lazyProp], OutputAssetImpl.prototype, "names", null);
|
|
444
|
-
__decorate([lazyProp], OutputAssetImpl.prototype, "source", null);
|
|
445
|
-
|
|
446
|
-
//#endregion
|
|
447
|
-
//#region src/utils/transform-rendered-module.ts
|
|
448
|
-
function transformToRenderedModule(bindingRenderedModule) {
|
|
449
|
-
return {
|
|
450
|
-
get code() {
|
|
451
|
-
return bindingRenderedModule.code;
|
|
452
|
-
},
|
|
453
|
-
get renderedLength() {
|
|
454
|
-
return bindingRenderedModule.code?.length || 0;
|
|
455
|
-
},
|
|
456
|
-
get renderedExports() {
|
|
457
|
-
return bindingRenderedModule.renderedExports;
|
|
458
|
-
}
|
|
459
|
-
};
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
//#endregion
|
|
463
|
-
//#region src/utils/transform-rendered-chunk.ts
|
|
464
|
-
function transformRenderedChunk(chunk) {
|
|
465
|
-
let modules = null;
|
|
466
|
-
return {
|
|
467
|
-
type: "chunk",
|
|
468
|
-
get name() {
|
|
469
|
-
return chunk.name;
|
|
470
|
-
},
|
|
471
|
-
get isEntry() {
|
|
472
|
-
return chunk.isEntry;
|
|
473
|
-
},
|
|
474
|
-
get isDynamicEntry() {
|
|
475
|
-
return chunk.isDynamicEntry;
|
|
476
|
-
},
|
|
477
|
-
get facadeModuleId() {
|
|
478
|
-
return chunk.facadeModuleId;
|
|
479
|
-
},
|
|
480
|
-
get moduleIds() {
|
|
481
|
-
return chunk.moduleIds;
|
|
482
|
-
},
|
|
483
|
-
get exports() {
|
|
484
|
-
return chunk.exports;
|
|
485
|
-
},
|
|
486
|
-
get fileName() {
|
|
487
|
-
return chunk.fileName;
|
|
488
|
-
},
|
|
489
|
-
get imports() {
|
|
490
|
-
return chunk.imports;
|
|
491
|
-
},
|
|
492
|
-
get dynamicImports() {
|
|
493
|
-
return chunk.dynamicImports;
|
|
494
|
-
},
|
|
495
|
-
get modules() {
|
|
496
|
-
if (!modules) modules = transformChunkModules(chunk.modules);
|
|
497
|
-
return modules;
|
|
498
|
-
}
|
|
499
|
-
};
|
|
500
|
-
}
|
|
501
|
-
function transformChunkModules(modules) {
|
|
502
|
-
const result = {};
|
|
503
|
-
for (let i = 0; i < modules.values.length; i++) {
|
|
504
|
-
let key = modules.keys[i];
|
|
505
|
-
const mod = modules.values[i];
|
|
506
|
-
result[key] = transformToRenderedModule(mod);
|
|
507
|
-
}
|
|
508
|
-
return result;
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
//#endregion
|
|
512
|
-
//#region src/types/output-chunk-impl.ts
|
|
513
|
-
var OutputChunkImpl = class extends PlainObjectLike {
|
|
514
|
-
type = "chunk";
|
|
515
|
-
constructor(bindingChunk) {
|
|
516
|
-
super();
|
|
517
|
-
this.bindingChunk = bindingChunk;
|
|
518
|
-
}
|
|
519
|
-
get fileName() {
|
|
520
|
-
return this.bindingChunk.getFileName();
|
|
521
|
-
}
|
|
522
|
-
get name() {
|
|
523
|
-
return this.bindingChunk.getName();
|
|
524
|
-
}
|
|
525
|
-
get exports() {
|
|
526
|
-
return this.bindingChunk.getExports();
|
|
527
|
-
}
|
|
528
|
-
get isEntry() {
|
|
529
|
-
return this.bindingChunk.getIsEntry();
|
|
530
|
-
}
|
|
531
|
-
get facadeModuleId() {
|
|
532
|
-
return this.bindingChunk.getFacadeModuleId() || null;
|
|
533
|
-
}
|
|
534
|
-
get isDynamicEntry() {
|
|
535
|
-
return this.bindingChunk.getIsDynamicEntry();
|
|
536
|
-
}
|
|
537
|
-
get sourcemapFileName() {
|
|
538
|
-
return this.bindingChunk.getSourcemapFileName() || null;
|
|
539
|
-
}
|
|
540
|
-
get preliminaryFileName() {
|
|
541
|
-
return this.bindingChunk.getPreliminaryFileName();
|
|
542
|
-
}
|
|
543
|
-
get code() {
|
|
544
|
-
return this.bindingChunk.getCode();
|
|
545
|
-
}
|
|
546
|
-
get modules() {
|
|
547
|
-
return transformChunkModules(this.bindingChunk.getModules());
|
|
548
|
-
}
|
|
549
|
-
get imports() {
|
|
550
|
-
return this.bindingChunk.getImports();
|
|
551
|
-
}
|
|
552
|
-
get dynamicImports() {
|
|
553
|
-
return this.bindingChunk.getDynamicImports();
|
|
554
|
-
}
|
|
555
|
-
get moduleIds() {
|
|
556
|
-
return this.bindingChunk.getModuleIds();
|
|
557
|
-
}
|
|
558
|
-
get map() {
|
|
559
|
-
const mapString = this.bindingChunk.getMap();
|
|
560
|
-
return mapString ? transformToRollupSourceMap(mapString) : null;
|
|
561
|
-
}
|
|
562
|
-
__rolldown_external_memory_handle__(keepDataAlive) {
|
|
563
|
-
if (keepDataAlive) this.#evaluateAllLazyFields();
|
|
564
|
-
return this.bindingChunk.dropInner();
|
|
565
|
-
}
|
|
566
|
-
#evaluateAllLazyFields() {
|
|
567
|
-
for (const field of getLazyFields(this)) this[field];
|
|
568
|
-
}
|
|
569
|
-
};
|
|
570
|
-
__decorate([lazyProp], OutputChunkImpl.prototype, "fileName", null);
|
|
571
|
-
__decorate([lazyProp], OutputChunkImpl.prototype, "name", null);
|
|
572
|
-
__decorate([lazyProp], OutputChunkImpl.prototype, "exports", null);
|
|
573
|
-
__decorate([lazyProp], OutputChunkImpl.prototype, "isEntry", null);
|
|
574
|
-
__decorate([lazyProp], OutputChunkImpl.prototype, "facadeModuleId", null);
|
|
575
|
-
__decorate([lazyProp], OutputChunkImpl.prototype, "isDynamicEntry", null);
|
|
576
|
-
__decorate([lazyProp], OutputChunkImpl.prototype, "sourcemapFileName", null);
|
|
577
|
-
__decorate([lazyProp], OutputChunkImpl.prototype, "preliminaryFileName", null);
|
|
578
|
-
__decorate([lazyProp], OutputChunkImpl.prototype, "code", null);
|
|
579
|
-
__decorate([lazyProp], OutputChunkImpl.prototype, "modules", null);
|
|
580
|
-
__decorate([lazyProp], OutputChunkImpl.prototype, "imports", null);
|
|
581
|
-
__decorate([lazyProp], OutputChunkImpl.prototype, "dynamicImports", null);
|
|
582
|
-
__decorate([lazyProp], OutputChunkImpl.prototype, "moduleIds", null);
|
|
583
|
-
__decorate([lazyProp], OutputChunkImpl.prototype, "map", null);
|
|
584
|
-
|
|
585
|
-
//#endregion
|
|
586
|
-
//#region src/types/sourcemap.ts
|
|
587
|
-
function bindingifySourcemap(map) {
|
|
588
|
-
if (map == null) return;
|
|
589
|
-
return { inner: typeof map === "string" ? map : {
|
|
590
|
-
file: map.file ?? void 0,
|
|
591
|
-
mappings: map.mappings,
|
|
592
|
-
sourceRoot: "sourceRoot" in map ? map.sourceRoot ?? void 0 : void 0,
|
|
593
|
-
sources: map.sources?.map((s) => s ?? void 0),
|
|
594
|
-
sourcesContent: map.sourcesContent?.map((s) => s ?? void 0),
|
|
595
|
-
names: map.names,
|
|
596
|
-
x_google_ignoreList: map.x_google_ignoreList,
|
|
597
|
-
debugId: "debugId" in map ? map.debugId : void 0
|
|
598
|
-
} };
|
|
599
|
-
}
|
|
600
|
-
|
|
601
|
-
//#endregion
|
|
602
|
-
//#region src/utils/transform-to-rollup-output.ts
|
|
603
|
-
function transformToRollupSourceMap(map) {
|
|
604
|
-
const obj = {
|
|
605
|
-
...JSON.parse(map),
|
|
606
|
-
toString() {
|
|
607
|
-
return JSON.stringify(obj);
|
|
608
|
-
},
|
|
609
|
-
toUrl() {
|
|
610
|
-
return `data:application/json;charset=utf-8;base64,${Buffer.from(obj.toString(), "utf-8").toString("base64")}`;
|
|
611
|
-
}
|
|
612
|
-
};
|
|
613
|
-
return obj;
|
|
614
|
-
}
|
|
615
|
-
function transformToRollupOutputChunk(bindingChunk) {
|
|
616
|
-
return new OutputChunkImpl(bindingChunk);
|
|
617
|
-
}
|
|
618
|
-
function transformToMutableRollupOutputChunk(bindingChunk, changed) {
|
|
619
|
-
const chunk = {
|
|
620
|
-
type: "chunk",
|
|
621
|
-
get code() {
|
|
622
|
-
return bindingChunk.getCode();
|
|
623
|
-
},
|
|
624
|
-
fileName: bindingChunk.getFileName(),
|
|
625
|
-
name: bindingChunk.getName(),
|
|
626
|
-
get modules() {
|
|
627
|
-
return transformChunkModules(bindingChunk.getModules());
|
|
628
|
-
},
|
|
629
|
-
get imports() {
|
|
630
|
-
return bindingChunk.getImports();
|
|
631
|
-
},
|
|
632
|
-
get dynamicImports() {
|
|
633
|
-
return bindingChunk.getDynamicImports();
|
|
634
|
-
},
|
|
635
|
-
exports: bindingChunk.getExports(),
|
|
636
|
-
isEntry: bindingChunk.getIsEntry(),
|
|
637
|
-
facadeModuleId: bindingChunk.getFacadeModuleId() || null,
|
|
638
|
-
isDynamicEntry: bindingChunk.getIsDynamicEntry(),
|
|
639
|
-
get moduleIds() {
|
|
640
|
-
return bindingChunk.getModuleIds();
|
|
641
|
-
},
|
|
642
|
-
get map() {
|
|
643
|
-
const map = bindingChunk.getMap();
|
|
644
|
-
return map ? transformToRollupSourceMap(map) : null;
|
|
645
|
-
},
|
|
646
|
-
sourcemapFileName: bindingChunk.getSourcemapFileName() || null,
|
|
647
|
-
preliminaryFileName: bindingChunk.getPreliminaryFileName()
|
|
648
|
-
};
|
|
649
|
-
const cache = {};
|
|
650
|
-
return new Proxy(chunk, {
|
|
651
|
-
get(target, p) {
|
|
652
|
-
if (p in cache) return cache[p];
|
|
653
|
-
const value = target[p];
|
|
654
|
-
cache[p] = value;
|
|
655
|
-
return value;
|
|
656
|
-
},
|
|
657
|
-
set(_target, p, newValue) {
|
|
658
|
-
cache[p] = newValue;
|
|
659
|
-
changed.updated.add(bindingChunk.getFileName());
|
|
660
|
-
return true;
|
|
661
|
-
},
|
|
662
|
-
has(target, p) {
|
|
663
|
-
if (p in cache) return true;
|
|
664
|
-
return p in target;
|
|
665
|
-
}
|
|
666
|
-
});
|
|
667
|
-
}
|
|
668
|
-
function transformToRollupOutputAsset(bindingAsset) {
|
|
669
|
-
return new OutputAssetImpl(bindingAsset);
|
|
670
|
-
}
|
|
671
|
-
function transformToMutableRollupOutputAsset(bindingAsset, changed) {
|
|
672
|
-
const asset = {
|
|
673
|
-
type: "asset",
|
|
674
|
-
fileName: bindingAsset.getFileName(),
|
|
675
|
-
originalFileName: bindingAsset.getOriginalFileName() || null,
|
|
676
|
-
originalFileNames: bindingAsset.getOriginalFileNames(),
|
|
677
|
-
get source() {
|
|
678
|
-
return transformAssetSource(bindingAsset.getSource());
|
|
679
|
-
},
|
|
680
|
-
name: bindingAsset.getName() ?? void 0,
|
|
681
|
-
names: bindingAsset.getNames()
|
|
682
|
-
};
|
|
683
|
-
const cache = {};
|
|
684
|
-
return new Proxy(asset, {
|
|
685
|
-
get(target, p) {
|
|
686
|
-
if (p in cache) return cache[p];
|
|
687
|
-
const value = target[p];
|
|
688
|
-
cache[p] = value;
|
|
689
|
-
return value;
|
|
690
|
-
},
|
|
691
|
-
set(_target, p, newValue) {
|
|
692
|
-
cache[p] = newValue;
|
|
693
|
-
changed.updated.add(bindingAsset.getFileName());
|
|
694
|
-
return true;
|
|
695
|
-
}
|
|
696
|
-
});
|
|
697
|
-
}
|
|
698
|
-
function transformToRollupOutput(output) {
|
|
699
|
-
const { chunks, assets } = output;
|
|
700
|
-
return { output: [...chunks.map((chunk) => transformToRollupOutputChunk(chunk)), ...assets.map((asset) => transformToRollupOutputAsset(asset))] };
|
|
701
|
-
}
|
|
702
|
-
function transformToMutableRollupOutput(output, changed) {
|
|
703
|
-
const { chunks, assets } = output;
|
|
704
|
-
return { output: [...chunks.map((chunk) => transformToMutableRollupOutputChunk(chunk, changed)), ...assets.map((asset) => transformToMutableRollupOutputAsset(asset, changed))] };
|
|
705
|
-
}
|
|
706
|
-
function transformToOutputBundle(context, output, changed) {
|
|
707
|
-
const bundle = Object.fromEntries(transformToMutableRollupOutput(output, changed).output.map((item) => [item.fileName, item]));
|
|
708
|
-
return new Proxy(bundle, {
|
|
709
|
-
set(_target, _p, _newValue, _receiver) {
|
|
710
|
-
const originalStackTraceLimit = Error.stackTraceLimit;
|
|
711
|
-
Error.stackTraceLimit = 2;
|
|
712
|
-
const message = "This plugin assigns to bundle variable. This is discouraged by Rollup and is not supported by Rolldown. This will be ignored. https://rollupjs.org/plugin-development/#generatebundle:~:text=DANGER,this.emitFile.";
|
|
713
|
-
const stack = new Error(message).stack ?? message;
|
|
714
|
-
Error.stackTraceLimit = originalStackTraceLimit;
|
|
715
|
-
context.warn({
|
|
716
|
-
message: stack,
|
|
717
|
-
code: "UNSUPPORTED_BUNDLE_ASSIGNMENT"
|
|
718
|
-
});
|
|
719
|
-
return true;
|
|
720
|
-
},
|
|
721
|
-
deleteProperty(target, property) {
|
|
722
|
-
if (typeof property === "string") changed.deleted.add(property);
|
|
723
|
-
return true;
|
|
724
|
-
}
|
|
725
|
-
});
|
|
726
|
-
}
|
|
727
|
-
function collectChangedBundle(changed, bundle) {
|
|
728
|
-
const changes = {};
|
|
729
|
-
for (const key in bundle) {
|
|
730
|
-
if (changed.deleted.has(key) || !changed.updated.has(key)) continue;
|
|
731
|
-
const item = bundle[key];
|
|
732
|
-
if (item.type === "asset") changes[key] = {
|
|
733
|
-
filename: item.fileName,
|
|
734
|
-
originalFileNames: item.originalFileNames,
|
|
735
|
-
source: bindingAssetSource(item.source),
|
|
736
|
-
names: item.names
|
|
737
|
-
};
|
|
738
|
-
else changes[key] = {
|
|
739
|
-
code: item.code,
|
|
740
|
-
filename: item.fileName,
|
|
741
|
-
name: item.name,
|
|
742
|
-
isEntry: item.isEntry,
|
|
743
|
-
exports: item.exports,
|
|
744
|
-
modules: {},
|
|
745
|
-
imports: item.imports,
|
|
746
|
-
dynamicImports: item.dynamicImports,
|
|
747
|
-
facadeModuleId: item.facadeModuleId || void 0,
|
|
748
|
-
isDynamicEntry: item.isDynamicEntry,
|
|
749
|
-
moduleIds: item.moduleIds,
|
|
750
|
-
map: bindingifySourcemap(item.map),
|
|
751
|
-
sourcemapFilename: item.sourcemapFileName || void 0,
|
|
752
|
-
preliminaryFilename: item.preliminaryFileName
|
|
753
|
-
};
|
|
754
|
-
}
|
|
755
|
-
return {
|
|
756
|
-
changes,
|
|
757
|
-
deleted: changed.deleted
|
|
758
|
-
};
|
|
759
|
-
}
|
|
760
|
-
|
|
761
|
-
//#endregion
|
|
762
|
-
//#region src/builtin-plugin/utils.ts
|
|
763
|
-
var BuiltinPlugin = class {
|
|
764
|
-
/** Vite-specific option to control plugin ordering */
|
|
765
|
-
enforce;
|
|
766
|
-
constructor(name, _options) {
|
|
767
|
-
this.name = name;
|
|
768
|
-
this._options = _options;
|
|
769
|
-
}
|
|
770
|
-
};
|
|
771
|
-
function makeBuiltinPluginCallable(plugin) {
|
|
772
|
-
let callablePlugin = new BindingCallableBuiltinPlugin(bindingifyBuiltInPlugin(plugin));
|
|
773
|
-
const wrappedPlugin = plugin;
|
|
774
|
-
for (const key in callablePlugin) wrappedPlugin[key] = async function(...args) {
|
|
775
|
-
try {
|
|
776
|
-
return await callablePlugin[key](...args);
|
|
777
|
-
} catch (e) {
|
|
778
|
-
if (e instanceof Error && !e.stack?.includes("at ")) Error.captureStackTrace(e, wrappedPlugin[key]);
|
|
779
|
-
return error(logPluginError(e, plugin.name, {
|
|
780
|
-
hook: key,
|
|
781
|
-
id: key === "transform" ? args[2] : void 0
|
|
782
|
-
}));
|
|
783
|
-
}
|
|
784
|
-
};
|
|
785
|
-
return wrappedPlugin;
|
|
786
|
-
}
|
|
787
|
-
function bindingifyBuiltInPlugin(plugin) {
|
|
788
|
-
return {
|
|
789
|
-
__name: plugin.name,
|
|
790
|
-
options: plugin._options
|
|
791
|
-
};
|
|
792
|
-
}
|
|
793
|
-
function bindingifyManifestPlugin(plugin, pluginContextData) {
|
|
794
|
-
const { isOutputOptionsForLegacyChunks, ...options } = plugin._options;
|
|
795
|
-
return {
|
|
796
|
-
__name: plugin.name,
|
|
797
|
-
options: {
|
|
798
|
-
...options,
|
|
799
|
-
isLegacy: isOutputOptionsForLegacyChunks ? (opts) => {
|
|
800
|
-
return isOutputOptionsForLegacyChunks(pluginContextData.getOutputOptions(opts));
|
|
801
|
-
} : void 0
|
|
802
|
-
}
|
|
803
|
-
};
|
|
804
|
-
}
|
|
805
|
-
function bindingifyCSSPostPlugin(plugin, pluginContextData) {
|
|
806
|
-
const { isOutputOptionsForLegacyChunks, ...options } = plugin._options;
|
|
807
|
-
return {
|
|
808
|
-
__name: plugin.name,
|
|
809
|
-
options: {
|
|
810
|
-
...options,
|
|
811
|
-
isLegacy: isOutputOptionsForLegacyChunks ? (opts) => {
|
|
812
|
-
return isOutputOptionsForLegacyChunks(pluginContextData.getOutputOptions(opts));
|
|
813
|
-
} : void 0,
|
|
814
|
-
cssScopeTo() {
|
|
815
|
-
const cssScopeTo = {};
|
|
816
|
-
for (const [id, opts] of pluginContextData.moduleOptionMap.entries()) if (opts?.meta.vite?.cssScopeTo) cssScopeTo[id] = opts.meta.vite.cssScopeTo;
|
|
817
|
-
return cssScopeTo;
|
|
818
|
-
}
|
|
819
|
-
}
|
|
820
|
-
};
|
|
821
|
-
}
|
|
822
|
-
function bindingifyViteHtmlPlugin(plugin, onLog, logLevel, watchMode, pluginContextData) {
|
|
823
|
-
const { preHooks, normalHooks, postHooks, applyHtmlTransforms, ...options } = plugin._options;
|
|
824
|
-
if (preHooks.length + normalHooks.length + postHooks.length > 0) return {
|
|
825
|
-
__name: plugin.name,
|
|
826
|
-
options: {
|
|
827
|
-
...options,
|
|
828
|
-
transformIndexHtml: async (html, path, filename, hook, output, chunk) => {
|
|
829
|
-
const pluginContext = new MinimalPluginContextImpl(onLog, logLevel, plugin.name, watchMode, "transformIndexHtml");
|
|
830
|
-
const context = {
|
|
831
|
-
path,
|
|
832
|
-
filename,
|
|
833
|
-
bundle: output ? transformToOutputBundle(pluginContext, output, {
|
|
834
|
-
updated: /* @__PURE__ */ new Set(),
|
|
835
|
-
deleted: /* @__PURE__ */ new Set()
|
|
836
|
-
}) : void 0,
|
|
837
|
-
chunk: chunk ? transformToRollupOutputChunk(chunk) : void 0
|
|
838
|
-
};
|
|
839
|
-
switch (hook) {
|
|
840
|
-
case "transform": return await applyHtmlTransforms(html, preHooks, pluginContext, context);
|
|
841
|
-
case "generateBundle": return await applyHtmlTransforms(html, [...normalHooks, ...postHooks], pluginContext, context);
|
|
842
|
-
}
|
|
843
|
-
},
|
|
844
|
-
setModuleSideEffects(id) {
|
|
845
|
-
let opts = pluginContextData.getModuleOption(id);
|
|
846
|
-
pluginContextData.updateModuleOption(id, {
|
|
847
|
-
moduleSideEffects: true,
|
|
848
|
-
meta: opts.meta,
|
|
849
|
-
invalidate: true
|
|
850
|
-
});
|
|
851
|
-
}
|
|
852
|
-
}
|
|
853
|
-
};
|
|
854
|
-
return {
|
|
855
|
-
__name: plugin.name,
|
|
856
|
-
options: plugin._options
|
|
857
|
-
};
|
|
858
|
-
}
|
|
859
|
-
|
|
860
|
-
//#endregion
|
|
861
|
-
//#region src/utils/normalize-string-or-regex.ts
|
|
862
|
-
function normalizedStringOrRegex(pattern) {
|
|
863
|
-
if (!pattern) return;
|
|
864
|
-
if (!isReadonlyArray(pattern)) return [pattern];
|
|
865
|
-
return pattern;
|
|
866
|
-
}
|
|
867
|
-
function isReadonlyArray(input) {
|
|
868
|
-
return Array.isArray(input);
|
|
869
|
-
}
|
|
870
|
-
|
|
871
|
-
//#endregion
|
|
872
|
-
export { augmentCodeLocation as A, LOG_LEVEL_INFO as C, unimplemented as D, arraify as E, logNoFileSystemInBrowser as F, logParseError as I, logPluginError as L, logCycleLoading as M, logInputHookInOutputPlugin as N, unreachable as O, logMultiplyNotifyOption as P, locate as R, LOG_LEVEL_ERROR as S, logLevelPriority as T, PlainObjectLike as _, bindingifyManifestPlugin as a, normalizeLog as b, collectChangedBundle as c, bindingifySourcemap as d, transformRenderedChunk as f, lazyProp as g, transformAssetSource as h, bindingifyCSSPostPlugin as i, error as j, unsupported as k, transformToOutputBundle as l, bindingAssetSource as m, BuiltinPlugin as n, bindingifyViteHtmlPlugin as o, __decorate as p, bindingifyBuiltInPlugin as r, makeBuiltinPluginCallable as s, normalizedStringOrRegex as t, transformToRollupOutput as u, MinimalPluginContextImpl as v, LOG_LEVEL_WARN as w, LOG_LEVEL_DEBUG as x, VERSION as y, getCodeFrame as z };
|