@voidzero-dev/vite-plus-core 0.1.1-alpha.0 → 0.1.2

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 (29) hide show
  1. package/dist/rolldown/cli.mjs +1 -1
  2. package/dist/rolldown/config.d.mts +0 -1
  3. package/dist/rolldown/filter-index.d.mts +0 -1
  4. package/dist/rolldown/index.mjs +1 -1
  5. package/dist/rolldown/parallel-plugin.d.mts +0 -1
  6. package/dist/rolldown/shared/{watch-Cn-znpX_.mjs → watch-CVufTfok.mjs} +1 -1
  7. package/dist/tsdown/{build-BjQ7Rt90-tMPZTflz.js → build-TmLngPCw-I7MHSf0I.js} +269 -188
  8. package/dist/tsdown/build-gOkJM1H9-BRI3DQle.js +6 -0
  9. package/dist/tsdown/{debug-BUVkFfEZ-D3UMJnif.js → debug-tOJ_PtrM-DITcI9An.js} +2 -2
  10. package/dist/tsdown/{detect-CCATtVj7-DhvBg5EF.js → detect-DK-FDZQ9-CALXiuJa.js} +1 -1
  11. package/dist/tsdown/{dist-CFTDWtv2.js → dist-DVPyDO-_.js} +5 -2
  12. package/dist/tsdown/{dist-DNcnO8LL.js → dist-uzMTIu3J.js} +488 -521
  13. package/dist/tsdown/{filename-CPj0AKvV.js → filename-C2azOotK.js} +2 -2
  14. package/dist/tsdown/{index-node-ShM0x2b6-Bt7Chc0I.js → index-node-Djp92Gzb-fgHTblzo.js} +1 -1
  15. package/dist/tsdown/index-types.d.ts +175 -25
  16. package/dist/tsdown/index.js +5 -5
  17. package/dist/tsdown/{main-B3qcLRNf.js → main-BWoReXjl.js} +72 -69
  18. package/dist/tsdown/npm_cjs_chunk_lt.cjs +31 -0
  19. package/dist/tsdown/npm_cjs_chunk_range.cjs +7 -22
  20. package/dist/tsdown/npm_cjs_chunk_semver.cjs +17 -17
  21. package/dist/tsdown/npm_entry_semver_functions_lt.cjs +7 -0
  22. package/dist/tsdown/npm_entry_semver_functions_satisfies.cjs +2 -1
  23. package/dist/tsdown/npm_entry_semver_ranges_min-version.cjs +2 -1
  24. package/dist/tsdown/{resolver-j7HY1N36-DHVsN9q6.js → resolver-CdD-yT15-OWjlgV0D.js} +1 -1
  25. package/dist/tsdown/run.js +209 -68
  26. package/dist/tsdown/{tsc-CBjlgM2A.js → tsc-D6YfZJBZ.js} +62 -67
  27. package/dist/tsdown/{tsc-context-D1h5oZB8.js → tsc-context-CGmk4Cps.js} +1 -1
  28. package/package.json +12 -8
  29. package/dist/tsdown/build-2oRq4mfQ-YC_gzK3u.js +0 -6
@@ -1,10 +1,10 @@
1
1
  import { r as __toESM, t as __commonJSMin } from "./chunk-CdeBBKNj.js";
2
- import { C as green, E as yellow, S as dim, T as underline, _ as resolveRegex, a as createLogger, b as blue, c as getNameLabel, d as matchPattern, f as noop, g as resolveComma, h as promiseWithResolvers, i as LogLevels, l as globalLogger, m as prettyFormat, n as q, o as debounce, p as pkgExists, r as version, s as generateColor, t as K, u as importWithError, v as slash, w as red, x as bold, y as toArray } from "./main-B3qcLRNf.js";
2
+ import { C as resolveComma, E as toArray, S as promiseWithResolvers, T as slash, _ as debounce, a as createLogger, b as noop, c as globalLogger, d as bold, f as dim, g as yellow, h as underline, i as LogLevels, l as prettyFormat, m as red, n as q, o as generateColor, p as green, r as version, s as getNameLabel, t as K, u as blue, v as importWithError, w as resolveRegex, x as pkgExists, y as matchPattern } from "./main-BWoReXjl.js";
3
3
  import { t as createDebug } from "./node-Ba_UB_xO.js";
4
- import { i as RE_JS, n as RE_DTS, o as RE_NODE_MODULES$1, t as RE_CSS } from "./filename-CPj0AKvV.js";
4
+ import { i as RE_JS, n as RE_DTS, o as RE_NODE_MODULES$1, t as RE_CSS$1 } from "./filename-C2azOotK.js";
5
5
  import module$1, { builtinModules, createRequire, isBuiltin } from "node:module";
6
- import process$1, { env } from "node:process";
7
6
  import { fileURLToPath, pathToFileURL } from "node:url";
7
+ import process$1, { env } from "node:process";
8
8
  import readline from "node:readline";
9
9
  import { formatWithOptions, inspect, promisify } from "node:util";
10
10
  import { createRequire as createRequire$1 } from "module";
@@ -22,7 +22,7 @@ import { Buffer } from "node:buffer";
22
22
  import { brotliCompress, gzip } from "node:zlib";
23
23
  import { importGlobPlugin } from "@voidzero-dev/vite-plus-core/rolldown/experimental";
24
24
 
25
- //#region ../../node_modules/.pnpm/tsdown@0.21.0-beta.2_@arethetypeswrong+core@0.18.2_@typescript+native-preview@7.0.0-dev_d0d0ed2124937ee9dd401a280008a3bf/node_modules/tsdown/dist/format-J6JPSe_8.mjs
25
+ //#region ../../node_modules/.pnpm/tsdown@0.21.0_@arethetypeswrong+core@0.18.2_@tsdown+css@0.21.0_@tsdown+exe@0.21.0_@type_743816f26d68021f6369d2afb428dae9/node_modules/tsdown/dist/format-CM79ZE77.mjs
26
26
  function fsExists(path) {
27
27
  return access(path).then(() => true, () => false);
28
28
  }
@@ -109,7 +109,25 @@ function resolveDepsConfig(config, logger) {
109
109
  skipNodeModulesBundle
110
110
  };
111
111
  }
112
- function DepPlugin({ pkg, deps: { alwaysBundle, onlyAllowBundle: inlineOnly, skipNodeModulesBundle }, logger, nameLabel }) {
112
+ async function parseBundledDep(moduleId) {
113
+ const slashed = slash(moduleId);
114
+ const lastNmIdx = slashed.lastIndexOf("/node_modules/");
115
+ if (lastNmIdx === -1) return;
116
+ const parts = slashed.slice(lastNmIdx + 14).split("/");
117
+ let name;
118
+ if (parts[0][0] === "@") name = `${parts[0]}/${parts[1]}`;
119
+ else name = parts[0];
120
+ const root = slashed.slice(0, lastNmIdx + 14 + name.length);
121
+ try {
122
+ const json = JSON.parse(await readFile(path.join(root, "package.json"), "utf8"));
123
+ return {
124
+ name,
125
+ pkgName: json.name,
126
+ version: json.version
127
+ };
128
+ } catch {}
129
+ }
130
+ function DepPlugin({ pkg, deps: { alwaysBundle, onlyAllowBundle, skipNodeModulesBundle }, logger, nameLabel }, tsdownBundle) {
113
131
  const deps = pkg && Array.from(getProductionDeps(pkg));
114
132
  return {
115
133
  name: "tsdown:external",
@@ -127,32 +145,30 @@ function DepPlugin({ pkg, deps: { alwaysBundle, onlyAllowBundle: inlineOnly, ski
127
145
  };
128
146
  }
129
147
  },
130
- generateBundle: inlineOnly === false ? void 0 : {
148
+ generateBundle: {
131
149
  order: "post",
132
- handler(options, bundle) {
150
+ async handler(options, bundle) {
133
151
  const deps = /* @__PURE__ */ new Set();
134
152
  const importers = /* @__PURE__ */ new Map();
135
153
  for (const chunk of Object.values(bundle)) {
136
154
  if (chunk.type === "asset") continue;
137
155
  for (const id of chunk.moduleIds) {
138
- if (!RE_NODE_MODULES$1.test(id)) continue;
139
- const parts = slash(id).split("/node_modules/").at(-1)?.split("/");
140
- if (!parts) continue;
141
- let dep;
142
- if (parts[0][0] === "@") dep = `${parts[0]}/${parts[1]}`;
143
- else dep = parts[0];
144
- deps.add(dep);
156
+ const parsed = await parseBundledDep(id);
157
+ if (!parsed) continue;
158
+ deps.add(parsed.name);
159
+ if (!tsdownBundle.inlinedDeps.has(parsed.pkgName)) tsdownBundle.inlinedDeps.set(parsed.pkgName, /* @__PURE__ */ new Set());
160
+ tsdownBundle.inlinedDeps.get(parsed.pkgName).add(parsed.version);
145
161
  const module = this.getModuleInfo(id);
146
- if (module) importers.set(dep, new Set([...module.importers, ...importers.get(dep) || []]));
162
+ if (module) importers.set(parsed.name, new Set([...module.importers, ...importers.get(parsed.name) || []]));
147
163
  }
148
164
  }
149
165
  debug$6("found deps in bundle: %o", deps);
150
- if (inlineOnly) {
151
- const errors = Array.from(deps).filter((dep) => !matchPattern(dep, inlineOnly)).map((dep) => `${yellow(dep)} is located in ${blue`node_modules`} but is not included in ${blue`deps.onlyAllowBundle`} option.\nTo fix this, either add it to ${blue`deps.onlyAllowBundle`}, declare it as a production or peer dependency in your package.json, or externalize it manually.\nImported by\n${[...importers.get(dep) || []].map((s) => `- ${underline(s)}`).join("\n")}`);
166
+ if (onlyAllowBundle) {
167
+ const errors = Array.from(deps).filter((dep) => !matchPattern(dep, onlyAllowBundle)).map((dep) => `${yellow(dep)} is located in ${blue`node_modules`} but is not included in ${blue`deps.onlyAllowBundle`} option.\nTo fix this, either add it to ${blue`deps.onlyAllowBundle`}, declare it as a production or peer dependency in your package.json, or externalize it manually.\nImported by\n${[...importers.get(dep) || []].map((s) => `- ${underline(s)}`).join("\n")}`);
152
168
  if (errors.length) this.error(errors.join("\n\n"));
153
- const unusedPatterns = inlineOnly.filter((pattern) => !Array.from(deps).some((dep) => matchPattern(dep, [pattern])));
169
+ const unusedPatterns = onlyAllowBundle.filter((pattern) => !Array.from(deps).some((dep) => matchPattern(dep, [pattern])));
154
170
  if (unusedPatterns.length) logger.info(nameLabel, `The following entries in ${blue`deps.onlyAllowBundle`} are not used in the bundle:\n${unusedPatterns.map((pattern) => `- ${yellow(pattern)}`).join("\n")}\nConsider removing them to keep your configuration clean.`);
155
- } else if (deps.size) logger.info(nameLabel, `Hint: consider adding ${blue`deps.onlyAllowBundle`} option to avoid unintended bundling of dependencies, or set ${blue`deps.onlyAllowBundle: false`} to disable this hint.\nSee more at ${underline`https://tsdown.dev/options/dependencies#deps-onlyallowbundle`}\nDetected dependencies in bundle:\n${Array.from(deps).map((dep) => `- ${blue(dep)}`).join("\n")}`);
171
+ } else if (onlyAllowBundle == null && deps.size) logger.info(nameLabel, `Hint: consider adding ${blue`deps.onlyAllowBundle`} option to avoid unintended bundling of dependencies, or set ${blue`deps.onlyAllowBundle: false`} to disable this hint.\nSee more at ${underline`https://tsdown.dev/options/dependencies#deps-onlyallowbundle`}\nDetected dependencies in bundle:\n${Array.from(deps).map((dep) => `- ${blue(dep)}`).join("\n")}`);
156
172
  }
157
173
  }
158
174
  };
@@ -198,6 +214,26 @@ function detectIndentation(jsonText) {
198
214
  return 2;
199
215
  }
200
216
 
217
+ //#endregion
218
+ //#region ../../node_modules/.pnpm/tsdown@0.21.0_@arethetypeswrong+core@0.18.2_@tsdown+css@0.21.0_@tsdown+exe@0.21.0_@type_743816f26d68021f6369d2afb428dae9/node_modules/tsdown/dist/css-CzF_A79W.mjs
219
+ const defaultCssBundleName = "style.css";
220
+ function resolveCssOptions(options = {}, topLevelTarget) {
221
+ let cssTarget;
222
+ if (options.target === false) cssTarget = void 0;
223
+ else if (options.target == null) cssTarget = topLevelTarget;
224
+ else cssTarget = resolveComma(toArray(options.target));
225
+ return {
226
+ transformer: options.transformer ?? "lightningcss",
227
+ splitting: options.splitting ?? false,
228
+ fileName: options.fileName ?? "style.css",
229
+ minify: options.minify ?? false,
230
+ target: cssTarget,
231
+ preprocessorOptions: options.preprocessorOptions,
232
+ lightningcss: options.lightningcss,
233
+ postcss: options.postcss
234
+ };
235
+ }
236
+
201
237
  //#endregion
202
238
  //#region ../../node_modules/.pnpm/defu@6.1.4/node_modules/defu/dist/defu.mjs
203
239
  function isPlainObject(value) {
@@ -3140,10 +3176,10 @@ function createConfigCoreLoader(options) {
3140
3176
  }
3141
3177
 
3142
3178
  //#endregion
3143
- //#region ../../node_modules/.pnpm/tsdown@0.21.0-beta.2_@arethetypeswrong+core@0.18.2_@typescript+native-preview@7.0.0-dev_d0d0ed2124937ee9dd401a280008a3bf/node_modules/tsdown/dist/options-eWdmaqEa.mjs
3179
+ //#region ../../node_modules/.pnpm/tsdown@0.21.0_@arethetypeswrong+core@0.18.2_@tsdown+css@0.21.0_@tsdown+exe@0.21.0_@type_743816f26d68021f6369d2afb428dae9/node_modules/tsdown/dist/options-DpJJmGDp.mjs
3144
3180
  const __cjs_require$1 = createRequire(import.meta.url);
3145
- const satisfies$1 = __cjs_require$1("./npm_entry_semver_functions_satisfies.cjs");
3146
3181
  const picomatch = __cjs_require$1("./npm_entry_picomatch.cjs");
3182
+ const satisfies$1 = __cjs_require$1("./npm_entry_semver_functions_satisfies.cjs");
3147
3183
  const minVersion = __cjs_require$1("./npm_entry_semver_ranges_min-version.cjs");
3148
3184
  const check = (key) => key in env && env[key] !== "0" && env[key] !== "false";
3149
3185
  const isInCi = check("CI") || check("CONTINUOUS_INTEGRATION");
@@ -3184,13 +3220,6 @@ async function cleanChunks(outDir, chunks) {
3184
3220
  await fsRemove(filePath);
3185
3221
  }));
3186
3222
  }
3187
- const defaultCssBundleName = "style.css";
3188
- function resolveCssOptions(options = {}) {
3189
- return {
3190
- splitting: options.splitting ?? true,
3191
- fileName: options.fileName ?? defaultCssBundleName
3192
- };
3193
- }
3194
3223
  async function resolveEntry(logger, entry, cwd, color, nameLabel) {
3195
3224
  if (!entry || Object.keys(entry).length === 0) {
3196
3225
  const defaultEntry = path.resolve(cwd, "src/index.ts");
@@ -3208,6 +3237,12 @@ function toObjectEntry(entry, cwd) {
3208
3237
  if (!Array.isArray(entry)) return resolveObjectEntry(entry, cwd);
3209
3238
  return resolveArrayEntry(entry, cwd);
3210
3239
  }
3240
+ function isGlobEntry(entry) {
3241
+ if (!entry) return false;
3242
+ if (typeof entry === "string") return isDynamicPattern(entry);
3243
+ if (Array.isArray(entry)) return entry.some((e) => typeof e === "string" ? isDynamicPattern(e) : isGlobEntry(e));
3244
+ return Object.keys(entry).some((key) => key.includes("*"));
3245
+ }
3211
3246
  async function resolveObjectEntry(entries, cwd) {
3212
3247
  return Object.fromEntries((await Promise.all(Object.entries(entries).map(async ([key, value]) => {
3213
3248
  if (!key.includes("*")) {
@@ -3253,7 +3288,7 @@ async function resolveArrayEntry(entries, cwd) {
3253
3288
  const debug$3$2 = createDebug("tsdown:exe");
3254
3289
  function validateSea({ dts, entry, logger, nameLabel }) {
3255
3290
  if (process$1.versions.bun || process$1.versions.deno) throw new Error("The `exe` option is not supported in Bun and Deno environments.");
3256
- if (!satisfies$1(process$1.version, ">=25.5.0")) throw new Error(`Node.js version ${process$1.version} does not support \`exe\` option. Please upgrade to Node.js 25.5.0 or later.`);
3291
+ if (!satisfies$1(process$1.version, ">=25.7.0")) throw new Error(`Node.js version ${process$1.version} does not support \`exe\` option. Please upgrade to Node.js 25.7.0 or later.`);
3257
3292
  if (Object.keys(entry).length > 1) throw new Error(`The \`exe\` feature currently only supports single entry points. Found entries:\n${JSON.stringify(entry, void 0, 2)}`);
3258
3293
  if (dts) logger.warn(nameLabel, `Generating .d.ts files with \`exe\` option is not recommended since they won't be included in the executable. Consider separating your library and executable targets if you need type declarations.`);
3259
3294
  logger.info(nameLabel, "`exe` option is experimental and may change in future releases.");
@@ -3265,12 +3300,27 @@ async function buildExe(config, chunks) {
3265
3300
  const chunk = filteredChunks[0];
3266
3301
  debug$3$2("Building executable with SEA for chunk:", chunk.fileName);
3267
3302
  const bundledFile = path.join(config.outDir, chunk.fileName);
3268
- let outputFile;
3269
- if (config.exe.fileName) outputFile = typeof config.exe.fileName === "function" ? config.exe.fileName(chunk) : config.exe.fileName;
3270
- else {
3271
- outputFile = path.basename(bundledFile, path.extname(bundledFile));
3272
- if (process$1.platform === "win32") outputFile += ".exe";
3273
- }
3303
+ const { targets } = config.exe;
3304
+ if (targets?.length) {
3305
+ if (config.exe.seaConfig?.executable) config.logger.warn(config.nameLabel, "`seaConfig.executable` is ignored when `targets` is specified.");
3306
+ const { resolveNodeBinary, getTargetSuffix } = await importWithError("@tsdown/exe");
3307
+ for (const target of targets) {
3308
+ const nodeBinaryPath = await resolveNodeBinary(target, config.logger);
3309
+ const suffix = getTargetSuffix(target);
3310
+ await buildSingleExe(config, bundledFile, resolveOutputFileName(config.exe, chunk, bundledFile, target, suffix), nodeBinaryPath, target);
3311
+ }
3312
+ } else await buildSingleExe(config, bundledFile, resolveOutputFileName(config.exe, chunk, bundledFile));
3313
+ }
3314
+ function resolveOutputFileName(exe, chunk, bundledFile, target, suffix) {
3315
+ let baseName;
3316
+ if (exe.fileName) baseName = typeof exe.fileName === "function" ? exe.fileName(chunk) : exe.fileName;
3317
+ else baseName = path.basename(bundledFile, path.extname(bundledFile));
3318
+ if (suffix) baseName += suffix;
3319
+ if (target?.platform ? target.platform === "win" : process$1.platform === "win32") baseName += ".exe";
3320
+ return baseName;
3321
+ }
3322
+ async function buildSingleExe(config, bundledFile, outputFile, executable, target) {
3323
+ const exe = config.exe;
3274
3324
  const outputPath = path.join(config.outDir, outputFile);
3275
3325
  debug$3$2("Building SEA executable: %s -> %s", bundledFile, outputPath);
3276
3326
  const t = performance.now();
@@ -3278,26 +3328,39 @@ async function buildExe(config, chunks) {
3278
3328
  try {
3279
3329
  const seaConfig = {
3280
3330
  disableExperimentalSEAWarning: true,
3281
- ...config.exe.seaConfig,
3331
+ ...exe.seaConfig,
3282
3332
  main: bundledFile,
3283
3333
  output: outputPath,
3284
3334
  mainFormat: config.format === "es" ? "module" : "commonjs"
3285
3335
  };
3336
+ if (executable) seaConfig.executable = executable;
3286
3337
  const seaConfigPath = path.join(tempDir, "sea-config.json");
3287
3338
  await writeFile(seaConfigPath, JSON.stringify(seaConfig));
3288
3339
  debug$3$2("Wrote sea-config.json: %O -> %s", seaConfig, seaConfigPath);
3289
- await K(process$1.execPath, ["--build-sea", seaConfigPath], { nodeOptions: { stdio: "pipe" } });
3340
+ debug$3$2("Running: %s --build-sea %s", process$1.execPath, seaConfigPath);
3341
+ await K(process$1.execPath, ["--build-sea", seaConfigPath], {
3342
+ nodeOptions: { stdio: [
3343
+ "ignore",
3344
+ "ignore",
3345
+ "inherit"
3346
+ ] },
3347
+ throwOnError: true
3348
+ });
3290
3349
  } finally {
3291
- await fsRemove(tempDir);
3350
+ if (debug$3$2.enabled) debug$3$2("Preserving temp directory for debugging: %s", tempDir);
3351
+ else await fsRemove(tempDir);
3292
3352
  }
3293
- if (process$1.platform === "darwin") try {
3353
+ if ((target?.platform || process$1.platform) === "darwin") try {
3294
3354
  await K("codesign", [
3295
3355
  "--sign",
3296
3356
  "-",
3297
3357
  outputPath
3298
- ], { nodeOptions: { stdio: "pipe" } });
3358
+ ], {
3359
+ nodeOptions: { stdio: "inherit" },
3360
+ throwOnError: true
3361
+ });
3299
3362
  } catch {
3300
- config.logger.warn(config.nameLabel, `Failed to codesign the executable. You may need to sign it manually:\n codesign --sign - ${outputPath}`);
3363
+ config.logger.warn(config.nameLabel, `Failed to code-sign the executable. ${process$1.platform === "darwin" ? `You can sign it manually using:\n codesign --sign - "${outputPath}"` : `Automatic code signing is not supported on ${process$1.platform}.`}`);
3301
3364
  }
3302
3365
  const stat = await fsStat(outputPath);
3303
3366
  if (stat) {
@@ -3306,9 +3369,9 @@ async function buildExe(config, chunks) {
3306
3369
  }
3307
3370
  config.logger.success(config.nameLabel, `Built executable: ${red(path.relative(config.cwd, outputPath))}`, dim`(${Math.round(performance.now() - t)}ms)`);
3308
3371
  }
3309
- async function writeExports(options, chunks) {
3372
+ async function writeExports(options, chunks, inlinedDeps) {
3310
3373
  const { pkg } = options;
3311
- const { publishExports, ...generated } = await generateExports(pkg, chunks, options);
3374
+ const { publishExports, ...generated } = await generateExports(pkg, chunks, options, inlinedDeps);
3312
3375
  const updatedPkg = {
3313
3376
  ...pkg,
3314
3377
  ...generated,
@@ -3327,8 +3390,8 @@ function shouldExclude(fileName, exclude) {
3327
3390
  if (!exclude?.length) return false;
3328
3391
  return matchPattern(fileName, exclude);
3329
3392
  }
3330
- async function generateExports(pkg, chunks, options) {
3331
- let { exports: { devExports, all, packageJson = true, exclude, customExports, legacy }, css, logger } = options;
3393
+ async function generateExports(pkg, chunks, options, inlinedDeps) {
3394
+ let { exports: { devExports, all, packageJson = true, exclude, customExports, legacy, inlinedDependencies: emitInlinedDeps = true }, css, logger } = options;
3332
3395
  const pkgRoot = path.dirname(pkg.packageJsonPath);
3333
3396
  let main, module, cjsTypes, esmTypes;
3334
3397
  const exportsMap = /* @__PURE__ */ new Map();
@@ -3407,6 +3470,7 @@ async function generateExports(pkg, chunks, options) {
3407
3470
  module: legacy ? module || pkg.module : void 0,
3408
3471
  types: legacy ? cjsTypes || esmTypes || pkg.types : pkg.types,
3409
3472
  exports,
3473
+ inlinedDependencies: emitInlinedDeps ? inlinedDeps : void 0,
3410
3474
  publishExports
3411
3475
  };
3412
3476
  }
@@ -3429,7 +3493,7 @@ function exportMeta(exports, all, packageJson) {
3429
3493
  }
3430
3494
  function exportCss(exports, chunks, { splitting }, pkgRoot) {
3431
3495
  if (splitting) return;
3432
- for (const chunksByFormat of Object.values(chunks)) for (const chunk of chunksByFormat) if (chunk.type === "asset" && RE_CSS.test(chunk.fileName)) {
3496
+ for (const chunksByFormat of Object.values(chunks)) for (const chunk of chunksByFormat) if (chunk.type === "asset" && RE_CSS$1.test(chunk.fileName)) {
3433
3497
  const filename = slash(chunk.fileName);
3434
3498
  exports[`./${filename}`] = join$1(pkgRoot, chunk.outDir, filename);
3435
3499
  return;
@@ -3663,7 +3727,7 @@ async function nativeImport(id) {
3663
3727
  return mod.default || mod;
3664
3728
  }
3665
3729
  async function unrunImport(id) {
3666
- const { unrun } = await import("./dist-CFTDWtv2.js");
3730
+ const { unrun } = await import("./dist-DVPyDO-_.js");
3667
3731
  const { module } = await unrun({ path: pathToFileURL(id).href });
3668
3732
  return module;
3669
3733
  }
@@ -3697,6 +3761,7 @@ async function resolveUserConfig(userConfig, inlineConfig) {
3697
3761
  nodeProtocol = nodeProtocol ?? (removeNodeProtocol ? "strip" : false);
3698
3762
  outDir = path.resolve(cwd, outDir);
3699
3763
  clean = resolveClean(clean, outDir, cwd);
3764
+ const rawEntry = entry;
3700
3765
  const resolvedEntry = await resolveEntry(logger, entry, cwd, color, nameLabel);
3701
3766
  target = resolveTarget(logger, target, color, pkg, nameLabel);
3702
3767
  tsconfig = await resolveTsconfig(logger, tsconfig, cwd, color, nameLabel);
@@ -3762,7 +3827,7 @@ async function resolveUserConfig(userConfig, inlineConfig) {
3762
3827
  cjsDefault,
3763
3828
  clean,
3764
3829
  copy: publicDir || copy,
3765
- css: resolveCssOptions(css),
3830
+ css: resolveCssOptions(css, target),
3766
3831
  cwd,
3767
3832
  deps: depsConfig,
3768
3833
  devtools,
@@ -3784,6 +3849,7 @@ async function resolveUserConfig(userConfig, inlineConfig) {
3784
3849
  platform,
3785
3850
  plugins,
3786
3851
  publint,
3852
+ rawEntry,
3787
3853
  report,
3788
3854
  shims,
3789
3855
  sourcemap,
@@ -3795,13 +3861,9 @@ async function resolveUserConfig(userConfig, inlineConfig) {
3795
3861
  watch,
3796
3862
  write
3797
3863
  };
3798
- let defaultFormat = "esm";
3799
- if (exe) {
3800
- validateSea(config);
3801
- if (satisfies$1(process$1.version, "<25.7.0")) defaultFormat = "cjs";
3802
- }
3864
+ if (exe) validateSea(config);
3803
3865
  const objectFormat = typeof format === "object" && !Array.isArray(format);
3804
- return (objectFormat ? Object.keys(format) : resolveComma(toArray(format, defaultFormat))).map((fmt, idx) => {
3866
+ return (objectFormat ? Object.keys(format) : resolveComma(toArray(format, "esm"))).map((fmt, idx) => {
3805
3867
  const once = idx === 0;
3806
3868
  const overrides = objectFormat ? format[fmt] : void 0;
3807
3869
  return {
@@ -3851,7 +3913,119 @@ function filterConfig(filter, configCwd, name) {
3851
3913
  }
3852
3914
 
3853
3915
  //#endregion
3854
- //#region ../../node_modules/.pnpm/tsdown@0.21.0-beta.2_@arethetypeswrong+core@0.18.2_@typescript+native-preview@7.0.0-dev_d0d0ed2124937ee9dd401a280008a3bf/node_modules/tsdown/dist/watch-CqXGVrf6.mjs
3916
+ //#region ../../node_modules/.pnpm/tsdown@0.21.0_@arethetypeswrong+core@0.18.2_@tsdown+css@0.21.0_@tsdown+exe@0.21.0_@type_743816f26d68021f6369d2afb428dae9/node_modules/tsdown/dist/plugin-BQv869Ce.mjs
3917
+ /**
3918
+ * Detect and remove "pure CSS chunks" — JS chunks that exist only because
3919
+ * they imported CSS files. These chunks have no JS exports and all their
3920
+ * modules are CSS. Following Vite's implementation.
3921
+ */
3922
+ function removePureCssChunks(bundle, styles) {
3923
+ const pureCssChunkNames = [];
3924
+ for (const [fileName, chunk] of Object.entries(bundle)) {
3925
+ if (chunk.type !== "chunk") continue;
3926
+ if (chunk.exports.length > 0) continue;
3927
+ const moduleIds = Object.keys(chunk.modules);
3928
+ if (moduleIds.length === 0) continue;
3929
+ if (!moduleIds.every((id) => styles.has(id))) continue;
3930
+ pureCssChunkNames.push(fileName);
3931
+ }
3932
+ if (!pureCssChunkNames.length) return;
3933
+ const replaceEmptyChunk = getEmptyChunkReplacer(pureCssChunkNames);
3934
+ for (const file of Object.keys(bundle)) {
3935
+ const chunk = bundle[file];
3936
+ if (chunk.type !== "chunk") continue;
3937
+ let chunkImportsPureCssChunk = false;
3938
+ chunk.imports = chunk.imports.filter((importFile) => {
3939
+ if (pureCssChunkNames.includes(importFile)) {
3940
+ chunkImportsPureCssChunk = true;
3941
+ return false;
3942
+ }
3943
+ return true;
3944
+ });
3945
+ if (chunkImportsPureCssChunk) chunk.code = replaceEmptyChunk(chunk.code);
3946
+ }
3947
+ for (const fileName of pureCssChunkNames) {
3948
+ delete bundle[fileName];
3949
+ delete bundle[`${fileName}.map`];
3950
+ }
3951
+ }
3952
+ /**
3953
+ * Create a replacer function that replaces import statements for pure CSS
3954
+ * chunks with block comments of the same length, preserving source map offsets.
3955
+ */
3956
+ function getEmptyChunkReplacer(pureCssChunkNames) {
3957
+ const emptyChunkFiles = pureCssChunkNames.map((file) => escapeRegex(path.basename(file))).join("|");
3958
+ const emptyChunkRE = new RegExp(String.raw`\bimport\s*["'][^"']*(?:${emptyChunkFiles})["'];`, "g");
3959
+ return (code) => code.replace(emptyChunkRE, (m) => {
3960
+ return `/* empty css ${"".padEnd(m.length - 15)}*/`;
3961
+ });
3962
+ }
3963
+ function escapeRegex(str) {
3964
+ return str.replaceAll(/[.*+?^${}()|[\]\\]/g, String.raw`\$&`);
3965
+ }
3966
+ function createCssPostHooks(config, styles) {
3967
+ const collectedCSS = [];
3968
+ return {
3969
+ renderChunk(_code, chunk) {
3970
+ let chunkCSS = "";
3971
+ for (const id of Object.keys(chunk.modules)) {
3972
+ const code = styles.get(id);
3973
+ if (code) chunkCSS += code;
3974
+ }
3975
+ if (!chunkCSS) return;
3976
+ if (chunkCSS.length > 0 && !chunkCSS.endsWith("\n")) chunkCSS += "\n";
3977
+ if (config.css.splitting) {
3978
+ const cssAssetFileName = chunk.fileName.replace(/\.(m?js|cjs)$/, ".css");
3979
+ this.emitFile({
3980
+ type: "asset",
3981
+ fileName: cssAssetFileName,
3982
+ source: chunkCSS
3983
+ });
3984
+ } else collectedCSS.push(chunkCSS);
3985
+ },
3986
+ generateBundle(_outputOptions, bundle) {
3987
+ if (!config.css.splitting && collectedCSS.length > 0) {
3988
+ const allCSS = collectedCSS.join("");
3989
+ if (allCSS) this.emitFile({
3990
+ type: "asset",
3991
+ fileName: config.css.fileName,
3992
+ source: allCSS,
3993
+ originalFileName: defaultCssBundleName
3994
+ });
3995
+ collectedCSS.length = 0;
3996
+ }
3997
+ removePureCssChunks(bundle, styles);
3998
+ }
3999
+ };
4000
+ }
4001
+ const RE_CSS = /\.css(?:$|\?)/;
4002
+ function CssPlugin(config) {
4003
+ const styles = /* @__PURE__ */ new Map();
4004
+ const postHooks = createCssPostHooks(config, styles);
4005
+ return {
4006
+ name: "tsdown:builtin-css",
4007
+ buildStart() {
4008
+ styles.clear();
4009
+ },
4010
+ load: {
4011
+ filter: { id: RE_CSS },
4012
+ async handler(id) {
4013
+ let code = await readFile(id, "utf8");
4014
+ if (code.length > 0 && !code.endsWith("\n")) code += "\n";
4015
+ styles.set(id, code);
4016
+ return {
4017
+ code: "",
4018
+ moduleSideEffects: "no-treeshake",
4019
+ moduleType: "js"
4020
+ };
4021
+ }
4022
+ },
4023
+ ...postHooks
4024
+ };
4025
+ }
4026
+
4027
+ //#endregion
4028
+ //#region ../../node_modules/.pnpm/tsdown@0.21.0_@arethetypeswrong+core@0.18.2_@tsdown+css@0.21.0_@tsdown+exe@0.21.0_@type_743816f26d68021f6369d2afb428dae9/node_modules/tsdown/dist/watch-BAbxxJcJ.mjs
3855
4029
  /**
3856
4030
  * The `node:` protocol was added in Node.js v14.18.0.
3857
4031
  * @see https://nodejs.org/api/esm.html#node-imports
@@ -4182,7 +4356,7 @@ var Hookable = class {
4182
4356
  };
4183
4357
 
4184
4358
  //#endregion
4185
- //#region ../../node_modules/.pnpm/tsdown@0.21.0-beta.2_@arethetypeswrong+core@0.18.2_@typescript+native-preview@7.0.0-dev_d0d0ed2124937ee9dd401a280008a3bf/node_modules/tsdown/dist/build-BjQ7Rt90.mjs
4359
+ //#region ../../node_modules/.pnpm/tsdown@0.21.0_@arethetypeswrong+core@0.18.2_@tsdown+css@0.21.0_@tsdown+exe@0.21.0_@type_743816f26d68021f6369d2afb428dae9/node_modules/tsdown/dist/build-TmLngPCw.mjs
4186
4360
  const __cjs_require = createRequire(import.meta.url);
4187
4361
  const satisfies = __cjs_require("./npm_entry_semver_functions_satisfies.cjs");
4188
4362
  const coerce = __cjs_require("./npm_entry_semver_functions_coerce.cjs");
@@ -4342,7 +4516,8 @@ function executeOnSuccess(config) {
4342
4516
  if (typeof config.onSuccess === "string") {
4343
4517
  const p = q(config.onSuccess, [], { nodeOptions: {
4344
4518
  shell: true,
4345
- stdio: "inherit"
4519
+ stdio: "inherit",
4520
+ cwd: config.cwd
4346
4521
  } });
4347
4522
  p.then(({ exitCode }) => {
4348
4523
  if (exitCode) process$1.exitCode = exitCode;
@@ -4493,12 +4668,13 @@ async function bundleDone(bundleByPkg, bundle) {
4493
4668
  if (exportsConfigs.length) {
4494
4669
  if (exportsConfigs.length > 1) throw new Error(`Conflicting exports options for package at ${pkg.packageJsonPath}. Please merge them:\n${exportsConfigs.map((config) => `- ${formatWithOptions({ colors: true }, config.exports)}`).join("\n")}`);
4495
4670
  const chunks = {};
4671
+ const inlinedDeps = mergeInlinedDeps(ctx.bundles);
4496
4672
  for (const bundle of ctx.bundles) {
4497
4673
  if (!bundle.config.exports) continue;
4498
4674
  chunks[bundle.config.format] ||= [];
4499
4675
  chunks[bundle.config.format].push(...bundle.chunks);
4500
4676
  }
4501
- await writeExports(exportsConfigs[0], chunks);
4677
+ await writeExports(exportsConfigs[0], chunks, inlinedDeps);
4502
4678
  }
4503
4679
  const publintConfigs = dedupeConfigs(configs, "publint");
4504
4680
  const attwConfigs = dedupeConfigs(configs, "attw");
@@ -4516,7 +4692,7 @@ async function bundleDone(bundleByPkg, bundle) {
4516
4692
  async function packTarball(packageJsonPath) {
4517
4693
  const pkgDir = path.dirname(packageJsonPath);
4518
4694
  const destination = await mkdtemp(path.join(tmpdir(), "tsdown-pack-"));
4519
- const [{ detect }, { pack }] = await Promise.all([import("./detect-CCATtVj7-DhvBg5EF.js"), import("./index-node-ShM0x2b6-Bt7Chc0I.js")]);
4695
+ const [{ detect }, { pack }] = await Promise.all([import("./detect-DK-FDZQ9-CALXiuJa.js"), import("./index-node-Djp92Gzb-fgHTblzo.js")]);
4520
4696
  try {
4521
4697
  const detected = await detect({ cwd: pkgDir });
4522
4698
  if (detected?.name === "deno") throw new Error(`Cannot pack tarball for Deno projects at ${pkgDir}`);
@@ -4542,126 +4718,16 @@ function dedupeConfigs(configs, key) {
4542
4718
  if (results.length === 0) return [filtered[0]];
4543
4719
  return results;
4544
4720
  }
4545
- /**
4546
- * Converts esbuild target [^1] (which is also used by Rolldown [^2]) to Lightning CSS targets [^3].
4547
- *
4548
- * [^1]: https://esbuild.github.io/api/#target
4549
- * [^2]: https://github.com/rolldown/rolldown/blob/v1.0.0-beta.8/packages/rolldown/src/binding.d.ts#L1429-L1431
4550
- * [^3]: https://lightningcss.dev/transpilation.html
4551
- */
4552
- function esbuildTargetToLightningCSS(target) {
4553
- let targets;
4554
- const matches = [...target.join(" ").toLowerCase().matchAll(TARGET_REGEX)];
4555
- for (const match of matches) {
4556
- const browser = ESBUILD_LIGHTNINGCSS_MAPPING[match[1]];
4557
- if (!browser) continue;
4558
- const version = match[2];
4559
- const versionInt = parseVersion(version);
4560
- if (versionInt == null) continue;
4561
- targets = targets || {};
4562
- targets[browser] = versionInt;
4721
+ function mergeInlinedDeps(bundles) {
4722
+ const merged = /* @__PURE__ */ new Map();
4723
+ for (const bundle of bundles) for (const [pkgName, versions] of bundle.inlinedDeps) {
4724
+ if (!merged.has(pkgName)) merged.set(pkgName, /* @__PURE__ */ new Set());
4725
+ for (const v of versions) merged.get(pkgName).add(v);
4563
4726
  }
4564
- return targets;
4565
- }
4566
- const TARGET_REGEX = /([a-z]+)(\d+(?:\.\d+)*)/g;
4567
- const ESBUILD_LIGHTNINGCSS_MAPPING = {
4568
- chrome: "chrome",
4569
- edge: "edge",
4570
- firefox: "firefox",
4571
- ie: "ie",
4572
- ios: "ios_saf",
4573
- opera: "opera",
4574
- safari: "safari"
4575
- };
4576
- function parseVersion(version) {
4577
- const [major, minor = 0, patch = 0] = version.split("-")[0].split(".").map((v) => Number.parseInt(v, 10));
4578
- if (Number.isNaN(major) || Number.isNaN(minor) || Number.isNaN(patch)) return null;
4579
- return major << 16 | minor << 8 | patch;
4580
- }
4581
- async function LightningCSSPlugin(options) {
4582
- const LightningCSS = await import("unplugin-lightningcss/rolldown").catch(() => void 0);
4583
- if (!LightningCSS) return;
4584
- const targets = options.target && esbuildTargetToLightningCSS(options.target);
4585
- if (!targets) return;
4586
- return LightningCSS.default({ options: { targets } });
4587
- }
4588
- /**
4589
- * CSS Code Split Plugin
4590
- *
4591
- * When css.splitting is false, this plugin merges all CSS files into a single file.
4592
- * When css.splitting is true (default), CSS code splitting is preserved.
4593
- * Based on Vite's implementation.
4594
- */
4595
- function CssCodeSplitPlugin(config) {
4596
- const { splitting, fileName } = config.css;
4597
- if (splitting) return;
4598
- return {
4599
- name: "tsdown:css:splitting",
4600
- generateBundle(_outputOptions, bundle) {
4601
- const chunks = Object.values(bundle);
4602
- const cssAssets = /* @__PURE__ */ new Map();
4603
- for (const asset of chunks) if (asset.type === "asset" && typeof asset.source === "string" && RE_CSS.test(fileName)) cssAssets.set(asset.fileName, asset.source);
4604
- if (!cssAssets.size) return;
4605
- const chunkCSSMap = /* @__PURE__ */ new Map();
4606
- for (const chunk of chunks) {
4607
- if (chunk.type !== "chunk") continue;
4608
- for (const moduleId of chunk.moduleIds) if (RE_CSS.test(moduleId)) {
4609
- if (!chunkCSSMap.has(chunk.fileName)) chunkCSSMap.set(chunk.fileName, []);
4610
- break;
4611
- }
4612
- }
4613
- for (const cssFileName of cssAssets.keys()) {
4614
- const cssBaseName = normalizeCssFileName(cssFileName);
4615
- for (const chunkFileName of chunkCSSMap.keys()) if (normalizeChunkFileName(chunkFileName) === cssBaseName || chunkFileName.startsWith(`${cssBaseName}-`)) {
4616
- chunkCSSMap.get(chunkFileName).push(cssFileName);
4617
- break;
4618
- }
4619
- }
4620
- let extractedCss = "";
4621
- const collected = /* @__PURE__ */ new Set();
4622
- const dynamicImports = /* @__PURE__ */ new Set();
4623
- function collect(chunk) {
4624
- if (!chunk || chunk.type !== "chunk" || collected.has(chunk)) return;
4625
- collected.add(chunk);
4626
- chunk.imports.forEach((importName) => {
4627
- collect(bundle[importName]);
4628
- });
4629
- chunk.dynamicImports.forEach((importName) => {
4630
- dynamicImports.add(importName);
4631
- });
4632
- const files = chunkCSSMap.get(chunk.fileName);
4633
- if (files && files.length > 0) for (const filename of files) extractedCss += cssAssets.get(filename) ?? "";
4634
- }
4635
- for (const chunk of chunks) if (chunk.type === "chunk" && chunk.isEntry) collect(chunk);
4636
- for (const chunkName of dynamicImports) collect(bundle[chunkName]);
4637
- if (extractedCss) {
4638
- for (const fileName of cssAssets.keys()) delete bundle[fileName];
4639
- this.emitFile({
4640
- type: "asset",
4641
- source: extractedCss,
4642
- fileName,
4643
- originalFileName: defaultCssBundleName
4644
- });
4645
- }
4646
- }
4647
- };
4648
- }
4649
- const RE_CSS_HASH = /-[\w-]+\.css$/;
4650
- const RE_CHUNK_HASH = /-[\w-]+\.(m?js|cjs)$/;
4651
- const RE_CHUNK_EXT = /\.(m?js|cjs)$/;
4652
- /**
4653
- * Normalize CSS file name by removing hash pattern and extension.
4654
- * e.g., "async-DcjEOEdU.css" -> "async"
4655
- */
4656
- function normalizeCssFileName(cssFileName) {
4657
- return cssFileName.replace(RE_CSS_HASH, "").replace(RE_CSS, "");
4658
- }
4659
- /**
4660
- * Normalize chunk file name by removing hash pattern and extension.
4661
- * e.g., "async-CvIfFAic.mjs" -> "async"
4662
- */
4663
- function normalizeChunkFileName(chunkFileName) {
4664
- return chunkFileName.replace(RE_CHUNK_HASH, "").replace(RE_CHUNK_EXT, "");
4727
+ if (!merged.size) return void 0;
4728
+ const result = {};
4729
+ for (const [pkgName, versions] of merged) result[pkgName] = versions.size === 1 ? [...versions][0] : [...versions].toSorted();
4730
+ return result;
4665
4731
  }
4666
4732
  function resolveJsOutputExtension(packageType, format, fixedExtension) {
4667
4733
  switch (format) {
@@ -4703,7 +4769,7 @@ function resolveChunkAddon(chunkAddon, format) {
4703
4769
  if (typeof chunkAddon === "string") return chunkAddon;
4704
4770
  switch (true) {
4705
4771
  case RE_JS.test(chunk.fileName): return chunkAddon?.js || "";
4706
- case RE_CSS.test(chunk.fileName): return chunkAddon?.css || "";
4772
+ case RE_CSS$1.test(chunk.fileName): return chunkAddon?.css || "";
4707
4773
  case RE_DTS.test(chunk.fileName): return chunkAddon?.dts || "";
4708
4774
  default: return "";
4709
4775
  }
@@ -4725,9 +4791,9 @@ async function resolveInputOptions(config, format, configFiles, bundle, cjsDts,
4725
4791
  const { alias, checks: { legacyCjs, ...checks } = {}, cjsDefault, cwd, deps: { neverBundle }, devtools, dts, entry, env, globImport, loader, logger, nameLabel, nodeProtocol, platform, plugins: userPlugins, report, shims, target, treeshake, tsconfig, unused, watch } = config;
4726
4792
  const plugins = [];
4727
4793
  if (nodeProtocol) plugins.push(NodeProtocolPlugin(nodeProtocol));
4728
- if (config.pkg || config.deps.skipNodeModulesBundle) plugins.push(DepPlugin(config));
4794
+ if (config.pkg || config.deps.skipNodeModulesBundle) plugins.push(DepPlugin(config, bundle));
4729
4795
  if (dts) {
4730
- const { dts: dtsPlugin } = await import("./dist-DNcnO8LL.js");
4796
+ const { dts: dtsPlugin } = await import("./dist-uzMTIu3J.js");
4731
4797
  const options = {
4732
4798
  tsconfig,
4733
4799
  ...dts
@@ -4747,10 +4813,14 @@ async function resolveInputOptions(config, format, configFiles, bundle, cjsDts,
4747
4813
  ...unused
4748
4814
  }));
4749
4815
  }
4750
- if (target) plugins.push(await LightningCSSPlugin({ target }));
4751
- const cssPlugin = CssCodeSplitPlugin(config);
4752
- if (cssPlugin) plugins.push(cssPlugin);
4753
- plugins.push(ShebangPlugin(logger, cwd, nameLabel, isDualFormat));
4816
+ let cssPlugin;
4817
+ try {
4818
+ const { CssPlugin: AdvancedCssPlugin } = await import("@tsdown/css");
4819
+ cssPlugin = AdvancedCssPlugin(config, { logger });
4820
+ } catch {
4821
+ cssPlugin = CssPlugin(config);
4822
+ }
4823
+ plugins.push(cssPlugin, ShebangPlugin(logger, cwd, nameLabel, isDualFormat));
4754
4824
  if (globImport) plugins.push(importGlobPlugin({ root: cwd }));
4755
4825
  }
4756
4826
  if (report && LogLevels[logger.level] >= 3) plugins.push(ReportPlugin(config, cjsDts, isDualFormat));
@@ -4780,11 +4850,14 @@ async function resolveInputOptions(config, format, configFiles, bundle, cjsDts,
4780
4850
  inject
4781
4851
  },
4782
4852
  plugins,
4783
- moduleTypes: loader,
4853
+ moduleTypes: {
4854
+ ".node": "copy",
4855
+ ...loader
4856
+ },
4784
4857
  logLevel: logger.level === "error" ? "silent" : logger.level,
4785
4858
  onLog(level, log, defaultHandler) {
4786
4859
  if (cjsDefault && log.code === "MIXED_EXPORT") return;
4787
- if (logger.options?.failOnWarn && level === "warn") defaultHandler("error", log);
4860
+ if (logger.options?.failOnWarn && level === "warn" && log.code !== "PLUGIN_TIMINGS") defaultHandler("error", log);
4788
4861
  defaultHandler(level, log);
4789
4862
  },
4790
4863
  devtools: devtools || void 0,
@@ -4958,6 +5031,7 @@ async function buildSingle(config, configFiles, isDualFormat, clean, restart, do
4958
5031
  const bundle = {
4959
5032
  chunks,
4960
5033
  config,
5034
+ inlinedDeps: /* @__PURE__ */ new Map(),
4961
5035
  async [asyncDispose]() {
4962
5036
  debouncedPostBuild.cancel();
4963
5037
  ab?.abort();
@@ -4980,7 +5054,7 @@ async function buildSingle(config, configFiles, isDualFormat, clean, restart, do
4980
5054
  function handleWatcher(watcher) {
4981
5055
  const changedFile = [];
4982
5056
  let hasError = false;
4983
- watcher.on("change", (id, event) => {
5057
+ watcher.on("change", async (id, event) => {
4984
5058
  if (event.event === "update") {
4985
5059
  changedFile.push(id);
4986
5060
  debouncedPostBuild.cancel();
@@ -4990,6 +5064,13 @@ async function buildSingle(config, configFiles, isDualFormat, clean, restart, do
4990
5064
  globalLogger.info(`Reload config: ${id}, restarting...`);
4991
5065
  restart();
4992
5066
  }
5067
+ if ((event.event === "create" || event.event === "delete") && config.rawEntry && isGlobEntry(config.rawEntry)) {
5068
+ const newEntry = await toObjectEntry(config.rawEntry, config.cwd);
5069
+ if (Object.keys(config.entry).toSorted().join("\0") !== Object.keys(newEntry).toSorted().join("\0")) {
5070
+ globalLogger.info("Entry files changed, restarting...");
5071
+ restart();
5072
+ }
5073
+ }
4993
5074
  });
4994
5075
  watcher.on("event", async (event) => {
4995
5076
  switch (event.code) {