@rolldown/browser 1.0.0-beta.7-commit.a0a7d95
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/LICENSE +25 -0
- package/bin/cli.mjs +2 -0
- package/dist/browser-bundler.mjs +3514 -0
- package/dist/browser.js +4626 -0
- package/dist/cli.cjs +1759 -0
- package/dist/cli.mjs +1828 -0
- package/dist/experimental-index.cjs +87 -0
- package/dist/experimental-index.mjs +67 -0
- package/dist/index.cjs +9 -0
- package/dist/index.mjs +5 -0
- package/dist/parallel-plugin-worker.cjs +43 -0
- package/dist/parallel-plugin-worker.mjs +48 -0
- package/dist/parallel-plugin.cjs +9 -0
- package/dist/parallel-plugin.mjs +8 -0
- package/dist/parse-ast-index.cjs +4 -0
- package/dist/parse-ast-index.mjs +4 -0
- package/dist/rolldown-binding.wasi-browser.js +102 -0
- package/dist/rolldown-binding.wasi.cjs +127 -0
- package/dist/rolldown-binding.wasm32-wasi.wasm +0 -0
- package/dist/shared/chunk-BuCFLigr.mjs +12 -0
- package/dist/shared/chunk-Dc32QXFI.cjs +31 -0
- package/dist/shared/parse-ast-index-C29iO6Jv.cjs +316 -0
- package/dist/shared/parse-ast-index-GcZLh6_d.mjs +273 -0
- package/dist/shared/prompt-B3VJLbs9.mjs +854 -0
- package/dist/shared/prompt-wpCBKCzA.cjs +855 -0
- package/dist/shared/src-6_rb-jCl.cjs +3147 -0
- package/dist/shared/src-QrPvO0Ec.mjs +4375 -0
- package/dist/types/api/build.d.ts +18 -0
- package/dist/types/api/experimental.d.ts +7 -0
- package/dist/types/api/rolldown/index.d.ts +3 -0
- package/dist/types/api/rolldown/rolldown-build.d.ts +15 -0
- package/dist/types/api/watch/index.d.ts +3 -0
- package/dist/types/api/watch/watch-emitter.d.ts +31 -0
- package/dist/types/api/watch/watcher.d.ts +13 -0
- package/dist/types/binding.d.ts +1504 -0
- package/dist/types/builtin-plugin/alias-plugin.d.ts +10 -0
- package/dist/types/builtin-plugin/constructors.d.ts +22 -0
- package/dist/types/builtin-plugin/replace-plugin.d.ts +27 -0
- package/dist/types/builtin-plugin/transform-plugin.d.ts +9 -0
- package/dist/types/builtin-plugin/utils.d.ts +8 -0
- package/dist/types/cli/arguments/alias.d.ts +16 -0
- package/dist/types/cli/arguments/index.d.ts +15 -0
- package/dist/types/cli/arguments/normalize.d.ts +16 -0
- package/dist/types/cli/arguments/utils.d.ts +8 -0
- package/dist/types/cli/commands/bundle.d.ts +3 -0
- package/dist/types/cli/commands/help.d.ts +1 -0
- package/dist/types/cli/index.d.ts +1 -0
- package/dist/types/cli/load-config.d.ts +5 -0
- package/dist/types/cli/logger.d.ts +5 -0
- package/dist/types/constants/plugin-context.d.ts +7 -0
- package/dist/types/constants/plugin.d.ts +45 -0
- package/dist/types/experimental-index.d.ts +9 -0
- package/dist/types/index.d.ts +31 -0
- package/dist/types/log/log-handler.d.ts +4 -0
- package/dist/types/log/logger.d.ts +6 -0
- package/dist/types/log/logging.d.ts +12 -0
- package/dist/types/log/logs.d.ts +18 -0
- package/dist/types/options/generated/checks-options.d.ts +57 -0
- package/dist/types/options/input-options.d.ts +185 -0
- package/dist/types/options/normalized-input-options.d.ts +18 -0
- package/dist/types/options/normalized-output-options.d.ts +70 -0
- package/dist/types/options/output-options.d.ts +182 -0
- package/dist/types/options/watch-options.d.ts +5 -0
- package/dist/types/parallel-plugin-worker.d.ts +1 -0
- package/dist/types/parallel-plugin.d.ts +1 -0
- package/dist/types/parse-ast-index.d.ts +5 -0
- package/dist/types/plugin/bindingify-build-hooks.d.ts +10 -0
- package/dist/types/plugin/bindingify-hook-filter.d.ts +7 -0
- package/dist/types/plugin/bindingify-output-hooks.d.ts +14 -0
- package/dist/types/plugin/bindingify-plugin-hook-meta.d.ts +8 -0
- package/dist/types/plugin/bindingify-plugin.d.ts +17 -0
- package/dist/types/plugin/bindingify-watch-hooks.d.ts +5 -0
- package/dist/types/plugin/hook-filter.d.ts +49 -0
- package/dist/types/plugin/index.d.ts +141 -0
- package/dist/types/plugin/minimal-plugin-context.d.ts +24 -0
- package/dist/types/plugin/parallel-plugin-implementation.d.ts +10 -0
- package/dist/types/plugin/parallel-plugin.d.ts +9 -0
- package/dist/types/plugin/plugin-context-data.d.ts +21 -0
- package/dist/types/plugin/plugin-context.d.ts +67 -0
- package/dist/types/plugin/plugin-driver.d.ts +10 -0
- package/dist/types/plugin/transform-plugin-context.d.ts +28 -0
- package/dist/types/plugin/with-filter.d.ts +10 -0
- package/dist/types/types/assert.d.ts +14 -0
- package/dist/types/types/config-export.d.ts +5 -0
- package/dist/types/types/misc.d.ts +40 -0
- package/dist/types/types/module-info.d.ts +15 -0
- package/dist/types/types/module-side-effects.d.ts +12 -0
- package/dist/types/types/output-bundle.d.ts +4 -0
- package/dist/types/types/rolldown-options.d.ts +5 -0
- package/dist/types/types/rolldown-output.d.ts +66 -0
- package/dist/types/types/schema.d.ts +33 -0
- package/dist/types/types/sourcemap.d.ts +14 -0
- package/dist/types/types/utils.d.ts +13 -0
- package/dist/types/types.d.ts +7 -0
- package/dist/types/utils/asset-source.d.ts +4 -0
- package/dist/types/utils/async-flatten.d.ts +1 -0
- package/dist/types/utils/bindingify-input-options.d.ts +7 -0
- package/dist/types/utils/bindingify-output-options.d.ts +5 -0
- package/dist/types/utils/code-frame.d.ts +1 -0
- package/dist/types/utils/compose-js-plugins.d.ts +2 -0
- package/dist/types/utils/create-bundler-option.d.ts +11 -0
- package/dist/types/utils/create-bundler.d.ts +9 -0
- package/dist/types/utils/define-config.d.ts +5 -0
- package/dist/types/utils/error.d.ts +2 -0
- package/dist/types/utils/initialize-parallel-plugins.d.ts +17 -0
- package/dist/types/utils/misc.d.ts +7 -0
- package/dist/types/utils/normalize-hook.d.ts +7 -0
- package/dist/types/utils/normalize-plugin-option.d.ts +13 -0
- package/dist/types/utils/normalize-string-or-regex.d.ts +2 -0
- package/dist/types/utils/plugin/index.d.ts +2 -0
- package/dist/types/utils/resolved-external.d.ts +4 -0
- package/dist/types/utils/transform-module-info.d.ts +4 -0
- package/dist/types/utils/transform-rendered-chunk.d.ts +4 -0
- package/dist/types/utils/transform-rendered-module.d.ts +3 -0
- package/dist/types/utils/transform-side-effects.d.ts +3 -0
- package/dist/types/utils/transform-sourcemap.d.ts +3 -0
- package/dist/types/utils/transform-to-rollup-output.d.ts +11 -0
- package/dist/types/utils/validator.d.ts +6 -0
- package/dist/wasi-worker-browser.mjs +39 -0
- package/dist/wasi-worker.mjs +63 -0
- package/package.json +85 -0
|
@@ -0,0 +1,3147 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const require_chunk = require('./chunk-Dc32QXFI.cjs');
|
|
3
|
+
const require_parse_ast_index = require('./parse-ast-index-C29iO6Jv.cjs');
|
|
4
|
+
const src_rolldown_binding_wasi_cjs = require_chunk.__toESM(require("../rolldown-binding.wasi.cjs"));
|
|
5
|
+
const node_path = require_chunk.__toESM(require("node:path"));
|
|
6
|
+
const ansis = require_chunk.__toESM(require("ansis"));
|
|
7
|
+
const __valibot_to_json_schema = require_chunk.__toESM(require("@valibot/to-json-schema"));
|
|
8
|
+
const valibot = require_chunk.__toESM(require("valibot"));
|
|
9
|
+
const node_os = require_chunk.__toESM(require("node:os"));
|
|
10
|
+
const node_worker_threads = require_chunk.__toESM(require("node:worker_threads"));
|
|
11
|
+
|
|
12
|
+
//#region package.json
|
|
13
|
+
var version = "1.0.0-beta.7-commit.a0a7d95";
|
|
14
|
+
var description = "Fast JavaScript/TypeScript bundler in Rust with Rollup-compatible API.";
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region src/builtin-plugin/utils.ts
|
|
18
|
+
function makeBuiltinPluginCallable(plugin) {
|
|
19
|
+
let callablePlugin = new src_rolldown_binding_wasi_cjs.BindingCallableBuiltinPlugin(bindingifyBuiltInPlugin(plugin));
|
|
20
|
+
const wrappedPlugin = plugin;
|
|
21
|
+
for (const key in callablePlugin) wrappedPlugin[key] = function(...args) {
|
|
22
|
+
return callablePlugin[key](...args);
|
|
23
|
+
};
|
|
24
|
+
return wrappedPlugin;
|
|
25
|
+
}
|
|
26
|
+
function bindingifyBuiltInPlugin(plugin) {
|
|
27
|
+
return {
|
|
28
|
+
__name: plugin.name,
|
|
29
|
+
options: plugin._options
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
//#endregion
|
|
34
|
+
//#region src/builtin-plugin/constructors.ts
|
|
35
|
+
var BuiltinPlugin = class {
|
|
36
|
+
constructor(name, _options) {
|
|
37
|
+
this.name = name;
|
|
38
|
+
this._options = _options;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
function modulePreloadPolyfillPlugin(config) {
|
|
42
|
+
return new BuiltinPlugin("builtin:module-preload-polyfill", config);
|
|
43
|
+
}
|
|
44
|
+
function dynamicImportVarsPlugin() {
|
|
45
|
+
return new BuiltinPlugin("builtin:dynamic-import-vars");
|
|
46
|
+
}
|
|
47
|
+
function importGlobPlugin(config) {
|
|
48
|
+
return new BuiltinPlugin("builtin:import-glob", config);
|
|
49
|
+
}
|
|
50
|
+
function manifestPlugin(config) {
|
|
51
|
+
return new BuiltinPlugin("builtin:manifest", config);
|
|
52
|
+
}
|
|
53
|
+
function wasmHelperPlugin() {
|
|
54
|
+
return new BuiltinPlugin("builtin:wasm-helper");
|
|
55
|
+
}
|
|
56
|
+
function wasmFallbackPlugin() {
|
|
57
|
+
return new BuiltinPlugin("builtin:wasm-fallback");
|
|
58
|
+
}
|
|
59
|
+
function loadFallbackPlugin() {
|
|
60
|
+
return new BuiltinPlugin("builtin:load-fallback");
|
|
61
|
+
}
|
|
62
|
+
function jsonPlugin(config) {
|
|
63
|
+
return new BuiltinPlugin("builtin:json", config);
|
|
64
|
+
}
|
|
65
|
+
function buildImportAnalysisPlugin(config) {
|
|
66
|
+
return new BuiltinPlugin("builtin:build-import-analysis", config);
|
|
67
|
+
}
|
|
68
|
+
function viteResolvePlugin(config) {
|
|
69
|
+
const builtinPlugin = new BuiltinPlugin("builtin:vite-resolve", {
|
|
70
|
+
...config,
|
|
71
|
+
runtime: process.versions.deno ? "deno" : process.versions.bun ? "bun" : "node"
|
|
72
|
+
});
|
|
73
|
+
return makeBuiltinPluginCallable(builtinPlugin);
|
|
74
|
+
}
|
|
75
|
+
function moduleFederationPlugin(config) {
|
|
76
|
+
return new BuiltinPlugin("builtin:module-federation", {
|
|
77
|
+
...config,
|
|
78
|
+
remotes: config.remotes && Object.entries(config.remotes).map(([name, remote]) => {
|
|
79
|
+
if (typeof remote === "string") {
|
|
80
|
+
const [entryGlobalName] = remote.split("@");
|
|
81
|
+
const entry = remote.replace(entryGlobalName + "@", "");
|
|
82
|
+
return {
|
|
83
|
+
entry,
|
|
84
|
+
name,
|
|
85
|
+
entryGlobalName
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
return {
|
|
89
|
+
...remote,
|
|
90
|
+
name: remote.name ?? name
|
|
91
|
+
};
|
|
92
|
+
}),
|
|
93
|
+
manifest: config.manifest === false ? void 0 : config.manifest === true ? {} : config.manifest
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
function isolatedDeclarationPlugin(config) {
|
|
97
|
+
return new BuiltinPlugin("builtin:isolated-declaration", config);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
//#endregion
|
|
101
|
+
//#region src/utils/misc.ts
|
|
102
|
+
function arraify(value) {
|
|
103
|
+
return Array.isArray(value) ? value : [value];
|
|
104
|
+
}
|
|
105
|
+
function isNullish(value) {
|
|
106
|
+
return value === null || value === void 0;
|
|
107
|
+
}
|
|
108
|
+
function isPromiseLike(value) {
|
|
109
|
+
return value && (typeof value === "object" || typeof value === "function") && typeof value.then === "function";
|
|
110
|
+
}
|
|
111
|
+
function unimplemented(info) {
|
|
112
|
+
if (info) throw new Error(`unimplemented: ${info}`);
|
|
113
|
+
throw new Error("unimplemented");
|
|
114
|
+
}
|
|
115
|
+
function unreachable(info) {
|
|
116
|
+
if (info) throw new Error(`unreachable: ${info}`);
|
|
117
|
+
throw new Error("unreachable");
|
|
118
|
+
}
|
|
119
|
+
function unsupported(info) {
|
|
120
|
+
throw new Error(`UNSUPPORTED: ${info}`);
|
|
121
|
+
}
|
|
122
|
+
function noop(..._args) {}
|
|
123
|
+
|
|
124
|
+
//#endregion
|
|
125
|
+
//#region src/log/logging.ts
|
|
126
|
+
const LOG_LEVEL_SILENT = "silent";
|
|
127
|
+
const LOG_LEVEL_ERROR = "error";
|
|
128
|
+
const LOG_LEVEL_WARN = "warn";
|
|
129
|
+
const LOG_LEVEL_INFO = "info";
|
|
130
|
+
const LOG_LEVEL_DEBUG = "debug";
|
|
131
|
+
const logLevelPriority = {
|
|
132
|
+
[LOG_LEVEL_DEBUG]: 0,
|
|
133
|
+
[LOG_LEVEL_INFO]: 1,
|
|
134
|
+
[LOG_LEVEL_WARN]: 2,
|
|
135
|
+
[LOG_LEVEL_SILENT]: 3
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
//#endregion
|
|
139
|
+
//#region src/log/log-handler.ts
|
|
140
|
+
const normalizeLog = (log) => typeof log === "string" ? { message: log } : typeof log === "function" ? normalizeLog(log()) : log;
|
|
141
|
+
function getLogHandler(level, code, logger, pluginName, logLevel) {
|
|
142
|
+
if (logLevelPriority[level] < logLevelPriority[logLevel]) return noop;
|
|
143
|
+
return (log, pos) => {
|
|
144
|
+
if (pos != null) logger(LOG_LEVEL_WARN, require_parse_ast_index.logInvalidLogPosition(pluginName));
|
|
145
|
+
log = normalizeLog(log);
|
|
146
|
+
if (log.code && !log.pluginCode) log.pluginCode = log.code;
|
|
147
|
+
log.code = code;
|
|
148
|
+
log.plugin = pluginName;
|
|
149
|
+
logger(level, log);
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
//#endregion
|
|
154
|
+
//#region src/log/logger.ts
|
|
155
|
+
function getLogger(plugins, onLog, logLevel, watchMode) {
|
|
156
|
+
const minimalPriority = logLevelPriority[logLevel];
|
|
157
|
+
const logger = (level, log, skipped = new Set()) => {
|
|
158
|
+
const logPriority = logLevelPriority[level];
|
|
159
|
+
if (logPriority < minimalPriority) return;
|
|
160
|
+
for (const plugin of getSortedPlugins("onLog", plugins)) {
|
|
161
|
+
if (skipped.has(plugin)) continue;
|
|
162
|
+
const { onLog: pluginOnLog } = plugin;
|
|
163
|
+
if (pluginOnLog) {
|
|
164
|
+
const getLogHandler$1 = (level$1) => {
|
|
165
|
+
if (logLevelPriority[level$1] < minimalPriority) return () => {};
|
|
166
|
+
return (log$1) => logger(level$1, normalizeLog(log$1), new Set(skipped).add(plugin));
|
|
167
|
+
};
|
|
168
|
+
const handler = "handler" in pluginOnLog ? pluginOnLog.handler : pluginOnLog;
|
|
169
|
+
if (handler.call({
|
|
170
|
+
debug: getLogHandler$1(LOG_LEVEL_DEBUG),
|
|
171
|
+
error: (log$1) => require_parse_ast_index.error(normalizeLog(log$1)),
|
|
172
|
+
info: getLogHandler$1(LOG_LEVEL_INFO),
|
|
173
|
+
meta: {
|
|
174
|
+
rollupVersion: "4.23.0",
|
|
175
|
+
rolldownVersion: VERSION,
|
|
176
|
+
watchMode
|
|
177
|
+
},
|
|
178
|
+
warn: getLogHandler$1(LOG_LEVEL_WARN),
|
|
179
|
+
pluginName: plugin.name || "unknown"
|
|
180
|
+
}, level, log) === false) return;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
onLog(level, log);
|
|
184
|
+
};
|
|
185
|
+
return logger;
|
|
186
|
+
}
|
|
187
|
+
const getOnLog = (config, logLevel, printLog = defaultPrintLog) => {
|
|
188
|
+
const { onwarn, onLog } = config;
|
|
189
|
+
const defaultOnLog = getDefaultOnLog(printLog, onwarn);
|
|
190
|
+
if (onLog) {
|
|
191
|
+
const minimalPriority = logLevelPriority[logLevel];
|
|
192
|
+
return (level, log) => onLog(level, addLogToString(log), (level$1, handledLog) => {
|
|
193
|
+
if (level$1 === LOG_LEVEL_ERROR) return require_parse_ast_index.error(normalizeLog(handledLog));
|
|
194
|
+
if (logLevelPriority[level$1] >= minimalPriority) defaultOnLog(level$1, normalizeLog(handledLog));
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
return defaultOnLog;
|
|
198
|
+
};
|
|
199
|
+
const getDefaultOnLog = (printLog, onwarn) => onwarn ? (level, log) => {
|
|
200
|
+
if (level === LOG_LEVEL_WARN) onwarn(addLogToString(log), (warning) => printLog(LOG_LEVEL_WARN, normalizeLog(warning)));
|
|
201
|
+
else printLog(level, log);
|
|
202
|
+
} : printLog;
|
|
203
|
+
const addLogToString = (log) => {
|
|
204
|
+
Object.defineProperty(log, "toString", {
|
|
205
|
+
value: () => getExtendedLogMessage(log),
|
|
206
|
+
writable: true
|
|
207
|
+
});
|
|
208
|
+
return log;
|
|
209
|
+
};
|
|
210
|
+
const defaultPrintLog = (level, log) => {
|
|
211
|
+
const message = getExtendedLogMessage(log);
|
|
212
|
+
switch (level) {
|
|
213
|
+
case LOG_LEVEL_WARN: return console.warn(message);
|
|
214
|
+
case LOG_LEVEL_DEBUG: return console.debug(message);
|
|
215
|
+
default: return console.info(message);
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
const getExtendedLogMessage = (log) => {
|
|
219
|
+
let prefix = "";
|
|
220
|
+
if (log.plugin) prefix += `(${log.plugin} plugin) `;
|
|
221
|
+
if (log.loc) prefix += `${relativeId(log.loc.file)} (${log.loc.line}:${log.loc.column}) `;
|
|
222
|
+
return prefix + log.message;
|
|
223
|
+
};
|
|
224
|
+
function relativeId(id) {
|
|
225
|
+
if (!node_path.default.isAbsolute(id)) return id;
|
|
226
|
+
return node_path.default.relative(node_path.default.resolve(), id);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
//#endregion
|
|
230
|
+
//#region src/utils/normalize-hook.ts
|
|
231
|
+
function normalizeHook(hook) {
|
|
232
|
+
if (typeof hook === "function" || typeof hook === "string") return {
|
|
233
|
+
handler: hook,
|
|
234
|
+
options: {},
|
|
235
|
+
meta: {}
|
|
236
|
+
};
|
|
237
|
+
if (typeof hook === "object" && hook !== null) {
|
|
238
|
+
const { handler, order,...options } = hook;
|
|
239
|
+
return {
|
|
240
|
+
handler,
|
|
241
|
+
options,
|
|
242
|
+
meta: { order }
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
unreachable("Invalid hook type");
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
//#endregion
|
|
249
|
+
//#region src/constants/plugin.ts
|
|
250
|
+
const ENUMERATED_INPUT_PLUGIN_HOOK_NAMES = [
|
|
251
|
+
"options",
|
|
252
|
+
"buildStart",
|
|
253
|
+
"resolveId",
|
|
254
|
+
"load",
|
|
255
|
+
"transform",
|
|
256
|
+
"moduleParsed",
|
|
257
|
+
"buildEnd",
|
|
258
|
+
"onLog",
|
|
259
|
+
"resolveDynamicImport",
|
|
260
|
+
"closeBundle",
|
|
261
|
+
"closeWatcher",
|
|
262
|
+
"watchChange"
|
|
263
|
+
];
|
|
264
|
+
const ENUMERATED_OUTPUT_PLUGIN_HOOK_NAMES = [
|
|
265
|
+
"augmentChunkHash",
|
|
266
|
+
"outputOptions",
|
|
267
|
+
"renderChunk",
|
|
268
|
+
"renderStart",
|
|
269
|
+
"renderError",
|
|
270
|
+
"writeBundle",
|
|
271
|
+
"generateBundle"
|
|
272
|
+
];
|
|
273
|
+
const ENUMERATED_PLUGIN_HOOK_NAMES = [
|
|
274
|
+
...ENUMERATED_INPUT_PLUGIN_HOOK_NAMES,
|
|
275
|
+
...ENUMERATED_OUTPUT_PLUGIN_HOOK_NAMES,
|
|
276
|
+
"footer",
|
|
277
|
+
"banner",
|
|
278
|
+
"intro",
|
|
279
|
+
"outro"
|
|
280
|
+
];
|
|
281
|
+
const DEFINED_HOOK_NAMES = {
|
|
282
|
+
[ENUMERATED_PLUGIN_HOOK_NAMES[0]]: ENUMERATED_PLUGIN_HOOK_NAMES[0],
|
|
283
|
+
[ENUMERATED_PLUGIN_HOOK_NAMES[1]]: ENUMERATED_PLUGIN_HOOK_NAMES[1],
|
|
284
|
+
[ENUMERATED_PLUGIN_HOOK_NAMES[2]]: ENUMERATED_PLUGIN_HOOK_NAMES[2],
|
|
285
|
+
[ENUMERATED_PLUGIN_HOOK_NAMES[3]]: ENUMERATED_PLUGIN_HOOK_NAMES[3],
|
|
286
|
+
[ENUMERATED_PLUGIN_HOOK_NAMES[4]]: ENUMERATED_PLUGIN_HOOK_NAMES[4],
|
|
287
|
+
[ENUMERATED_PLUGIN_HOOK_NAMES[5]]: ENUMERATED_PLUGIN_HOOK_NAMES[5],
|
|
288
|
+
[ENUMERATED_PLUGIN_HOOK_NAMES[6]]: ENUMERATED_PLUGIN_HOOK_NAMES[6],
|
|
289
|
+
[ENUMERATED_PLUGIN_HOOK_NAMES[7]]: ENUMERATED_PLUGIN_HOOK_NAMES[7],
|
|
290
|
+
[ENUMERATED_PLUGIN_HOOK_NAMES[8]]: ENUMERATED_PLUGIN_HOOK_NAMES[8],
|
|
291
|
+
[ENUMERATED_PLUGIN_HOOK_NAMES[9]]: ENUMERATED_PLUGIN_HOOK_NAMES[9],
|
|
292
|
+
[ENUMERATED_PLUGIN_HOOK_NAMES[10]]: ENUMERATED_PLUGIN_HOOK_NAMES[10],
|
|
293
|
+
[ENUMERATED_PLUGIN_HOOK_NAMES[11]]: ENUMERATED_PLUGIN_HOOK_NAMES[11],
|
|
294
|
+
[ENUMERATED_PLUGIN_HOOK_NAMES[12]]: ENUMERATED_PLUGIN_HOOK_NAMES[12],
|
|
295
|
+
[ENUMERATED_PLUGIN_HOOK_NAMES[13]]: ENUMERATED_PLUGIN_HOOK_NAMES[13],
|
|
296
|
+
[ENUMERATED_PLUGIN_HOOK_NAMES[14]]: ENUMERATED_PLUGIN_HOOK_NAMES[14],
|
|
297
|
+
[ENUMERATED_PLUGIN_HOOK_NAMES[15]]: ENUMERATED_PLUGIN_HOOK_NAMES[15],
|
|
298
|
+
[ENUMERATED_PLUGIN_HOOK_NAMES[16]]: ENUMERATED_PLUGIN_HOOK_NAMES[16],
|
|
299
|
+
[ENUMERATED_PLUGIN_HOOK_NAMES[17]]: ENUMERATED_PLUGIN_HOOK_NAMES[17],
|
|
300
|
+
[ENUMERATED_PLUGIN_HOOK_NAMES[18]]: ENUMERATED_PLUGIN_HOOK_NAMES[18],
|
|
301
|
+
[ENUMERATED_PLUGIN_HOOK_NAMES[19]]: ENUMERATED_PLUGIN_HOOK_NAMES[19],
|
|
302
|
+
[ENUMERATED_PLUGIN_HOOK_NAMES[20]]: ENUMERATED_PLUGIN_HOOK_NAMES[20],
|
|
303
|
+
[ENUMERATED_PLUGIN_HOOK_NAMES[21]]: ENUMERATED_PLUGIN_HOOK_NAMES[21],
|
|
304
|
+
[ENUMERATED_PLUGIN_HOOK_NAMES[22]]: ENUMERATED_PLUGIN_HOOK_NAMES[22]
|
|
305
|
+
};
|
|
306
|
+
|
|
307
|
+
//#endregion
|
|
308
|
+
//#region src/utils/async-flatten.ts
|
|
309
|
+
async function asyncFlatten(array) {
|
|
310
|
+
do
|
|
311
|
+
array = (await Promise.all(array)).flat(Infinity);
|
|
312
|
+
while (array.some((v) => v?.then));
|
|
313
|
+
return array;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
//#endregion
|
|
317
|
+
//#region src/utils/normalize-plugin-option.ts
|
|
318
|
+
const normalizePluginOption = async (plugins) => (await asyncFlatten([plugins])).filter(Boolean);
|
|
319
|
+
function checkOutputPluginOption(plugins, onLog) {
|
|
320
|
+
for (const plugin of plugins) for (const hook of ENUMERATED_INPUT_PLUGIN_HOOK_NAMES) if (hook in plugin) {
|
|
321
|
+
delete plugin[hook];
|
|
322
|
+
onLog(LOG_LEVEL_WARN, require_parse_ast_index.logInputHookInOutputPlugin(plugin.name, hook));
|
|
323
|
+
}
|
|
324
|
+
return plugins;
|
|
325
|
+
}
|
|
326
|
+
function normalizePlugins(plugins, anonymousPrefix) {
|
|
327
|
+
for (const [index, plugin] of plugins.entries()) {
|
|
328
|
+
if ("_parallel" in plugin) continue;
|
|
329
|
+
if (plugin instanceof BuiltinPlugin) continue;
|
|
330
|
+
if (!plugin.name) plugin.name = `${anonymousPrefix}${index + 1}`;
|
|
331
|
+
}
|
|
332
|
+
return plugins;
|
|
333
|
+
}
|
|
334
|
+
const ANONYMOUS_PLUGIN_PREFIX = "at position ";
|
|
335
|
+
const ANONYMOUS_OUTPUT_PLUGIN_PREFIX = "at output position ";
|
|
336
|
+
|
|
337
|
+
//#endregion
|
|
338
|
+
//#region src/plugin/minimal-plugin-context.ts
|
|
339
|
+
var MinimalPluginContextImpl = class {
|
|
340
|
+
info;
|
|
341
|
+
warn;
|
|
342
|
+
debug;
|
|
343
|
+
meta;
|
|
344
|
+
constructor(onLog, logLevel, pluginName, watchMode, hookName) {
|
|
345
|
+
this.pluginName = pluginName;
|
|
346
|
+
this.hookName = hookName;
|
|
347
|
+
this.debug = getLogHandler(LOG_LEVEL_DEBUG, "PLUGIN_LOG", onLog, pluginName, logLevel);
|
|
348
|
+
this.info = getLogHandler(LOG_LEVEL_INFO, "PLUGIN_LOG", onLog, pluginName, logLevel);
|
|
349
|
+
this.warn = getLogHandler(LOG_LEVEL_WARN, "PLUGIN_WARNING", onLog, pluginName, logLevel);
|
|
350
|
+
this.meta = {
|
|
351
|
+
rollupVersion: "4.23.0",
|
|
352
|
+
rolldownVersion: VERSION,
|
|
353
|
+
watchMode
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
error(e) {
|
|
357
|
+
return require_parse_ast_index.error(require_parse_ast_index.logPluginError(normalizeLog(e), this.pluginName, { hook: this.hookName }));
|
|
358
|
+
}
|
|
359
|
+
};
|
|
360
|
+
|
|
361
|
+
//#endregion
|
|
362
|
+
//#region src/plugin/plugin-driver.ts
|
|
363
|
+
var PluginDriver = class {
|
|
364
|
+
static async callOptionsHook(inputOptions, watchMode = false) {
|
|
365
|
+
const logLevel = inputOptions.logLevel || LOG_LEVEL_INFO;
|
|
366
|
+
const plugins = getSortedPlugins("options", getObjectPlugins(await normalizePluginOption(inputOptions.plugins)));
|
|
367
|
+
const logger = getLogger(plugins, getOnLog(inputOptions, logLevel), logLevel, watchMode);
|
|
368
|
+
for (const plugin of plugins) {
|
|
369
|
+
const name = plugin.name || "unknown";
|
|
370
|
+
const options = plugin.options;
|
|
371
|
+
if (options) {
|
|
372
|
+
const { handler } = normalizeHook(options);
|
|
373
|
+
const result = await handler.call(new MinimalPluginContextImpl(logger, logLevel, name, watchMode, "onLog"), inputOptions);
|
|
374
|
+
if (result) inputOptions = result;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
return inputOptions;
|
|
378
|
+
}
|
|
379
|
+
static callOutputOptionsHook(rawPlugins, outputOptions, onLog, logLevel, watchMode) {
|
|
380
|
+
const sortedPlugins = getSortedPlugins("outputOptions", getObjectPlugins(rawPlugins));
|
|
381
|
+
for (const plugin of sortedPlugins) {
|
|
382
|
+
const name = plugin.name || "unknown";
|
|
383
|
+
const options = plugin.outputOptions;
|
|
384
|
+
if (options) {
|
|
385
|
+
const { handler } = normalizeHook(options);
|
|
386
|
+
const result = handler.call(new MinimalPluginContextImpl(onLog, logLevel, name, watchMode), outputOptions);
|
|
387
|
+
if (result) outputOptions = result;
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
return outputOptions;
|
|
391
|
+
}
|
|
392
|
+
};
|
|
393
|
+
function getObjectPlugins(plugins) {
|
|
394
|
+
return plugins.filter((plugin) => {
|
|
395
|
+
if (!plugin) return void 0;
|
|
396
|
+
if ("_parallel" in plugin) return void 0;
|
|
397
|
+
if (plugin instanceof BuiltinPlugin) return void 0;
|
|
398
|
+
return plugin;
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
function getSortedPlugins(hookName, plugins) {
|
|
402
|
+
const pre = [];
|
|
403
|
+
const normal = [];
|
|
404
|
+
const post = [];
|
|
405
|
+
for (const plugin of plugins) {
|
|
406
|
+
const hook = plugin[hookName];
|
|
407
|
+
if (hook) {
|
|
408
|
+
if (typeof hook === "object") {
|
|
409
|
+
if (hook.order === "pre") {
|
|
410
|
+
pre.push(plugin);
|
|
411
|
+
continue;
|
|
412
|
+
}
|
|
413
|
+
if (hook.order === "post") {
|
|
414
|
+
post.push(plugin);
|
|
415
|
+
continue;
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
normal.push(plugin);
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
return [
|
|
422
|
+
...pre,
|
|
423
|
+
...normal,
|
|
424
|
+
...post
|
|
425
|
+
];
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
//#endregion
|
|
429
|
+
//#region src/utils/validator.ts
|
|
430
|
+
const StringOrRegExpSchema = valibot.union([valibot.string(), valibot.instance(RegExp)]);
|
|
431
|
+
const LogLevelSchema = valibot.union([
|
|
432
|
+
valibot.literal("debug"),
|
|
433
|
+
valibot.literal("info"),
|
|
434
|
+
valibot.literal("warn")
|
|
435
|
+
]);
|
|
436
|
+
const LogLevelOptionSchema = valibot.union([LogLevelSchema, valibot.literal("silent")]);
|
|
437
|
+
const LogLevelWithErrorSchema = valibot.union([LogLevelSchema, valibot.literal("error")]);
|
|
438
|
+
const RollupLogSchema = valibot.any();
|
|
439
|
+
const RollupLogWithStringSchema = valibot.union([RollupLogSchema, valibot.string()]);
|
|
440
|
+
const InputOptionSchema = valibot.union([
|
|
441
|
+
valibot.string(),
|
|
442
|
+
valibot.array(valibot.string()),
|
|
443
|
+
valibot.record(valibot.string(), valibot.string())
|
|
444
|
+
]);
|
|
445
|
+
const ExternalSchema = valibot.union([
|
|
446
|
+
StringOrRegExpSchema,
|
|
447
|
+
valibot.array(StringOrRegExpSchema),
|
|
448
|
+
valibot.pipe(valibot.function(), valibot.args(valibot.tuple([
|
|
449
|
+
valibot.string(),
|
|
450
|
+
valibot.optional(valibot.string()),
|
|
451
|
+
valibot.boolean()
|
|
452
|
+
])), valibot.returns(valibot.nullish(valibot.boolean())))
|
|
453
|
+
]);
|
|
454
|
+
const ModuleTypesSchema = valibot.record(valibot.string(), valibot.union([
|
|
455
|
+
valibot.literal("base64"),
|
|
456
|
+
valibot.literal("binary"),
|
|
457
|
+
valibot.literal("css"),
|
|
458
|
+
valibot.literal("dataurl"),
|
|
459
|
+
valibot.literal("empty"),
|
|
460
|
+
valibot.literal("js"),
|
|
461
|
+
valibot.literal("json"),
|
|
462
|
+
valibot.literal("jsx"),
|
|
463
|
+
valibot.literal("text"),
|
|
464
|
+
valibot.literal("ts"),
|
|
465
|
+
valibot.literal("tsx")
|
|
466
|
+
]));
|
|
467
|
+
const JsxOptionsSchema = valibot.strictObject({
|
|
468
|
+
development: valibot.pipe(valibot.optional(valibot.boolean()), valibot.description("Development specific information")),
|
|
469
|
+
factory: valibot.pipe(valibot.optional(valibot.string()), valibot.description("Jsx element transformation")),
|
|
470
|
+
fragment: valibot.pipe(valibot.optional(valibot.string()), valibot.description("Jsx fragment transformation")),
|
|
471
|
+
importSource: valibot.pipe(valibot.optional(valibot.string()), valibot.description("Import the factory of element and fragment if mode is classic")),
|
|
472
|
+
jsxImportSource: valibot.pipe(valibot.optional(valibot.string()), valibot.description("Import the factory of element and fragment if mode is automatic")),
|
|
473
|
+
mode: valibot.pipe(valibot.optional(valibot.union([
|
|
474
|
+
valibot.literal("classic"),
|
|
475
|
+
valibot.literal("automatic"),
|
|
476
|
+
valibot.literal("preserve")
|
|
477
|
+
])), valibot.description("Jsx transformation mode")),
|
|
478
|
+
refresh: valibot.pipe(valibot.optional(valibot.boolean()), valibot.description("React refresh transformation"))
|
|
479
|
+
});
|
|
480
|
+
const HelperModeSchema = valibot.union([valibot.literal("Runtime"), valibot.literal("External")]);
|
|
481
|
+
const DecoratorOptionSchema = valibot.object({
|
|
482
|
+
legacy: valibot.optional(valibot.boolean()),
|
|
483
|
+
emitDecoratorMetadata: valibot.optional(valibot.boolean())
|
|
484
|
+
});
|
|
485
|
+
const HelpersSchema = valibot.object({ mode: valibot.optional(HelperModeSchema) });
|
|
486
|
+
const RewriteImportExtensionsSchema = valibot.union([
|
|
487
|
+
valibot.literal("rewrite"),
|
|
488
|
+
valibot.literal("remove"),
|
|
489
|
+
valibot.boolean()
|
|
490
|
+
]);
|
|
491
|
+
const TypescriptSchema = valibot.object({
|
|
492
|
+
jsxPragma: valibot.optional(valibot.string()),
|
|
493
|
+
jsxPragmaFrag: valibot.optional(valibot.string()),
|
|
494
|
+
onlyRemoveTypeImports: valibot.optional(valibot.boolean()),
|
|
495
|
+
allowNamespaces: valibot.optional(valibot.boolean()),
|
|
496
|
+
allowDeclareFields: valibot.optional(valibot.boolean()),
|
|
497
|
+
declaration: valibot.optional(valibot.object({
|
|
498
|
+
stripInternal: valibot.optional(valibot.boolean()),
|
|
499
|
+
sourcemap: valibot.optional(valibot.boolean())
|
|
500
|
+
})),
|
|
501
|
+
rewriteImportExtensions: valibot.optional(RewriteImportExtensionsSchema)
|
|
502
|
+
});
|
|
503
|
+
const AssumptionsSchema = valibot.object({
|
|
504
|
+
ignoreFunctionLength: valibot.optional(valibot.boolean()),
|
|
505
|
+
noDocumentAll: valibot.optional(valibot.boolean()),
|
|
506
|
+
objectRestNoSymbols: valibot.optional(valibot.boolean()),
|
|
507
|
+
pureGetters: valibot.optional(valibot.boolean()),
|
|
508
|
+
setPublicClassFields: valibot.optional(valibot.boolean())
|
|
509
|
+
});
|
|
510
|
+
const TransformOptionsSchema = valibot.object({
|
|
511
|
+
assumptions: valibot.optional(AssumptionsSchema),
|
|
512
|
+
typescript: valibot.optional(TypescriptSchema),
|
|
513
|
+
helpers: valibot.optional(HelpersSchema),
|
|
514
|
+
decorators: valibot.optional(DecoratorOptionSchema)
|
|
515
|
+
});
|
|
516
|
+
const WatchOptionsSchema = valibot.strictObject({
|
|
517
|
+
chokidar: valibot.optional(valibot.never(`The "watch.chokidar" option is deprecated, please use "watch.notify" instead of it`)),
|
|
518
|
+
exclude: valibot.optional(valibot.union([StringOrRegExpSchema, valibot.array(StringOrRegExpSchema)])),
|
|
519
|
+
include: valibot.optional(valibot.union([StringOrRegExpSchema, valibot.array(StringOrRegExpSchema)])),
|
|
520
|
+
notify: valibot.pipe(valibot.optional(valibot.strictObject({
|
|
521
|
+
compareContents: valibot.optional(valibot.boolean()),
|
|
522
|
+
pollInterval: valibot.optional(valibot.number())
|
|
523
|
+
})), valibot.description("Notify options")),
|
|
524
|
+
skipWrite: valibot.pipe(valibot.optional(valibot.boolean()), valibot.description("Skip the bundle.write() step")),
|
|
525
|
+
buildDelay: valibot.pipe(valibot.optional(valibot.number()), valibot.description("Throttle watch rebuilds"))
|
|
526
|
+
});
|
|
527
|
+
const ChecksOptionsSchema = valibot.strictObject({
|
|
528
|
+
circularDependency: valibot.pipe(valibot.optional(valibot.boolean()), valibot.description("Whether to emit warning when detecting circular dependency")),
|
|
529
|
+
eval: valibot.pipe(valibot.optional(valibot.boolean()), valibot.description("Whether to emit warning when detecting eval")),
|
|
530
|
+
missingGlobalName: valibot.pipe(valibot.optional(valibot.boolean()), valibot.description("Whether to emit warning when detecting missing global name")),
|
|
531
|
+
missingNameOptionForIifeExport: valibot.pipe(valibot.optional(valibot.boolean()), valibot.description("Whether to emit warning when detecting missing name option for iife export")),
|
|
532
|
+
mixedExport: valibot.pipe(valibot.optional(valibot.boolean()), valibot.description("Whether to emit warning when detecting mixed export")),
|
|
533
|
+
unresolvedEntry: valibot.pipe(valibot.optional(valibot.boolean()), valibot.description("Whether to emit warning when detecting unresolved entry")),
|
|
534
|
+
unresolvedImport: valibot.pipe(valibot.optional(valibot.boolean()), valibot.description("Whether to emit warning when detecting unresolved import")),
|
|
535
|
+
filenameConflict: valibot.pipe(valibot.optional(valibot.boolean()), valibot.description("Whether to emit warning when detecting filename conflict")),
|
|
536
|
+
commonJsVariableInEsm: valibot.pipe(valibot.optional(valibot.boolean()), valibot.description("Whether to emit warning when detecting common js variable in esm")),
|
|
537
|
+
importIsUndefined: valibot.pipe(valibot.optional(valibot.boolean()), valibot.description("Whether to emit warning when detecting import is undefined")),
|
|
538
|
+
configurationFieldConflict: valibot.pipe(valibot.optional(valibot.boolean()), valibot.description("Whether to emit warning when detecting configuration field conflict"))
|
|
539
|
+
});
|
|
540
|
+
const MinifyOptionsSchema = valibot.strictObject({
|
|
541
|
+
mangle: valibot.boolean(),
|
|
542
|
+
compress: valibot.boolean(),
|
|
543
|
+
deadCodeElimination: valibot.boolean(),
|
|
544
|
+
removeWhitespace: valibot.boolean()
|
|
545
|
+
});
|
|
546
|
+
const ResolveOptionsSchema = valibot.strictObject({
|
|
547
|
+
alias: valibot.optional(valibot.record(valibot.string(), valibot.union([valibot.string(), valibot.array(valibot.string())]))),
|
|
548
|
+
aliasFields: valibot.optional(valibot.array(valibot.array(valibot.string()))),
|
|
549
|
+
conditionNames: valibot.optional(valibot.array(valibot.string())),
|
|
550
|
+
extensionAlias: valibot.optional(valibot.record(valibot.string(), valibot.array(valibot.string()))),
|
|
551
|
+
exportsFields: valibot.optional(valibot.array(valibot.array(valibot.string()))),
|
|
552
|
+
extensions: valibot.optional(valibot.array(valibot.string())),
|
|
553
|
+
mainFields: valibot.optional(valibot.array(valibot.string())),
|
|
554
|
+
mainFiles: valibot.optional(valibot.array(valibot.string())),
|
|
555
|
+
modules: valibot.optional(valibot.array(valibot.string())),
|
|
556
|
+
symlinks: valibot.optional(valibot.boolean()),
|
|
557
|
+
tsconfigFilename: valibot.optional(valibot.string())
|
|
558
|
+
});
|
|
559
|
+
const TreeshakingOptionsSchema = valibot.union([valibot.boolean(), valibot.looseObject({
|
|
560
|
+
annotations: valibot.optional(valibot.boolean()),
|
|
561
|
+
manualPureFunctions: valibot.optional(valibot.array(valibot.string())),
|
|
562
|
+
unknownGlobalSideEffects: valibot.optional(valibot.boolean())
|
|
563
|
+
})]);
|
|
564
|
+
const OnLogSchema = valibot.pipe(valibot.function(), valibot.args(valibot.tuple([
|
|
565
|
+
LogLevelSchema,
|
|
566
|
+
RollupLogSchema,
|
|
567
|
+
valibot.pipe(valibot.function(), valibot.args(valibot.tuple([LogLevelWithErrorSchema, RollupLogWithStringSchema])))
|
|
568
|
+
])));
|
|
569
|
+
const OnwarnSchema = valibot.pipe(valibot.function(), valibot.args(valibot.tuple([RollupLogSchema, valibot.pipe(valibot.function(), valibot.args(valibot.tuple([valibot.union([RollupLogWithStringSchema, valibot.pipe(valibot.function(), valibot.returns(RollupLogWithStringSchema))])])))])));
|
|
570
|
+
const HmrSchema = valibot.union([valibot.boolean(), valibot.strictObject({
|
|
571
|
+
port: valibot.optional(valibot.number()),
|
|
572
|
+
host: valibot.optional(valibot.string()),
|
|
573
|
+
implement: valibot.optional(valibot.string())
|
|
574
|
+
})]);
|
|
575
|
+
const InputOptionsSchema = valibot.strictObject({
|
|
576
|
+
input: valibot.optional(InputOptionSchema),
|
|
577
|
+
plugins: valibot.optional(valibot.custom(() => true)),
|
|
578
|
+
external: valibot.optional(ExternalSchema),
|
|
579
|
+
resolve: valibot.optional(ResolveOptionsSchema),
|
|
580
|
+
cwd: valibot.pipe(valibot.optional(valibot.string()), valibot.description("Current working directory")),
|
|
581
|
+
platform: valibot.pipe(valibot.optional(valibot.union([
|
|
582
|
+
valibot.literal("browser"),
|
|
583
|
+
valibot.literal("neutral"),
|
|
584
|
+
valibot.literal("node")
|
|
585
|
+
])), valibot.description(`Platform for which the code should be generated (node, ${ansis.default.underline("browser")}, neutral)`)),
|
|
586
|
+
shimMissingExports: valibot.pipe(valibot.optional(valibot.boolean()), valibot.description("Create shim variables for missing exports")),
|
|
587
|
+
treeshake: valibot.optional(TreeshakingOptionsSchema),
|
|
588
|
+
logLevel: valibot.pipe(valibot.optional(LogLevelOptionSchema), valibot.description(`Log level (${ansis.default.dim("silent")}, ${ansis.default.underline(ansis.default.gray("info"))}, debug, ${ansis.default.yellow("warn")})`)),
|
|
589
|
+
onLog: valibot.optional(OnLogSchema),
|
|
590
|
+
onwarn: valibot.optional(OnwarnSchema),
|
|
591
|
+
moduleTypes: valibot.pipe(valibot.optional(ModuleTypesSchema), valibot.description("Module types for customized extensions")),
|
|
592
|
+
experimental: valibot.optional(valibot.strictObject({
|
|
593
|
+
disableLiveBindings: valibot.optional(valibot.boolean()),
|
|
594
|
+
enableComposingJsPlugins: valibot.optional(valibot.boolean()),
|
|
595
|
+
resolveNewUrlToAsset: valibot.optional(valibot.boolean()),
|
|
596
|
+
strictExecutionOrder: valibot.optional(valibot.boolean()),
|
|
597
|
+
hmr: valibot.optional(HmrSchema)
|
|
598
|
+
})),
|
|
599
|
+
define: valibot.pipe(valibot.optional(valibot.record(valibot.string(), valibot.string())), valibot.description("Define global variables")),
|
|
600
|
+
inject: valibot.optional(valibot.record(valibot.string(), valibot.union([valibot.string(), valibot.tuple([valibot.string(), valibot.string()])]))),
|
|
601
|
+
profilerNames: valibot.optional(valibot.boolean()),
|
|
602
|
+
jsx: valibot.optional(valibot.union([
|
|
603
|
+
valibot.boolean(),
|
|
604
|
+
JsxOptionsSchema,
|
|
605
|
+
valibot.string("react"),
|
|
606
|
+
valibot.string("react-jsx"),
|
|
607
|
+
valibot.string("preserve")
|
|
608
|
+
])),
|
|
609
|
+
transform: valibot.optional(TransformOptionsSchema),
|
|
610
|
+
watch: valibot.optional(valibot.union([WatchOptionsSchema, valibot.literal(false)])),
|
|
611
|
+
dropLabels: valibot.pipe(valibot.optional(valibot.array(valibot.string())), valibot.description("Remove labeled statements with these label names")),
|
|
612
|
+
checks: valibot.optional(ChecksOptionsSchema),
|
|
613
|
+
keepNames: valibot.pipe(valibot.optional(valibot.boolean()), valibot.description("Keep function/class name")),
|
|
614
|
+
debug: valibot.pipe(valibot.optional(valibot.object({ buildId: valibot.pipe(valibot.optional(valibot.string()), valibot.description("Used to name the build.")) })), valibot.description("Enable debug mode. Emit debug information to disk. This might slow down the build process significantly."))
|
|
615
|
+
});
|
|
616
|
+
const InputCliOverrideSchema = valibot.strictObject({
|
|
617
|
+
external: valibot.pipe(valibot.optional(valibot.array(valibot.string())), valibot.description("Comma-separated list of module ids to exclude from the bundle `<module-id>,...`")),
|
|
618
|
+
inject: valibot.pipe(valibot.optional(valibot.record(valibot.string(), valibot.string())), valibot.description("Inject import statements on demand")),
|
|
619
|
+
treeshake: valibot.pipe(valibot.optional(valibot.boolean()), valibot.description("enable treeshaking")),
|
|
620
|
+
jsx: valibot.pipe(valibot.optional(JsxOptionsSchema), valibot.description("enable jsx"))
|
|
621
|
+
});
|
|
622
|
+
const InputCliOptionsSchema = valibot.omit(valibot.strictObject({
|
|
623
|
+
...InputOptionsSchema.entries,
|
|
624
|
+
...InputCliOverrideSchema.entries
|
|
625
|
+
}), [
|
|
626
|
+
"input",
|
|
627
|
+
"plugins",
|
|
628
|
+
"onwarn",
|
|
629
|
+
"onLog",
|
|
630
|
+
"resolve",
|
|
631
|
+
"experimental",
|
|
632
|
+
"profilerNames",
|
|
633
|
+
"watch"
|
|
634
|
+
]);
|
|
635
|
+
var ESTarget = /* @__PURE__ */ function(ESTarget$1) {
|
|
636
|
+
ESTarget$1["ES6"] = "es6";
|
|
637
|
+
ESTarget$1["ES2015"] = "es2015";
|
|
638
|
+
ESTarget$1["ES2016"] = "es2016";
|
|
639
|
+
ESTarget$1["ES2017"] = "es2017";
|
|
640
|
+
ESTarget$1["ES2018"] = "es2018";
|
|
641
|
+
ESTarget$1["ES2019"] = "es2019";
|
|
642
|
+
ESTarget$1["ES2020"] = "es2020";
|
|
643
|
+
ESTarget$1["ES2021"] = "es2021";
|
|
644
|
+
ESTarget$1["ES2022"] = "es2022";
|
|
645
|
+
ESTarget$1["ES2023"] = "es2023";
|
|
646
|
+
ESTarget$1["ES2024"] = "es2024";
|
|
647
|
+
ESTarget$1["ESNext"] = "esnext";
|
|
648
|
+
return ESTarget$1;
|
|
649
|
+
}(ESTarget || {});
|
|
650
|
+
const ModuleFormatSchema = valibot.union([
|
|
651
|
+
valibot.literal("es"),
|
|
652
|
+
valibot.literal("cjs"),
|
|
653
|
+
valibot.literal("esm"),
|
|
654
|
+
valibot.literal("module"),
|
|
655
|
+
valibot.literal("commonjs"),
|
|
656
|
+
valibot.literal("iife"),
|
|
657
|
+
valibot.literal("umd")
|
|
658
|
+
]);
|
|
659
|
+
const AddonFunctionSchema = valibot.pipe(valibot.function(), valibot.args(valibot.tuple([valibot.custom(() => true)])), valibot.returnsAsync(valibot.unionAsync([valibot.string(), valibot.pipeAsync(valibot.promise(), valibot.awaitAsync(), valibot.string())])));
|
|
660
|
+
const ChunkFileNamesSchema = valibot.union([valibot.string(), valibot.pipe(valibot.function(), valibot.args(valibot.tuple([valibot.custom(() => true)])), valibot.returns(valibot.string()))]);
|
|
661
|
+
const AssetFileNamesSchema = valibot.union([valibot.string(), valibot.pipe(valibot.function(), valibot.args(valibot.tuple([valibot.custom(() => true)])), valibot.returns(valibot.string()))]);
|
|
662
|
+
const SanitizeFileNameSchema = valibot.union([valibot.boolean(), valibot.pipe(valibot.function(), valibot.args(valibot.tuple([valibot.string()])), valibot.returns(valibot.string()))]);
|
|
663
|
+
const GlobalsFunctionSchema = valibot.pipe(valibot.function(), valibot.args(valibot.tuple([valibot.string()])), valibot.returns(valibot.string()));
|
|
664
|
+
const AdvancedChunksSchema = valibot.strictObject({
|
|
665
|
+
minSize: valibot.optional(valibot.number()),
|
|
666
|
+
maxSize: valibot.optional(valibot.number()),
|
|
667
|
+
minModuleSize: valibot.optional(valibot.number()),
|
|
668
|
+
maxModuleSize: valibot.optional(valibot.number()),
|
|
669
|
+
minShareCount: valibot.optional(valibot.number()),
|
|
670
|
+
groups: valibot.optional(valibot.array(valibot.strictObject({
|
|
671
|
+
name: valibot.string(),
|
|
672
|
+
test: valibot.optional(valibot.union([valibot.string(), valibot.instance(RegExp)])),
|
|
673
|
+
priority: valibot.optional(valibot.number()),
|
|
674
|
+
minSize: valibot.optional(valibot.number()),
|
|
675
|
+
minShareCount: valibot.optional(valibot.number()),
|
|
676
|
+
maxSize: valibot.optional(valibot.number()),
|
|
677
|
+
minModuleSize: valibot.optional(valibot.number()),
|
|
678
|
+
maxModuleSize: valibot.optional(valibot.number())
|
|
679
|
+
})))
|
|
680
|
+
});
|
|
681
|
+
const OutputOptionsSchema = valibot.strictObject({
|
|
682
|
+
dir: valibot.pipe(valibot.optional(valibot.string()), valibot.description("Output directory, defaults to `dist` if `file` is not set")),
|
|
683
|
+
file: valibot.pipe(valibot.optional(valibot.string()), valibot.description("Single output file")),
|
|
684
|
+
exports: valibot.pipe(valibot.optional(valibot.union([
|
|
685
|
+
valibot.literal("auto"),
|
|
686
|
+
valibot.literal("named"),
|
|
687
|
+
valibot.literal("default"),
|
|
688
|
+
valibot.literal("none")
|
|
689
|
+
])), valibot.description(`Specify a export mode (${ansis.default.underline("auto")}, named, default, none)`)),
|
|
690
|
+
hashCharacters: valibot.pipe(valibot.optional(valibot.union([
|
|
691
|
+
valibot.literal("base64"),
|
|
692
|
+
valibot.literal("base36"),
|
|
693
|
+
valibot.literal("hex")
|
|
694
|
+
])), valibot.description("Use the specified character set for file hashes")),
|
|
695
|
+
format: valibot.pipe(valibot.optional(ModuleFormatSchema), valibot.description(`Output format of the generated bundle (supports ${ansis.default.underline("esm")}, cjs, and iife)`)),
|
|
696
|
+
sourcemap: valibot.pipe(valibot.optional(valibot.union([
|
|
697
|
+
valibot.boolean(),
|
|
698
|
+
valibot.literal("inline"),
|
|
699
|
+
valibot.literal("hidden")
|
|
700
|
+
])), valibot.description(`Generate sourcemap (\`-s inline\` for inline, or ${ansis.default.bold("pass the `-s` on the last argument if you want to generate `.map` file")})`)),
|
|
701
|
+
sourcemapDebugIds: valibot.pipe(valibot.optional(valibot.boolean()), valibot.description("Inject sourcemap debug IDs")),
|
|
702
|
+
sourcemapIgnoreList: valibot.optional(valibot.union([valibot.boolean(), valibot.custom(() => true)])),
|
|
703
|
+
sourcemapPathTransform: valibot.optional(valibot.custom(() => true)),
|
|
704
|
+
banner: valibot.optional(valibot.union([valibot.string(), AddonFunctionSchema])),
|
|
705
|
+
footer: valibot.optional(valibot.union([valibot.string(), AddonFunctionSchema])),
|
|
706
|
+
intro: valibot.optional(valibot.union([valibot.string(), AddonFunctionSchema])),
|
|
707
|
+
outro: valibot.optional(valibot.union([valibot.string(), AddonFunctionSchema])),
|
|
708
|
+
extend: valibot.pipe(valibot.optional(valibot.boolean()), valibot.description("Extend global variable defined by name in IIFE / UMD formats")),
|
|
709
|
+
esModule: valibot.optional(valibot.union([valibot.boolean(), valibot.literal("if-default-prop")])),
|
|
710
|
+
assetFileNames: valibot.optional(AssetFileNamesSchema),
|
|
711
|
+
entryFileNames: valibot.optional(ChunkFileNamesSchema),
|
|
712
|
+
chunkFileNames: valibot.optional(ChunkFileNamesSchema),
|
|
713
|
+
cssEntryFileNames: valibot.optional(ChunkFileNamesSchema),
|
|
714
|
+
cssChunkFileNames: valibot.optional(ChunkFileNamesSchema),
|
|
715
|
+
sanitizeFileName: valibot.optional(SanitizeFileNameSchema),
|
|
716
|
+
minify: valibot.pipe(valibot.optional(valibot.union([
|
|
717
|
+
valibot.boolean(),
|
|
718
|
+
valibot.string("dce-only"),
|
|
719
|
+
MinifyOptionsSchema
|
|
720
|
+
])), valibot.description("Minify the bundled file")),
|
|
721
|
+
name: valibot.pipe(valibot.optional(valibot.string()), valibot.description("Name for UMD / IIFE format outputs")),
|
|
722
|
+
globals: valibot.pipe(valibot.optional(valibot.union([valibot.record(valibot.string(), valibot.string()), GlobalsFunctionSchema])), valibot.description("Global variable of UMD / IIFE dependencies (syntax: `key=value`)")),
|
|
723
|
+
externalLiveBindings: valibot.pipe(valibot.optional(valibot.boolean()), valibot.description("external live bindings")),
|
|
724
|
+
inlineDynamicImports: valibot.pipe(valibot.optional(valibot.boolean()), valibot.description("Inline dynamic imports")),
|
|
725
|
+
advancedChunks: valibot.optional(AdvancedChunksSchema),
|
|
726
|
+
comments: valibot.pipe(valibot.optional(valibot.union([valibot.literal("none"), valibot.literal("preserve-legal")])), valibot.description("Control comments in the output")),
|
|
727
|
+
target: valibot.pipe(valibot.optional(valibot.enum(ESTarget)), valibot.description("The JavaScript target environment")),
|
|
728
|
+
plugins: valibot.optional(valibot.custom(() => true))
|
|
729
|
+
});
|
|
730
|
+
const getAddonDescription = (placement, wrapper) => {
|
|
731
|
+
return `Code to insert the ${ansis.default.bold(placement)} of the bundled file (${ansis.default.bold(wrapper)} the wrapper function)`;
|
|
732
|
+
};
|
|
733
|
+
const OutputCliOverrideSchema = valibot.strictObject({
|
|
734
|
+
assetFileNames: valibot.pipe(valibot.optional(valibot.string()), valibot.description("Name pattern for asset files")),
|
|
735
|
+
entryFileNames: valibot.pipe(valibot.optional(valibot.string()), valibot.description("Name pattern for emitted entry chunks")),
|
|
736
|
+
chunkFileNames: valibot.pipe(valibot.optional(valibot.string()), valibot.description("Name pattern for emitted secondary chunks")),
|
|
737
|
+
cssEntryFileNames: valibot.pipe(valibot.optional(valibot.string()), valibot.description("Name pattern for emitted css entry chunks")),
|
|
738
|
+
cssChunkFileNames: valibot.pipe(valibot.optional(valibot.string()), valibot.description("Name pattern for emitted css secondary chunks")),
|
|
739
|
+
sanitizeFileName: valibot.pipe(valibot.optional(valibot.boolean()), valibot.description("Sanitize file name")),
|
|
740
|
+
banner: valibot.pipe(valibot.optional(valibot.string()), valibot.description(getAddonDescription("top", "outside"))),
|
|
741
|
+
footer: valibot.pipe(valibot.optional(valibot.string()), valibot.description(getAddonDescription("bottom", "outside"))),
|
|
742
|
+
intro: valibot.pipe(valibot.optional(valibot.string()), valibot.description(getAddonDescription("top", "inside"))),
|
|
743
|
+
outro: valibot.pipe(valibot.optional(valibot.string()), valibot.description(getAddonDescription("bottom", "inside"))),
|
|
744
|
+
esModule: valibot.pipe(valibot.optional(valibot.boolean()), valibot.description("Always generate `__esModule` marks in non-ESM formats, defaults to `if-default-prop` (use `--no-esModule` to always disable)")),
|
|
745
|
+
globals: valibot.pipe(valibot.optional(valibot.record(valibot.string(), valibot.string())), valibot.description("Global variable of UMD / IIFE dependencies (syntax: `key=value`)")),
|
|
746
|
+
advancedChunks: valibot.pipe(valibot.optional(valibot.strictObject({
|
|
747
|
+
minSize: valibot.pipe(valibot.optional(valibot.number()), valibot.description("Minimum size of the chunk")),
|
|
748
|
+
minShareCount: valibot.pipe(valibot.optional(valibot.number()), valibot.description("Minimum share count of the chunk"))
|
|
749
|
+
})), valibot.description("Global variable of UMD / IIFE dependencies (syntax: `key=value`)")),
|
|
750
|
+
minify: valibot.pipe(valibot.optional(valibot.boolean()), valibot.description("Minify the bundled file"))
|
|
751
|
+
});
|
|
752
|
+
const OutputCliOptionsSchema = valibot.omit(valibot.strictObject({
|
|
753
|
+
...OutputOptionsSchema.entries,
|
|
754
|
+
...OutputCliOverrideSchema.entries
|
|
755
|
+
}), [
|
|
756
|
+
"sourcemapIgnoreList",
|
|
757
|
+
"sourcemapPathTransform",
|
|
758
|
+
"plugins"
|
|
759
|
+
]);
|
|
760
|
+
const CliOptionsSchema = valibot.strictObject({
|
|
761
|
+
config: valibot.pipe(valibot.optional(valibot.union([valibot.string(), valibot.boolean()])), valibot.description("Path to the config file (default: `rolldown.config.js`)")),
|
|
762
|
+
help: valibot.pipe(valibot.optional(valibot.boolean()), valibot.description("Show help")),
|
|
763
|
+
version: valibot.pipe(valibot.optional(valibot.boolean()), valibot.description("Show version number")),
|
|
764
|
+
watch: valibot.pipe(valibot.optional(valibot.boolean()), valibot.description("Watch files in bundle and rebuild on changes")),
|
|
765
|
+
...InputCliOptionsSchema.entries,
|
|
766
|
+
...OutputCliOptionsSchema.entries
|
|
767
|
+
});
|
|
768
|
+
function validateCliOptions(options) {
|
|
769
|
+
let parsed = valibot.safeParse(CliOptionsSchema, options);
|
|
770
|
+
return [parsed.output, parsed.issues?.map((issue) => {
|
|
771
|
+
const option = issue.path?.map((pathItem) => pathItem.key).join(" ");
|
|
772
|
+
return `Invalid value for option ${option}: ${issue.message}`;
|
|
773
|
+
})];
|
|
774
|
+
}
|
|
775
|
+
const inputHelperMsgRecord = { output: { ignored: true } };
|
|
776
|
+
const outputHelperMsgRecord = {};
|
|
777
|
+
function validateOption(key, options) {
|
|
778
|
+
if (globalThis.process?.env?.ROLLDOWN_OPTIONS_VALIDATION === "loose") return;
|
|
779
|
+
let parsed = valibot.safeParse(key === "input" ? InputOptionsSchema : OutputOptionsSchema, options);
|
|
780
|
+
if (!parsed.success) {
|
|
781
|
+
const errors = parsed.issues.map((issue) => {
|
|
782
|
+
const issuePaths = issue.path.map((path$2) => path$2.key);
|
|
783
|
+
let issueMsg = issue.message;
|
|
784
|
+
if (issue.type === "union") {
|
|
785
|
+
const subIssue = issue.issues?.find((i) => !(i.type !== issue.received && i.input === issue.input));
|
|
786
|
+
if (subIssue) {
|
|
787
|
+
if (subIssue.path) issuePaths.push(subIssue.path.map((path$2) => path$2.key));
|
|
788
|
+
issueMsg = subIssue.message;
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
const stringPath = issuePaths.join(".");
|
|
792
|
+
const helper = key === "input" ? inputHelperMsgRecord[stringPath] : outputHelperMsgRecord[stringPath];
|
|
793
|
+
if (helper && helper.ignored) return "";
|
|
794
|
+
return `- For the "${stringPath}". ${issueMsg}. ${helper ? helper.msg : ""}`;
|
|
795
|
+
}).filter(Boolean);
|
|
796
|
+
if (errors.length) throw new Error(`Failed validate ${key} options.\n` + errors.join("\n"));
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
function getInputCliKeys() {
|
|
800
|
+
return valibot.keyof(InputCliOptionsSchema).options;
|
|
801
|
+
}
|
|
802
|
+
function getOutputCliKeys() {
|
|
803
|
+
return valibot.keyof(OutputCliOptionsSchema).options;
|
|
804
|
+
}
|
|
805
|
+
function getJsonSchema() {
|
|
806
|
+
return (0, __valibot_to_json_schema.toJsonSchema)(CliOptionsSchema);
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
//#endregion
|
|
810
|
+
//#region src/constants/plugin-context.ts
|
|
811
|
+
const SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF = Symbol("plugin-context-resolve-caller");
|
|
812
|
+
|
|
813
|
+
//#endregion
|
|
814
|
+
//#region src/options/normalized-input-options.ts
|
|
815
|
+
var NormalizedInputOptionsImpl = class {
|
|
816
|
+
inner;
|
|
817
|
+
constructor(inner, onLog) {
|
|
818
|
+
this.onLog = onLog;
|
|
819
|
+
this.inner = inner;
|
|
820
|
+
}
|
|
821
|
+
get shimMissingExports() {
|
|
822
|
+
return this.inner.shimMissingExports;
|
|
823
|
+
}
|
|
824
|
+
get input() {
|
|
825
|
+
return this.inner.input;
|
|
826
|
+
}
|
|
827
|
+
get cwd() {
|
|
828
|
+
return this.inner.cwd ?? void 0;
|
|
829
|
+
}
|
|
830
|
+
get platform() {
|
|
831
|
+
return this.inner.platform;
|
|
832
|
+
}
|
|
833
|
+
};
|
|
834
|
+
|
|
835
|
+
//#endregion
|
|
836
|
+
//#region src/types/sourcemap.ts
|
|
837
|
+
function bindingifySourcemap$1(map) {
|
|
838
|
+
if (map == null) return;
|
|
839
|
+
return { inner: typeof map === "string" ? map : {
|
|
840
|
+
file: map.file ?? void 0,
|
|
841
|
+
mappings: map.mappings,
|
|
842
|
+
sourceRoot: "sourceRoot" in map ? map.sourceRoot ?? void 0 : void 0,
|
|
843
|
+
sources: map.sources?.map((s) => s ?? void 0),
|
|
844
|
+
sourcesContent: map.sourcesContent?.map((s) => s ?? void 0),
|
|
845
|
+
names: map.names,
|
|
846
|
+
x_google_ignoreList: map.x_google_ignoreList,
|
|
847
|
+
debugId: "debugId" in map ? map.debugId : void 0
|
|
848
|
+
} };
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
//#endregion
|
|
852
|
+
//#region src/utils/error.ts
|
|
853
|
+
function normalizeErrors(rawErrors) {
|
|
854
|
+
const errors = rawErrors.map((e) => e instanceof Error ? e : Object.assign(new Error(), {
|
|
855
|
+
kind: e.kind,
|
|
856
|
+
message: e.message,
|
|
857
|
+
stack: void 0
|
|
858
|
+
}));
|
|
859
|
+
let summary = `Build failed with ${errors.length} error${errors.length < 2 ? "" : "s"}:\n`;
|
|
860
|
+
for (let i = 0; i < errors.length; i++) {
|
|
861
|
+
summary += "\n";
|
|
862
|
+
if (i >= 5) {
|
|
863
|
+
summary += "...";
|
|
864
|
+
break;
|
|
865
|
+
}
|
|
866
|
+
summary += getErrorMessage(errors[i]);
|
|
867
|
+
}
|
|
868
|
+
const wrapper = new Error(summary);
|
|
869
|
+
Object.defineProperty(wrapper, "errors", {
|
|
870
|
+
configurable: true,
|
|
871
|
+
enumerable: true,
|
|
872
|
+
get: () => errors,
|
|
873
|
+
set: (value) => Object.defineProperty(wrapper, "errors", {
|
|
874
|
+
configurable: true,
|
|
875
|
+
enumerable: true,
|
|
876
|
+
value
|
|
877
|
+
})
|
|
878
|
+
});
|
|
879
|
+
return wrapper;
|
|
880
|
+
}
|
|
881
|
+
function getErrorMessage(e) {
|
|
882
|
+
if (Object.hasOwn(e, "kind")) return e.message;
|
|
883
|
+
let s = "";
|
|
884
|
+
if (e.plugin) s += `[plugin ${e.plugin}]`;
|
|
885
|
+
const id = e.id ?? e.loc?.file;
|
|
886
|
+
if (id) {
|
|
887
|
+
s += " " + id;
|
|
888
|
+
if (e.loc) s += `:${e.loc.line}:${e.loc.column}`;
|
|
889
|
+
}
|
|
890
|
+
if (s) s += "\n";
|
|
891
|
+
const message = `${e.name ?? "Error"}: ${e.message}`;
|
|
892
|
+
s += message;
|
|
893
|
+
if (e.frame) s = joinNewLine(s, e.frame);
|
|
894
|
+
if (e.stack) s = joinNewLine(s, e.stack.replace(message, ""));
|
|
895
|
+
return s;
|
|
896
|
+
}
|
|
897
|
+
function joinNewLine(s1, s2) {
|
|
898
|
+
return s1.replace(/\n+$/, "") + "\n" + s2.replace(/^\n+/, "");
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
//#endregion
|
|
902
|
+
//#region src/utils/resolved-external.ts
|
|
903
|
+
function transformResolvedExternal(bindingResolvedExternal$1) {
|
|
904
|
+
switch (bindingResolvedExternal$1.type) {
|
|
905
|
+
case "Bool": return bindingResolvedExternal$1.field0;
|
|
906
|
+
case "Absolute": return "absolute";
|
|
907
|
+
case "Relative": unreachable(`The PluginContext resolve result external couldn't be 'relative'`);
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
function bindingResolvedExternal(external) {
|
|
911
|
+
if (typeof external === "boolean") return {
|
|
912
|
+
type: "Bool",
|
|
913
|
+
field0: external
|
|
914
|
+
};
|
|
915
|
+
if (external === "absolute") return { type: "Absolute" };
|
|
916
|
+
if (external === "relative") return { type: "Relative" };
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
//#endregion
|
|
920
|
+
//#region src/utils/transform-module-info.ts
|
|
921
|
+
function transformModuleInfo(info, option) {
|
|
922
|
+
return {
|
|
923
|
+
get ast() {
|
|
924
|
+
return unsupported("ModuleInfo#ast");
|
|
925
|
+
},
|
|
926
|
+
get code() {
|
|
927
|
+
return info.code;
|
|
928
|
+
},
|
|
929
|
+
id: info.id,
|
|
930
|
+
importers: info.importers,
|
|
931
|
+
dynamicImporters: info.dynamicImporters,
|
|
932
|
+
importedIds: info.importedIds,
|
|
933
|
+
dynamicallyImportedIds: info.dynamicallyImportedIds,
|
|
934
|
+
exports: info.exports,
|
|
935
|
+
isEntry: info.isEntry,
|
|
936
|
+
...option
|
|
937
|
+
};
|
|
938
|
+
}
|
|
939
|
+
|
|
940
|
+
//#endregion
|
|
941
|
+
//#region src/utils/transform-side-effects.ts
|
|
942
|
+
function bindingifySideEffects(sideEffects) {
|
|
943
|
+
switch (sideEffects) {
|
|
944
|
+
case true: return src_rolldown_binding_wasi_cjs.BindingHookSideEffects.True;
|
|
945
|
+
case false: return src_rolldown_binding_wasi_cjs.BindingHookSideEffects.False;
|
|
946
|
+
case "no-treeshake": return src_rolldown_binding_wasi_cjs.BindingHookSideEffects.NoTreeshake;
|
|
947
|
+
case null:
|
|
948
|
+
case void 0: return void 0;
|
|
949
|
+
default: throw new Error(`Unexpected side effects: ${sideEffects}`);
|
|
950
|
+
}
|
|
951
|
+
}
|
|
952
|
+
|
|
953
|
+
//#endregion
|
|
954
|
+
//#region src/utils/transform-sourcemap.ts
|
|
955
|
+
function isEmptySourcemapFiled(array) {
|
|
956
|
+
if (!array) return true;
|
|
957
|
+
if (array.length === 0 || !array[0]) return true;
|
|
958
|
+
return false;
|
|
959
|
+
}
|
|
960
|
+
function normalizeTransformHookSourcemap(id, originalCode, rawMap) {
|
|
961
|
+
if (!rawMap) return;
|
|
962
|
+
let map = typeof rawMap === "object" ? rawMap : JSON.parse(rawMap);
|
|
963
|
+
if (isEmptySourcemapFiled(map.sourcesContent)) map.sourcesContent = [originalCode];
|
|
964
|
+
if (isEmptySourcemapFiled(map.sources) || map.sources && map.sources.length === 1 && map.sources[0] !== id) map.sources = [id];
|
|
965
|
+
return map;
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
//#endregion
|
|
969
|
+
//#region src/plugin/bindingify-hook-filter.ts
|
|
970
|
+
function bindingifyStringFilter(matcher) {
|
|
971
|
+
if (typeof matcher === "string" || matcher instanceof RegExp) return { include: [matcher] };
|
|
972
|
+
if (Array.isArray(matcher)) return { include: matcher };
|
|
973
|
+
return {
|
|
974
|
+
include: matcher.include ? arraify(matcher.include) : void 0,
|
|
975
|
+
exclude: matcher.exclude ? arraify(matcher.exclude) : void 0
|
|
976
|
+
};
|
|
977
|
+
}
|
|
978
|
+
function bindingifyResolveIdFilter(filterOption) {
|
|
979
|
+
return filterOption?.id ? bindingifyStringFilter(filterOption.id) : void 0;
|
|
980
|
+
}
|
|
981
|
+
function bindingifyLoadFilter(filterOption) {
|
|
982
|
+
return filterOption?.id ? bindingifyStringFilter(filterOption.id) : void 0;
|
|
983
|
+
}
|
|
984
|
+
function bindingifyTransformFilter(filterOption) {
|
|
985
|
+
if (!filterOption) return void 0;
|
|
986
|
+
const { id, code, moduleType } = filterOption;
|
|
987
|
+
let moduleTypeRet;
|
|
988
|
+
if (moduleType) if (Array.isArray(moduleType)) moduleTypeRet = moduleType;
|
|
989
|
+
else moduleTypeRet = moduleType.include;
|
|
990
|
+
return {
|
|
991
|
+
id: id ? bindingifyStringFilter(id) : void 0,
|
|
992
|
+
code: code ? bindingifyStringFilter(code) : void 0,
|
|
993
|
+
moduleType: moduleTypeRet
|
|
994
|
+
};
|
|
995
|
+
}
|
|
996
|
+
|
|
997
|
+
//#endregion
|
|
998
|
+
//#region src/plugin/bindingify-plugin-hook-meta.ts
|
|
999
|
+
function bindingifyPluginHookMeta(options) {
|
|
1000
|
+
return { order: bindingPluginOrder(options.order) };
|
|
1001
|
+
}
|
|
1002
|
+
function bindingPluginOrder(order) {
|
|
1003
|
+
switch (order) {
|
|
1004
|
+
case "post": return src_rolldown_binding_wasi_cjs.BindingPluginOrder.Post;
|
|
1005
|
+
case "pre": return src_rolldown_binding_wasi_cjs.BindingPluginOrder.Pre;
|
|
1006
|
+
case null:
|
|
1007
|
+
case void 0: return void 0;
|
|
1008
|
+
default: throw new Error(`Unknown plugin order: ${order}`);
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
1011
|
+
|
|
1012
|
+
//#endregion
|
|
1013
|
+
//#region src/utils/asset-source.ts
|
|
1014
|
+
function transformAssetSource(bindingAssetSource$1) {
|
|
1015
|
+
return bindingAssetSource$1.inner;
|
|
1016
|
+
}
|
|
1017
|
+
function bindingAssetSource(source) {
|
|
1018
|
+
return { inner: source };
|
|
1019
|
+
}
|
|
1020
|
+
|
|
1021
|
+
//#endregion
|
|
1022
|
+
//#region src/plugin/plugin-context.ts
|
|
1023
|
+
var PluginContextImpl = class extends MinimalPluginContextImpl {
|
|
1024
|
+
getModuleInfo;
|
|
1025
|
+
constructor(outputOptions, context, plugin, data, onLog, logLevel, watchMode, currentLoadingModule) {
|
|
1026
|
+
super(onLog, logLevel, plugin.name, watchMode);
|
|
1027
|
+
this.outputOptions = outputOptions;
|
|
1028
|
+
this.context = context;
|
|
1029
|
+
this.data = data;
|
|
1030
|
+
this.onLog = onLog;
|
|
1031
|
+
this.currentLoadingModule = currentLoadingModule;
|
|
1032
|
+
this.getModuleInfo = (id) => this.data.getModuleInfo(id, context);
|
|
1033
|
+
}
|
|
1034
|
+
async load(options) {
|
|
1035
|
+
const id = options.id;
|
|
1036
|
+
if (id === this.currentLoadingModule) this.onLog(LOG_LEVEL_WARN, require_parse_ast_index.logCycleLoading(this.pluginName, this.currentLoadingModule));
|
|
1037
|
+
const moduleInfo = this.data.getModuleInfo(id, this.context);
|
|
1038
|
+
if (moduleInfo && moduleInfo.code !== null) return moduleInfo;
|
|
1039
|
+
const rawOptions = {
|
|
1040
|
+
meta: options.meta || {},
|
|
1041
|
+
moduleSideEffects: options.moduleSideEffects || null,
|
|
1042
|
+
invalidate: false
|
|
1043
|
+
};
|
|
1044
|
+
this.data.updateModuleOption(id, rawOptions);
|
|
1045
|
+
async function createLoadModulePromise(context, data) {
|
|
1046
|
+
const loadPromise = data.loadModulePromiseMap.get(id);
|
|
1047
|
+
if (loadPromise) return loadPromise;
|
|
1048
|
+
let resolveFn;
|
|
1049
|
+
const promise = new Promise((resolve, _) => {
|
|
1050
|
+
resolveFn = resolve;
|
|
1051
|
+
});
|
|
1052
|
+
data.loadModulePromiseMap.set(id, promise);
|
|
1053
|
+
try {
|
|
1054
|
+
await context.load(id, bindingifySideEffects(options.moduleSideEffects), (_success) => {
|
|
1055
|
+
resolveFn();
|
|
1056
|
+
});
|
|
1057
|
+
} finally {
|
|
1058
|
+
data.loadModulePromiseMap.delete(id);
|
|
1059
|
+
}
|
|
1060
|
+
return promise;
|
|
1061
|
+
}
|
|
1062
|
+
await createLoadModulePromise(this.context, this.data);
|
|
1063
|
+
return this.data.getModuleInfo(id, this.context);
|
|
1064
|
+
}
|
|
1065
|
+
async resolve(source, importer, options) {
|
|
1066
|
+
let receipt = void 0;
|
|
1067
|
+
if (options != null) receipt = this.data.saveResolveOptions(options);
|
|
1068
|
+
const res = await this.context.resolve(source, importer, {
|
|
1069
|
+
custom: receipt,
|
|
1070
|
+
skipSelf: options?.skipSelf
|
|
1071
|
+
});
|
|
1072
|
+
if (receipt != null) this.data.removeSavedResolveOptions(receipt);
|
|
1073
|
+
if (res == null) return null;
|
|
1074
|
+
const info = this.data.getModuleOption(res.id) || {};
|
|
1075
|
+
return {
|
|
1076
|
+
...res,
|
|
1077
|
+
external: transformResolvedExternal(res.external),
|
|
1078
|
+
...info
|
|
1079
|
+
};
|
|
1080
|
+
}
|
|
1081
|
+
emitFile = (file) => {
|
|
1082
|
+
if (file.type === "prebuilt-chunk") return unimplemented("PluginContext.emitFile with type prebuilt-chunk");
|
|
1083
|
+
if (file.type === "chunk") return this.context.emitChunk(file);
|
|
1084
|
+
const fnSanitizedFileName = file.fileName || typeof this.outputOptions.sanitizeFileName !== "function" ? void 0 : this.outputOptions.sanitizeFileName(file.name || "asset");
|
|
1085
|
+
const filename = file.fileName ? void 0 : this.getAssetFileNames(file);
|
|
1086
|
+
return this.context.emitFile({
|
|
1087
|
+
...file,
|
|
1088
|
+
originalFileName: file.originalFileName || void 0,
|
|
1089
|
+
source: bindingAssetSource(file.source)
|
|
1090
|
+
}, filename, fnSanitizedFileName);
|
|
1091
|
+
};
|
|
1092
|
+
getAssetFileNames(file) {
|
|
1093
|
+
if (typeof this.outputOptions.assetFileNames === "function") return this.outputOptions.assetFileNames({
|
|
1094
|
+
names: file.name ? [file.name] : [],
|
|
1095
|
+
originalFileNames: file.originalFileName ? [file.originalFileName] : [],
|
|
1096
|
+
source: file.source,
|
|
1097
|
+
type: "asset"
|
|
1098
|
+
});
|
|
1099
|
+
}
|
|
1100
|
+
getFileName(referenceId) {
|
|
1101
|
+
return this.context.getFileName(referenceId);
|
|
1102
|
+
}
|
|
1103
|
+
getModuleIds() {
|
|
1104
|
+
return this.data.getModuleIds(this.context);
|
|
1105
|
+
}
|
|
1106
|
+
addWatchFile(id) {
|
|
1107
|
+
this.context.addWatchFile(id);
|
|
1108
|
+
}
|
|
1109
|
+
parse(input, options) {
|
|
1110
|
+
return require_parse_ast_index.parseAst(input, options);
|
|
1111
|
+
}
|
|
1112
|
+
};
|
|
1113
|
+
|
|
1114
|
+
//#endregion
|
|
1115
|
+
//#region src/plugin/transform-plugin-context.ts
|
|
1116
|
+
var TransformPluginContextImpl = class extends PluginContextImpl {
|
|
1117
|
+
constructor(outputOptions, context, plugin, data, inner, moduleId, moduleSource, onLog, LogLevelOption, watchMode) {
|
|
1118
|
+
super(outputOptions, context, plugin, data, onLog, LogLevelOption, watchMode, moduleId);
|
|
1119
|
+
this.inner = inner;
|
|
1120
|
+
this.moduleId = moduleId;
|
|
1121
|
+
this.moduleSource = moduleSource;
|
|
1122
|
+
const getLogHandler$1 = (handler) => (log, pos) => {
|
|
1123
|
+
log = normalizeLog(log);
|
|
1124
|
+
if (pos) require_parse_ast_index.augmentCodeLocation(log, pos, moduleSource, moduleId);
|
|
1125
|
+
log.id = moduleId;
|
|
1126
|
+
log.hook = "transform";
|
|
1127
|
+
handler(log);
|
|
1128
|
+
};
|
|
1129
|
+
this.debug = getLogHandler$1(this.debug);
|
|
1130
|
+
this.warn = getLogHandler$1(this.warn);
|
|
1131
|
+
this.info = getLogHandler$1(this.info);
|
|
1132
|
+
}
|
|
1133
|
+
error(e, pos) {
|
|
1134
|
+
if (typeof e === "string") e = { message: e };
|
|
1135
|
+
if (pos) require_parse_ast_index.augmentCodeLocation(e, pos, this.moduleSource, this.moduleId);
|
|
1136
|
+
e.id = this.moduleId;
|
|
1137
|
+
e.hook = "transform";
|
|
1138
|
+
return require_parse_ast_index.error(require_parse_ast_index.logPluginError(normalizeLog(e), this.pluginName));
|
|
1139
|
+
}
|
|
1140
|
+
getCombinedSourcemap() {
|
|
1141
|
+
return JSON.parse(this.inner.getCombinedSourcemap());
|
|
1142
|
+
}
|
|
1143
|
+
};
|
|
1144
|
+
|
|
1145
|
+
//#endregion
|
|
1146
|
+
//#region src/plugin/bindingify-build-hooks.ts
|
|
1147
|
+
function bindingifyBuildStart(args) {
|
|
1148
|
+
const hook = args.plugin.buildStart;
|
|
1149
|
+
if (!hook) return {};
|
|
1150
|
+
const { handler, meta } = normalizeHook(hook);
|
|
1151
|
+
return {
|
|
1152
|
+
plugin: async (ctx, opts) => {
|
|
1153
|
+
await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), new NormalizedInputOptionsImpl(opts, args.onLog));
|
|
1154
|
+
},
|
|
1155
|
+
meta: bindingifyPluginHookMeta(meta)
|
|
1156
|
+
};
|
|
1157
|
+
}
|
|
1158
|
+
function bindingifyBuildEnd(args) {
|
|
1159
|
+
const hook = args.plugin.buildEnd;
|
|
1160
|
+
if (!hook) return {};
|
|
1161
|
+
const { handler, meta } = normalizeHook(hook);
|
|
1162
|
+
return {
|
|
1163
|
+
plugin: async (ctx, err) => {
|
|
1164
|
+
await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), err ? normalizeErrors(err) : void 0);
|
|
1165
|
+
},
|
|
1166
|
+
meta: bindingifyPluginHookMeta(meta)
|
|
1167
|
+
};
|
|
1168
|
+
}
|
|
1169
|
+
function bindingifyResolveId(args) {
|
|
1170
|
+
const hook = args.plugin.resolveId;
|
|
1171
|
+
if (!hook) return {};
|
|
1172
|
+
const { handler, meta, options } = normalizeHook(hook);
|
|
1173
|
+
return {
|
|
1174
|
+
plugin: async (ctx, specifier, importer, extraOptions) => {
|
|
1175
|
+
const contextResolveOptions = extraOptions.custom != null ? args.pluginContextData.getSavedResolveOptions(extraOptions.custom) : void 0;
|
|
1176
|
+
const newExtraOptions = {
|
|
1177
|
+
...extraOptions,
|
|
1178
|
+
custom: contextResolveOptions?.custom,
|
|
1179
|
+
[SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF]: contextResolveOptions?.[SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF]
|
|
1180
|
+
};
|
|
1181
|
+
const ret = await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), specifier, importer ?? void 0, newExtraOptions);
|
|
1182
|
+
if (ret == null) return;
|
|
1183
|
+
if (ret === false) return {
|
|
1184
|
+
id: specifier,
|
|
1185
|
+
external: bindingResolvedExternal(true),
|
|
1186
|
+
normalizeExternalId: true
|
|
1187
|
+
};
|
|
1188
|
+
if (typeof ret === "string") return {
|
|
1189
|
+
id: ret,
|
|
1190
|
+
normalizeExternalId: true
|
|
1191
|
+
};
|
|
1192
|
+
let exist = args.pluginContextData.updateModuleOption(ret.id, {
|
|
1193
|
+
meta: ret.meta || {},
|
|
1194
|
+
moduleSideEffects: ret.moduleSideEffects ?? null,
|
|
1195
|
+
invalidate: false
|
|
1196
|
+
});
|
|
1197
|
+
return {
|
|
1198
|
+
id: ret.id,
|
|
1199
|
+
external: bindingResolvedExternal(ret.external),
|
|
1200
|
+
normalizeExternalId: false,
|
|
1201
|
+
sideEffects: bindingifySideEffects(exist.moduleSideEffects)
|
|
1202
|
+
};
|
|
1203
|
+
},
|
|
1204
|
+
meta: bindingifyPluginHookMeta(meta),
|
|
1205
|
+
filter: bindingifyResolveIdFilter(options.filter)
|
|
1206
|
+
};
|
|
1207
|
+
}
|
|
1208
|
+
function bindingifyResolveDynamicImport(args) {
|
|
1209
|
+
const hook = args.plugin.resolveDynamicImport;
|
|
1210
|
+
if (!hook) return {};
|
|
1211
|
+
const { handler, meta } = normalizeHook(hook);
|
|
1212
|
+
return {
|
|
1213
|
+
plugin: async (ctx, specifier, importer) => {
|
|
1214
|
+
const ret = await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), specifier, importer ?? void 0);
|
|
1215
|
+
if (ret == null) return;
|
|
1216
|
+
if (ret === false) return {
|
|
1217
|
+
id: specifier,
|
|
1218
|
+
external: bindingResolvedExternal(true)
|
|
1219
|
+
};
|
|
1220
|
+
if (typeof ret === "string") return { id: ret };
|
|
1221
|
+
const result = {
|
|
1222
|
+
id: ret.id,
|
|
1223
|
+
external: bindingResolvedExternal(ret.external)
|
|
1224
|
+
};
|
|
1225
|
+
if (ret.moduleSideEffects !== null) result.sideEffects = bindingifySideEffects(ret.moduleSideEffects);
|
|
1226
|
+
args.pluginContextData.updateModuleOption(ret.id, {
|
|
1227
|
+
meta: ret.meta || {},
|
|
1228
|
+
moduleSideEffects: ret.moduleSideEffects || null,
|
|
1229
|
+
invalidate: false
|
|
1230
|
+
});
|
|
1231
|
+
return result;
|
|
1232
|
+
},
|
|
1233
|
+
meta: bindingifyPluginHookMeta(meta)
|
|
1234
|
+
};
|
|
1235
|
+
}
|
|
1236
|
+
function bindingifyTransform(args) {
|
|
1237
|
+
const hook = args.plugin.transform;
|
|
1238
|
+
if (!hook) return {};
|
|
1239
|
+
const { handler, meta, options } = normalizeHook(hook);
|
|
1240
|
+
return {
|
|
1241
|
+
plugin: async (ctx, code, id, meta$1) => {
|
|
1242
|
+
const ret = await handler.call(new TransformPluginContextImpl(args.outputOptions, ctx.inner(), args.plugin, args.pluginContextData, ctx, id, code, args.onLog, args.logLevel, args.watchMode), code, id, meta$1);
|
|
1243
|
+
if (ret == null) return void 0;
|
|
1244
|
+
if (typeof ret === "string") return { code: ret };
|
|
1245
|
+
let moduleOption = args.pluginContextData.updateModuleOption(id, {
|
|
1246
|
+
meta: ret.meta ?? {},
|
|
1247
|
+
moduleSideEffects: ret.moduleSideEffects ?? null,
|
|
1248
|
+
invalidate: false
|
|
1249
|
+
});
|
|
1250
|
+
return {
|
|
1251
|
+
code: ret.code,
|
|
1252
|
+
map: bindingifySourcemap$1(normalizeTransformHookSourcemap(id, code, ret.map)),
|
|
1253
|
+
sideEffects: bindingifySideEffects(moduleOption.moduleSideEffects),
|
|
1254
|
+
moduleType: ret.moduleType
|
|
1255
|
+
};
|
|
1256
|
+
},
|
|
1257
|
+
meta: bindingifyPluginHookMeta(meta),
|
|
1258
|
+
filter: bindingifyTransformFilter(options.filter)
|
|
1259
|
+
};
|
|
1260
|
+
}
|
|
1261
|
+
function bindingifyLoad(args) {
|
|
1262
|
+
const hook = args.plugin.load;
|
|
1263
|
+
if (!hook) return {};
|
|
1264
|
+
const { handler, meta, options } = normalizeHook(hook);
|
|
1265
|
+
return {
|
|
1266
|
+
plugin: async (ctx, id) => {
|
|
1267
|
+
const ret = await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode, id), id);
|
|
1268
|
+
if (ret == null) return;
|
|
1269
|
+
if (typeof ret === "string") return { code: ret };
|
|
1270
|
+
let moduleOption = args.pluginContextData.updateModuleOption(id, {
|
|
1271
|
+
meta: ret.meta || {},
|
|
1272
|
+
moduleSideEffects: ret.moduleSideEffects ?? null,
|
|
1273
|
+
invalidate: false
|
|
1274
|
+
});
|
|
1275
|
+
let map = preProcessSourceMap(ret, id);
|
|
1276
|
+
return {
|
|
1277
|
+
code: ret.code,
|
|
1278
|
+
map: bindingifySourcemap$1(map),
|
|
1279
|
+
moduleType: ret.moduleType,
|
|
1280
|
+
sideEffects: bindingifySideEffects(moduleOption.moduleSideEffects)
|
|
1281
|
+
};
|
|
1282
|
+
},
|
|
1283
|
+
meta: bindingifyPluginHookMeta(meta),
|
|
1284
|
+
filter: bindingifyLoadFilter(options.filter)
|
|
1285
|
+
};
|
|
1286
|
+
}
|
|
1287
|
+
function preProcessSourceMap(ret, id) {
|
|
1288
|
+
if (!ret.map) return;
|
|
1289
|
+
let map = typeof ret.map === "object" ? ret.map : JSON.parse(ret.map);
|
|
1290
|
+
if (!isEmptySourcemapFiled(map.sources)) {
|
|
1291
|
+
const directory = node_path.default.dirname(id) || ".";
|
|
1292
|
+
const sourceRoot = map.sourceRoot || ".";
|
|
1293
|
+
map.sources = map.sources.map((source) => node_path.default.resolve(directory, sourceRoot, source));
|
|
1294
|
+
}
|
|
1295
|
+
return map;
|
|
1296
|
+
}
|
|
1297
|
+
function bindingifyModuleParsed(args) {
|
|
1298
|
+
const hook = args.plugin.moduleParsed;
|
|
1299
|
+
if (!hook) return {};
|
|
1300
|
+
const { handler, meta } = normalizeHook(hook);
|
|
1301
|
+
return {
|
|
1302
|
+
plugin: async (ctx, moduleInfo) => {
|
|
1303
|
+
await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), transformModuleInfo(moduleInfo, args.pluginContextData.getModuleOption(moduleInfo.id)));
|
|
1304
|
+
},
|
|
1305
|
+
meta: bindingifyPluginHookMeta(meta)
|
|
1306
|
+
};
|
|
1307
|
+
}
|
|
1308
|
+
|
|
1309
|
+
//#endregion
|
|
1310
|
+
//#region src/utils/transform-rendered-module.ts
|
|
1311
|
+
function transformToRenderedModule(bindingRenderedModule) {
|
|
1312
|
+
return {
|
|
1313
|
+
get code() {
|
|
1314
|
+
return bindingRenderedModule.code;
|
|
1315
|
+
},
|
|
1316
|
+
get renderedLength() {
|
|
1317
|
+
return bindingRenderedModule.code?.length || 0;
|
|
1318
|
+
},
|
|
1319
|
+
get renderedExports() {
|
|
1320
|
+
return bindingRenderedModule.renderedExports;
|
|
1321
|
+
}
|
|
1322
|
+
};
|
|
1323
|
+
}
|
|
1324
|
+
|
|
1325
|
+
//#endregion
|
|
1326
|
+
//#region src/utils/transform-rendered-chunk.ts
|
|
1327
|
+
function transformRenderedChunk(chunk) {
|
|
1328
|
+
let modules = null;
|
|
1329
|
+
return {
|
|
1330
|
+
get name() {
|
|
1331
|
+
return chunk.name;
|
|
1332
|
+
},
|
|
1333
|
+
get isEntry() {
|
|
1334
|
+
return chunk.isEntry;
|
|
1335
|
+
},
|
|
1336
|
+
get isDynamicEntry() {
|
|
1337
|
+
return chunk.isDynamicEntry;
|
|
1338
|
+
},
|
|
1339
|
+
get facadeModuleId() {
|
|
1340
|
+
return chunk.facadeModuleId;
|
|
1341
|
+
},
|
|
1342
|
+
get moduleIds() {
|
|
1343
|
+
return chunk.moduleIds;
|
|
1344
|
+
},
|
|
1345
|
+
get exports() {
|
|
1346
|
+
return chunk.exports;
|
|
1347
|
+
},
|
|
1348
|
+
get fileName() {
|
|
1349
|
+
return chunk.fileName;
|
|
1350
|
+
},
|
|
1351
|
+
get imports() {
|
|
1352
|
+
return chunk.imports;
|
|
1353
|
+
},
|
|
1354
|
+
get dynamicImports() {
|
|
1355
|
+
return chunk.dynamicImports;
|
|
1356
|
+
},
|
|
1357
|
+
get modules() {
|
|
1358
|
+
if (!modules) modules = transformChunkModules(chunk.modules);
|
|
1359
|
+
return modules;
|
|
1360
|
+
}
|
|
1361
|
+
};
|
|
1362
|
+
}
|
|
1363
|
+
function transformChunkModules(modules) {
|
|
1364
|
+
const result = {};
|
|
1365
|
+
for (let i = 0; i < modules.values.length; i++) {
|
|
1366
|
+
let key = modules.keys[i];
|
|
1367
|
+
const mod = modules.values[i];
|
|
1368
|
+
result[key] = transformToRenderedModule(mod);
|
|
1369
|
+
}
|
|
1370
|
+
return result;
|
|
1371
|
+
}
|
|
1372
|
+
|
|
1373
|
+
//#endregion
|
|
1374
|
+
//#region src/utils/bindingify-output-options.ts
|
|
1375
|
+
function bindingifyOutputOptions(outputOptions) {
|
|
1376
|
+
const { dir, format, exports: exports$1, hashCharacters, sourcemap, sourcemapDebugIds, sourcemapIgnoreList, sourcemapPathTransform, name, assetFileNames, entryFileNames, chunkFileNames, cssEntryFileNames, cssChunkFileNames, banner, footer, intro, outro, esModule, globals, file, sanitizeFileName } = outputOptions;
|
|
1377
|
+
return {
|
|
1378
|
+
dir,
|
|
1379
|
+
file: file == null ? void 0 : file,
|
|
1380
|
+
format: bindingifyFormat(format),
|
|
1381
|
+
exports: exports$1,
|
|
1382
|
+
hashCharacters,
|
|
1383
|
+
sourcemap: bindingifySourcemap(sourcemap),
|
|
1384
|
+
sourcemapDebugIds,
|
|
1385
|
+
sourcemapIgnoreList: bindingifySourcemapIgnoreList(sourcemapIgnoreList),
|
|
1386
|
+
sourcemapPathTransform,
|
|
1387
|
+
banner: bindingifyAddon(banner),
|
|
1388
|
+
footer: bindingifyAddon(footer),
|
|
1389
|
+
intro: bindingifyAddon(intro),
|
|
1390
|
+
outro: bindingifyAddon(outro),
|
|
1391
|
+
extend: outputOptions.extend,
|
|
1392
|
+
globals,
|
|
1393
|
+
esModule,
|
|
1394
|
+
name,
|
|
1395
|
+
assetFileNames: bindingifyAssetFilenames(assetFileNames),
|
|
1396
|
+
entryFileNames,
|
|
1397
|
+
chunkFileNames,
|
|
1398
|
+
cssEntryFileNames,
|
|
1399
|
+
cssChunkFileNames,
|
|
1400
|
+
plugins: [],
|
|
1401
|
+
minify: outputOptions.minify,
|
|
1402
|
+
externalLiveBindings: outputOptions.externalLiveBindings,
|
|
1403
|
+
inlineDynamicImports: outputOptions.inlineDynamicImports,
|
|
1404
|
+
advancedChunks: outputOptions.advancedChunks,
|
|
1405
|
+
polyfillRequire: outputOptions.polyfillRequire,
|
|
1406
|
+
target: outputOptions.target,
|
|
1407
|
+
sanitizeFileName
|
|
1408
|
+
};
|
|
1409
|
+
}
|
|
1410
|
+
function bindingifyAddon(configAddon) {
|
|
1411
|
+
return async (chunk) => {
|
|
1412
|
+
if (typeof configAddon === "function") return configAddon(transformRenderedChunk(chunk));
|
|
1413
|
+
return configAddon || "";
|
|
1414
|
+
};
|
|
1415
|
+
}
|
|
1416
|
+
function bindingifyFormat(format) {
|
|
1417
|
+
switch (format) {
|
|
1418
|
+
case void 0:
|
|
1419
|
+
case "es":
|
|
1420
|
+
case "esm":
|
|
1421
|
+
case "module": return "es";
|
|
1422
|
+
case "cjs":
|
|
1423
|
+
case "commonjs": return "cjs";
|
|
1424
|
+
case "iife": return "iife";
|
|
1425
|
+
case "umd": return "umd";
|
|
1426
|
+
case "experimental-app": return "app";
|
|
1427
|
+
default: unimplemented(`output.format: ${format}`);
|
|
1428
|
+
}
|
|
1429
|
+
}
|
|
1430
|
+
function bindingifySourcemap(sourcemap) {
|
|
1431
|
+
switch (sourcemap) {
|
|
1432
|
+
case true: return "file";
|
|
1433
|
+
case "inline": return "inline";
|
|
1434
|
+
case false:
|
|
1435
|
+
case void 0: return void 0;
|
|
1436
|
+
case "hidden": return "hidden";
|
|
1437
|
+
default: throw new Error(`unknown sourcemap: ${sourcemap}`);
|
|
1438
|
+
}
|
|
1439
|
+
}
|
|
1440
|
+
function bindingifySourcemapIgnoreList(sourcemapIgnoreList) {
|
|
1441
|
+
return typeof sourcemapIgnoreList === "function" ? sourcemapIgnoreList : sourcemapIgnoreList === false ? () => false : (relativeSourcePath, _sourcemapPath) => relativeSourcePath.includes("node_modules");
|
|
1442
|
+
}
|
|
1443
|
+
function bindingifyAssetFilenames(assetFileNames) {
|
|
1444
|
+
if (typeof assetFileNames === "function") return (asset) => {
|
|
1445
|
+
return assetFileNames({
|
|
1446
|
+
names: asset.names,
|
|
1447
|
+
originalFileNames: asset.originalFileNames,
|
|
1448
|
+
source: transformAssetSource(asset.source),
|
|
1449
|
+
type: "asset"
|
|
1450
|
+
});
|
|
1451
|
+
};
|
|
1452
|
+
return assetFileNames;
|
|
1453
|
+
}
|
|
1454
|
+
|
|
1455
|
+
//#endregion
|
|
1456
|
+
//#region src/options/normalized-output-options.ts
|
|
1457
|
+
var NormalizedOutputOptionsImpl = class {
|
|
1458
|
+
constructor(inner, outputOptions, normalizedOutputPlugins) {
|
|
1459
|
+
this.inner = inner;
|
|
1460
|
+
this.outputOptions = outputOptions;
|
|
1461
|
+
this.normalizedOutputPlugins = normalizedOutputPlugins;
|
|
1462
|
+
}
|
|
1463
|
+
get dir() {
|
|
1464
|
+
return this.inner.dir ?? void 0;
|
|
1465
|
+
}
|
|
1466
|
+
get entryFileNames() {
|
|
1467
|
+
return this.inner.entryFilenames || this.outputOptions.entryFileNames;
|
|
1468
|
+
}
|
|
1469
|
+
get chunkFileNames() {
|
|
1470
|
+
return this.inner.chunkFilenames || this.outputOptions.chunkFileNames;
|
|
1471
|
+
}
|
|
1472
|
+
get assetFileNames() {
|
|
1473
|
+
return this.inner.assetFilenames || this.outputOptions.assetFileNames;
|
|
1474
|
+
}
|
|
1475
|
+
get format() {
|
|
1476
|
+
return this.inner.format;
|
|
1477
|
+
}
|
|
1478
|
+
get exports() {
|
|
1479
|
+
return this.inner.exports;
|
|
1480
|
+
}
|
|
1481
|
+
get sourcemap() {
|
|
1482
|
+
return this.inner.sourcemap;
|
|
1483
|
+
}
|
|
1484
|
+
get cssEntryFileNames() {
|
|
1485
|
+
return this.inner.cssEntryFilenames || this.outputOptions.cssEntryFileNames;
|
|
1486
|
+
}
|
|
1487
|
+
get cssChunkFileNames() {
|
|
1488
|
+
return this.inner.cssChunkFilenames || this.outputOptions.cssChunkFileNames;
|
|
1489
|
+
}
|
|
1490
|
+
get shimMissingExports() {
|
|
1491
|
+
return this.inner.shimMissingExports;
|
|
1492
|
+
}
|
|
1493
|
+
get name() {
|
|
1494
|
+
return this.inner.name ?? void 0;
|
|
1495
|
+
}
|
|
1496
|
+
get file() {
|
|
1497
|
+
return this.inner.file ?? void 0;
|
|
1498
|
+
}
|
|
1499
|
+
get inlineDynamicImports() {
|
|
1500
|
+
return this.inner.inlineDynamicImports;
|
|
1501
|
+
}
|
|
1502
|
+
get externalLiveBindings() {
|
|
1503
|
+
return this.inner.externalLiveBindings;
|
|
1504
|
+
}
|
|
1505
|
+
get banner() {
|
|
1506
|
+
return normalizeAddon(this.outputOptions.banner);
|
|
1507
|
+
}
|
|
1508
|
+
get footer() {
|
|
1509
|
+
return normalizeAddon(this.outputOptions.footer);
|
|
1510
|
+
}
|
|
1511
|
+
get intro() {
|
|
1512
|
+
return normalizeAddon(this.outputOptions.intro);
|
|
1513
|
+
}
|
|
1514
|
+
get outro() {
|
|
1515
|
+
return normalizeAddon(this.outputOptions.outro);
|
|
1516
|
+
}
|
|
1517
|
+
get esModule() {
|
|
1518
|
+
return this.inner.esModule;
|
|
1519
|
+
}
|
|
1520
|
+
get extend() {
|
|
1521
|
+
return this.inner.extend;
|
|
1522
|
+
}
|
|
1523
|
+
get globals() {
|
|
1524
|
+
return this.inner.globals || this.outputOptions.globals;
|
|
1525
|
+
}
|
|
1526
|
+
get hashCharacters() {
|
|
1527
|
+
return this.inner.hashCharacters;
|
|
1528
|
+
}
|
|
1529
|
+
get sourcemapDebugIds() {
|
|
1530
|
+
return this.inner.sourcemapDebugIds;
|
|
1531
|
+
}
|
|
1532
|
+
get sourcemapIgnoreList() {
|
|
1533
|
+
return bindingifySourcemapIgnoreList(this.outputOptions.sourcemapIgnoreList);
|
|
1534
|
+
}
|
|
1535
|
+
get sourcemapPathTransform() {
|
|
1536
|
+
return this.outputOptions.sourcemapPathTransform;
|
|
1537
|
+
}
|
|
1538
|
+
get minify() {
|
|
1539
|
+
return this.inner.minify;
|
|
1540
|
+
}
|
|
1541
|
+
get comments() {
|
|
1542
|
+
return this.inner.comments;
|
|
1543
|
+
}
|
|
1544
|
+
get polyfillRequire() {
|
|
1545
|
+
return this.inner.polyfillRequire;
|
|
1546
|
+
}
|
|
1547
|
+
get plugins() {
|
|
1548
|
+
return this.normalizedOutputPlugins;
|
|
1549
|
+
}
|
|
1550
|
+
};
|
|
1551
|
+
function normalizeAddon(value) {
|
|
1552
|
+
if (typeof value === "function") return value;
|
|
1553
|
+
return () => value || "";
|
|
1554
|
+
}
|
|
1555
|
+
|
|
1556
|
+
//#endregion
|
|
1557
|
+
//#region src/utils/transform-to-rollup-output.ts
|
|
1558
|
+
function transformToRollupSourceMap(map) {
|
|
1559
|
+
const parsed = JSON.parse(map);
|
|
1560
|
+
const obj = {
|
|
1561
|
+
...parsed,
|
|
1562
|
+
toString() {
|
|
1563
|
+
return JSON.stringify(obj);
|
|
1564
|
+
},
|
|
1565
|
+
toUrl() {
|
|
1566
|
+
return `data:application/json;charset=utf-8;base64,${Buffer.from(obj.toString(), "utf-8").toString("base64")}`;
|
|
1567
|
+
}
|
|
1568
|
+
};
|
|
1569
|
+
return obj;
|
|
1570
|
+
}
|
|
1571
|
+
function transformToRollupOutputChunk(bindingChunk, changed) {
|
|
1572
|
+
const chunk = {
|
|
1573
|
+
type: "chunk",
|
|
1574
|
+
get code() {
|
|
1575
|
+
return bindingChunk.code;
|
|
1576
|
+
},
|
|
1577
|
+
fileName: bindingChunk.fileName,
|
|
1578
|
+
name: bindingChunk.name,
|
|
1579
|
+
get modules() {
|
|
1580
|
+
return transformChunkModules(bindingChunk.modules);
|
|
1581
|
+
},
|
|
1582
|
+
get imports() {
|
|
1583
|
+
return bindingChunk.imports;
|
|
1584
|
+
},
|
|
1585
|
+
get dynamicImports() {
|
|
1586
|
+
return bindingChunk.dynamicImports;
|
|
1587
|
+
},
|
|
1588
|
+
exports: bindingChunk.exports,
|
|
1589
|
+
isEntry: bindingChunk.isEntry,
|
|
1590
|
+
facadeModuleId: bindingChunk.facadeModuleId || null,
|
|
1591
|
+
isDynamicEntry: bindingChunk.isDynamicEntry,
|
|
1592
|
+
get moduleIds() {
|
|
1593
|
+
return bindingChunk.moduleIds;
|
|
1594
|
+
},
|
|
1595
|
+
get map() {
|
|
1596
|
+
return bindingChunk.map ? transformToRollupSourceMap(bindingChunk.map) : null;
|
|
1597
|
+
},
|
|
1598
|
+
sourcemapFileName: bindingChunk.sourcemapFileName || null,
|
|
1599
|
+
preliminaryFileName: bindingChunk.preliminaryFileName
|
|
1600
|
+
};
|
|
1601
|
+
const cache = {};
|
|
1602
|
+
return new Proxy(chunk, {
|
|
1603
|
+
get(target, p) {
|
|
1604
|
+
if (p in cache) return cache[p];
|
|
1605
|
+
const value = target[p];
|
|
1606
|
+
cache[p] = value;
|
|
1607
|
+
return value;
|
|
1608
|
+
},
|
|
1609
|
+
set(target, p, newValue) {
|
|
1610
|
+
cache[p] = newValue;
|
|
1611
|
+
changed?.updated.add(bindingChunk.fileName);
|
|
1612
|
+
return true;
|
|
1613
|
+
},
|
|
1614
|
+
has(target, p) {
|
|
1615
|
+
if (p in cache) return true;
|
|
1616
|
+
return p in target;
|
|
1617
|
+
}
|
|
1618
|
+
});
|
|
1619
|
+
}
|
|
1620
|
+
function transformToRollupOutputAsset(bindingAsset, changed) {
|
|
1621
|
+
const asset = {
|
|
1622
|
+
type: "asset",
|
|
1623
|
+
fileName: bindingAsset.fileName,
|
|
1624
|
+
originalFileName: bindingAsset.originalFileName || null,
|
|
1625
|
+
originalFileNames: bindingAsset.originalFileNames,
|
|
1626
|
+
get source() {
|
|
1627
|
+
return transformAssetSource(bindingAsset.source);
|
|
1628
|
+
},
|
|
1629
|
+
name: bindingAsset.name ?? void 0,
|
|
1630
|
+
names: bindingAsset.names
|
|
1631
|
+
};
|
|
1632
|
+
const cache = {};
|
|
1633
|
+
return new Proxy(asset, {
|
|
1634
|
+
get(target, p) {
|
|
1635
|
+
if (p in cache) return cache[p];
|
|
1636
|
+
const value = target[p];
|
|
1637
|
+
cache[p] = value;
|
|
1638
|
+
return value;
|
|
1639
|
+
},
|
|
1640
|
+
set(target, p, newValue) {
|
|
1641
|
+
cache[p] = newValue;
|
|
1642
|
+
changed?.updated.add(bindingAsset.fileName);
|
|
1643
|
+
return true;
|
|
1644
|
+
}
|
|
1645
|
+
});
|
|
1646
|
+
}
|
|
1647
|
+
function transformToRollupOutput(output, changed) {
|
|
1648
|
+
handleOutputErrors(output);
|
|
1649
|
+
const { chunks, assets } = output;
|
|
1650
|
+
return { output: [...chunks.map((chunk) => transformToRollupOutputChunk(chunk, changed)), ...assets.map((asset) => transformToRollupOutputAsset(asset, changed))] };
|
|
1651
|
+
}
|
|
1652
|
+
function handleOutputErrors(output) {
|
|
1653
|
+
const rawErrors = output.errors;
|
|
1654
|
+
if (rawErrors.length > 0) throw normalizeErrors(rawErrors);
|
|
1655
|
+
}
|
|
1656
|
+
function transformToOutputBundle(output, changed) {
|
|
1657
|
+
const bundle = Object.fromEntries(transformToRollupOutput(output, changed).output.map((item) => [item.fileName, item]));
|
|
1658
|
+
return new Proxy(bundle, { deleteProperty(target, property) {
|
|
1659
|
+
if (typeof property === "string") changed.deleted.add(property);
|
|
1660
|
+
return true;
|
|
1661
|
+
} });
|
|
1662
|
+
}
|
|
1663
|
+
function collectChangedBundle(changed, bundle) {
|
|
1664
|
+
const assets = [];
|
|
1665
|
+
const chunks = [];
|
|
1666
|
+
for (const key in bundle) {
|
|
1667
|
+
if (changed.deleted.has(key) || !changed.updated.has(key)) continue;
|
|
1668
|
+
const item = bundle[key];
|
|
1669
|
+
if (item.type === "asset") assets.push({
|
|
1670
|
+
filename: item.fileName,
|
|
1671
|
+
originalFileNames: item.originalFileNames,
|
|
1672
|
+
source: bindingAssetSource(item.source),
|
|
1673
|
+
names: item.names
|
|
1674
|
+
});
|
|
1675
|
+
else chunks.push({
|
|
1676
|
+
code: item.code,
|
|
1677
|
+
filename: item.fileName,
|
|
1678
|
+
name: item.name,
|
|
1679
|
+
isEntry: item.isEntry,
|
|
1680
|
+
exports: item.exports,
|
|
1681
|
+
modules: {},
|
|
1682
|
+
imports: item.imports,
|
|
1683
|
+
dynamicImports: item.dynamicImports,
|
|
1684
|
+
facadeModuleId: item.facadeModuleId || void 0,
|
|
1685
|
+
isDynamicEntry: item.isDynamicEntry,
|
|
1686
|
+
moduleIds: item.moduleIds,
|
|
1687
|
+
map: bindingifySourcemap$1(item.map),
|
|
1688
|
+
sourcemapFilename: item.sourcemapFileName || void 0,
|
|
1689
|
+
preliminaryFilename: item.preliminaryFileName
|
|
1690
|
+
});
|
|
1691
|
+
}
|
|
1692
|
+
return {
|
|
1693
|
+
assets,
|
|
1694
|
+
chunks,
|
|
1695
|
+
deleted: Array.from(changed.deleted)
|
|
1696
|
+
};
|
|
1697
|
+
}
|
|
1698
|
+
|
|
1699
|
+
//#endregion
|
|
1700
|
+
//#region src/plugin/bindingify-output-hooks.ts
|
|
1701
|
+
function bindingifyRenderStart(args) {
|
|
1702
|
+
const hook = args.plugin.renderStart;
|
|
1703
|
+
if (!hook) return {};
|
|
1704
|
+
const { handler, meta } = normalizeHook(hook);
|
|
1705
|
+
return {
|
|
1706
|
+
plugin: async (ctx, opts) => {
|
|
1707
|
+
handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), new NormalizedOutputOptionsImpl(opts, args.outputOptions, args.normalizedOutputPlugins), new NormalizedInputOptionsImpl(opts, args.onLog));
|
|
1708
|
+
},
|
|
1709
|
+
meta: bindingifyPluginHookMeta(meta)
|
|
1710
|
+
};
|
|
1711
|
+
}
|
|
1712
|
+
function bindingifyRenderChunk(args) {
|
|
1713
|
+
const hook = args.plugin.renderChunk;
|
|
1714
|
+
if (!hook) return {};
|
|
1715
|
+
const { handler, meta } = normalizeHook(hook);
|
|
1716
|
+
return {
|
|
1717
|
+
plugin: async (ctx, code, chunk, opts, meta$1) => {
|
|
1718
|
+
if (args.pluginContextData.getRenderChunkMeta() == null) args.pluginContextData.setRenderChunkMeta({ chunks: Object.fromEntries(Object.entries(meta$1.chunks).map(([key, value]) => [key, transformRenderedChunk(value)])) });
|
|
1719
|
+
const ret = await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), code, transformRenderedChunk(chunk), new NormalizedOutputOptionsImpl(opts, args.outputOptions, args.normalizedOutputPlugins), args.pluginContextData.getRenderChunkMeta());
|
|
1720
|
+
if (ret == null) return;
|
|
1721
|
+
if (typeof ret === "string") return { code: ret };
|
|
1722
|
+
if (!ret.map) return { code: ret.code };
|
|
1723
|
+
return {
|
|
1724
|
+
code: ret.code,
|
|
1725
|
+
map: bindingifySourcemap$1(ret.map)
|
|
1726
|
+
};
|
|
1727
|
+
},
|
|
1728
|
+
meta: bindingifyPluginHookMeta(meta)
|
|
1729
|
+
};
|
|
1730
|
+
}
|
|
1731
|
+
function bindingifyAugmentChunkHash(args) {
|
|
1732
|
+
const hook = args.plugin.augmentChunkHash;
|
|
1733
|
+
if (!hook) return {};
|
|
1734
|
+
const { handler, meta } = normalizeHook(hook);
|
|
1735
|
+
return {
|
|
1736
|
+
plugin: async (ctx, chunk) => {
|
|
1737
|
+
return await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), transformRenderedChunk(chunk));
|
|
1738
|
+
},
|
|
1739
|
+
meta: bindingifyPluginHookMeta(meta)
|
|
1740
|
+
};
|
|
1741
|
+
}
|
|
1742
|
+
function bindingifyRenderError(args) {
|
|
1743
|
+
const hook = args.plugin.renderError;
|
|
1744
|
+
if (!hook) return {};
|
|
1745
|
+
const { handler, meta } = normalizeHook(hook);
|
|
1746
|
+
return {
|
|
1747
|
+
plugin: async (ctx, err) => {
|
|
1748
|
+
handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), normalizeErrors(err));
|
|
1749
|
+
},
|
|
1750
|
+
meta: bindingifyPluginHookMeta(meta)
|
|
1751
|
+
};
|
|
1752
|
+
}
|
|
1753
|
+
function bindingifyGenerateBundle(args) {
|
|
1754
|
+
const hook = args.plugin.generateBundle;
|
|
1755
|
+
if (!hook) return {};
|
|
1756
|
+
const { handler, meta } = normalizeHook(hook);
|
|
1757
|
+
return {
|
|
1758
|
+
plugin: async (ctx, bundle, isWrite, opts) => {
|
|
1759
|
+
const changed = {
|
|
1760
|
+
updated: new Set(),
|
|
1761
|
+
deleted: new Set()
|
|
1762
|
+
};
|
|
1763
|
+
const output = transformToOutputBundle(bundle, changed);
|
|
1764
|
+
await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), new NormalizedOutputOptionsImpl(opts, args.outputOptions, args.normalizedOutputPlugins), output, isWrite);
|
|
1765
|
+
return collectChangedBundle(changed, output);
|
|
1766
|
+
},
|
|
1767
|
+
meta: bindingifyPluginHookMeta(meta)
|
|
1768
|
+
};
|
|
1769
|
+
}
|
|
1770
|
+
function bindingifyWriteBundle(args) {
|
|
1771
|
+
const hook = args.plugin.writeBundle;
|
|
1772
|
+
if (!hook) return {};
|
|
1773
|
+
const { handler, meta } = normalizeHook(hook);
|
|
1774
|
+
return {
|
|
1775
|
+
plugin: async (ctx, bundle, opts) => {
|
|
1776
|
+
const changed = {
|
|
1777
|
+
updated: new Set(),
|
|
1778
|
+
deleted: new Set()
|
|
1779
|
+
};
|
|
1780
|
+
const output = transformToOutputBundle(bundle, changed);
|
|
1781
|
+
await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), new NormalizedOutputOptionsImpl(opts, args.outputOptions, args.normalizedOutputPlugins), output);
|
|
1782
|
+
return collectChangedBundle(changed, output);
|
|
1783
|
+
},
|
|
1784
|
+
meta: bindingifyPluginHookMeta(meta)
|
|
1785
|
+
};
|
|
1786
|
+
}
|
|
1787
|
+
function bindingifyCloseBundle(args) {
|
|
1788
|
+
const hook = args.plugin.closeBundle;
|
|
1789
|
+
if (!hook) return {};
|
|
1790
|
+
const { handler, meta } = normalizeHook(hook);
|
|
1791
|
+
return {
|
|
1792
|
+
plugin: async (ctx) => {
|
|
1793
|
+
await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode));
|
|
1794
|
+
},
|
|
1795
|
+
meta: bindingifyPluginHookMeta(meta)
|
|
1796
|
+
};
|
|
1797
|
+
}
|
|
1798
|
+
function bindingifyBanner(args) {
|
|
1799
|
+
const hook = args.plugin.banner;
|
|
1800
|
+
if (!hook) return {};
|
|
1801
|
+
const { handler, meta } = normalizeHook(hook);
|
|
1802
|
+
return {
|
|
1803
|
+
plugin: async (ctx, chunk) => {
|
|
1804
|
+
if (typeof handler === "string") return handler;
|
|
1805
|
+
return handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), transformRenderedChunk(chunk));
|
|
1806
|
+
},
|
|
1807
|
+
meta: bindingifyPluginHookMeta(meta)
|
|
1808
|
+
};
|
|
1809
|
+
}
|
|
1810
|
+
function bindingifyFooter(args) {
|
|
1811
|
+
const hook = args.plugin.footer;
|
|
1812
|
+
if (!hook) return {};
|
|
1813
|
+
const { handler, meta } = normalizeHook(hook);
|
|
1814
|
+
return {
|
|
1815
|
+
plugin: async (ctx, chunk) => {
|
|
1816
|
+
if (typeof handler === "string") return handler;
|
|
1817
|
+
return handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), transformRenderedChunk(chunk));
|
|
1818
|
+
},
|
|
1819
|
+
meta: bindingifyPluginHookMeta(meta)
|
|
1820
|
+
};
|
|
1821
|
+
}
|
|
1822
|
+
function bindingifyIntro(args) {
|
|
1823
|
+
const hook = args.plugin.intro;
|
|
1824
|
+
if (!hook) return {};
|
|
1825
|
+
const { handler, meta } = normalizeHook(hook);
|
|
1826
|
+
return {
|
|
1827
|
+
plugin: async (ctx, chunk) => {
|
|
1828
|
+
if (typeof handler === "string") return handler;
|
|
1829
|
+
return handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), transformRenderedChunk(chunk));
|
|
1830
|
+
},
|
|
1831
|
+
meta: bindingifyPluginHookMeta(meta)
|
|
1832
|
+
};
|
|
1833
|
+
}
|
|
1834
|
+
function bindingifyOutro(args) {
|
|
1835
|
+
const hook = args.plugin.outro;
|
|
1836
|
+
if (!hook) return {};
|
|
1837
|
+
const { handler, meta } = normalizeHook(hook);
|
|
1838
|
+
return {
|
|
1839
|
+
plugin: async (ctx, chunk) => {
|
|
1840
|
+
if (typeof handler === "string") return handler;
|
|
1841
|
+
return handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), transformRenderedChunk(chunk));
|
|
1842
|
+
},
|
|
1843
|
+
meta: bindingifyPluginHookMeta(meta)
|
|
1844
|
+
};
|
|
1845
|
+
}
|
|
1846
|
+
|
|
1847
|
+
//#endregion
|
|
1848
|
+
//#region src/plugin/bindingify-watch-hooks.ts
|
|
1849
|
+
function bindingifyWatchChange(args) {
|
|
1850
|
+
const hook = args.plugin.watchChange;
|
|
1851
|
+
if (!hook) return {};
|
|
1852
|
+
const { handler, meta } = normalizeHook(hook);
|
|
1853
|
+
return {
|
|
1854
|
+
plugin: async (ctx, id, event) => {
|
|
1855
|
+
await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), id, { event });
|
|
1856
|
+
},
|
|
1857
|
+
meta: bindingifyPluginHookMeta(meta)
|
|
1858
|
+
};
|
|
1859
|
+
}
|
|
1860
|
+
function bindingifyCloseWatcher(args) {
|
|
1861
|
+
const hook = args.plugin.closeWatcher;
|
|
1862
|
+
if (!hook) return {};
|
|
1863
|
+
const { handler, meta } = normalizeHook(hook);
|
|
1864
|
+
return {
|
|
1865
|
+
plugin: async (ctx) => {
|
|
1866
|
+
await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode));
|
|
1867
|
+
},
|
|
1868
|
+
meta: bindingifyPluginHookMeta(meta)
|
|
1869
|
+
};
|
|
1870
|
+
}
|
|
1871
|
+
|
|
1872
|
+
//#endregion
|
|
1873
|
+
//#region src/plugin/bindingify-plugin.ts
|
|
1874
|
+
function bindingifyPlugin(plugin, options, outputOptions, pluginContextData, normalizedOutputPlugins, onLog, logLevel, watchMode) {
|
|
1875
|
+
const args = {
|
|
1876
|
+
plugin,
|
|
1877
|
+
options,
|
|
1878
|
+
outputOptions,
|
|
1879
|
+
pluginContextData,
|
|
1880
|
+
onLog,
|
|
1881
|
+
logLevel,
|
|
1882
|
+
watchMode,
|
|
1883
|
+
normalizedOutputPlugins
|
|
1884
|
+
};
|
|
1885
|
+
const { plugin: buildStart, meta: buildStartMeta } = bindingifyBuildStart(args);
|
|
1886
|
+
const { plugin: resolveId, meta: resolveIdMeta, filter: resolveIdFilter } = bindingifyResolveId(args);
|
|
1887
|
+
const { plugin: resolveDynamicImport, meta: resolveDynamicImportMeta } = bindingifyResolveDynamicImport(args);
|
|
1888
|
+
const { plugin: buildEnd, meta: buildEndMeta } = bindingifyBuildEnd(args);
|
|
1889
|
+
const { plugin: transform, meta: transformMeta, filter: transformFilter } = bindingifyTransform(args);
|
|
1890
|
+
const { plugin: moduleParsed, meta: moduleParsedMeta } = bindingifyModuleParsed(args);
|
|
1891
|
+
const { plugin: load, meta: loadMeta, filter: loadFilter } = bindingifyLoad(args);
|
|
1892
|
+
const { plugin: renderChunk, meta: renderChunkMeta } = bindingifyRenderChunk(args);
|
|
1893
|
+
const { plugin: augmentChunkHash, meta: augmentChunkHashMeta } = bindingifyAugmentChunkHash(args);
|
|
1894
|
+
const { plugin: renderStart, meta: renderStartMeta } = bindingifyRenderStart(args);
|
|
1895
|
+
const { plugin: renderError, meta: renderErrorMeta } = bindingifyRenderError(args);
|
|
1896
|
+
const { plugin: generateBundle, meta: generateBundleMeta } = bindingifyGenerateBundle(args);
|
|
1897
|
+
const { plugin: writeBundle, meta: writeBundleMeta } = bindingifyWriteBundle(args);
|
|
1898
|
+
const { plugin: closeBundle, meta: closeBundleMeta } = bindingifyCloseBundle(args);
|
|
1899
|
+
const { plugin: banner, meta: bannerMeta } = bindingifyBanner(args);
|
|
1900
|
+
const { plugin: footer, meta: footerMeta } = bindingifyFooter(args);
|
|
1901
|
+
const { plugin: intro, meta: introMeta } = bindingifyIntro(args);
|
|
1902
|
+
const { plugin: outro, meta: outroMeta } = bindingifyOutro(args);
|
|
1903
|
+
const { plugin: watchChange, meta: watchChangeMeta } = bindingifyWatchChange(args);
|
|
1904
|
+
const { plugin: closeWatcher, meta: closeWatcherMeta } = bindingifyCloseWatcher(args);
|
|
1905
|
+
const result = {
|
|
1906
|
+
name: plugin.name,
|
|
1907
|
+
buildStart,
|
|
1908
|
+
buildStartMeta,
|
|
1909
|
+
resolveId,
|
|
1910
|
+
resolveIdMeta,
|
|
1911
|
+
resolveIdFilter,
|
|
1912
|
+
resolveDynamicImport,
|
|
1913
|
+
resolveDynamicImportMeta,
|
|
1914
|
+
buildEnd,
|
|
1915
|
+
buildEndMeta,
|
|
1916
|
+
transform,
|
|
1917
|
+
transformMeta,
|
|
1918
|
+
transformFilter,
|
|
1919
|
+
moduleParsed,
|
|
1920
|
+
moduleParsedMeta,
|
|
1921
|
+
load,
|
|
1922
|
+
loadMeta,
|
|
1923
|
+
loadFilter,
|
|
1924
|
+
renderChunk,
|
|
1925
|
+
renderChunkMeta,
|
|
1926
|
+
augmentChunkHash,
|
|
1927
|
+
augmentChunkHashMeta,
|
|
1928
|
+
renderStart,
|
|
1929
|
+
renderStartMeta,
|
|
1930
|
+
renderError,
|
|
1931
|
+
renderErrorMeta,
|
|
1932
|
+
generateBundle,
|
|
1933
|
+
generateBundleMeta,
|
|
1934
|
+
writeBundle,
|
|
1935
|
+
writeBundleMeta,
|
|
1936
|
+
closeBundle,
|
|
1937
|
+
closeBundleMeta,
|
|
1938
|
+
banner,
|
|
1939
|
+
bannerMeta,
|
|
1940
|
+
footer,
|
|
1941
|
+
footerMeta,
|
|
1942
|
+
intro,
|
|
1943
|
+
introMeta,
|
|
1944
|
+
outro,
|
|
1945
|
+
outroMeta,
|
|
1946
|
+
watchChange,
|
|
1947
|
+
watchChangeMeta,
|
|
1948
|
+
closeWatcher,
|
|
1949
|
+
closeWatcherMeta
|
|
1950
|
+
};
|
|
1951
|
+
return wrapHandlers(result);
|
|
1952
|
+
}
|
|
1953
|
+
function wrapHandlers(plugin) {
|
|
1954
|
+
for (const hookName of [
|
|
1955
|
+
"buildStart",
|
|
1956
|
+
"resolveId",
|
|
1957
|
+
"resolveDynamicImport",
|
|
1958
|
+
"buildEnd",
|
|
1959
|
+
"transform",
|
|
1960
|
+
"moduleParsed",
|
|
1961
|
+
"load",
|
|
1962
|
+
"renderChunk",
|
|
1963
|
+
"augmentChunkHash",
|
|
1964
|
+
"renderStart",
|
|
1965
|
+
"renderError",
|
|
1966
|
+
"generateBundle",
|
|
1967
|
+
"writeBundle",
|
|
1968
|
+
"closeBundle",
|
|
1969
|
+
"banner",
|
|
1970
|
+
"footer",
|
|
1971
|
+
"intro",
|
|
1972
|
+
"outro",
|
|
1973
|
+
"watchChange",
|
|
1974
|
+
"closeWatcher"
|
|
1975
|
+
]) {
|
|
1976
|
+
const handler = plugin[hookName];
|
|
1977
|
+
if (handler) plugin[hookName] = async (...args) => {
|
|
1978
|
+
try {
|
|
1979
|
+
return await handler(...args);
|
|
1980
|
+
} catch (e) {
|
|
1981
|
+
return require_parse_ast_index.error(require_parse_ast_index.logPluginError(e, plugin.name, {
|
|
1982
|
+
hook: hookName,
|
|
1983
|
+
id: hookName === "transform" ? args[2] : void 0
|
|
1984
|
+
}));
|
|
1985
|
+
}
|
|
1986
|
+
};
|
|
1987
|
+
}
|
|
1988
|
+
return plugin;
|
|
1989
|
+
}
|
|
1990
|
+
|
|
1991
|
+
//#endregion
|
|
1992
|
+
//#region src/plugin/plugin-context-data.ts
|
|
1993
|
+
var PluginContextData = class {
|
|
1994
|
+
moduleOptionMap = new Map();
|
|
1995
|
+
resolveOptionsMap = new Map();
|
|
1996
|
+
loadModulePromiseMap = new Map();
|
|
1997
|
+
meta = null;
|
|
1998
|
+
updateModuleOption(id, option) {
|
|
1999
|
+
const existing = this.moduleOptionMap.get(id);
|
|
2000
|
+
if (existing) {
|
|
2001
|
+
if (option.moduleSideEffects != null) existing.moduleSideEffects = option.moduleSideEffects;
|
|
2002
|
+
if (option.meta != null) Object.assign(existing.meta, option.meta);
|
|
2003
|
+
if (option.invalidate != null) existing.invalidate = option.invalidate;
|
|
2004
|
+
} else {
|
|
2005
|
+
this.moduleOptionMap.set(id, option);
|
|
2006
|
+
return option;
|
|
2007
|
+
}
|
|
2008
|
+
return existing;
|
|
2009
|
+
}
|
|
2010
|
+
getModuleOption(id) {
|
|
2011
|
+
const option = this.moduleOptionMap.get(id);
|
|
2012
|
+
if (!option) {
|
|
2013
|
+
const raw = {
|
|
2014
|
+
moduleSideEffects: null,
|
|
2015
|
+
meta: {}
|
|
2016
|
+
};
|
|
2017
|
+
this.moduleOptionMap.set(id, raw);
|
|
2018
|
+
return raw;
|
|
2019
|
+
}
|
|
2020
|
+
return option;
|
|
2021
|
+
}
|
|
2022
|
+
getModuleInfo(id, context) {
|
|
2023
|
+
const bindingInfo = context.getModuleInfo(id);
|
|
2024
|
+
if (bindingInfo) {
|
|
2025
|
+
const info = transformModuleInfo(bindingInfo, this.getModuleOption(id));
|
|
2026
|
+
return this.proxyModuleInfo(id, info);
|
|
2027
|
+
}
|
|
2028
|
+
return null;
|
|
2029
|
+
}
|
|
2030
|
+
proxyModuleInfo(id, info) {
|
|
2031
|
+
let moduleSideEffects = info.moduleSideEffects;
|
|
2032
|
+
Object.defineProperty(info, "moduleSideEffects", {
|
|
2033
|
+
get() {
|
|
2034
|
+
return moduleSideEffects;
|
|
2035
|
+
},
|
|
2036
|
+
set: (v) => {
|
|
2037
|
+
this.updateModuleOption(id, {
|
|
2038
|
+
moduleSideEffects: v,
|
|
2039
|
+
meta: info.meta,
|
|
2040
|
+
invalidate: true
|
|
2041
|
+
});
|
|
2042
|
+
moduleSideEffects = v;
|
|
2043
|
+
}
|
|
2044
|
+
});
|
|
2045
|
+
return info;
|
|
2046
|
+
}
|
|
2047
|
+
getModuleIds(context) {
|
|
2048
|
+
const moduleIds = context.getModuleIds();
|
|
2049
|
+
return moduleIds.values();
|
|
2050
|
+
}
|
|
2051
|
+
saveResolveOptions(options) {
|
|
2052
|
+
const index = this.resolveOptionsMap.size;
|
|
2053
|
+
this.resolveOptionsMap.set(index, options);
|
|
2054
|
+
return index;
|
|
2055
|
+
}
|
|
2056
|
+
getSavedResolveOptions(receipt) {
|
|
2057
|
+
return this.resolveOptionsMap.get(receipt);
|
|
2058
|
+
}
|
|
2059
|
+
removeSavedResolveOptions(receipt) {
|
|
2060
|
+
this.resolveOptionsMap.delete(receipt);
|
|
2061
|
+
}
|
|
2062
|
+
setRenderChunkMeta(meta) {
|
|
2063
|
+
this.meta = meta;
|
|
2064
|
+
}
|
|
2065
|
+
getRenderChunkMeta() {
|
|
2066
|
+
return this.meta;
|
|
2067
|
+
}
|
|
2068
|
+
};
|
|
2069
|
+
|
|
2070
|
+
//#endregion
|
|
2071
|
+
//#region src/utils/normalize-string-or-regex.ts
|
|
2072
|
+
function normalizedStringOrRegex(pattern) {
|
|
2073
|
+
if (!pattern) return void 0;
|
|
2074
|
+
if (!Array.isArray(pattern)) pattern = [pattern];
|
|
2075
|
+
return pattern;
|
|
2076
|
+
}
|
|
2077
|
+
|
|
2078
|
+
//#endregion
|
|
2079
|
+
//#region src/utils/bindingify-input-options.ts
|
|
2080
|
+
function bindingifyInputOptions(rawPlugins, inputOptions, outputOptions, normalizedOutputPlugins, onLog, logLevel, watchMode) {
|
|
2081
|
+
const pluginContextData = new PluginContextData();
|
|
2082
|
+
const plugins = rawPlugins.map((plugin) => {
|
|
2083
|
+
if ("_parallel" in plugin) return void 0;
|
|
2084
|
+
if (plugin instanceof BuiltinPlugin) return bindingifyBuiltInPlugin(plugin);
|
|
2085
|
+
return bindingifyPlugin(plugin, inputOptions, outputOptions, pluginContextData, normalizedOutputPlugins, onLog, logLevel, watchMode);
|
|
2086
|
+
});
|
|
2087
|
+
return {
|
|
2088
|
+
input: bindingifyInput(inputOptions.input),
|
|
2089
|
+
plugins,
|
|
2090
|
+
cwd: inputOptions.cwd ?? process.cwd(),
|
|
2091
|
+
external: bindingifyExternal(inputOptions.external),
|
|
2092
|
+
resolve: bindingifyResolve(inputOptions.resolve),
|
|
2093
|
+
platform: inputOptions.platform,
|
|
2094
|
+
shimMissingExports: inputOptions.shimMissingExports,
|
|
2095
|
+
logLevel: bindingifyLogLevel(logLevel),
|
|
2096
|
+
onLog,
|
|
2097
|
+
treeshake: bindingifyTreeshakeOptions(inputOptions.treeshake),
|
|
2098
|
+
moduleTypes: inputOptions.moduleTypes,
|
|
2099
|
+
define: inputOptions.define ? Object.entries(inputOptions.define) : void 0,
|
|
2100
|
+
inject: bindingifyInject(inputOptions.inject),
|
|
2101
|
+
experimental: {
|
|
2102
|
+
strictExecutionOrder: inputOptions.experimental?.strictExecutionOrder,
|
|
2103
|
+
disableLiveBindings: inputOptions.experimental?.disableLiveBindings,
|
|
2104
|
+
viteMode: inputOptions.experimental?.viteMode,
|
|
2105
|
+
resolveNewUrlToAsset: inputOptions.experimental?.resolveNewUrlToAsset,
|
|
2106
|
+
hmr: bindingifyHmr(inputOptions.experimental?.hmr)
|
|
2107
|
+
},
|
|
2108
|
+
profilerNames: inputOptions?.profilerNames,
|
|
2109
|
+
jsx: bindingifyJsx(inputOptions.jsx),
|
|
2110
|
+
transform: inputOptions.transform,
|
|
2111
|
+
watch: bindingifyWatch(inputOptions.watch),
|
|
2112
|
+
dropLabels: inputOptions.dropLabels,
|
|
2113
|
+
keepNames: inputOptions.keepNames,
|
|
2114
|
+
checks: inputOptions.checks,
|
|
2115
|
+
deferSyncScanData: () => {
|
|
2116
|
+
let ret = [];
|
|
2117
|
+
pluginContextData.moduleOptionMap.forEach((value, key) => {
|
|
2118
|
+
if (value.invalidate) ret.push({
|
|
2119
|
+
id: key,
|
|
2120
|
+
sideEffects: bindingifySideEffects(value.moduleSideEffects)
|
|
2121
|
+
});
|
|
2122
|
+
});
|
|
2123
|
+
return ret;
|
|
2124
|
+
},
|
|
2125
|
+
makeAbsoluteExternalsRelative: bindingifyMakeAbsoluteExternalsRelative(inputOptions.makeAbsoluteExternalsRelative),
|
|
2126
|
+
debug: inputOptions.debug
|
|
2127
|
+
};
|
|
2128
|
+
}
|
|
2129
|
+
function bindingifyHmr(hmr) {
|
|
2130
|
+
if (hmr) {
|
|
2131
|
+
if (typeof hmr === "boolean") return hmr ? {} : void 0;
|
|
2132
|
+
return hmr;
|
|
2133
|
+
}
|
|
2134
|
+
}
|
|
2135
|
+
function bindingifyExternal(external) {
|
|
2136
|
+
if (external) {
|
|
2137
|
+
if (typeof external === "function") return (id, importer, isResolved) => {
|
|
2138
|
+
if (id.startsWith("\0")) return false;
|
|
2139
|
+
return external(id, importer, isResolved) ?? false;
|
|
2140
|
+
};
|
|
2141
|
+
const externalArr = arraify(external);
|
|
2142
|
+
return (id, _importer, _isResolved) => {
|
|
2143
|
+
return externalArr.some((pat) => {
|
|
2144
|
+
if (pat instanceof RegExp) return pat.test(id);
|
|
2145
|
+
return id === pat;
|
|
2146
|
+
});
|
|
2147
|
+
};
|
|
2148
|
+
}
|
|
2149
|
+
}
|
|
2150
|
+
function bindingifyResolve(resolve) {
|
|
2151
|
+
if (resolve) {
|
|
2152
|
+
const { alias, extensionAlias,...rest } = resolve;
|
|
2153
|
+
return {
|
|
2154
|
+
alias: alias ? Object.entries(alias).map(([name, replacement]) => ({
|
|
2155
|
+
find: name,
|
|
2156
|
+
replacements: arraify(replacement)
|
|
2157
|
+
})) : void 0,
|
|
2158
|
+
extensionAlias: extensionAlias ? Object.entries(extensionAlias).map(([name, value]) => ({
|
|
2159
|
+
target: name,
|
|
2160
|
+
replacements: value
|
|
2161
|
+
})) : void 0,
|
|
2162
|
+
...rest
|
|
2163
|
+
};
|
|
2164
|
+
}
|
|
2165
|
+
}
|
|
2166
|
+
function bindingifyInject(inject) {
|
|
2167
|
+
if (inject) return Object.entries(inject).map(([alias, item]) => {
|
|
2168
|
+
if (Array.isArray(item)) {
|
|
2169
|
+
if (item[1] === "*") return {
|
|
2170
|
+
tagNamespace: true,
|
|
2171
|
+
alias,
|
|
2172
|
+
from: item[0]
|
|
2173
|
+
};
|
|
2174
|
+
return {
|
|
2175
|
+
tagNamed: true,
|
|
2176
|
+
alias,
|
|
2177
|
+
from: item[0],
|
|
2178
|
+
imported: item[1]
|
|
2179
|
+
};
|
|
2180
|
+
} else return {
|
|
2181
|
+
tagNamed: true,
|
|
2182
|
+
imported: "default",
|
|
2183
|
+
alias,
|
|
2184
|
+
from: item
|
|
2185
|
+
};
|
|
2186
|
+
});
|
|
2187
|
+
}
|
|
2188
|
+
function bindingifyLogLevel(logLevel) {
|
|
2189
|
+
switch (logLevel) {
|
|
2190
|
+
case "silent": return src_rolldown_binding_wasi_cjs.BindingLogLevel.Silent;
|
|
2191
|
+
case "debug": return src_rolldown_binding_wasi_cjs.BindingLogLevel.Debug;
|
|
2192
|
+
case "warn": return src_rolldown_binding_wasi_cjs.BindingLogLevel.Warn;
|
|
2193
|
+
case "info": return src_rolldown_binding_wasi_cjs.BindingLogLevel.Info;
|
|
2194
|
+
default: throw new Error(`Unexpected log level: ${logLevel}`);
|
|
2195
|
+
}
|
|
2196
|
+
}
|
|
2197
|
+
function bindingifyInput(input) {
|
|
2198
|
+
if (input === void 0) return [];
|
|
2199
|
+
if (typeof input === "string") return [{ import: input }];
|
|
2200
|
+
if (Array.isArray(input)) return input.map((src) => ({ import: src }));
|
|
2201
|
+
return Object.entries(input).map(([name, import_path]) => {
|
|
2202
|
+
return {
|
|
2203
|
+
name,
|
|
2204
|
+
import: import_path
|
|
2205
|
+
};
|
|
2206
|
+
});
|
|
2207
|
+
}
|
|
2208
|
+
function bindingifyJsx(input) {
|
|
2209
|
+
switch (input) {
|
|
2210
|
+
case false: return { type: "Disable" };
|
|
2211
|
+
case "react": return { type: "React" };
|
|
2212
|
+
case "react-jsx": return { type: "ReactJsx" };
|
|
2213
|
+
case "preserve": return { type: "Preserve" };
|
|
2214
|
+
case void 0: return void 0;
|
|
2215
|
+
}
|
|
2216
|
+
if (input.mode === "preserve") return { type: "Preserve" };
|
|
2217
|
+
const mode = input.mode ?? "automatic";
|
|
2218
|
+
return {
|
|
2219
|
+
type: "Enable",
|
|
2220
|
+
field0: {
|
|
2221
|
+
runtime: mode,
|
|
2222
|
+
importSource: mode === "classic" ? input.importSource : mode === "automatic" ? input.jsxImportSource : void 0,
|
|
2223
|
+
pragma: input.factory,
|
|
2224
|
+
pragmaFrag: input.fragment,
|
|
2225
|
+
development: input.development,
|
|
2226
|
+
refresh: input.refresh
|
|
2227
|
+
}
|
|
2228
|
+
};
|
|
2229
|
+
}
|
|
2230
|
+
function bindingifyWatch(watch$1) {
|
|
2231
|
+
if (watch$1) return {
|
|
2232
|
+
buildDelay: watch$1.buildDelay,
|
|
2233
|
+
skipWrite: watch$1.skipWrite,
|
|
2234
|
+
include: normalizedStringOrRegex(watch$1.include),
|
|
2235
|
+
exclude: normalizedStringOrRegex(watch$1.exclude)
|
|
2236
|
+
};
|
|
2237
|
+
}
|
|
2238
|
+
function bindingifyTreeshakeOptions(config) {
|
|
2239
|
+
if (config === false) return void 0;
|
|
2240
|
+
if (config === true || config === void 0) return { moduleSideEffects: true };
|
|
2241
|
+
let normalizedConfig = {
|
|
2242
|
+
moduleSideEffects: true,
|
|
2243
|
+
annotations: config.annotations,
|
|
2244
|
+
manualPureFunctions: config.manualPureFunctions,
|
|
2245
|
+
unknownGlobalSideEffects: config.unknownGlobalSideEffects
|
|
2246
|
+
};
|
|
2247
|
+
if (config.moduleSideEffects === void 0) normalizedConfig.moduleSideEffects = true;
|
|
2248
|
+
else if (config.moduleSideEffects === "no-external") normalizedConfig.moduleSideEffects = [{
|
|
2249
|
+
external: true,
|
|
2250
|
+
sideEffects: false
|
|
2251
|
+
}, {
|
|
2252
|
+
external: false,
|
|
2253
|
+
sideEffects: true
|
|
2254
|
+
}];
|
|
2255
|
+
else normalizedConfig.moduleSideEffects = config.moduleSideEffects;
|
|
2256
|
+
return normalizedConfig;
|
|
2257
|
+
}
|
|
2258
|
+
function bindingifyMakeAbsoluteExternalsRelative(makeAbsoluteExternalsRelative) {
|
|
2259
|
+
if (makeAbsoluteExternalsRelative === "ifRelativeSource") return { type: "IfRelativeSource" };
|
|
2260
|
+
if (typeof makeAbsoluteExternalsRelative === "boolean") return {
|
|
2261
|
+
type: "Bool",
|
|
2262
|
+
field0: makeAbsoluteExternalsRelative
|
|
2263
|
+
};
|
|
2264
|
+
}
|
|
2265
|
+
|
|
2266
|
+
//#endregion
|
|
2267
|
+
//#region ../../node_modules/.pnpm/remeda@2.21.2/node_modules/remeda/dist/chunk-D6FCK2GA.js
|
|
2268
|
+
function u$1(o, n, a) {
|
|
2269
|
+
let t$1 = (r) => o(r, ...n);
|
|
2270
|
+
return a === void 0 ? t$1 : Object.assign(t$1, {
|
|
2271
|
+
lazy: a,
|
|
2272
|
+
lazyArgs: n
|
|
2273
|
+
});
|
|
2274
|
+
}
|
|
2275
|
+
|
|
2276
|
+
//#endregion
|
|
2277
|
+
//#region ../../node_modules/.pnpm/remeda@2.21.2/node_modules/remeda/dist/chunk-WIMGWYZL.js
|
|
2278
|
+
function u(r, n, o) {
|
|
2279
|
+
let a = r.length - n.length;
|
|
2280
|
+
if (a === 0) return r(...n);
|
|
2281
|
+
if (a === 1) return u$1(r, n, o);
|
|
2282
|
+
throw new Error("Wrong number of arguments");
|
|
2283
|
+
}
|
|
2284
|
+
|
|
2285
|
+
//#endregion
|
|
2286
|
+
//#region ../../node_modules/.pnpm/remeda@2.21.2/node_modules/remeda/dist/chunk-5NQBDF4H.js
|
|
2287
|
+
function t(...n) {
|
|
2288
|
+
return u(Object.keys, n);
|
|
2289
|
+
}
|
|
2290
|
+
|
|
2291
|
+
//#endregion
|
|
2292
|
+
//#region src/utils/plugin/index.ts
|
|
2293
|
+
const isPluginHookName = function() {
|
|
2294
|
+
const PLUGIN_HOOK_NAMES_SET = new Set(ENUMERATED_PLUGIN_HOOK_NAMES);
|
|
2295
|
+
return function isPluginHookName$1(hookName) {
|
|
2296
|
+
return PLUGIN_HOOK_NAMES_SET.has(hookName);
|
|
2297
|
+
};
|
|
2298
|
+
}();
|
|
2299
|
+
|
|
2300
|
+
//#endregion
|
|
2301
|
+
//#region src/utils/compose-js-plugins.ts
|
|
2302
|
+
const unsupportedHookName = [
|
|
2303
|
+
"augmentChunkHash",
|
|
2304
|
+
"generateBundle",
|
|
2305
|
+
"moduleParsed",
|
|
2306
|
+
"onLog",
|
|
2307
|
+
"options",
|
|
2308
|
+
"outputOptions",
|
|
2309
|
+
"renderError",
|
|
2310
|
+
"renderStart",
|
|
2311
|
+
"resolveDynamicImport",
|
|
2312
|
+
"writeBundle"
|
|
2313
|
+
];
|
|
2314
|
+
const unsupportedHooks = new Set(unsupportedHookName);
|
|
2315
|
+
function isUnsupportedHooks(hookName) {
|
|
2316
|
+
return unsupportedHooks.has(hookName);
|
|
2317
|
+
}
|
|
2318
|
+
function createComposedPlugin(plugins) {
|
|
2319
|
+
const names = [];
|
|
2320
|
+
const batchedHooks = {};
|
|
2321
|
+
plugins.forEach((plugin, index) => {
|
|
2322
|
+
const pluginName = plugin.name || `Anonymous(index: ${index})`;
|
|
2323
|
+
names.push(pluginName);
|
|
2324
|
+
t(plugin).forEach((pluginProp) => {
|
|
2325
|
+
if (isUnsupportedHooks(pluginProp)) throw new Error(`Failed to compose js plugins. Plugin ${pluginName} has an unsupported hook: ${pluginProp}`);
|
|
2326
|
+
if (!isPluginHookName(pluginProp)) return;
|
|
2327
|
+
switch (pluginProp) {
|
|
2328
|
+
case "buildStart": {
|
|
2329
|
+
const handlers = batchedHooks.buildStart ?? [];
|
|
2330
|
+
batchedHooks.buildStart = handlers;
|
|
2331
|
+
if (plugin.buildStart) handlers.push([plugin.buildStart, plugin]);
|
|
2332
|
+
break;
|
|
2333
|
+
}
|
|
2334
|
+
case "load": {
|
|
2335
|
+
const handlers = batchedHooks.load ?? [];
|
|
2336
|
+
batchedHooks.load = handlers;
|
|
2337
|
+
if (plugin.load) handlers.push([plugin.load, plugin]);
|
|
2338
|
+
break;
|
|
2339
|
+
}
|
|
2340
|
+
case "transform": {
|
|
2341
|
+
const handlers = batchedHooks.transform ?? [];
|
|
2342
|
+
batchedHooks.transform = handlers;
|
|
2343
|
+
if (plugin.transform) handlers.push([plugin.transform, plugin]);
|
|
2344
|
+
break;
|
|
2345
|
+
}
|
|
2346
|
+
case "resolveId": {
|
|
2347
|
+
const handlers = batchedHooks.resolveId ?? [];
|
|
2348
|
+
batchedHooks.resolveId = handlers;
|
|
2349
|
+
if (plugin.resolveId) handlers.push([plugin.resolveId, plugin]);
|
|
2350
|
+
break;
|
|
2351
|
+
}
|
|
2352
|
+
case "buildEnd": {
|
|
2353
|
+
const handlers = batchedHooks.buildEnd ?? [];
|
|
2354
|
+
batchedHooks.buildEnd = handlers;
|
|
2355
|
+
if (plugin.buildEnd) handlers.push([plugin.buildEnd, plugin]);
|
|
2356
|
+
break;
|
|
2357
|
+
}
|
|
2358
|
+
case "renderChunk": {
|
|
2359
|
+
const handlers = batchedHooks.renderChunk ?? [];
|
|
2360
|
+
batchedHooks.renderChunk = handlers;
|
|
2361
|
+
if (plugin.renderChunk) handlers.push([plugin.renderChunk, plugin]);
|
|
2362
|
+
break;
|
|
2363
|
+
}
|
|
2364
|
+
case "banner":
|
|
2365
|
+
case "footer":
|
|
2366
|
+
case "intro":
|
|
2367
|
+
case "outro": {
|
|
2368
|
+
const hook = plugin[pluginProp];
|
|
2369
|
+
if (hook) (batchedHooks[pluginProp] ??= []).push([hook, plugin]);
|
|
2370
|
+
break;
|
|
2371
|
+
}
|
|
2372
|
+
case "closeBundle": {
|
|
2373
|
+
const handlers = batchedHooks.closeBundle ?? [];
|
|
2374
|
+
batchedHooks.closeBundle = handlers;
|
|
2375
|
+
if (plugin.closeBundle) handlers.push([plugin.closeBundle, plugin]);
|
|
2376
|
+
break;
|
|
2377
|
+
}
|
|
2378
|
+
case "watchChange": {
|
|
2379
|
+
const handlers = batchedHooks.watchChange ?? [];
|
|
2380
|
+
batchedHooks.watchChange = handlers;
|
|
2381
|
+
if (plugin.watchChange) handlers.push([plugin.watchChange, plugin]);
|
|
2382
|
+
break;
|
|
2383
|
+
}
|
|
2384
|
+
case "closeWatcher": {
|
|
2385
|
+
const handlers = batchedHooks.closeWatcher ?? [];
|
|
2386
|
+
batchedHooks.closeWatcher = handlers;
|
|
2387
|
+
if (plugin.closeWatcher) handlers.push([plugin.closeWatcher, plugin]);
|
|
2388
|
+
break;
|
|
2389
|
+
}
|
|
2390
|
+
default: {}
|
|
2391
|
+
}
|
|
2392
|
+
});
|
|
2393
|
+
});
|
|
2394
|
+
const composed = { name: `Composed(${names.join(", ")})` };
|
|
2395
|
+
const createFixedPluginResolveFnMap = new Map();
|
|
2396
|
+
function applyFixedPluginResolveFn(ctx, plugin) {
|
|
2397
|
+
const createFixedPluginResolveFn = createFixedPluginResolveFnMap.get(plugin);
|
|
2398
|
+
if (createFixedPluginResolveFn) ctx.resolve = createFixedPluginResolveFn(ctx, ctx.resolve.bind(ctx));
|
|
2399
|
+
return ctx;
|
|
2400
|
+
}
|
|
2401
|
+
if (batchedHooks.resolveId) {
|
|
2402
|
+
const batchedHandlers = batchedHooks.resolveId;
|
|
2403
|
+
const handlerSymbols = batchedHandlers.map(([_handler, plugin]) => Symbol(plugin.name ?? `Anonymous`));
|
|
2404
|
+
for (let handlerIdx = 0; handlerIdx < batchedHandlers.length; handlerIdx++) {
|
|
2405
|
+
const [_handler, plugin] = batchedHandlers[handlerIdx];
|
|
2406
|
+
const handlerSymbol = handlerSymbols[handlerIdx];
|
|
2407
|
+
const createFixedPluginResolveFn = (ctx, resolve) => {
|
|
2408
|
+
return (source, importer, rawContextResolveOptions) => {
|
|
2409
|
+
const contextResolveOptions = rawContextResolveOptions ?? {};
|
|
2410
|
+
if (contextResolveOptions.skipSelf) {
|
|
2411
|
+
contextResolveOptions[SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF] = handlerSymbol;
|
|
2412
|
+
contextResolveOptions.skipSelf = false;
|
|
2413
|
+
}
|
|
2414
|
+
return resolve(source, importer, contextResolveOptions);
|
|
2415
|
+
};
|
|
2416
|
+
};
|
|
2417
|
+
createFixedPluginResolveFnMap.set(plugin, createFixedPluginResolveFn);
|
|
2418
|
+
}
|
|
2419
|
+
composed.resolveId = async function(source, importer, rawHookResolveIdOptions) {
|
|
2420
|
+
const hookResolveIdOptions = rawHookResolveIdOptions;
|
|
2421
|
+
const symbolForCallerThatSkipSelf = hookResolveIdOptions?.[SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF];
|
|
2422
|
+
for (let handlerIdx = 0; handlerIdx < batchedHandlers.length; handlerIdx++) {
|
|
2423
|
+
const [handler, plugin] = batchedHandlers[handlerIdx];
|
|
2424
|
+
const handlerSymbol = handlerSymbols[handlerIdx];
|
|
2425
|
+
if (symbolForCallerThatSkipSelf === handlerSymbol) continue;
|
|
2426
|
+
const { handler: handlerFn } = normalizeHook(handler);
|
|
2427
|
+
const result = await handlerFn.call(applyFixedPluginResolveFn(this, plugin), source, importer, rawHookResolveIdOptions);
|
|
2428
|
+
if (!isNullish(result)) return result;
|
|
2429
|
+
}
|
|
2430
|
+
};
|
|
2431
|
+
}
|
|
2432
|
+
t(batchedHooks).forEach((hookName) => {
|
|
2433
|
+
switch (hookName) {
|
|
2434
|
+
case "resolveId": break;
|
|
2435
|
+
case "buildStart": {
|
|
2436
|
+
if (batchedHooks.buildStart) {
|
|
2437
|
+
const batchedHandlers = batchedHooks.buildStart;
|
|
2438
|
+
composed.buildStart = async function(options) {
|
|
2439
|
+
await Promise.all(batchedHandlers.map(([handler, plugin]) => {
|
|
2440
|
+
const { handler: handlerFn } = normalizeHook(handler);
|
|
2441
|
+
return handlerFn.call(applyFixedPluginResolveFn(this, plugin), options);
|
|
2442
|
+
}));
|
|
2443
|
+
};
|
|
2444
|
+
}
|
|
2445
|
+
break;
|
|
2446
|
+
}
|
|
2447
|
+
case "load": {
|
|
2448
|
+
if (batchedHooks.load) {
|
|
2449
|
+
const batchedHandlers = batchedHooks.load;
|
|
2450
|
+
composed.load = async function(id) {
|
|
2451
|
+
for (const [handler, plugin] of batchedHandlers) {
|
|
2452
|
+
const { handler: handlerFn } = normalizeHook(handler);
|
|
2453
|
+
const result = await handlerFn.call(applyFixedPluginResolveFn(this, plugin), id);
|
|
2454
|
+
if (!isNullish(result)) return result;
|
|
2455
|
+
}
|
|
2456
|
+
};
|
|
2457
|
+
}
|
|
2458
|
+
break;
|
|
2459
|
+
}
|
|
2460
|
+
case "transform": {
|
|
2461
|
+
if (batchedHooks.transform) {
|
|
2462
|
+
const batchedHandlers = batchedHooks.transform;
|
|
2463
|
+
composed.transform = async function(initialCode, id, moduleType) {
|
|
2464
|
+
let code = initialCode;
|
|
2465
|
+
let moduleSideEffects = void 0;
|
|
2466
|
+
function updateOutput(newCode, newModuleSideEffects) {
|
|
2467
|
+
code = newCode;
|
|
2468
|
+
moduleSideEffects = newModuleSideEffects ?? void 0;
|
|
2469
|
+
}
|
|
2470
|
+
for (const [handler, plugin] of batchedHandlers) {
|
|
2471
|
+
const { handler: handlerFn } = normalizeHook(handler);
|
|
2472
|
+
this.getCombinedSourcemap = () => {
|
|
2473
|
+
throw new Error(`The getCombinedSourcemap is not implement in transform hook at composedJsPlugins`);
|
|
2474
|
+
};
|
|
2475
|
+
const result = await handlerFn.call(applyFixedPluginResolveFn(this, plugin), code, id, moduleType);
|
|
2476
|
+
if (!isNullish(result)) {
|
|
2477
|
+
if (typeof result === "string") updateOutput(result);
|
|
2478
|
+
else if (result.code) updateOutput(result.code, result.moduleSideEffects);
|
|
2479
|
+
}
|
|
2480
|
+
}
|
|
2481
|
+
return {
|
|
2482
|
+
code,
|
|
2483
|
+
moduleSideEffects
|
|
2484
|
+
};
|
|
2485
|
+
};
|
|
2486
|
+
}
|
|
2487
|
+
break;
|
|
2488
|
+
}
|
|
2489
|
+
case "buildEnd": {
|
|
2490
|
+
if (batchedHooks.buildEnd) {
|
|
2491
|
+
const batchedHandlers = batchedHooks.buildEnd;
|
|
2492
|
+
composed.buildEnd = async function(err) {
|
|
2493
|
+
await Promise.all(batchedHandlers.map(([handler, plugin]) => {
|
|
2494
|
+
const { handler: handlerFn } = normalizeHook(handler);
|
|
2495
|
+
return handlerFn.call(applyFixedPluginResolveFn(this, plugin), err);
|
|
2496
|
+
}));
|
|
2497
|
+
};
|
|
2498
|
+
}
|
|
2499
|
+
break;
|
|
2500
|
+
}
|
|
2501
|
+
case "renderChunk": {
|
|
2502
|
+
if (batchedHooks.renderChunk) {
|
|
2503
|
+
const batchedHandlers = batchedHooks.renderChunk;
|
|
2504
|
+
composed.renderChunk = async function(code, chunk, options, meta) {
|
|
2505
|
+
for (const [handler, plugin] of batchedHandlers) {
|
|
2506
|
+
const { handler: handlerFn } = normalizeHook(handler);
|
|
2507
|
+
const result = await handlerFn.call(applyFixedPluginResolveFn(this, plugin), code, chunk, options, meta);
|
|
2508
|
+
if (!isNullish(result)) return result;
|
|
2509
|
+
}
|
|
2510
|
+
};
|
|
2511
|
+
}
|
|
2512
|
+
break;
|
|
2513
|
+
}
|
|
2514
|
+
case "banner":
|
|
2515
|
+
case "footer":
|
|
2516
|
+
case "intro":
|
|
2517
|
+
case "outro": {
|
|
2518
|
+
const hooks = batchedHooks[hookName];
|
|
2519
|
+
if (hooks?.length) composed[hookName] = async function(chunk) {
|
|
2520
|
+
const ret = [];
|
|
2521
|
+
for (const [hook, plugin] of hooks) {
|
|
2522
|
+
const { handler } = normalizeHook(hook);
|
|
2523
|
+
ret.push(typeof handler === "string" ? handler : await handler.call(applyFixedPluginResolveFn(this, plugin), chunk));
|
|
2524
|
+
}
|
|
2525
|
+
return ret.join("\n");
|
|
2526
|
+
};
|
|
2527
|
+
break;
|
|
2528
|
+
}
|
|
2529
|
+
case "closeBundle": {
|
|
2530
|
+
if (batchedHooks.closeBundle) {
|
|
2531
|
+
const batchedHandlers = batchedHooks.closeBundle;
|
|
2532
|
+
composed.closeBundle = async function() {
|
|
2533
|
+
await Promise.all(batchedHandlers.map(([handler, plugin]) => {
|
|
2534
|
+
const { handler: handlerFn } = normalizeHook(handler);
|
|
2535
|
+
return handlerFn.call(applyFixedPluginResolveFn(this, plugin));
|
|
2536
|
+
}));
|
|
2537
|
+
};
|
|
2538
|
+
}
|
|
2539
|
+
break;
|
|
2540
|
+
}
|
|
2541
|
+
case "watchChange": {
|
|
2542
|
+
if (batchedHooks.watchChange) {
|
|
2543
|
+
const batchedHandlers = batchedHooks.watchChange;
|
|
2544
|
+
composed.watchChange = async function(id, event) {
|
|
2545
|
+
await Promise.all(batchedHandlers.map(([handler, plugin]) => {
|
|
2546
|
+
const { handler: handlerFn } = normalizeHook(handler);
|
|
2547
|
+
return handlerFn.call(applyFixedPluginResolveFn(this, plugin), id, event);
|
|
2548
|
+
}));
|
|
2549
|
+
};
|
|
2550
|
+
}
|
|
2551
|
+
break;
|
|
2552
|
+
}
|
|
2553
|
+
case "closeWatcher": {
|
|
2554
|
+
if (batchedHooks.closeWatcher) {
|
|
2555
|
+
const batchedHandlers = batchedHooks.closeWatcher;
|
|
2556
|
+
composed.closeWatcher = async function() {
|
|
2557
|
+
await Promise.all(batchedHandlers.map(([handler, plugin]) => {
|
|
2558
|
+
const { handler: handlerFn } = normalizeHook(handler);
|
|
2559
|
+
return handlerFn.call(applyFixedPluginResolveFn(this, plugin));
|
|
2560
|
+
}));
|
|
2561
|
+
};
|
|
2562
|
+
}
|
|
2563
|
+
break;
|
|
2564
|
+
}
|
|
2565
|
+
default: {}
|
|
2566
|
+
}
|
|
2567
|
+
});
|
|
2568
|
+
return composed;
|
|
2569
|
+
}
|
|
2570
|
+
function isComposablePlugin(plugin) {
|
|
2571
|
+
if (plugin instanceof BuiltinPlugin) return false;
|
|
2572
|
+
if ("_parallel" in plugin) return false;
|
|
2573
|
+
const hasNotComposablePattern = t(plugin).some((hookName) => {
|
|
2574
|
+
if (!isPluginHookName(hookName)) return false;
|
|
2575
|
+
const OK_TO_COMPOSE = false;
|
|
2576
|
+
if (isUnsupportedHooks(hookName)) return !OK_TO_COMPOSE;
|
|
2577
|
+
if (plugin[hookName]) {
|
|
2578
|
+
const { meta } = normalizeHook(plugin[hookName]);
|
|
2579
|
+
if (meta.order === "pre" || meta.order === "post") return !OK_TO_COMPOSE;
|
|
2580
|
+
}
|
|
2581
|
+
return OK_TO_COMPOSE;
|
|
2582
|
+
});
|
|
2583
|
+
if (hasNotComposablePattern) return false;
|
|
2584
|
+
return true;
|
|
2585
|
+
}
|
|
2586
|
+
function composeJsPlugins(plugins) {
|
|
2587
|
+
const newPlugins = [];
|
|
2588
|
+
const toBeComposed = [];
|
|
2589
|
+
plugins.forEach((plugin) => {
|
|
2590
|
+
if (isComposablePlugin(plugin)) toBeComposed.push(plugin);
|
|
2591
|
+
else {
|
|
2592
|
+
if (toBeComposed.length > 0) {
|
|
2593
|
+
if (toBeComposed.length > 1) newPlugins.push(createComposedPlugin(toBeComposed));
|
|
2594
|
+
else newPlugins.push(toBeComposed[0]);
|
|
2595
|
+
toBeComposed.length = 0;
|
|
2596
|
+
}
|
|
2597
|
+
newPlugins.push(plugin);
|
|
2598
|
+
}
|
|
2599
|
+
});
|
|
2600
|
+
if (toBeComposed.length > 0) {
|
|
2601
|
+
if (toBeComposed.length > 1) newPlugins.push(createComposedPlugin(toBeComposed));
|
|
2602
|
+
else newPlugins.push(toBeComposed[0]);
|
|
2603
|
+
toBeComposed.length = 0;
|
|
2604
|
+
}
|
|
2605
|
+
return newPlugins;
|
|
2606
|
+
}
|
|
2607
|
+
|
|
2608
|
+
//#endregion
|
|
2609
|
+
//#region src/utils/initialize-parallel-plugins.ts
|
|
2610
|
+
async function initializeParallelPlugins(plugins) {
|
|
2611
|
+
const pluginInfos = [];
|
|
2612
|
+
for (const [index, plugin] of plugins.entries()) if ("_parallel" in plugin) {
|
|
2613
|
+
const { fileUrl, options } = plugin._parallel;
|
|
2614
|
+
pluginInfos.push({
|
|
2615
|
+
index,
|
|
2616
|
+
fileUrl,
|
|
2617
|
+
options
|
|
2618
|
+
});
|
|
2619
|
+
}
|
|
2620
|
+
if (pluginInfos.length <= 0) return void 0;
|
|
2621
|
+
const count = Math.min((0, node_os.availableParallelism)(), 8);
|
|
2622
|
+
const parallelJsPluginRegistry = new src_rolldown_binding_wasi_cjs.ParallelJsPluginRegistry(count);
|
|
2623
|
+
const registryId = parallelJsPluginRegistry.id;
|
|
2624
|
+
const workers = await initializeWorkers(registryId, count, pluginInfos);
|
|
2625
|
+
const stopWorkers = async () => {
|
|
2626
|
+
await Promise.all(workers.map((worker) => worker.terminate()));
|
|
2627
|
+
};
|
|
2628
|
+
return {
|
|
2629
|
+
registry: parallelJsPluginRegistry,
|
|
2630
|
+
stopWorkers
|
|
2631
|
+
};
|
|
2632
|
+
}
|
|
2633
|
+
function initializeWorkers(registryId, count, pluginInfos) {
|
|
2634
|
+
return Promise.all(Array.from({ length: count }, (_, i) => initializeWorker(registryId, pluginInfos, i)));
|
|
2635
|
+
}
|
|
2636
|
+
async function initializeWorker(registryId, pluginInfos, threadNumber) {
|
|
2637
|
+
const urlString = (void 0)("#parallel-plugin-worker");
|
|
2638
|
+
const workerData = {
|
|
2639
|
+
registryId,
|
|
2640
|
+
pluginInfos,
|
|
2641
|
+
threadNumber
|
|
2642
|
+
};
|
|
2643
|
+
let worker;
|
|
2644
|
+
try {
|
|
2645
|
+
worker = new node_worker_threads.Worker(new URL(urlString), { workerData });
|
|
2646
|
+
worker.unref();
|
|
2647
|
+
await new Promise((resolve, reject) => {
|
|
2648
|
+
worker.once("message", async (message) => {
|
|
2649
|
+
if (message.type === "error") reject(message.error);
|
|
2650
|
+
else resolve();
|
|
2651
|
+
});
|
|
2652
|
+
});
|
|
2653
|
+
return worker;
|
|
2654
|
+
} catch (e) {
|
|
2655
|
+
worker?.terminate();
|
|
2656
|
+
throw e;
|
|
2657
|
+
}
|
|
2658
|
+
}
|
|
2659
|
+
|
|
2660
|
+
//#endregion
|
|
2661
|
+
//#region src/utils/create-bundler-option.ts
|
|
2662
|
+
async function createBundlerOptions(inputOptions, outputOptions, watchMode, isClose) {
|
|
2663
|
+
const inputPlugins = await normalizePluginOption(inputOptions.plugins);
|
|
2664
|
+
const outputPlugins = await normalizePluginOption(outputOptions.plugins);
|
|
2665
|
+
const logLevel = inputOptions.logLevel || LOG_LEVEL_INFO;
|
|
2666
|
+
const onLog = getLogger(getObjectPlugins(inputPlugins), getOnLog(inputOptions, logLevel), logLevel, watchMode);
|
|
2667
|
+
if (!isClose) outputOptions = PluginDriver.callOutputOptionsHook([...inputPlugins, ...outputPlugins], outputOptions, onLog, logLevel, watchMode);
|
|
2668
|
+
if (outputOptions.minify === true) onLog(LOG_LEVEL_WARN, require_parse_ast_index.logMinifyWarning());
|
|
2669
|
+
const normalizedOutputPlugins = await normalizePluginOption(outputOptions.plugins);
|
|
2670
|
+
let plugins = [...normalizePlugins(inputPlugins, ANONYMOUS_PLUGIN_PREFIX), ...checkOutputPluginOption(normalizePlugins(normalizedOutputPlugins, ANONYMOUS_OUTPUT_PLUGIN_PREFIX), onLog)];
|
|
2671
|
+
if (inputOptions.experimental?.enableComposingJsPlugins ?? false) plugins = composeJsPlugins(plugins);
|
|
2672
|
+
const parallelPluginInitResult = await initializeParallelPlugins(plugins);
|
|
2673
|
+
try {
|
|
2674
|
+
const bindingInputOptions = bindingifyInputOptions(plugins, inputOptions, outputOptions, normalizedOutputPlugins, onLog, logLevel, watchMode);
|
|
2675
|
+
const bindingOutputOptions = bindingifyOutputOptions(outputOptions);
|
|
2676
|
+
return {
|
|
2677
|
+
bundlerOptions: {
|
|
2678
|
+
inputOptions: bindingInputOptions,
|
|
2679
|
+
outputOptions: bindingOutputOptions,
|
|
2680
|
+
parallelPluginsRegistry: parallelPluginInitResult?.registry
|
|
2681
|
+
},
|
|
2682
|
+
inputOptions,
|
|
2683
|
+
onLog,
|
|
2684
|
+
stopWorkers: parallelPluginInitResult?.stopWorkers
|
|
2685
|
+
};
|
|
2686
|
+
} catch (e) {
|
|
2687
|
+
await parallelPluginInitResult?.stopWorkers();
|
|
2688
|
+
throw e;
|
|
2689
|
+
}
|
|
2690
|
+
}
|
|
2691
|
+
|
|
2692
|
+
//#endregion
|
|
2693
|
+
//#region src/utils/create-bundler.ts
|
|
2694
|
+
let asyncRuntimeShutdown = false;
|
|
2695
|
+
async function createBundler(inputOptions, outputOptions, isClose) {
|
|
2696
|
+
const option = await createBundlerOptions(inputOptions, outputOptions, false, isClose);
|
|
2697
|
+
if (asyncRuntimeShutdown) (0, src_rolldown_binding_wasi_cjs.startAsyncRuntime)();
|
|
2698
|
+
try {
|
|
2699
|
+
return {
|
|
2700
|
+
bundler: new src_rolldown_binding_wasi_cjs.Bundler(option.bundlerOptions),
|
|
2701
|
+
stopWorkers: option.stopWorkers,
|
|
2702
|
+
shutdown: () => {
|
|
2703
|
+
(0, src_rolldown_binding_wasi_cjs.shutdownAsyncRuntime)();
|
|
2704
|
+
asyncRuntimeShutdown = true;
|
|
2705
|
+
}
|
|
2706
|
+
};
|
|
2707
|
+
} catch (e) {
|
|
2708
|
+
await option.stopWorkers?.();
|
|
2709
|
+
throw e;
|
|
2710
|
+
}
|
|
2711
|
+
}
|
|
2712
|
+
|
|
2713
|
+
//#endregion
|
|
2714
|
+
//#region src/api/rolldown/rolldown-build.ts
|
|
2715
|
+
Symbol.asyncDispose ??= Symbol("Symbol.asyncDispose");
|
|
2716
|
+
var RolldownBuild = class {
|
|
2717
|
+
#inputOptions;
|
|
2718
|
+
#bundler;
|
|
2719
|
+
constructor(inputOptions) {
|
|
2720
|
+
this.#inputOptions = inputOptions;
|
|
2721
|
+
}
|
|
2722
|
+
get closed() {
|
|
2723
|
+
return this.#bundler?.bundler.closed ?? false;
|
|
2724
|
+
}
|
|
2725
|
+
async #getBundlerWithStopWorker(outputOptions, isClose) {
|
|
2726
|
+
if (this.#bundler) await this.#bundler.stopWorkers?.();
|
|
2727
|
+
return this.#bundler = await createBundler(this.#inputOptions, outputOptions, isClose);
|
|
2728
|
+
}
|
|
2729
|
+
async generate(outputOptions = {}) {
|
|
2730
|
+
validateOption("output", outputOptions);
|
|
2731
|
+
const { bundler } = await this.#getBundlerWithStopWorker(outputOptions);
|
|
2732
|
+
const output = await bundler.generate();
|
|
2733
|
+
return transformToRollupOutput(output);
|
|
2734
|
+
}
|
|
2735
|
+
async write(outputOptions = {}) {
|
|
2736
|
+
validateOption("output", outputOptions);
|
|
2737
|
+
const { bundler } = await this.#getBundlerWithStopWorker(outputOptions);
|
|
2738
|
+
const output = await bundler.write();
|
|
2739
|
+
return transformToRollupOutput(output);
|
|
2740
|
+
}
|
|
2741
|
+
async close() {
|
|
2742
|
+
const { bundler, stopWorkers, shutdown } = await this.#getBundlerWithStopWorker({}, true);
|
|
2743
|
+
await stopWorkers?.();
|
|
2744
|
+
await bundler.close();
|
|
2745
|
+
shutdown();
|
|
2746
|
+
}
|
|
2747
|
+
async [Symbol.asyncDispose]() {
|
|
2748
|
+
await this.close();
|
|
2749
|
+
}
|
|
2750
|
+
async generateHmrPatch(changedFiles) {
|
|
2751
|
+
return this.#bundler?.bundler.generateHmrPatch(changedFiles);
|
|
2752
|
+
}
|
|
2753
|
+
get watchFiles() {
|
|
2754
|
+
return this.#bundler?.bundler.watchFiles ?? [];
|
|
2755
|
+
}
|
|
2756
|
+
};
|
|
2757
|
+
|
|
2758
|
+
//#endregion
|
|
2759
|
+
//#region src/api/rolldown/index.ts
|
|
2760
|
+
const rolldown = async (input) => {
|
|
2761
|
+
validateOption("input", input);
|
|
2762
|
+
const inputOptions = await PluginDriver.callOptionsHook(input);
|
|
2763
|
+
return new RolldownBuild(inputOptions);
|
|
2764
|
+
};
|
|
2765
|
+
|
|
2766
|
+
//#endregion
|
|
2767
|
+
//#region src/api/build.ts
|
|
2768
|
+
async function build(options) {
|
|
2769
|
+
if (Array.isArray(options)) return Promise.all(options.map((opts) => build(opts)));
|
|
2770
|
+
else {
|
|
2771
|
+
const { output, write = true,...inputOptions } = options;
|
|
2772
|
+
const build$1 = await rolldown(inputOptions);
|
|
2773
|
+
try {
|
|
2774
|
+
if (write) return await build$1.write(output);
|
|
2775
|
+
else return await build$1.generate(output);
|
|
2776
|
+
} finally {
|
|
2777
|
+
await build$1.close();
|
|
2778
|
+
}
|
|
2779
|
+
}
|
|
2780
|
+
}
|
|
2781
|
+
|
|
2782
|
+
//#endregion
|
|
2783
|
+
//#region src/api/watch/watch-emitter.ts
|
|
2784
|
+
var WatcherEmitter = class {
|
|
2785
|
+
listeners = new Map();
|
|
2786
|
+
timer;
|
|
2787
|
+
constructor() {
|
|
2788
|
+
this.timer = setInterval(
|
|
2789
|
+
() => {},
|
|
2790
|
+
1e9
|
|
2791
|
+
/* Low power usage */
|
|
2792
|
+
);
|
|
2793
|
+
}
|
|
2794
|
+
on(event, listener) {
|
|
2795
|
+
const listeners = this.listeners.get(event);
|
|
2796
|
+
if (listeners) listeners.push(listener);
|
|
2797
|
+
else this.listeners.set(event, [listener]);
|
|
2798
|
+
return this;
|
|
2799
|
+
}
|
|
2800
|
+
async onEvent(event) {
|
|
2801
|
+
const listeners = this.listeners.get(event.eventKind());
|
|
2802
|
+
if (listeners) switch (event.eventKind()) {
|
|
2803
|
+
case "close":
|
|
2804
|
+
case "restart":
|
|
2805
|
+
for (const listener of listeners) await listener();
|
|
2806
|
+
break;
|
|
2807
|
+
case "event":
|
|
2808
|
+
for (const listener of listeners) {
|
|
2809
|
+
const code = event.bundleEventKind();
|
|
2810
|
+
switch (code) {
|
|
2811
|
+
case "BUNDLE_END":
|
|
2812
|
+
const { duration, output } = event.bundleEndData();
|
|
2813
|
+
await listener({
|
|
2814
|
+
code: "BUNDLE_END",
|
|
2815
|
+
duration,
|
|
2816
|
+
output: [output]
|
|
2817
|
+
});
|
|
2818
|
+
break;
|
|
2819
|
+
case "ERROR":
|
|
2820
|
+
const errors = event.errors();
|
|
2821
|
+
await listener({
|
|
2822
|
+
code: "ERROR",
|
|
2823
|
+
error: normalizeErrors(errors)
|
|
2824
|
+
});
|
|
2825
|
+
break;
|
|
2826
|
+
default:
|
|
2827
|
+
await listener({ code });
|
|
2828
|
+
break;
|
|
2829
|
+
}
|
|
2830
|
+
}
|
|
2831
|
+
break;
|
|
2832
|
+
case "change":
|
|
2833
|
+
for (const listener of listeners) {
|
|
2834
|
+
const { path: path$2, kind } = event.watchChangeData();
|
|
2835
|
+
await listener(path$2, { event: kind });
|
|
2836
|
+
}
|
|
2837
|
+
break;
|
|
2838
|
+
default: throw new Error(`Unknown event: ${event}`);
|
|
2839
|
+
}
|
|
2840
|
+
}
|
|
2841
|
+
async close() {
|
|
2842
|
+
clearInterval(this.timer);
|
|
2843
|
+
}
|
|
2844
|
+
};
|
|
2845
|
+
|
|
2846
|
+
//#endregion
|
|
2847
|
+
//#region src/api/watch/watcher.ts
|
|
2848
|
+
var Watcher = class {
|
|
2849
|
+
closed;
|
|
2850
|
+
inner;
|
|
2851
|
+
emitter;
|
|
2852
|
+
stopWorkers;
|
|
2853
|
+
constructor(emitter, inner, stopWorkers) {
|
|
2854
|
+
this.closed = false;
|
|
2855
|
+
this.inner = inner;
|
|
2856
|
+
this.emitter = emitter;
|
|
2857
|
+
const originClose = emitter.close.bind(emitter);
|
|
2858
|
+
emitter.close = async () => {
|
|
2859
|
+
await this.close();
|
|
2860
|
+
originClose();
|
|
2861
|
+
};
|
|
2862
|
+
this.stopWorkers = stopWorkers;
|
|
2863
|
+
}
|
|
2864
|
+
async close() {
|
|
2865
|
+
if (this.closed) return;
|
|
2866
|
+
this.closed = true;
|
|
2867
|
+
for (const stop of this.stopWorkers) await stop?.();
|
|
2868
|
+
await this.inner.close();
|
|
2869
|
+
(0, src_rolldown_binding_wasi_cjs.shutdownAsyncRuntime)();
|
|
2870
|
+
}
|
|
2871
|
+
start() {
|
|
2872
|
+
process.nextTick(() => this.inner.start(this.emitter.onEvent.bind(this.emitter)));
|
|
2873
|
+
}
|
|
2874
|
+
};
|
|
2875
|
+
async function createWatcher(emitter, input) {
|
|
2876
|
+
const options = arraify(input);
|
|
2877
|
+
const bundlerOptions = await Promise.all(options.map((option) => arraify(option.output || {}).map(async (output) => {
|
|
2878
|
+
const inputOptions = await PluginDriver.callOptionsHook(option, true);
|
|
2879
|
+
return createBundlerOptions(inputOptions, output, true);
|
|
2880
|
+
})).flat());
|
|
2881
|
+
const notifyOptions = getValidNotifyOption(bundlerOptions);
|
|
2882
|
+
const bindingWatcher = new src_rolldown_binding_wasi_cjs.BindingWatcher(bundlerOptions.map((option) => option.bundlerOptions), notifyOptions);
|
|
2883
|
+
const watcher = new Watcher(emitter, bindingWatcher, bundlerOptions.map((option) => option.stopWorkers));
|
|
2884
|
+
watcher.start();
|
|
2885
|
+
}
|
|
2886
|
+
function getValidNotifyOption(bundlerOptions) {
|
|
2887
|
+
let result;
|
|
2888
|
+
for (const option of bundlerOptions) if (option.inputOptions.watch) {
|
|
2889
|
+
const notifyOption = option.inputOptions.watch.notify;
|
|
2890
|
+
if (notifyOption) if (result) {
|
|
2891
|
+
option.onLog(LOG_LEVEL_WARN, require_parse_ast_index.logMultiplyNotifyOption());
|
|
2892
|
+
return result;
|
|
2893
|
+
} else result = notifyOption;
|
|
2894
|
+
}
|
|
2895
|
+
}
|
|
2896
|
+
|
|
2897
|
+
//#endregion
|
|
2898
|
+
//#region src/api/watch/index.ts
|
|
2899
|
+
const watch = (input) => {
|
|
2900
|
+
const emitter = new WatcherEmitter();
|
|
2901
|
+
createWatcher(emitter, input);
|
|
2902
|
+
return emitter;
|
|
2903
|
+
};
|
|
2904
|
+
|
|
2905
|
+
//#endregion
|
|
2906
|
+
//#region src/plugin/with-filter.ts
|
|
2907
|
+
function withFilterImpl(pluginOption, filterObjectList) {
|
|
2908
|
+
if (isPromiseLike(pluginOption)) return pluginOption.then((p) => withFilter(p, filterObjectList));
|
|
2909
|
+
if (pluginOption == false || pluginOption == null) return pluginOption;
|
|
2910
|
+
if (Array.isArray(pluginOption)) return pluginOption.map((p) => withFilter(p, filterObjectList));
|
|
2911
|
+
let plugin = pluginOption;
|
|
2912
|
+
let filterObjectIndex = findMatchedFilterObject(plugin.name, filterObjectList);
|
|
2913
|
+
if (filterObjectIndex === -1) return plugin;
|
|
2914
|
+
let filterObject = filterObjectList[filterObjectIndex];
|
|
2915
|
+
Object.keys(plugin).forEach((key) => {
|
|
2916
|
+
switch (key) {
|
|
2917
|
+
case "transform":
|
|
2918
|
+
case "resolveId":
|
|
2919
|
+
case "load":
|
|
2920
|
+
if (!plugin[key]) return;
|
|
2921
|
+
if (typeof plugin[key] === "object") plugin[key].filter = filterObject[key] ?? plugin[key].filter;
|
|
2922
|
+
else plugin[key] = {
|
|
2923
|
+
handler: plugin[key],
|
|
2924
|
+
filter: filterObject[key]
|
|
2925
|
+
};
|
|
2926
|
+
break;
|
|
2927
|
+
default: break;
|
|
2928
|
+
}
|
|
2929
|
+
});
|
|
2930
|
+
return plugin;
|
|
2931
|
+
}
|
|
2932
|
+
function withFilter(pluginOption, filterObject) {
|
|
2933
|
+
return withFilterImpl(pluginOption, arraify(filterObject));
|
|
2934
|
+
}
|
|
2935
|
+
function findMatchedFilterObject(pluginName, overrideFilterObjectList) {
|
|
2936
|
+
if (overrideFilterObjectList.length === 1 && overrideFilterObjectList[0].pluginNamePattern === void 0) return 0;
|
|
2937
|
+
for (let i = 0; i < overrideFilterObjectList.length; i++) for (let j = 0; j < (overrideFilterObjectList[i].pluginNamePattern ?? []).length; j++) {
|
|
2938
|
+
let pattern = overrideFilterObjectList[i].pluginNamePattern[j];
|
|
2939
|
+
if (typeof pattern === "string" && pattern === pluginName) return i;
|
|
2940
|
+
else if (pattern instanceof RegExp && pattern.test(pluginName)) return i;
|
|
2941
|
+
}
|
|
2942
|
+
return -1;
|
|
2943
|
+
}
|
|
2944
|
+
|
|
2945
|
+
//#endregion
|
|
2946
|
+
//#region src/utils/define-config.ts
|
|
2947
|
+
function defineConfig(config) {
|
|
2948
|
+
return config;
|
|
2949
|
+
}
|
|
2950
|
+
|
|
2951
|
+
//#endregion
|
|
2952
|
+
//#region src/index.ts
|
|
2953
|
+
const VERSION = version;
|
|
2954
|
+
|
|
2955
|
+
//#endregion
|
|
2956
|
+
Object.defineProperty(exports, 'BuiltinPlugin', {
|
|
2957
|
+
enumerable: true,
|
|
2958
|
+
get: function () {
|
|
2959
|
+
return BuiltinPlugin;
|
|
2960
|
+
}
|
|
2961
|
+
});
|
|
2962
|
+
Object.defineProperty(exports, 'PluginContextData', {
|
|
2963
|
+
enumerable: true,
|
|
2964
|
+
get: function () {
|
|
2965
|
+
return PluginContextData;
|
|
2966
|
+
}
|
|
2967
|
+
});
|
|
2968
|
+
Object.defineProperty(exports, 'VERSION', {
|
|
2969
|
+
enumerable: true,
|
|
2970
|
+
get: function () {
|
|
2971
|
+
return VERSION;
|
|
2972
|
+
}
|
|
2973
|
+
});
|
|
2974
|
+
Object.defineProperty(exports, 'arraify', {
|
|
2975
|
+
enumerable: true,
|
|
2976
|
+
get: function () {
|
|
2977
|
+
return arraify;
|
|
2978
|
+
}
|
|
2979
|
+
});
|
|
2980
|
+
Object.defineProperty(exports, 'bindingifyPlugin', {
|
|
2981
|
+
enumerable: true,
|
|
2982
|
+
get: function () {
|
|
2983
|
+
return bindingifyPlugin;
|
|
2984
|
+
}
|
|
2985
|
+
});
|
|
2986
|
+
Object.defineProperty(exports, 'build', {
|
|
2987
|
+
enumerable: true,
|
|
2988
|
+
get: function () {
|
|
2989
|
+
return build;
|
|
2990
|
+
}
|
|
2991
|
+
});
|
|
2992
|
+
Object.defineProperty(exports, 'buildImportAnalysisPlugin', {
|
|
2993
|
+
enumerable: true,
|
|
2994
|
+
get: function () {
|
|
2995
|
+
return buildImportAnalysisPlugin;
|
|
2996
|
+
}
|
|
2997
|
+
});
|
|
2998
|
+
Object.defineProperty(exports, 'composeJsPlugins', {
|
|
2999
|
+
enumerable: true,
|
|
3000
|
+
get: function () {
|
|
3001
|
+
return composeJsPlugins;
|
|
3002
|
+
}
|
|
3003
|
+
});
|
|
3004
|
+
Object.defineProperty(exports, 'createBundler', {
|
|
3005
|
+
enumerable: true,
|
|
3006
|
+
get: function () {
|
|
3007
|
+
return createBundler;
|
|
3008
|
+
}
|
|
3009
|
+
});
|
|
3010
|
+
Object.defineProperty(exports, 'defineConfig', {
|
|
3011
|
+
enumerable: true,
|
|
3012
|
+
get: function () {
|
|
3013
|
+
return defineConfig;
|
|
3014
|
+
}
|
|
3015
|
+
});
|
|
3016
|
+
Object.defineProperty(exports, 'description', {
|
|
3017
|
+
enumerable: true,
|
|
3018
|
+
get: function () {
|
|
3019
|
+
return description;
|
|
3020
|
+
}
|
|
3021
|
+
});
|
|
3022
|
+
Object.defineProperty(exports, 'dynamicImportVarsPlugin', {
|
|
3023
|
+
enumerable: true,
|
|
3024
|
+
get: function () {
|
|
3025
|
+
return dynamicImportVarsPlugin;
|
|
3026
|
+
}
|
|
3027
|
+
});
|
|
3028
|
+
Object.defineProperty(exports, 'getInputCliKeys', {
|
|
3029
|
+
enumerable: true,
|
|
3030
|
+
get: function () {
|
|
3031
|
+
return getInputCliKeys;
|
|
3032
|
+
}
|
|
3033
|
+
});
|
|
3034
|
+
Object.defineProperty(exports, 'getJsonSchema', {
|
|
3035
|
+
enumerable: true,
|
|
3036
|
+
get: function () {
|
|
3037
|
+
return getJsonSchema;
|
|
3038
|
+
}
|
|
3039
|
+
});
|
|
3040
|
+
Object.defineProperty(exports, 'getOutputCliKeys', {
|
|
3041
|
+
enumerable: true,
|
|
3042
|
+
get: function () {
|
|
3043
|
+
return getOutputCliKeys;
|
|
3044
|
+
}
|
|
3045
|
+
});
|
|
3046
|
+
Object.defineProperty(exports, 'handleOutputErrors', {
|
|
3047
|
+
enumerable: true,
|
|
3048
|
+
get: function () {
|
|
3049
|
+
return handleOutputErrors;
|
|
3050
|
+
}
|
|
3051
|
+
});
|
|
3052
|
+
Object.defineProperty(exports, 'importGlobPlugin', {
|
|
3053
|
+
enumerable: true,
|
|
3054
|
+
get: function () {
|
|
3055
|
+
return importGlobPlugin;
|
|
3056
|
+
}
|
|
3057
|
+
});
|
|
3058
|
+
Object.defineProperty(exports, 'isolatedDeclarationPlugin', {
|
|
3059
|
+
enumerable: true,
|
|
3060
|
+
get: function () {
|
|
3061
|
+
return isolatedDeclarationPlugin;
|
|
3062
|
+
}
|
|
3063
|
+
});
|
|
3064
|
+
Object.defineProperty(exports, 'jsonPlugin', {
|
|
3065
|
+
enumerable: true,
|
|
3066
|
+
get: function () {
|
|
3067
|
+
return jsonPlugin;
|
|
3068
|
+
}
|
|
3069
|
+
});
|
|
3070
|
+
Object.defineProperty(exports, 'loadFallbackPlugin', {
|
|
3071
|
+
enumerable: true,
|
|
3072
|
+
get: function () {
|
|
3073
|
+
return loadFallbackPlugin;
|
|
3074
|
+
}
|
|
3075
|
+
});
|
|
3076
|
+
Object.defineProperty(exports, 'manifestPlugin', {
|
|
3077
|
+
enumerable: true,
|
|
3078
|
+
get: function () {
|
|
3079
|
+
return manifestPlugin;
|
|
3080
|
+
}
|
|
3081
|
+
});
|
|
3082
|
+
Object.defineProperty(exports, 'moduleFederationPlugin', {
|
|
3083
|
+
enumerable: true,
|
|
3084
|
+
get: function () {
|
|
3085
|
+
return moduleFederationPlugin;
|
|
3086
|
+
}
|
|
3087
|
+
});
|
|
3088
|
+
Object.defineProperty(exports, 'modulePreloadPolyfillPlugin', {
|
|
3089
|
+
enumerable: true,
|
|
3090
|
+
get: function () {
|
|
3091
|
+
return modulePreloadPolyfillPlugin;
|
|
3092
|
+
}
|
|
3093
|
+
});
|
|
3094
|
+
Object.defineProperty(exports, 'normalizedStringOrRegex', {
|
|
3095
|
+
enumerable: true,
|
|
3096
|
+
get: function () {
|
|
3097
|
+
return normalizedStringOrRegex;
|
|
3098
|
+
}
|
|
3099
|
+
});
|
|
3100
|
+
Object.defineProperty(exports, 'rolldown', {
|
|
3101
|
+
enumerable: true,
|
|
3102
|
+
get: function () {
|
|
3103
|
+
return rolldown;
|
|
3104
|
+
}
|
|
3105
|
+
});
|
|
3106
|
+
Object.defineProperty(exports, 'validateCliOptions', {
|
|
3107
|
+
enumerable: true,
|
|
3108
|
+
get: function () {
|
|
3109
|
+
return validateCliOptions;
|
|
3110
|
+
}
|
|
3111
|
+
});
|
|
3112
|
+
Object.defineProperty(exports, 'version', {
|
|
3113
|
+
enumerable: true,
|
|
3114
|
+
get: function () {
|
|
3115
|
+
return version;
|
|
3116
|
+
}
|
|
3117
|
+
});
|
|
3118
|
+
Object.defineProperty(exports, 'viteResolvePlugin', {
|
|
3119
|
+
enumerable: true,
|
|
3120
|
+
get: function () {
|
|
3121
|
+
return viteResolvePlugin;
|
|
3122
|
+
}
|
|
3123
|
+
});
|
|
3124
|
+
Object.defineProperty(exports, 'wasmFallbackPlugin', {
|
|
3125
|
+
enumerable: true,
|
|
3126
|
+
get: function () {
|
|
3127
|
+
return wasmFallbackPlugin;
|
|
3128
|
+
}
|
|
3129
|
+
});
|
|
3130
|
+
Object.defineProperty(exports, 'wasmHelperPlugin', {
|
|
3131
|
+
enumerable: true,
|
|
3132
|
+
get: function () {
|
|
3133
|
+
return wasmHelperPlugin;
|
|
3134
|
+
}
|
|
3135
|
+
});
|
|
3136
|
+
Object.defineProperty(exports, 'watch', {
|
|
3137
|
+
enumerable: true,
|
|
3138
|
+
get: function () {
|
|
3139
|
+
return watch;
|
|
3140
|
+
}
|
|
3141
|
+
});
|
|
3142
|
+
Object.defineProperty(exports, 'withFilter', {
|
|
3143
|
+
enumerable: true,
|
|
3144
|
+
get: function () {
|
|
3145
|
+
return withFilter;
|
|
3146
|
+
}
|
|
3147
|
+
});
|