@rolldown/browser 1.0.0-beta.8-commit.a98d94e → 1.0.0-beta.8-commit.852c603

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.
Files changed (31) hide show
  1. package/dist/browser.mjs +308 -147
  2. package/dist/cli.cjs +3 -2
  3. package/dist/cli.mjs +3 -2
  4. package/dist/experimental-index.cjs +2 -1
  5. package/dist/experimental-index.d.cts +1 -1
  6. package/dist/experimental-index.d.mts +1 -1
  7. package/dist/experimental-index.mjs +2 -1
  8. package/dist/filter-expression-index.cjs +11 -0
  9. package/dist/filter-expression-index.d.cts +3 -0
  10. package/dist/filter-expression-index.d.mts +3 -0
  11. package/dist/filter-expression-index.mjs +4 -0
  12. package/dist/index.cjs +2 -1
  13. package/dist/index.d.cts +2 -2
  14. package/dist/index.d.mts +2 -2
  15. package/dist/index.mjs +2 -1
  16. package/dist/parallel-plugin-worker.cjs +2 -1
  17. package/dist/parallel-plugin-worker.mjs +2 -1
  18. package/dist/parallel-plugin.d.cts +1 -1
  19. package/dist/parallel-plugin.d.mts +1 -1
  20. package/dist/rolldown-binding.wasi-browser.js +1 -0
  21. package/dist/rolldown-binding.wasi.cjs +1 -0
  22. package/dist/rolldown-binding.wasm32-wasi.wasm +0 -0
  23. package/dist/shared/filter-expression-index-CIS7Rrin.mjs +69 -0
  24. package/dist/shared/filter-expression-index-CRtoeipP.cjs +119 -0
  25. package/dist/shared/{input-options.d-P0YdGzip.d.cts → input-options.d-C0G2toUx.d.cts} +83 -21
  26. package/dist/shared/{input-options.d-CMFIv0CX.d.mts → input-options.d-D_2wMOSn.d.mts} +83 -21
  27. package/dist/shared/{src-CJ9XODOK.cjs → src-DbbYa-_8.cjs} +247 -132
  28. package/dist/shared/{src-D9guL4ht.mjs → src-RM00Zc4c.mjs} +1780 -1664
  29. package/package.json +1 -1
  30. /package/dist/shared/{prompt-_yrURmmm.cjs → prompt-At99RuKY.cjs} +0 -0
  31. /package/dist/shared/{prompt-B7SnYdwU.mjs → prompt-BqVpALUY.mjs} +0 -0
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  const require_chunk = require('./chunk-qZFfknuJ.cjs');
3
3
  const require_parse_ast_index = require('./parse-ast-index-B9pj8J1q.cjs');
4
+ const require_filter_expression_index = require('./filter-expression-index-CRtoeipP.cjs');
4
5
  const src_rolldown_binding_wasi_cjs = require_chunk.__toESM(require("../rolldown-binding.wasi.cjs"));
5
6
  const node_path = require_chunk.__toESM(require("node:path"));
6
7
  const __valibot_to_json_schema = require_chunk.__toESM(require("@valibot/to-json-schema"));
@@ -10,7 +11,7 @@ const node_os = require_chunk.__toESM(require("node:os"));
10
11
  const node_worker_threads = require_chunk.__toESM(require("node:worker_threads"));
11
12
 
12
13
  //#region package.json
13
- var version = "1.0.0-beta.8-commit.a98d94e";
14
+ var version = "1.0.0-beta.8-commit.852c603";
14
15
  var description = "Fast JavaScript/TypeScript bundler in Rust with Rollup-compatible API.";
15
16
 
16
17
  //#endregion
@@ -138,13 +139,13 @@ const logLevelPriority = {
138
139
  //#endregion
139
140
  //#region src/log/log-handler.ts
140
141
  const normalizeLog = (log) => typeof log === "string" ? { message: log } : typeof log === "function" ? normalizeLog(log()) : log;
141
- function getLogHandler(level, code, logger, pluginName, logLevel) {
142
+ function getLogHandler(level, code$1, logger, pluginName, logLevel) {
142
143
  if (logLevelPriority[level] < logLevelPriority[logLevel]) return noop;
143
144
  return (log, pos) => {
144
145
  if (pos != null) logger(LOG_LEVEL_WARN, require_parse_ast_index.logInvalidLogPosition(pluginName));
145
146
  log = normalizeLog(log);
146
147
  if (log.code && !log.pluginCode) log.pluginCode = log.code;
147
- log.code = code;
148
+ log.code = code$1;
148
149
  log.plugin = pluginName;
149
150
  logger(level, log);
150
151
  };
@@ -221,9 +222,9 @@ const getExtendedLogMessage = (log) => {
221
222
  if (log.loc) prefix += `${relativeId(log.loc.file)} (${log.loc.line}:${log.loc.column}) `;
222
223
  return prefix + log.message;
223
224
  };
224
- function relativeId(id) {
225
- if (!node_path.default.isAbsolute(id)) return id;
226
- return node_path.default.relative(node_path.default.resolve(), id);
225
+ function relativeId(id$1) {
226
+ if (!node_path.default.isAbsolute(id$1)) return id$1;
227
+ return node_path.default.relative(node_path.default.resolve(), id$1);
227
228
  }
228
229
 
229
230
  //#endregion
@@ -797,7 +798,7 @@ function validateOption(key, options) {
797
798
  const issuePaths = issue.path.map((path$2) => path$2.key);
798
799
  let issueMsg = issue.message;
799
800
  if (issue.type === "union") {
800
- const subIssue = issue.issues?.find((i) => !(i.type !== issue.received && i.input === issue.input));
801
+ const subIssue = issue.issues?.find((i$1) => !(i$1.type !== issue.received && i$1.input === issue.input));
801
802
  if (subIssue) {
802
803
  if (subIssue.path) issuePaths.push(subIssue.path.map((path$2) => path$2.key));
803
804
  issueMsg = subIssue.message;
@@ -878,13 +879,13 @@ function normalizeErrors(rawErrors) {
878
879
  stack: void 0
879
880
  }));
880
881
  let summary = `Build failed with ${errors.length} error${errors.length < 2 ? "" : "s"}:\n`;
881
- for (let i = 0; i < errors.length; i++) {
882
+ for (let i$1 = 0; i$1 < errors.length; i$1++) {
882
883
  summary += "\n";
883
- if (i >= 5) {
884
+ if (i$1 >= 5) {
884
885
  summary += "...";
885
886
  break;
886
887
  }
887
- summary += getErrorMessage(errors[i]);
888
+ summary += getErrorMessage(errors[i$1]);
888
889
  }
889
890
  const wrapper = new Error(summary);
890
891
  Object.defineProperty(wrapper, "errors", {
@@ -903,9 +904,9 @@ function getErrorMessage(e) {
903
904
  if (Object.hasOwn(e, "kind")) return e.message;
904
905
  let s = "";
905
906
  if (e.plugin) s += `[plugin ${e.plugin}]`;
906
- const id = e.id ?? e.loc?.file;
907
- if (id) {
908
- s += " " + id;
907
+ const id$1 = e.id ?? e.loc?.file;
908
+ if (id$1) {
909
+ s += " " + id$1;
909
910
  if (e.loc) s += `:${e.loc.line}:${e.loc.column}`;
910
911
  }
911
912
  if (s) s += "\n";
@@ -960,41 +961,173 @@ function isEmptySourcemapFiled(array) {
960
961
  if (array.length === 0 || !array[0]) return true;
961
962
  return false;
962
963
  }
963
- function normalizeTransformHookSourcemap(id, originalCode, rawMap) {
964
+ function normalizeTransformHookSourcemap(id$1, originalCode, rawMap) {
964
965
  if (!rawMap) return;
965
966
  let map = typeof rawMap === "object" ? rawMap : JSON.parse(rawMap);
966
967
  if (isEmptySourcemapFiled(map.sourcesContent)) map.sourcesContent = [originalCode];
967
- if (isEmptySourcemapFiled(map.sources) || map.sources && map.sources.length === 1 && map.sources[0] !== id) map.sources = [id];
968
+ if (isEmptySourcemapFiled(map.sources) || map.sources && map.sources.length === 1 && map.sources[0] !== id$1) map.sources = [id$1];
968
969
  return map;
969
970
  }
970
971
 
972
+ //#endregion
973
+ //#region ../../node_modules/.pnpm/remeda@2.21.2/node_modules/remeda/dist/chunk-D6FCK2GA.js
974
+ function u$1(o, n, a) {
975
+ let t$1 = (r) => o(r, ...n);
976
+ return a === void 0 ? t$1 : Object.assign(t$1, {
977
+ lazy: a,
978
+ lazyArgs: n
979
+ });
980
+ }
981
+
982
+ //#endregion
983
+ //#region ../../node_modules/.pnpm/remeda@2.21.2/node_modules/remeda/dist/chunk-WIMGWYZL.js
984
+ function u(r, n, o) {
985
+ let a = r.length - n.length;
986
+ if (a === 0) return r(...n);
987
+ if (a === 1) return u$1(r, n, o);
988
+ throw new Error("Wrong number of arguments");
989
+ }
990
+
991
+ //#endregion
992
+ //#region ../../node_modules/.pnpm/remeda@2.21.2/node_modules/remeda/dist/chunk-3IFJP4R5.js
993
+ function d(...r) {
994
+ return u(i, r);
995
+ }
996
+ var i = (r, t$1) => {
997
+ let a = [[], []];
998
+ for (let [o, e] of r.entries()) t$1(e, o, r) ? a[0].push(e) : a[1].push(e);
999
+ return a;
1000
+ };
1001
+
1002
+ //#endregion
1003
+ //#region ../../node_modules/.pnpm/remeda@2.21.2/node_modules/remeda/dist/chunk-5NQBDF4H.js
1004
+ function t(...n) {
1005
+ return u(Object.keys, n);
1006
+ }
1007
+
971
1008
  //#endregion
972
1009
  //#region src/plugin/bindingify-hook-filter.ts
973
- function bindingifyStringFilter(matcher) {
974
- if (typeof matcher === "string" || matcher instanceof RegExp) return { include: [matcher] };
975
- if (Array.isArray(matcher)) return { include: matcher };
976
- return {
977
- include: matcher.include ? arraify(matcher.include) : void 0,
978
- exclude: matcher.exclude ? arraify(matcher.exclude) : void 0
979
- };
1010
+ function generalHookFilterMatcherToFilterExprs(matcher, stringKind) {
1011
+ if (typeof matcher === "string" || matcher instanceof RegExp) return [require_filter_expression_index.include(require_filter_expression_index.id(matcher))];
1012
+ if (Array.isArray(matcher)) return matcher.map((m) => require_filter_expression_index.include(require_filter_expression_index.id(m)));
1013
+ if (matcher.custom) return matcher.custom;
1014
+ let ret = [];
1015
+ let isCode = stringKind === "code";
1016
+ if (matcher.exclude) ret.push(...arraify(matcher.exclude).map((m) => require_filter_expression_index.exclude(isCode ? require_filter_expression_index.code(m) : require_filter_expression_index.id(m))));
1017
+ if (matcher.include) ret.push(...arraify(matcher.include).map((m) => require_filter_expression_index.include(isCode ? require_filter_expression_index.code(m) : require_filter_expression_index.id(m))));
1018
+ return ret;
1019
+ }
1020
+ function transformFilterMatcherToFilterExprs(filterOption) {
1021
+ if (!filterOption) return void 0;
1022
+ const { id: id$1, code: code$1, moduleType: moduleType$1, custom } = filterOption;
1023
+ if (custom) return custom;
1024
+ let ret = [];
1025
+ let idIncludes = [];
1026
+ let idExcludes = [];
1027
+ let codeIncludes = [];
1028
+ let codeExcludes = [];
1029
+ if (id$1) [idIncludes, idExcludes] = d(generalHookFilterMatcherToFilterExprs(id$1, "id") ?? [], (m) => m.kind === "include");
1030
+ if (code$1) [codeIncludes, codeExcludes] = d(generalHookFilterMatcherToFilterExprs(code$1, "code") ?? [], (m) => m.kind === "include");
1031
+ ret.push(...idExcludes);
1032
+ ret.push(...codeExcludes);
1033
+ let cursor;
1034
+ if (moduleType$1) {
1035
+ let moduleTypes = Array.isArray(moduleType$1) ? moduleType$1 : moduleType$1.include ?? [];
1036
+ cursor = joinFilterExprsWithOr(moduleTypes.map((m) => require_filter_expression_index.moduleType(m)));
1037
+ }
1038
+ if (idIncludes.length) {
1039
+ let joinedOrExpr = joinFilterExprsWithOr(idIncludes.map((item) => item.expr));
1040
+ if (!cursor) cursor = joinedOrExpr;
1041
+ else cursor = require_filter_expression_index.and(cursor, joinedOrExpr);
1042
+ }
1043
+ if (codeIncludes.length) {
1044
+ let joinedOrExpr = joinFilterExprsWithOr(codeIncludes.map((item) => item.expr));
1045
+ if (!cursor) cursor = joinedOrExpr;
1046
+ else cursor = require_filter_expression_index.and(cursor, joinedOrExpr);
1047
+ }
1048
+ if (cursor) ret.push(require_filter_expression_index.include(cursor));
1049
+ return ret;
1050
+ }
1051
+ function joinFilterExprsWithOr(filterExprs) {
1052
+ if (filterExprs.length === 1) return filterExprs[0];
1053
+ return require_filter_expression_index.or(filterExprs[0], joinFilterExprsWithOr(filterExprs.slice(1)));
1054
+ }
1055
+ function bindingifyGeneralHookFilter(matcher, stringKind) {
1056
+ let filterExprs = generalHookFilterMatcherToFilterExprs(matcher, stringKind);
1057
+ let custom = [];
1058
+ if (filterExprs) custom = filterExprs.map(bindingifyFilterExpr);
1059
+ return { custom: custom.length > 0 ? custom : void 0 };
1060
+ }
1061
+ function bindingifyFilterExpr(expr) {
1062
+ let list = [];
1063
+ bindingifyFilterExprImpl(expr, list);
1064
+ return list;
1065
+ }
1066
+ function bindingifyFilterExprImpl(expr, list) {
1067
+ switch (expr.kind) {
1068
+ case "and": {
1069
+ bindingifyFilterExprImpl(expr.right, list);
1070
+ bindingifyFilterExprImpl(expr.left, list);
1071
+ list.push({ kind: "And" });
1072
+ break;
1073
+ }
1074
+ case "not": {
1075
+ bindingifyFilterExprImpl(expr.expr, list);
1076
+ list.push({ kind: "Not" });
1077
+ break;
1078
+ }
1079
+ case "id": {
1080
+ list.push({
1081
+ kind: "Id",
1082
+ value: expr.pattern
1083
+ });
1084
+ break;
1085
+ }
1086
+ case "moduleType": {
1087
+ list.push({
1088
+ kind: "ModuleType",
1089
+ value: expr.pattern
1090
+ });
1091
+ break;
1092
+ }
1093
+ case "code": {
1094
+ list.push({
1095
+ kind: "Code",
1096
+ value: expr.pattern
1097
+ });
1098
+ break;
1099
+ }
1100
+ case "include": {
1101
+ bindingifyFilterExprImpl(expr.expr, list);
1102
+ list.push({ kind: "Include" });
1103
+ break;
1104
+ }
1105
+ case "exclude": {
1106
+ bindingifyFilterExprImpl(expr.expr, list);
1107
+ list.push({ kind: "Exclude" });
1108
+ break;
1109
+ }
1110
+ default: throw new Error(`Unknown filter expression kind: ${expr.kind}`);
1111
+ }
980
1112
  }
981
1113
  function bindingifyResolveIdFilter(filterOption) {
982
- return filterOption?.id ? bindingifyStringFilter(filterOption.id) : void 0;
1114
+ return filterOption?.id ? bindingifyGeneralHookFilter(filterOption.id, "id") : void 0;
983
1115
  }
984
1116
  function bindingifyLoadFilter(filterOption) {
985
- return filterOption?.id ? bindingifyStringFilter(filterOption.id) : void 0;
1117
+ return filterOption?.id ? bindingifyGeneralHookFilter(filterOption.id, "id") : void 0;
986
1118
  }
987
1119
  function bindingifyTransformFilter(filterOption) {
988
1120
  if (!filterOption) return void 0;
989
- const { id, code, moduleType } = filterOption;
990
- let moduleTypeRet;
991
- if (moduleType) if (Array.isArray(moduleType)) moduleTypeRet = moduleType;
992
- else moduleTypeRet = moduleType.include;
993
- return {
994
- id: id ? bindingifyStringFilter(id) : void 0,
995
- code: code ? bindingifyStringFilter(code) : void 0,
996
- moduleType: moduleTypeRet
997
- };
1121
+ let custom = transformFilterMatcherToFilterExprs(filterOption);
1122
+ let ret = [];
1123
+ if (custom) ret = custom.map(bindingifyFilterExpr);
1124
+ return { custom: ret.length > 0 ? ret : void 0 };
1125
+ }
1126
+ function bindingifyRenderChunkFilter(filterOption) {
1127
+ if (filterOption) {
1128
+ const { code: code$1 } = filterOption;
1129
+ return { custom: code$1 ? bindingifyGeneralHookFilter(code$1, "code").custom : void 0 };
1130
+ }
998
1131
  }
999
1132
 
1000
1133
  //#endregion
@@ -1032,39 +1165,37 @@ var PluginContextImpl = class extends MinimalPluginContextImpl {
1032
1165
  this.data = data;
1033
1166
  this.onLog = onLog;
1034
1167
  this.currentLoadingModule = currentLoadingModule;
1035
- this.getModuleInfo = (id) => this.data.getModuleInfo(id, context);
1168
+ this.getModuleInfo = (id$1) => this.data.getModuleInfo(id$1, context);
1036
1169
  }
1037
1170
  async load(options) {
1038
- const id = options.id;
1039
- if (id === this.currentLoadingModule) this.onLog(LOG_LEVEL_WARN, require_parse_ast_index.logCycleLoading(this.pluginName, this.currentLoadingModule));
1040
- const moduleInfo = this.data.getModuleInfo(id, this.context);
1171
+ const id$1 = options.id;
1172
+ if (id$1 === this.currentLoadingModule) this.onLog(LOG_LEVEL_WARN, require_parse_ast_index.logCycleLoading(this.pluginName, this.currentLoadingModule));
1173
+ const moduleInfo = this.data.getModuleInfo(id$1, this.context);
1041
1174
  if (moduleInfo && moduleInfo.code !== null) return moduleInfo;
1042
1175
  const rawOptions = {
1043
1176
  meta: options.meta || {},
1044
1177
  moduleSideEffects: options.moduleSideEffects || null,
1045
1178
  invalidate: false
1046
1179
  };
1047
- this.data.updateModuleOption(id, rawOptions);
1180
+ this.data.updateModuleOption(id$1, rawOptions);
1048
1181
  async function createLoadModulePromise(context, data) {
1049
- const loadPromise = data.loadModulePromiseMap.get(id);
1182
+ const loadPromise = data.loadModulePromiseMap.get(id$1);
1050
1183
  if (loadPromise) return loadPromise;
1051
- let resolveFn;
1052
1184
  const promise = new Promise((resolve, _) => {
1053
- resolveFn = resolve;
1185
+ data.loadModulePromiseResolveFnMap.set(id$1, resolve);
1054
1186
  });
1055
- data.loadModulePromiseMap.set(id, promise);
1187
+ data.loadModulePromiseMap.set(id$1, promise);
1056
1188
  try {
1057
- await context.load(id, bindingifySideEffects(options.moduleSideEffects), (_success) => {
1058
- resolveFn();
1059
- });
1189
+ await context.load(id$1, bindingifySideEffects(options.moduleSideEffects));
1060
1190
  } catch (e) {
1061
- data.loadModulePromiseMap.delete(id);
1191
+ data.loadModulePromiseMap.delete(id$1);
1192
+ data.loadModulePromiseResolveFnMap.delete(id$1);
1062
1193
  throw e;
1063
1194
  }
1064
1195
  return promise;
1065
1196
  }
1066
1197
  await createLoadModulePromise(this.context, this.data);
1067
- return this.data.getModuleInfo(id, this.context);
1198
+ return this.data.getModuleInfo(id$1, this.context);
1068
1199
  }
1069
1200
  async resolve(source, importer, options) {
1070
1201
  let receipt = void 0;
@@ -1107,8 +1238,8 @@ var PluginContextImpl = class extends MinimalPluginContextImpl {
1107
1238
  getModuleIds() {
1108
1239
  return this.data.getModuleIds(this.context);
1109
1240
  }
1110
- addWatchFile(id) {
1111
- this.context.addWatchFile(id);
1241
+ addWatchFile(id$1) {
1242
+ this.context.addWatchFile(id$1);
1112
1243
  }
1113
1244
  parse(input, options) {
1114
1245
  return require_parse_ast_index.parseAst(input, options);
@@ -1242,18 +1373,18 @@ function bindingifyTransform(args) {
1242
1373
  if (!hook) return {};
1243
1374
  const { handler, meta, options } = normalizeHook(hook);
1244
1375
  return {
1245
- plugin: async (ctx, code, id, meta$1) => {
1246
- 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);
1376
+ plugin: async (ctx, code$1, id$1, meta$1) => {
1377
+ const ret = await handler.call(new TransformPluginContextImpl(args.outputOptions, ctx.inner(), args.plugin, args.pluginContextData, ctx, id$1, code$1, args.onLog, args.logLevel, args.watchMode), code$1, id$1, meta$1);
1247
1378
  if (ret == null) return void 0;
1248
1379
  if (typeof ret === "string") return { code: ret };
1249
- let moduleOption = args.pluginContextData.updateModuleOption(id, {
1380
+ let moduleOption = args.pluginContextData.updateModuleOption(id$1, {
1250
1381
  meta: ret.meta ?? {},
1251
1382
  moduleSideEffects: ret.moduleSideEffects ?? null,
1252
1383
  invalidate: false
1253
1384
  });
1254
1385
  return {
1255
1386
  code: ret.code,
1256
- map: bindingifySourcemap$1(normalizeTransformHookSourcemap(id, code, ret.map)),
1387
+ map: bindingifySourcemap$1(normalizeTransformHookSourcemap(id$1, code$1, ret.map)),
1257
1388
  sideEffects: bindingifySideEffects(moduleOption.moduleSideEffects),
1258
1389
  moduleType: ret.moduleType
1259
1390
  };
@@ -1267,16 +1398,16 @@ function bindingifyLoad(args) {
1267
1398
  if (!hook) return {};
1268
1399
  const { handler, meta, options } = normalizeHook(hook);
1269
1400
  return {
1270
- plugin: async (ctx, id) => {
1271
- const ret = await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode, id), id);
1401
+ plugin: async (ctx, id$1) => {
1402
+ const ret = await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode, id$1), id$1);
1272
1403
  if (ret == null) return;
1273
1404
  if (typeof ret === "string") return { code: ret };
1274
- let moduleOption = args.pluginContextData.updateModuleOption(id, {
1405
+ let moduleOption = args.pluginContextData.updateModuleOption(id$1, {
1275
1406
  meta: ret.meta || {},
1276
1407
  moduleSideEffects: ret.moduleSideEffects ?? null,
1277
1408
  invalidate: false
1278
1409
  });
1279
- let map = preProcessSourceMap(ret, id);
1410
+ let map = preProcessSourceMap(ret, id$1);
1280
1411
  return {
1281
1412
  code: ret.code,
1282
1413
  map: bindingifySourcemap$1(map),
@@ -1288,11 +1419,11 @@ function bindingifyLoad(args) {
1288
1419
  filter: bindingifyLoadFilter(options.filter)
1289
1420
  };
1290
1421
  }
1291
- function preProcessSourceMap(ret, id) {
1422
+ function preProcessSourceMap(ret, id$1) {
1292
1423
  if (!ret.map) return;
1293
1424
  let map = typeof ret.map === "object" ? ret.map : JSON.parse(ret.map);
1294
1425
  if (!isEmptySourcemapFiled(map.sources)) {
1295
- const directory = node_path.default.dirname(id) || ".";
1426
+ const directory = node_path.default.dirname(id$1) || ".";
1296
1427
  const sourceRoot = map.sourceRoot || ".";
1297
1428
  map.sources = map.sources.map((source) => node_path.default.resolve(directory, sourceRoot, source));
1298
1429
  }
@@ -1366,9 +1497,9 @@ function transformRenderedChunk(chunk) {
1366
1497
  }
1367
1498
  function transformChunkModules(modules) {
1368
1499
  const result = {};
1369
- for (let i = 0; i < modules.values.length; i++) {
1370
- let key = modules.keys[i];
1371
- const mod = modules.values[i];
1500
+ for (let i$1 = 0; i$1 < modules.values.length; i$1++) {
1501
+ let key = modules.keys[i$1];
1502
+ const mod = modules.values[i$1];
1372
1503
  result[key] = transformToRenderedModule(mod);
1373
1504
  }
1374
1505
  return result;
@@ -1716,11 +1847,11 @@ function bindingifyRenderStart(args) {
1716
1847
  function bindingifyRenderChunk(args) {
1717
1848
  const hook = args.plugin.renderChunk;
1718
1849
  if (!hook) return {};
1719
- const { handler, meta } = normalizeHook(hook);
1850
+ const { handler, meta, options } = normalizeHook(hook);
1720
1851
  return {
1721
- plugin: async (ctx, code, chunk, opts, meta$1) => {
1852
+ plugin: async (ctx, code$1, chunk, opts, meta$1) => {
1722
1853
  if (args.pluginContextData.getRenderChunkMeta() == null) args.pluginContextData.setRenderChunkMeta({ chunks: Object.fromEntries(Object.entries(meta$1.chunks).map(([key, value]) => [key, transformRenderedChunk(value)])) });
1723
- 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());
1854
+ const ret = await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), code$1, transformRenderedChunk(chunk), new NormalizedOutputOptionsImpl(opts, args.outputOptions, args.normalizedOutputPlugins), args.pluginContextData.getRenderChunkMeta());
1724
1855
  if (ret == null) return;
1725
1856
  if (typeof ret === "string") return { code: ret };
1726
1857
  if (!ret.map) return { code: ret.code };
@@ -1729,7 +1860,8 @@ function bindingifyRenderChunk(args) {
1729
1860
  map: bindingifySourcemap$1(ret.map)
1730
1861
  };
1731
1862
  },
1732
- meta: bindingifyPluginHookMeta(meta)
1863
+ meta: bindingifyPluginHookMeta(meta),
1864
+ filter: bindingifyRenderChunkFilter(options.filter)
1733
1865
  };
1734
1866
  }
1735
1867
  function bindingifyAugmentChunkHash(args) {
@@ -1855,8 +1987,8 @@ function bindingifyWatchChange(args) {
1855
1987
  if (!hook) return {};
1856
1988
  const { handler, meta } = normalizeHook(hook);
1857
1989
  return {
1858
- plugin: async (ctx, id, event) => {
1859
- await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), id, { event });
1990
+ plugin: async (ctx, id$1, event) => {
1991
+ await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), id$1, { event });
1860
1992
  },
1861
1993
  meta: bindingifyPluginHookMeta(meta)
1862
1994
  };
@@ -1954,7 +2086,7 @@ function bindingifyPlugin(plugin, options, outputOptions, pluginContextData, nor
1954
2086
  const { plugin: transform, meta: transformMeta, filter: transformFilter } = bindingifyTransform(args);
1955
2087
  const { plugin: moduleParsed, meta: moduleParsedMeta } = bindingifyModuleParsed(args);
1956
2088
  const { plugin: load, meta: loadMeta, filter: loadFilter } = bindingifyLoad(args);
1957
- const { plugin: renderChunk, meta: renderChunkMeta } = bindingifyRenderChunk(args);
2089
+ const { plugin: renderChunk, meta: renderChunkMeta, filter: renderChunkFilter } = bindingifyRenderChunk(args);
1958
2090
  const { plugin: augmentChunkHash, meta: augmentChunkHashMeta } = bindingifyAugmentChunkHash(args);
1959
2091
  const { plugin: renderStart, meta: renderStartMeta } = bindingifyRenderStart(args);
1960
2092
  const { plugin: renderError, meta: renderErrorMeta } = bindingifyRenderError(args);
@@ -1989,6 +2121,7 @@ function bindingifyPlugin(plugin, options, outputOptions, pluginContextData, nor
1989
2121
  loadFilter,
1990
2122
  renderChunk,
1991
2123
  renderChunkMeta,
2124
+ renderChunkFilter,
1992
2125
  augmentChunkHash,
1993
2126
  augmentChunkHashMeta,
1994
2127
  renderStart,
@@ -2061,47 +2194,48 @@ var PluginContextData = class {
2061
2194
  moduleOptionMap = new Map();
2062
2195
  resolveOptionsMap = new Map();
2063
2196
  loadModulePromiseMap = new Map();
2197
+ loadModulePromiseResolveFnMap = new Map();
2064
2198
  renderedChunkMeta = null;
2065
- updateModuleOption(id, option) {
2066
- const existing = this.moduleOptionMap.get(id);
2199
+ updateModuleOption(id$1, option) {
2200
+ const existing = this.moduleOptionMap.get(id$1);
2067
2201
  if (existing) {
2068
2202
  if (option.moduleSideEffects != null) existing.moduleSideEffects = option.moduleSideEffects;
2069
2203
  if (option.meta != null) Object.assign(existing.meta, option.meta);
2070
2204
  if (option.invalidate != null) existing.invalidate = option.invalidate;
2071
2205
  } else {
2072
- this.moduleOptionMap.set(id, option);
2206
+ this.moduleOptionMap.set(id$1, option);
2073
2207
  return option;
2074
2208
  }
2075
2209
  return existing;
2076
2210
  }
2077
- getModuleOption(id) {
2078
- const option = this.moduleOptionMap.get(id);
2211
+ getModuleOption(id$1) {
2212
+ const option = this.moduleOptionMap.get(id$1);
2079
2213
  if (!option) {
2080
2214
  const raw = {
2081
2215
  moduleSideEffects: null,
2082
2216
  meta: {}
2083
2217
  };
2084
- this.moduleOptionMap.set(id, raw);
2218
+ this.moduleOptionMap.set(id$1, raw);
2085
2219
  return raw;
2086
2220
  }
2087
2221
  return option;
2088
2222
  }
2089
- getModuleInfo(id, context) {
2090
- const bindingInfo = context.getModuleInfo(id);
2223
+ getModuleInfo(id$1, context) {
2224
+ const bindingInfo = context.getModuleInfo(id$1);
2091
2225
  if (bindingInfo) {
2092
- const info = transformModuleInfo(bindingInfo, this.getModuleOption(id));
2093
- return this.proxyModuleInfo(id, info);
2226
+ const info = transformModuleInfo(bindingInfo, this.getModuleOption(id$1));
2227
+ return this.proxyModuleInfo(id$1, info);
2094
2228
  }
2095
2229
  return null;
2096
2230
  }
2097
- proxyModuleInfo(id, info) {
2231
+ proxyModuleInfo(id$1, info) {
2098
2232
  let moduleSideEffects = info.moduleSideEffects;
2099
2233
  Object.defineProperty(info, "moduleSideEffects", {
2100
2234
  get() {
2101
2235
  return moduleSideEffects;
2102
2236
  },
2103
2237
  set: (v) => {
2104
- this.updateModuleOption(id, {
2238
+ this.updateModuleOption(id$1, {
2105
2239
  moduleSideEffects: v,
2106
2240
  meta: info.meta,
2107
2241
  invalidate: true
@@ -2132,9 +2266,14 @@ var PluginContextData = class {
2132
2266
  getRenderChunkMeta() {
2133
2267
  return this.renderedChunkMeta;
2134
2268
  }
2269
+ markModuleLoaded(id$1, _success) {
2270
+ const resolve = this.loadModulePromiseResolveFnMap.get(id$1);
2271
+ if (resolve) resolve();
2272
+ }
2135
2273
  clear() {
2136
2274
  this.renderedChunkMeta = null;
2137
2275
  this.loadModulePromiseMap.clear();
2276
+ this.loadModulePromiseResolveFnMap.clear();
2138
2277
  }
2139
2278
  };
2140
2279
 
@@ -2198,7 +2337,8 @@ function bindingifyInputOptions(rawPlugins, inputOptions, outputOptions, normali
2198
2337
  },
2199
2338
  makeAbsoluteExternalsRelative: bindingifyMakeAbsoluteExternalsRelative(inputOptions.makeAbsoluteExternalsRelative),
2200
2339
  debug: inputOptions.debug,
2201
- invalidateJsSideCache: pluginContextData.clear.bind(pluginContextData)
2340
+ invalidateJsSideCache: pluginContextData.clear.bind(pluginContextData),
2341
+ markModuleLoaded: pluginContextData.markModuleLoaded.bind(pluginContextData)
2202
2342
  };
2203
2343
  }
2204
2344
  function bindingifyHmr(hmr) {
@@ -2209,15 +2349,15 @@ function bindingifyHmr(hmr) {
2209
2349
  }
2210
2350
  function bindingifyExternal(external) {
2211
2351
  if (external) {
2212
- if (typeof external === "function") return (id, importer, isResolved) => {
2213
- if (id.startsWith("\0")) return false;
2214
- return external(id, importer, isResolved) ?? false;
2352
+ if (typeof external === "function") return (id$1, importer, isResolved) => {
2353
+ if (id$1.startsWith("\0")) return false;
2354
+ return external(id$1, importer, isResolved) ?? false;
2215
2355
  };
2216
2356
  const externalArr = arraify(external);
2217
- return (id, _importer, _isResolved) => {
2357
+ return (id$1, _importer, _isResolved) => {
2218
2358
  return externalArr.some((pat) => {
2219
- if (pat instanceof RegExp) return pat.test(id);
2220
- return id === pat;
2359
+ if (pat instanceof RegExp) return pat.test(id$1);
2360
+ return id$1 === pat;
2221
2361
  });
2222
2362
  };
2223
2363
  }
@@ -2338,31 +2478,6 @@ function bindingifyMakeAbsoluteExternalsRelative(makeAbsoluteExternalsRelative)
2338
2478
  };
2339
2479
  }
2340
2480
 
2341
- //#endregion
2342
- //#region ../../node_modules/.pnpm/remeda@2.21.2/node_modules/remeda/dist/chunk-D6FCK2GA.js
2343
- function u$1(o, n, a) {
2344
- let t$1 = (r) => o(r, ...n);
2345
- return a === void 0 ? t$1 : Object.assign(t$1, {
2346
- lazy: a,
2347
- lazyArgs: n
2348
- });
2349
- }
2350
-
2351
- //#endregion
2352
- //#region ../../node_modules/.pnpm/remeda@2.21.2/node_modules/remeda/dist/chunk-WIMGWYZL.js
2353
- function u(r, n, o) {
2354
- let a = r.length - n.length;
2355
- if (a === 0) return r(...n);
2356
- if (a === 1) return u$1(r, n, o);
2357
- throw new Error("Wrong number of arguments");
2358
- }
2359
-
2360
- //#endregion
2361
- //#region ../../node_modules/.pnpm/remeda@2.21.2/node_modules/remeda/dist/chunk-5NQBDF4H.js
2362
- function t(...n) {
2363
- return u(Object.keys, n);
2364
- }
2365
-
2366
2481
  //#endregion
2367
2482
  //#region src/utils/plugin/index.ts
2368
2483
  const isPluginHookName = function() {
@@ -2522,10 +2637,10 @@ function createComposedPlugin(plugins) {
2522
2637
  case "load": {
2523
2638
  if (batchedHooks.load) {
2524
2639
  const batchedHandlers = batchedHooks.load;
2525
- composed.load = async function(id) {
2640
+ composed.load = async function(id$1) {
2526
2641
  for (const [handler, plugin] of batchedHandlers) {
2527
2642
  const { handler: handlerFn } = normalizeHook(handler);
2528
- const result = await handlerFn.call(applyFixedPluginResolveFn(this, plugin), id);
2643
+ const result = await handlerFn.call(applyFixedPluginResolveFn(this, plugin), id$1);
2529
2644
  if (!isNullish(result)) return result;
2530
2645
  }
2531
2646
  };
@@ -2535,11 +2650,11 @@ function createComposedPlugin(plugins) {
2535
2650
  case "transform": {
2536
2651
  if (batchedHooks.transform) {
2537
2652
  const batchedHandlers = batchedHooks.transform;
2538
- composed.transform = async function(initialCode, id, moduleType) {
2539
- let code = initialCode;
2653
+ composed.transform = async function(initialCode, id$1, moduleType$1) {
2654
+ let code$1 = initialCode;
2540
2655
  let moduleSideEffects = void 0;
2541
2656
  function updateOutput(newCode, newModuleSideEffects) {
2542
- code = newCode;
2657
+ code$1 = newCode;
2543
2658
  moduleSideEffects = newModuleSideEffects ?? void 0;
2544
2659
  }
2545
2660
  for (const [handler, plugin] of batchedHandlers) {
@@ -2547,14 +2662,14 @@ function createComposedPlugin(plugins) {
2547
2662
  this.getCombinedSourcemap = () => {
2548
2663
  throw new Error(`The getCombinedSourcemap is not implement in transform hook at composedJsPlugins`);
2549
2664
  };
2550
- const result = await handlerFn.call(applyFixedPluginResolveFn(this, plugin), code, id, moduleType);
2665
+ const result = await handlerFn.call(applyFixedPluginResolveFn(this, plugin), code$1, id$1, moduleType$1);
2551
2666
  if (!isNullish(result)) {
2552
2667
  if (typeof result === "string") updateOutput(result);
2553
2668
  else if (result.code) updateOutput(result.code, result.moduleSideEffects);
2554
2669
  }
2555
2670
  }
2556
2671
  return {
2557
- code,
2672
+ code: code$1,
2558
2673
  moduleSideEffects
2559
2674
  };
2560
2675
  };
@@ -2576,10 +2691,10 @@ function createComposedPlugin(plugins) {
2576
2691
  case "renderChunk": {
2577
2692
  if (batchedHooks.renderChunk) {
2578
2693
  const batchedHandlers = batchedHooks.renderChunk;
2579
- composed.renderChunk = async function(code, chunk, options, meta) {
2694
+ composed.renderChunk = async function(code$1, chunk, options, meta) {
2580
2695
  for (const [handler, plugin] of batchedHandlers) {
2581
2696
  const { handler: handlerFn } = normalizeHook(handler);
2582
- const result = await handlerFn.call(applyFixedPluginResolveFn(this, plugin), code, chunk, options, meta);
2697
+ const result = await handlerFn.call(applyFixedPluginResolveFn(this, plugin), code$1, chunk, options, meta);
2583
2698
  if (!isNullish(result)) return result;
2584
2699
  }
2585
2700
  };
@@ -2616,10 +2731,10 @@ function createComposedPlugin(plugins) {
2616
2731
  case "watchChange": {
2617
2732
  if (batchedHooks.watchChange) {
2618
2733
  const batchedHandlers = batchedHooks.watchChange;
2619
- composed.watchChange = async function(id, event) {
2734
+ composed.watchChange = async function(id$1, event) {
2620
2735
  await Promise.all(batchedHandlers.map(([handler, plugin]) => {
2621
2736
  const { handler: handlerFn } = normalizeHook(handler);
2622
- return handlerFn.call(applyFixedPluginResolveFn(this, plugin), id, event);
2737
+ return handlerFn.call(applyFixedPluginResolveFn(this, plugin), id$1, event);
2623
2738
  }));
2624
2739
  };
2625
2740
  }
@@ -2706,7 +2821,7 @@ async function initializeParallelPlugins(plugins) {
2706
2821
  };
2707
2822
  }
2708
2823
  function initializeWorkers(registryId, count, pluginInfos) {
2709
- return Promise.all(Array.from({ length: count }, (_, i) => initializeWorker(registryId, pluginInfos, i)));
2824
+ return Promise.all(Array.from({ length: count }, (_, i$1) => initializeWorker(registryId, pluginInfos, i$1)));
2710
2825
  }
2711
2826
  async function initializeWorker(registryId, pluginInfos, threadNumber) {
2712
2827
  const urlString = (void 0)("#parallel-plugin-worker");
@@ -2880,8 +2995,8 @@ var WatcherEmitter = class {
2880
2995
  break;
2881
2996
  case "event":
2882
2997
  for (const listener of listeners) {
2883
- const code = event.bundleEventKind();
2884
- switch (code) {
2998
+ const code$1 = event.bundleEventKind();
2999
+ switch (code$1) {
2885
3000
  case "BUNDLE_END":
2886
3001
  const { duration, output } = event.bundleEndData();
2887
3002
  await listener({
@@ -2898,7 +3013,7 @@ var WatcherEmitter = class {
2898
3013
  });
2899
3014
  break;
2900
3015
  default:
2901
- await listener({ code });
3016
+ await listener({ code: code$1 });
2902
3017
  break;
2903
3018
  }
2904
3019
  }
@@ -3008,10 +3123,10 @@ function withFilter(pluginOption, filterObject) {
3008
3123
  }
3009
3124
  function findMatchedFilterObject(pluginName, overrideFilterObjectList) {
3010
3125
  if (overrideFilterObjectList.length === 1 && overrideFilterObjectList[0].pluginNamePattern === void 0) return 0;
3011
- for (let i = 0; i < overrideFilterObjectList.length; i++) for (let j = 0; j < (overrideFilterObjectList[i].pluginNamePattern ?? []).length; j++) {
3012
- let pattern = overrideFilterObjectList[i].pluginNamePattern[j];
3013
- if (typeof pattern === "string" && pattern === pluginName) return i;
3014
- else if (pattern instanceof RegExp && pattern.test(pluginName)) return i;
3126
+ for (let i$1 = 0; i$1 < overrideFilterObjectList.length; i$1++) for (let j = 0; j < (overrideFilterObjectList[i$1].pluginNamePattern ?? []).length; j++) {
3127
+ let pattern = overrideFilterObjectList[i$1].pluginNamePattern[j];
3128
+ if (typeof pattern === "string" && pattern === pluginName) return i$1;
3129
+ else if (pattern instanceof RegExp && pattern.test(pluginName)) return i$1;
3015
3130
  }
3016
3131
  return -1;
3017
3132
  }