rolldown 1.0.0-beta.8-commit.c76291c → 1.0.0-beta.8-commit.e270f24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.cjs +6 -6
- package/dist/cli.mjs +2 -2
- package/dist/experimental-index.cjs +2 -2
- package/dist/experimental-index.d.cts +2 -2
- package/dist/experimental-index.d.mts +2 -2
- package/dist/experimental-index.mjs +2 -2
- package/dist/filter-index.cjs +93 -11
- package/dist/filter-index.d.cts +4 -3
- package/dist/filter-index.d.mts +4 -3
- package/dist/filter-index.mjs +44 -3
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +2 -2
- package/dist/parallel-plugin-worker.cjs +2 -2
- package/dist/parallel-plugin-worker.mjs +2 -2
- package/dist/parallel-plugin.d.cts +2 -2
- package/dist/parallel-plugin.d.mts +2 -2
- package/dist/parse-ast-index.d.cts +1 -1
- package/dist/parse-ast-index.d.mts +1 -1
- package/dist/shared/{binding.d-BRwjFIld.d.cts → binding.d-DiufgqJs.d.mts} +1 -0
- package/dist/shared/{binding.d-DVNuaImz.d.mts → binding.d-TdksiV0L.d.cts} +1 -0
- package/dist/shared/{input-options.d-CcrldgHK.d.cts → input-options.d--njwKbQU.d.mts} +3 -56
- package/dist/shared/{input-options.d-DVGWBVp4.d.mts → input-options.d-xkHPeCns.d.cts} +3 -56
- package/dist/shared/misc-BWx4LNta.cjs +68 -0
- package/dist/shared/misc-CcQKSZ8O.mjs +28 -0
- package/dist/shared/{src-DdLhlxoJ.mjs → src-DbQfn8bU.mjs} +89 -89
- package/dist/shared/{src-_pefwDkF.cjs → src-WSLYLQjV.cjs} +103 -102
- package/package.json +16 -15
- package/dist/shared/filter-index-DblXSw9s.cjs +0 -255
- package/dist/shared/filter-index-hnEzlqRW.mjs +0 -174
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { __esm } from "./chunk-DUYDk_2O.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/utils/misc.ts
|
|
4
|
+
function arraify(value) {
|
|
5
|
+
return Array.isArray(value) ? value : [value];
|
|
6
|
+
}
|
|
7
|
+
function isNullish(value) {
|
|
8
|
+
return value === null || value === void 0;
|
|
9
|
+
}
|
|
10
|
+
function isPromiseLike(value) {
|
|
11
|
+
return value && (typeof value === "object" || typeof value === "function") && typeof value.then === "function";
|
|
12
|
+
}
|
|
13
|
+
function unimplemented(info) {
|
|
14
|
+
if (info) throw new Error(`unimplemented: ${info}`);
|
|
15
|
+
throw new Error("unimplemented");
|
|
16
|
+
}
|
|
17
|
+
function unreachable(info) {
|
|
18
|
+
if (info) throw new Error(`unreachable: ${info}`);
|
|
19
|
+
throw new Error("unreachable");
|
|
20
|
+
}
|
|
21
|
+
function unsupported(info) {
|
|
22
|
+
throw new Error(`UNSUPPORTED: ${info}`);
|
|
23
|
+
}
|
|
24
|
+
function noop(..._args) {}
|
|
25
|
+
var init_misc = __esm({ "src/utils/misc.ts"() {} });
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
export { arraify, init_misc, isNullish, isPromiseLike, noop, unimplemented, unreachable, unsupported };
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { __esm } from "./chunk-DUYDk_2O.mjs";
|
|
2
2
|
import { augmentCodeLocation, error, import_binding, init_logs, init_parse_ast_index, logCycleLoading, logInputHookInOutputPlugin, logInvalidLogPosition, logMultiplyNotifyOption, logPluginError, parseAst } from "./parse-ast-index-CHCsJTcD.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { arraify, init_misc, isNullish, noop, unimplemented, unreachable, unsupported } from "./misc-CcQKSZ8O.mjs";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import colors from "ansis";
|
|
6
|
+
import * as filter from "@rolldown/pluginutils";
|
|
6
7
|
import { availableParallelism } from "node:os";
|
|
7
8
|
import { Worker } from "node:worker_threads";
|
|
8
9
|
|
|
9
10
|
//#region package.json
|
|
10
|
-
var version = "1.0.0-beta.8-commit.
|
|
11
|
+
var version = "1.0.0-beta.8-commit.e270f24";
|
|
11
12
|
var description$1 = "Fast JavaScript/TypeScript bundler in Rust with Rollup-compatible API.";
|
|
12
13
|
|
|
13
14
|
//#endregion
|
|
@@ -118,13 +119,13 @@ var init_logging = __esm({ "src/log/logging.ts"() {
|
|
|
118
119
|
|
|
119
120
|
//#endregion
|
|
120
121
|
//#region src/log/log-handler.ts
|
|
121
|
-
function getLogHandler(level, code
|
|
122
|
+
function getLogHandler(level, code, logger, pluginName, logLevel) {
|
|
122
123
|
if (logLevelPriority[level] < logLevelPriority[logLevel]) return noop;
|
|
123
124
|
return (log, pos) => {
|
|
124
125
|
if (pos != null) logger(LOG_LEVEL_WARN, logInvalidLogPosition(pluginName));
|
|
125
126
|
log = normalizeLog(log);
|
|
126
127
|
if (log.code && !log.pluginCode) log.pluginCode = log.code;
|
|
127
|
-
log.code = code
|
|
128
|
+
log.code = code;
|
|
128
129
|
log.plugin = pluginName;
|
|
129
130
|
logger(level, log);
|
|
130
131
|
};
|
|
@@ -171,9 +172,9 @@ function getLogger(plugins, onLog, logLevel, watchMode) {
|
|
|
171
172
|
};
|
|
172
173
|
return logger;
|
|
173
174
|
}
|
|
174
|
-
function relativeId(id
|
|
175
|
-
if (!path.isAbsolute(id
|
|
176
|
-
return path.relative(path.resolve(), id
|
|
175
|
+
function relativeId(id) {
|
|
176
|
+
if (!path.isAbsolute(id)) return id;
|
|
177
|
+
return path.relative(path.resolve(), id);
|
|
177
178
|
}
|
|
178
179
|
var getOnLog, getDefaultOnLog, addLogToString, defaultPrintLog, getExtendedLogMessage;
|
|
179
180
|
var init_logger = __esm({ "src/log/logger.ts"() {
|
|
@@ -2212,9 +2213,9 @@ function getErrorMessage(e$5) {
|
|
|
2212
2213
|
if (Object.hasOwn(e$5, "kind")) return e$5.message;
|
|
2213
2214
|
let s$10 = "";
|
|
2214
2215
|
if (e$5.plugin) s$10 += `[plugin ${e$5.plugin}]`;
|
|
2215
|
-
const id
|
|
2216
|
-
if (id
|
|
2217
|
-
s$10 += " " + id
|
|
2216
|
+
const id = e$5.id ?? e$5.loc?.file;
|
|
2217
|
+
if (id) {
|
|
2218
|
+
s$10 += " " + id;
|
|
2218
2219
|
if (e$5.loc) s$10 += `:${e$5.loc.line}:${e$5.loc.column}`;
|
|
2219
2220
|
}
|
|
2220
2221
|
if (s$10) s$10 += "\n";
|
|
@@ -2274,11 +2275,11 @@ function isEmptySourcemapFiled(array$1) {
|
|
|
2274
2275
|
if (array$1.length === 0 || !array$1[0]) return true;
|
|
2275
2276
|
return false;
|
|
2276
2277
|
}
|
|
2277
|
-
function normalizeTransformHookSourcemap(id
|
|
2278
|
+
function normalizeTransformHookSourcemap(id, originalCode, rawMap) {
|
|
2278
2279
|
if (!rawMap) return;
|
|
2279
2280
|
let map = typeof rawMap === "object" ? rawMap : JSON.parse(rawMap);
|
|
2280
2281
|
if (isEmptySourcemapFiled(map.sourcesContent)) map.sourcesContent = [originalCode];
|
|
2281
|
-
if (isEmptySourcemapFiled(map.sources) || map.sources && map.sources.length === 1 && map.sources[0] !== id
|
|
2282
|
+
if (isEmptySourcemapFiled(map.sources) || map.sources && map.sources.length === 1 && map.sources[0] !== id) map.sources = [id];
|
|
2282
2283
|
return map;
|
|
2283
2284
|
}
|
|
2284
2285
|
var init_transform_sourcemap = __esm({ "src/utils/transform-sourcemap.ts"() {} });
|
|
@@ -3496,37 +3497,37 @@ var init_dist = __esm({ "../../node_modules/.pnpm/remeda@2.21.2/node_modules/rem
|
|
|
3496
3497
|
//#endregion
|
|
3497
3498
|
//#region src/plugin/bindingify-hook-filter.ts
|
|
3498
3499
|
function generalHookFilterMatcherToFilterExprs(matcher, stringKind) {
|
|
3499
|
-
if (typeof matcher === "string" || matcher instanceof RegExp) return [include(generateAtomMatcher(stringKind, matcher))];
|
|
3500
|
-
if (Array.isArray(matcher)) return matcher.map((m$10) => include(generateAtomMatcher(stringKind, m$10)));
|
|
3500
|
+
if (typeof matcher === "string" || matcher instanceof RegExp) return [filter.include(generateAtomMatcher(stringKind, matcher))];
|
|
3501
|
+
if (Array.isArray(matcher)) return matcher.map((m$10) => filter.include(generateAtomMatcher(stringKind, m$10)));
|
|
3501
3502
|
let ret = [];
|
|
3502
|
-
if (matcher.exclude) ret.push(...arraify(matcher.exclude).map((m$10) => exclude(generateAtomMatcher(stringKind, m$10))));
|
|
3503
|
-
if (matcher.include) ret.push(...arraify(matcher.include).map((m$10) => include(generateAtomMatcher(stringKind, m$10))));
|
|
3503
|
+
if (matcher.exclude) ret.push(...arraify(matcher.exclude).map((m$10) => filter.exclude(generateAtomMatcher(stringKind, m$10))));
|
|
3504
|
+
if (matcher.include) ret.push(...arraify(matcher.include).map((m$10) => filter.include(generateAtomMatcher(stringKind, m$10))));
|
|
3504
3505
|
return ret;
|
|
3505
3506
|
}
|
|
3506
3507
|
function generateAtomMatcher(kind, matcher) {
|
|
3507
|
-
return kind === "code" ? code(matcher) : id(matcher);
|
|
3508
|
+
return kind === "code" ? filter.code(matcher) : filter.id(matcher);
|
|
3508
3509
|
}
|
|
3509
3510
|
function transformFilterMatcherToFilterExprs(filterOption) {
|
|
3510
3511
|
if (!filterOption) return void 0;
|
|
3511
3512
|
if (Array.isArray(filterOption)) return filterOption;
|
|
3512
|
-
const { id
|
|
3513
|
+
const { id, code, moduleType } = filterOption;
|
|
3513
3514
|
let ret = [];
|
|
3514
3515
|
let idIncludes = [];
|
|
3515
3516
|
let idExcludes = [];
|
|
3516
3517
|
let codeIncludes = [];
|
|
3517
3518
|
let codeExcludes = [];
|
|
3518
|
-
if (id
|
|
3519
|
-
if (code
|
|
3519
|
+
if (id) [idIncludes, idExcludes] = d$3(generalHookFilterMatcherToFilterExprs(id, "id") ?? [], (m$10) => m$10.kind === "include");
|
|
3520
|
+
if (code) [codeIncludes, codeExcludes] = d$3(generalHookFilterMatcherToFilterExprs(code, "code") ?? [], (m$10) => m$10.kind === "include");
|
|
3520
3521
|
ret.push(...idExcludes);
|
|
3521
3522
|
ret.push(...codeExcludes);
|
|
3522
3523
|
let andExprList = [];
|
|
3523
|
-
if (moduleType
|
|
3524
|
-
let moduleTypes = Array.isArray(moduleType
|
|
3525
|
-
andExprList.push(or(...moduleTypes.map((m$10) => moduleType(m$10))));
|
|
3524
|
+
if (moduleType) {
|
|
3525
|
+
let moduleTypes = Array.isArray(moduleType) ? moduleType : moduleType.include ?? [];
|
|
3526
|
+
andExprList.push(filter.or(...moduleTypes.map((m$10) => filter.moduleType(m$10))));
|
|
3526
3527
|
}
|
|
3527
|
-
if (idIncludes.length) andExprList.push(or(...idIncludes.map((item) => item.expr)));
|
|
3528
|
-
if (codeIncludes.length) andExprList.push(or(...codeIncludes.map((item) => item.expr)));
|
|
3529
|
-
if (andExprList.length) ret.push(include(and(...andExprList)));
|
|
3528
|
+
if (idIncludes.length) andExprList.push(filter.or(...idIncludes.map((item) => item.expr)));
|
|
3529
|
+
if (codeIncludes.length) andExprList.push(filter.or(...codeIncludes.map((item) => item.expr)));
|
|
3530
|
+
if (andExprList.length) ret.push(filter.include(filter.and(...andExprList)));
|
|
3530
3531
|
return ret;
|
|
3531
3532
|
}
|
|
3532
3533
|
function bindingifyGeneralHookFilter(stringKind, pattern) {
|
|
@@ -3623,7 +3624,6 @@ function bindingifyRenderChunkFilter(filterOption) {
|
|
|
3623
3624
|
}
|
|
3624
3625
|
var init_bindingify_hook_filter = __esm({ "src/plugin/bindingify-hook-filter.ts"() {
|
|
3625
3626
|
init_dist();
|
|
3626
|
-
init_filter_index();
|
|
3627
3627
|
init_misc();
|
|
3628
3628
|
} });
|
|
3629
3629
|
|
|
@@ -3673,37 +3673,37 @@ var init_plugin_context = __esm({ "src/plugin/plugin-context.ts"() {
|
|
|
3673
3673
|
this.data = data;
|
|
3674
3674
|
this.onLog = onLog;
|
|
3675
3675
|
this.currentLoadingModule = currentLoadingModule;
|
|
3676
|
-
this.getModuleInfo = (id
|
|
3676
|
+
this.getModuleInfo = (id) => this.data.getModuleInfo(id, context);
|
|
3677
3677
|
}
|
|
3678
3678
|
async load(options) {
|
|
3679
|
-
const id
|
|
3680
|
-
if (id
|
|
3681
|
-
const moduleInfo = this.data.getModuleInfo(id
|
|
3679
|
+
const id = options.id;
|
|
3680
|
+
if (id === this.currentLoadingModule) this.onLog(LOG_LEVEL_WARN, logCycleLoading(this.pluginName, this.currentLoadingModule));
|
|
3681
|
+
const moduleInfo = this.data.getModuleInfo(id, this.context);
|
|
3682
3682
|
if (moduleInfo && moduleInfo.code !== null) return moduleInfo;
|
|
3683
3683
|
const rawOptions = {
|
|
3684
3684
|
meta: options.meta || {},
|
|
3685
3685
|
moduleSideEffects: options.moduleSideEffects || null,
|
|
3686
3686
|
invalidate: false
|
|
3687
3687
|
};
|
|
3688
|
-
this.data.updateModuleOption(id
|
|
3688
|
+
this.data.updateModuleOption(id, rawOptions);
|
|
3689
3689
|
async function createLoadModulePromise(context, data) {
|
|
3690
|
-
const loadPromise = data.loadModulePromiseMap.get(id
|
|
3690
|
+
const loadPromise = data.loadModulePromiseMap.get(id);
|
|
3691
3691
|
if (loadPromise) return loadPromise;
|
|
3692
3692
|
const promise$1 = new Promise((resolve, _) => {
|
|
3693
|
-
data.loadModulePromiseResolveFnMap.set(id
|
|
3693
|
+
data.loadModulePromiseResolveFnMap.set(id, resolve);
|
|
3694
3694
|
});
|
|
3695
|
-
data.loadModulePromiseMap.set(id
|
|
3695
|
+
data.loadModulePromiseMap.set(id, promise$1);
|
|
3696
3696
|
try {
|
|
3697
|
-
await context.load(id
|
|
3697
|
+
await context.load(id, bindingifySideEffects(options.moduleSideEffects));
|
|
3698
3698
|
} catch (e$5) {
|
|
3699
|
-
data.loadModulePromiseMap.delete(id
|
|
3700
|
-
data.loadModulePromiseResolveFnMap.delete(id
|
|
3699
|
+
data.loadModulePromiseMap.delete(id);
|
|
3700
|
+
data.loadModulePromiseResolveFnMap.delete(id);
|
|
3701
3701
|
throw e$5;
|
|
3702
3702
|
}
|
|
3703
3703
|
return promise$1;
|
|
3704
3704
|
}
|
|
3705
3705
|
await createLoadModulePromise(this.context, this.data);
|
|
3706
|
-
return this.data.getModuleInfo(id
|
|
3706
|
+
return this.data.getModuleInfo(id, this.context);
|
|
3707
3707
|
}
|
|
3708
3708
|
async resolve(source, importer, options) {
|
|
3709
3709
|
let receipt = void 0;
|
|
@@ -3746,8 +3746,8 @@ var init_plugin_context = __esm({ "src/plugin/plugin-context.ts"() {
|
|
|
3746
3746
|
getModuleIds() {
|
|
3747
3747
|
return this.data.getModuleIds(this.context);
|
|
3748
3748
|
}
|
|
3749
|
-
addWatchFile(id
|
|
3750
|
-
this.context.addWatchFile(id
|
|
3749
|
+
addWatchFile(id) {
|
|
3750
|
+
this.context.addWatchFile(id);
|
|
3751
3751
|
}
|
|
3752
3752
|
parse(input, options) {
|
|
3753
3753
|
return parseAst(input, options);
|
|
@@ -3888,18 +3888,18 @@ function bindingifyTransform(args$1) {
|
|
|
3888
3888
|
if (!hook) return {};
|
|
3889
3889
|
const { handler, meta, options } = normalizeHook(hook);
|
|
3890
3890
|
return {
|
|
3891
|
-
plugin: async (ctx, code
|
|
3892
|
-
const ret = await handler.call(new TransformPluginContextImpl(args$1.outputOptions, ctx.inner(), args$1.plugin, args$1.pluginContextData, ctx, id
|
|
3891
|
+
plugin: async (ctx, code, id, meta$1) => {
|
|
3892
|
+
const ret = await handler.call(new TransformPluginContextImpl(args$1.outputOptions, ctx.inner(), args$1.plugin, args$1.pluginContextData, ctx, id, code, args$1.onLog, args$1.logLevel, args$1.watchMode), code, id, meta$1);
|
|
3893
3893
|
if (ret == null) return void 0;
|
|
3894
3894
|
if (typeof ret === "string") return { code: ret };
|
|
3895
|
-
let moduleOption = args$1.pluginContextData.updateModuleOption(id
|
|
3895
|
+
let moduleOption = args$1.pluginContextData.updateModuleOption(id, {
|
|
3896
3896
|
meta: ret.meta ?? {},
|
|
3897
3897
|
moduleSideEffects: ret.moduleSideEffects ?? null,
|
|
3898
3898
|
invalidate: false
|
|
3899
3899
|
});
|
|
3900
3900
|
return {
|
|
3901
3901
|
code: ret.code,
|
|
3902
|
-
map: bindingifySourcemap(normalizeTransformHookSourcemap(id
|
|
3902
|
+
map: bindingifySourcemap(normalizeTransformHookSourcemap(id, code, ret.map)),
|
|
3903
3903
|
sideEffects: bindingifySideEffects(moduleOption.moduleSideEffects),
|
|
3904
3904
|
moduleType: ret.moduleType
|
|
3905
3905
|
};
|
|
@@ -3913,16 +3913,16 @@ function bindingifyLoad(args$1) {
|
|
|
3913
3913
|
if (!hook) return {};
|
|
3914
3914
|
const { handler, meta, options } = normalizeHook(hook);
|
|
3915
3915
|
return {
|
|
3916
|
-
plugin: async (ctx, id
|
|
3917
|
-
const ret = await handler.call(new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode, id
|
|
3916
|
+
plugin: async (ctx, id) => {
|
|
3917
|
+
const ret = await handler.call(new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode, id), id);
|
|
3918
3918
|
if (ret == null) return;
|
|
3919
3919
|
if (typeof ret === "string") return { code: ret };
|
|
3920
|
-
let moduleOption = args$1.pluginContextData.updateModuleOption(id
|
|
3920
|
+
let moduleOption = args$1.pluginContextData.updateModuleOption(id, {
|
|
3921
3921
|
meta: ret.meta || {},
|
|
3922
3922
|
moduleSideEffects: ret.moduleSideEffects ?? null,
|
|
3923
3923
|
invalidate: false
|
|
3924
3924
|
});
|
|
3925
|
-
let map = preProcessSourceMap(ret, id
|
|
3925
|
+
let map = preProcessSourceMap(ret, id);
|
|
3926
3926
|
return {
|
|
3927
3927
|
code: ret.code,
|
|
3928
3928
|
map: bindingifySourcemap(map),
|
|
@@ -3934,11 +3934,11 @@ function bindingifyLoad(args$1) {
|
|
|
3934
3934
|
filter: bindingifyLoadFilter(options.filter)
|
|
3935
3935
|
};
|
|
3936
3936
|
}
|
|
3937
|
-
function preProcessSourceMap(ret, id
|
|
3937
|
+
function preProcessSourceMap(ret, id) {
|
|
3938
3938
|
if (!ret.map) return;
|
|
3939
3939
|
let map = typeof ret.map === "object" ? ret.map : JSON.parse(ret.map);
|
|
3940
3940
|
if (!isEmptySourcemapFiled(map.sources)) {
|
|
3941
|
-
const directory = path.dirname(id
|
|
3941
|
+
const directory = path.dirname(id) || ".";
|
|
3942
3942
|
const sourceRoot = map.sourceRoot || ".";
|
|
3943
3943
|
map.sources = map.sources.map((source) => path.resolve(directory, sourceRoot, source));
|
|
3944
3944
|
}
|
|
@@ -4397,9 +4397,9 @@ function bindingifyRenderChunk(args$1) {
|
|
|
4397
4397
|
if (!hook) return {};
|
|
4398
4398
|
const { handler, meta, options } = normalizeHook(hook);
|
|
4399
4399
|
return {
|
|
4400
|
-
plugin: async (ctx, code
|
|
4400
|
+
plugin: async (ctx, code, chunk, opts, meta$1) => {
|
|
4401
4401
|
if (args$1.pluginContextData.getRenderChunkMeta() == null) args$1.pluginContextData.setRenderChunkMeta({ chunks: Object.fromEntries(Object.entries(meta$1.chunks).map(([key, value]) => [key, transformRenderedChunk(value)])) });
|
|
4402
|
-
const ret = await handler.call(new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode), code
|
|
4402
|
+
const ret = await handler.call(new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode), code, transformRenderedChunk(chunk), new NormalizedOutputOptionsImpl(opts, args$1.outputOptions, args$1.normalizedOutputPlugins), args$1.pluginContextData.getRenderChunkMeta());
|
|
4403
4403
|
if (ret == null) return;
|
|
4404
4404
|
if (typeof ret === "string") return { code: ret };
|
|
4405
4405
|
if (!ret.map) return { code: ret.code };
|
|
@@ -4547,8 +4547,8 @@ function bindingifyWatchChange(args$1) {
|
|
|
4547
4547
|
if (!hook) return {};
|
|
4548
4548
|
const { handler, meta } = normalizeHook(hook);
|
|
4549
4549
|
return {
|
|
4550
|
-
plugin: async (ctx, id
|
|
4551
|
-
await handler.call(new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode), id
|
|
4550
|
+
plugin: async (ctx, id, event) => {
|
|
4551
|
+
await handler.call(new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode), id, { event });
|
|
4552
4552
|
},
|
|
4553
4553
|
meta: bindingifyPluginHookMeta(meta)
|
|
4554
4554
|
};
|
|
@@ -4774,46 +4774,46 @@ var init_plugin_context_data = __esm({ "src/plugin/plugin-context-data.ts"() {
|
|
|
4774
4774
|
loadModulePromiseMap = new Map();
|
|
4775
4775
|
loadModulePromiseResolveFnMap = new Map();
|
|
4776
4776
|
renderedChunkMeta = null;
|
|
4777
|
-
updateModuleOption(id
|
|
4778
|
-
const existing = this.moduleOptionMap.get(id
|
|
4777
|
+
updateModuleOption(id, option) {
|
|
4778
|
+
const existing = this.moduleOptionMap.get(id);
|
|
4779
4779
|
if (existing) {
|
|
4780
4780
|
if (option.moduleSideEffects != null) existing.moduleSideEffects = option.moduleSideEffects;
|
|
4781
4781
|
if (option.meta != null) Object.assign(existing.meta, option.meta);
|
|
4782
4782
|
if (option.invalidate != null) existing.invalidate = option.invalidate;
|
|
4783
4783
|
} else {
|
|
4784
|
-
this.moduleOptionMap.set(id
|
|
4784
|
+
this.moduleOptionMap.set(id, option);
|
|
4785
4785
|
return option;
|
|
4786
4786
|
}
|
|
4787
4787
|
return existing;
|
|
4788
4788
|
}
|
|
4789
|
-
getModuleOption(id
|
|
4790
|
-
const option = this.moduleOptionMap.get(id
|
|
4789
|
+
getModuleOption(id) {
|
|
4790
|
+
const option = this.moduleOptionMap.get(id);
|
|
4791
4791
|
if (!option) {
|
|
4792
4792
|
const raw = {
|
|
4793
4793
|
moduleSideEffects: null,
|
|
4794
4794
|
meta: {}
|
|
4795
4795
|
};
|
|
4796
|
-
this.moduleOptionMap.set(id
|
|
4796
|
+
this.moduleOptionMap.set(id, raw);
|
|
4797
4797
|
return raw;
|
|
4798
4798
|
}
|
|
4799
4799
|
return option;
|
|
4800
4800
|
}
|
|
4801
|
-
getModuleInfo(id
|
|
4802
|
-
const bindingInfo = context.getModuleInfo(id
|
|
4801
|
+
getModuleInfo(id, context) {
|
|
4802
|
+
const bindingInfo = context.getModuleInfo(id);
|
|
4803
4803
|
if (bindingInfo) {
|
|
4804
|
-
const info = transformModuleInfo(bindingInfo, this.getModuleOption(id
|
|
4805
|
-
return this.proxyModuleInfo(id
|
|
4804
|
+
const info = transformModuleInfo(bindingInfo, this.getModuleOption(id));
|
|
4805
|
+
return this.proxyModuleInfo(id, info);
|
|
4806
4806
|
}
|
|
4807
4807
|
return null;
|
|
4808
4808
|
}
|
|
4809
|
-
proxyModuleInfo(id
|
|
4809
|
+
proxyModuleInfo(id, info) {
|
|
4810
4810
|
let moduleSideEffects = info.moduleSideEffects;
|
|
4811
4811
|
Object.defineProperty(info, "moduleSideEffects", {
|
|
4812
4812
|
get() {
|
|
4813
4813
|
return moduleSideEffects;
|
|
4814
4814
|
},
|
|
4815
4815
|
set: (v) => {
|
|
4816
|
-
this.updateModuleOption(id
|
|
4816
|
+
this.updateModuleOption(id, {
|
|
4817
4817
|
moduleSideEffects: v,
|
|
4818
4818
|
meta: info.meta,
|
|
4819
4819
|
invalidate: true
|
|
@@ -4844,8 +4844,8 @@ var init_plugin_context_data = __esm({ "src/plugin/plugin-context-data.ts"() {
|
|
|
4844
4844
|
getRenderChunkMeta() {
|
|
4845
4845
|
return this.renderedChunkMeta;
|
|
4846
4846
|
}
|
|
4847
|
-
markModuleLoaded(id
|
|
4848
|
-
const resolve = this.loadModulePromiseResolveFnMap.get(id
|
|
4847
|
+
markModuleLoaded(id, _success) {
|
|
4848
|
+
const resolve = this.loadModulePromiseResolveFnMap.get(id);
|
|
4849
4849
|
if (resolve) resolve();
|
|
4850
4850
|
}
|
|
4851
4851
|
clear() {
|
|
@@ -4929,15 +4929,15 @@ function bindingifyHmr(hmr) {
|
|
|
4929
4929
|
}
|
|
4930
4930
|
function bindingifyExternal(external) {
|
|
4931
4931
|
if (external) {
|
|
4932
|
-
if (typeof external === "function") return (id
|
|
4933
|
-
if (id
|
|
4934
|
-
return external(id
|
|
4932
|
+
if (typeof external === "function") return (id, importer, isResolved) => {
|
|
4933
|
+
if (id.startsWith("\0")) return false;
|
|
4934
|
+
return external(id, importer, isResolved) ?? false;
|
|
4935
4935
|
};
|
|
4936
4936
|
const externalArr = arraify(external);
|
|
4937
|
-
return (id
|
|
4937
|
+
return (id, _importer, _isResolved) => {
|
|
4938
4938
|
return externalArr.some((pat) => {
|
|
4939
|
-
if (pat instanceof RegExp) return pat.test(id
|
|
4940
|
-
return id
|
|
4939
|
+
if (pat instanceof RegExp) return pat.test(id);
|
|
4940
|
+
return id === pat;
|
|
4941
4941
|
});
|
|
4942
4942
|
};
|
|
4943
4943
|
}
|
|
@@ -5217,10 +5217,10 @@ function createComposedPlugin(plugins) {
|
|
|
5217
5217
|
case "load": {
|
|
5218
5218
|
if (batchedHooks.load) {
|
|
5219
5219
|
const batchedHandlers = batchedHooks.load;
|
|
5220
|
-
composed.load = async function(id
|
|
5220
|
+
composed.load = async function(id) {
|
|
5221
5221
|
for (const [handler, plugin] of batchedHandlers) {
|
|
5222
5222
|
const { handler: handlerFn } = normalizeHook(handler);
|
|
5223
|
-
const result = await handlerFn.call(applyFixedPluginResolveFn(this, plugin), id
|
|
5223
|
+
const result = await handlerFn.call(applyFixedPluginResolveFn(this, plugin), id);
|
|
5224
5224
|
if (!isNullish(result)) return result;
|
|
5225
5225
|
}
|
|
5226
5226
|
};
|
|
@@ -5230,11 +5230,11 @@ function createComposedPlugin(plugins) {
|
|
|
5230
5230
|
case "transform": {
|
|
5231
5231
|
if (batchedHooks.transform) {
|
|
5232
5232
|
const batchedHandlers = batchedHooks.transform;
|
|
5233
|
-
composed.transform = async function(initialCode, id
|
|
5234
|
-
let code
|
|
5233
|
+
composed.transform = async function(initialCode, id, moduleType) {
|
|
5234
|
+
let code = initialCode;
|
|
5235
5235
|
let moduleSideEffects = void 0;
|
|
5236
5236
|
function updateOutput(newCode, newModuleSideEffects) {
|
|
5237
|
-
code
|
|
5237
|
+
code = newCode;
|
|
5238
5238
|
moduleSideEffects = newModuleSideEffects ?? void 0;
|
|
5239
5239
|
}
|
|
5240
5240
|
for (const [handler, plugin] of batchedHandlers) {
|
|
@@ -5242,14 +5242,14 @@ function createComposedPlugin(plugins) {
|
|
|
5242
5242
|
this.getCombinedSourcemap = () => {
|
|
5243
5243
|
throw new Error(`The getCombinedSourcemap is not implement in transform hook at composedJsPlugins`);
|
|
5244
5244
|
};
|
|
5245
|
-
const result = await handlerFn.call(applyFixedPluginResolveFn(this, plugin), code
|
|
5245
|
+
const result = await handlerFn.call(applyFixedPluginResolveFn(this, plugin), code, id, moduleType);
|
|
5246
5246
|
if (!isNullish(result)) {
|
|
5247
5247
|
if (typeof result === "string") updateOutput(result);
|
|
5248
5248
|
else if (result.code) updateOutput(result.code, result.moduleSideEffects);
|
|
5249
5249
|
}
|
|
5250
5250
|
}
|
|
5251
5251
|
return {
|
|
5252
|
-
code
|
|
5252
|
+
code,
|
|
5253
5253
|
moduleSideEffects
|
|
5254
5254
|
};
|
|
5255
5255
|
};
|
|
@@ -5271,10 +5271,10 @@ function createComposedPlugin(plugins) {
|
|
|
5271
5271
|
case "renderChunk": {
|
|
5272
5272
|
if (batchedHooks.renderChunk) {
|
|
5273
5273
|
const batchedHandlers = batchedHooks.renderChunk;
|
|
5274
|
-
composed.renderChunk = async function(code
|
|
5274
|
+
composed.renderChunk = async function(code, chunk, options, meta) {
|
|
5275
5275
|
for (const [handler, plugin] of batchedHandlers) {
|
|
5276
5276
|
const { handler: handlerFn } = normalizeHook(handler);
|
|
5277
|
-
const result = await handlerFn.call(applyFixedPluginResolveFn(this, plugin), code
|
|
5277
|
+
const result = await handlerFn.call(applyFixedPluginResolveFn(this, plugin), code, chunk, options, meta);
|
|
5278
5278
|
if (!isNullish(result)) return result;
|
|
5279
5279
|
}
|
|
5280
5280
|
};
|
|
@@ -5311,10 +5311,10 @@ function createComposedPlugin(plugins) {
|
|
|
5311
5311
|
case "watchChange": {
|
|
5312
5312
|
if (batchedHooks.watchChange) {
|
|
5313
5313
|
const batchedHandlers = batchedHooks.watchChange;
|
|
5314
|
-
composed.watchChange = async function(id
|
|
5314
|
+
composed.watchChange = async function(id, event) {
|
|
5315
5315
|
await Promise.all(batchedHandlers.map(([handler, plugin]) => {
|
|
5316
5316
|
const { handler: handlerFn } = normalizeHook(handler);
|
|
5317
|
-
return handlerFn.call(applyFixedPluginResolveFn(this, plugin), id
|
|
5317
|
+
return handlerFn.call(applyFixedPluginResolveFn(this, plugin), id, event);
|
|
5318
5318
|
}));
|
|
5319
5319
|
};
|
|
5320
5320
|
}
|
|
@@ -5641,8 +5641,8 @@ var init_watch_emitter = __esm({ "src/api/watch/watch-emitter.ts"() {
|
|
|
5641
5641
|
break;
|
|
5642
5642
|
case "event":
|
|
5643
5643
|
for (const listener of listeners) {
|
|
5644
|
-
const code
|
|
5645
|
-
switch (code
|
|
5644
|
+
const code = event.bundleEventKind();
|
|
5645
|
+
switch (code) {
|
|
5646
5646
|
case "BUNDLE_END":
|
|
5647
5647
|
const { duration, output, result } = event.bundleEndData();
|
|
5648
5648
|
await listener({
|
|
@@ -5661,7 +5661,7 @@ var init_watch_emitter = __esm({ "src/api/watch/watch-emitter.ts"() {
|
|
|
5661
5661
|
});
|
|
5662
5662
|
break;
|
|
5663
5663
|
default:
|
|
5664
|
-
await listener({ code
|
|
5664
|
+
await listener({ code });
|
|
5665
5665
|
break;
|
|
5666
5666
|
}
|
|
5667
5667
|
}
|