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