@voidzero-dev/vite-plus-core 0.1.12-alpha.2 → 0.1.13-alpha.0

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.
@@ -5,7 +5,7 @@ import { C as version, S as description } from "./shared/bindingify-input-option
5
5
  import { t as arraify } from "./shared/misc-DJYbNKZX.mjs";
6
6
  import { a as getInputCliKeys, i as getCliSchemaInfo, l as styleText, o as getOutputCliKeys, r as logger, s as validateCliOptions } from "./shared/rolldown-build-CYoDea9V.mjs";
7
7
  import "./shared/error-CP8smW_P.mjs";
8
- import "./shared/parse-8FR1cSLd.mjs";
8
+ import "./shared/parse-BhVn_3w_.mjs";
9
9
  import { t as rolldown } from "./shared/rolldown-B7hI_r7G.mjs";
10
10
  import { t as loadConfig } from "./shared/load-config-CjCoDD5h.mjs";
11
11
  import path from "node:path";
@@ -3,7 +3,7 @@ import "./shared/normalize-string-or-regex-C5RWbu3O.mjs";
3
3
  import { x as VERSION } from "./shared/bindingify-input-options-D6u7COm1.mjs";
4
4
  import "./shared/rolldown-build-CYoDea9V.mjs";
5
5
  import "./shared/error-CP8smW_P.mjs";
6
- import "./shared/parse-8FR1cSLd.mjs";
6
+ import "./shared/parse-BhVn_3w_.mjs";
7
7
  import "./shared/rolldown-B7hI_r7G.mjs";
8
8
  import { t as defineConfig } from "./shared/define-config-DJOr6Iwt.mjs";
9
9
  import { t as loadConfig } from "./shared/load-config-CjCoDD5h.mjs";
@@ -3,7 +3,7 @@ import { n as BuiltinPlugin, t as normalizedStringOrRegex } from "./shared/norma
3
3
  import { o as transformToRollupOutput } from "./shared/bindingify-input-options-D6u7COm1.mjs";
4
4
  import { c as validateOption, n as createBundlerOptions, t as RolldownBuild, u as PluginDriver } from "./shared/rolldown-build-CYoDea9V.mjs";
5
5
  import { i as unwrapBindingResult, r as normalizeBindingResult } from "./shared/error-CP8smW_P.mjs";
6
- import { n as parseSync$1, t as parse$1 } from "./shared/parse-8FR1cSLd.mjs";
6
+ import { n as parseSync$1, t as parse$1 } from "./shared/parse-BhVn_3w_.mjs";
7
7
  import { a as viteImportGlobPlugin, c as viteModulePreloadPolyfillPlugin, d as viteResolvePlugin, f as viteWasmFallbackPlugin, i as viteDynamicImportVarsPlugin, l as viteReactRefreshWrapperPlugin, n as isolatedDeclarationPlugin, o as viteJsonPlugin, p as viteWebWorkerPostPlugin, r as viteBuildImportAnalysisPlugin, s as viteLoadFallbackPlugin, u as viteReporterPlugin } from "./shared/constructors-Ctal_Rbv.mjs";
8
8
  import { a as minifySync$1, i as minify$1, n as transform$1, r as transformSync$1, t as import_binding$1 } from "./shared/transform-BfdLLNnY.mjs";
9
9
  import { pathToFileURL } from "node:url";
@@ -4,7 +4,7 @@ import "./shared/normalize-string-or-regex-C5RWbu3O.mjs";
4
4
  import { a as BindingMagicString, b as RUNTIME_MODULE_ID, x as VERSION } from "./shared/bindingify-input-options-D6u7COm1.mjs";
5
5
  import "./shared/rolldown-build-CYoDea9V.mjs";
6
6
  import "./shared/error-CP8smW_P.mjs";
7
- import "./shared/parse-8FR1cSLd.mjs";
7
+ import "./shared/parse-BhVn_3w_.mjs";
8
8
  import { t as rolldown } from "./shared/rolldown-B7hI_r7G.mjs";
9
9
  import { t as defineConfig } from "./shared/define-config-DJOr6Iwt.mjs";
10
10
  import { isMainThread } from "node:worker_threads";
@@ -2,7 +2,7 @@ import { n as __toESM, t as require_binding } from "./shared/binding-C5G6_6ql.mj
2
2
  import "./shared/normalize-string-or-regex-C5RWbu3O.mjs";
3
3
  import { n as PluginContextData, r as bindingifyPlugin } from "./shared/bindingify-input-options-D6u7COm1.mjs";
4
4
  import "./shared/error-CP8smW_P.mjs";
5
- import "./shared/parse-8FR1cSLd.mjs";
5
+ import "./shared/parse-BhVn_3w_.mjs";
6
6
  import { parentPort, workerData } from "node:worker_threads";
7
7
  //#region src/parallel-plugin-worker.ts
8
8
  var import_binding = /* @__PURE__ */ __toESM(require_binding(), 1);
@@ -1,6 +1,6 @@
1
1
  import "./shared/binding-C5G6_6ql.mjs";
2
2
  import { l as locate, n as error, s as logParseError, t as augmentCodeLocation, u as getCodeFrame } from "./shared/logs-D80CXhvg.mjs";
3
- import { n as parseSync, t as parse } from "./shared/parse-8FR1cSLd.mjs";
3
+ import { n as parseSync, t as parse } from "./shared/parse-BhVn_3w_.mjs";
4
4
  //#region src/parse-ast-index.ts
5
5
  function wrap(result, filename, sourceText) {
6
6
  if (result.errors.length > 0) return normalizeParseError(filename, sourceText, result.errors);
@@ -1,5 +1,5 @@
1
1
  import { n as __toESM, t as require_binding } from "./binding-C5G6_6ql.mjs";
2
- //#region ../../../node_modules/.pnpm/oxc-parser@0.115.0/node_modules/oxc-parser/src-js/wrap.js
2
+ //#region ../../../node_modules/.pnpm/oxc-parser@0.120.0/node_modules/oxc-parser/src-js/wrap.js
3
3
  function wrap(result) {
4
4
  let program, module, comments, errors;
5
5
  return {
@@ -3,7 +3,7 @@ import { a as MinifyOptions, c as minifySync, d as parse, f as parseSync, i as t
3
3
  import * as ESTree from "@oxc-project/types";
4
4
  import { Program } from "@oxc-project/types";
5
5
 
6
- //#region ../../../node_modules/.pnpm/oxc-parser@0.115.0/node_modules/oxc-parser/src-js/generated/visit/visitor.d.ts
6
+ //#region ../../../node_modules/.pnpm/oxc-parser@0.120.0/node_modules/oxc-parser/src-js/generated/visit/visitor.d.ts
7
7
  interface VisitorObject$1 {
8
8
  DebuggerStatement?: (node: ESTree.DebuggerStatement) => void;
9
9
  "DebuggerStatement:exit"?: (node: ESTree.DebuggerStatement) => void;
@@ -1,8 +1,8 @@
1
1
  import "./shared/binding-C5G6_6ql.mjs";
2
2
  import "./shared/error-CP8smW_P.mjs";
3
- import { n as parseSync, t as parse } from "./shared/parse-8FR1cSLd.mjs";
3
+ import { n as parseSync, t as parse } from "./shared/parse-BhVn_3w_.mjs";
4
4
  import { a as minifySync, i as minify, n as transform, r as transformSync, t as import_binding } from "./shared/transform-BfdLLNnY.mjs";
5
- //#region ../../../node_modules/.pnpm/oxc-parser@0.115.0/node_modules/oxc-parser/src-js/generated/visit/walk.js
5
+ //#region ../../../node_modules/.pnpm/oxc-parser@0.120.0/node_modules/oxc-parser/src-js/generated/visit/walk.js
6
6
  function walkNode(node, visitors) {
7
7
  if (node == null) return;
8
8
  if (Array.isArray(node)) {
@@ -2012,7 +2012,7 @@ function walkTSUnionType(node, visitors) {
2012
2012
  exit !== null && exit(node);
2013
2013
  }
2014
2014
  //#endregion
2015
- //#region ../../../node_modules/.pnpm/oxc-parser@0.115.0/node_modules/oxc-parser/src-js/generated/visit/type_ids.js
2015
+ //#region ../../../node_modules/.pnpm/oxc-parser@0.120.0/node_modules/oxc-parser/src-js/generated/visit/type_ids.js
2016
2016
  /** Mapping from node type name to node type ID */
2017
2017
  const NODE_TYPE_IDS_MAP = new Map([
2018
2018
  ["DebuggerStatement", 0],
@@ -2182,7 +2182,7 @@ const NODE_TYPE_IDS_MAP = new Map([
2182
2182
  ["TSUnionType", 164]
2183
2183
  ]);
2184
2184
  //#endregion
2185
- //#region ../../../node_modules/.pnpm/oxc-parser@0.115.0/node_modules/oxc-parser/src-js/visit/visitor.js
2185
+ //#region ../../../node_modules/.pnpm/oxc-parser@0.120.0/node_modules/oxc-parser/src-js/visit/visitor.js
2186
2186
  let compiledVisitor;
2187
2187
  function createCompiledVisitor() {
2188
2188
  compiledVisitor = [];
@@ -1,5 +1,5 @@
1
1
  import { r as __toESM, t as __commonJSMin } from "./chunk-CSNpwdVU.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-4fHWraTN.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 z, o as generateColor, p as green, r as version, s as getNameLabel, t as R, u as blue, v as importWithError, w as resolveRegex, x as pkgExists, y as matchPattern } from "./main-JovZVvCY.js";
3
3
  import { t as createDebug } from "./node-B3Gdtau1.js";
4
4
  import { i as RE_JS, n as RE_DTS, o as RE_NODE_MODULES$1, t as RE_CSS } from "./filename-UU7z2A9Z.js";
5
5
  import module$1, { builtinModules, createRequire, isBuiltin } from "node:module";
@@ -7,21 +7,21 @@ import { pathToFileURL } from "node:url";
7
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
- import { createRequire as createRequire$1 } from "module";
11
10
  import path, { dirname, isAbsolute, join, parse, resolve } from "node:path";
12
11
  import { VERSION, build, watch } from "@voidzero-dev/vite-plus-core/rolldown";
13
- import { access, chmod, cp, mkdir, mkdtemp, readFile, rm, stat, writeFile } from "node:fs/promises";
12
+ import { access, chmod, cp, mkdir, mkdtemp, readFile, readdir, rm, stat, writeFile } from "node:fs/promises";
14
13
  import { and, id, importerId, include } from "@voidzero-dev/vite-plus-core/rolldown/filter";
15
14
  import * as nativeFs$1 from "fs";
16
15
  import nativeFs from "fs";
17
16
  import path$1, { basename, dirname as dirname$1, normalize as normalize$1, posix, relative, resolve as resolve$1, sep } from "path";
18
17
  import { fileURLToPath as fileURLToPath$1 } from "url";
18
+ import { createRequire as createRequire$1 } from "module";
19
19
  import { tmpdir } from "node:os";
20
- import re, { existsSync, readFileSync, writeFileSync } from "node:fs";
20
+ import fs$1, { existsSync, readFileSync, writeFileSync } from "node:fs";
21
21
  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
- //#region ../../node_modules/.pnpm/tsdown@0.21.2_@arethetypeswrong+core@0.18.2_@tsdown+css@0.21.2_@tsdown+exe@0.21.2_@type_059aa640a91d945cefc9d8c8db7a9cd0/node_modules/tsdown/dist/fs-Dd6Htx2P.mjs
24
+ //#region ../../node_modules/.pnpm/tsdown@0.21.4_@arethetypeswrong+core@0.18.2_@tsdown+css@0.21.4_@tsdown+exe@0.21.4_@type_17eb19013b58e1a32121480e0690eafa/node_modules/tsdown/dist/fs-Dd6Htx2P.mjs
25
25
  function fsExists(path) {
26
26
  return access(path).then(() => true, () => false);
27
27
  }
@@ -64,7 +64,7 @@ function stripExtname(filePath) {
64
64
  return filePath.slice(0, -ext.length);
65
65
  }
66
66
  //#endregion
67
- //#region ../../node_modules/.pnpm/tsdown@0.21.2_@arethetypeswrong+core@0.18.2_@tsdown+css@0.21.2_@tsdown+exe@0.21.2_@type_059aa640a91d945cefc9d8c8db7a9cd0/node_modules/tsdown/dist/format-DPVBd8E4.mjs
67
+ //#region ../../node_modules/.pnpm/tsdown@0.21.4_@arethetypeswrong+core@0.18.2_@tsdown+css@0.21.4_@tsdown+exe@0.21.4_@type_17eb19013b58e1a32121480e0690eafa/node_modules/tsdown/dist/format-DPVBd8E4.mjs
68
68
  const shimFile = path.resolve(import.meta.dirname, "..", "esm-shims.js");
69
69
  function getShimsInject(format, platform) {
70
70
  if (format === "es" && platform === "node") return {
@@ -2917,87 +2917,87 @@ quansync$1({
2917
2917
  */
2918
2918
  const quansync = quansync$1;
2919
2919
  quansync$1({
2920
- sync: re.readFileSync,
2921
- async: re.promises.readFile
2920
+ sync: fs$1.readFileSync,
2921
+ async: fs$1.promises.readFile
2922
2922
  });
2923
2923
  quansync$1({
2924
- sync: re.writeFileSync,
2925
- async: re.promises.writeFile
2924
+ sync: fs$1.writeFileSync,
2925
+ async: fs$1.promises.writeFile
2926
2926
  });
2927
2927
  quansync$1({
2928
- sync: re.unlinkSync,
2929
- async: re.promises.unlink
2928
+ sync: fs$1.unlinkSync,
2929
+ async: fs$1.promises.unlink
2930
2930
  });
2931
2931
  quansync$1({
2932
- sync: re.accessSync,
2933
- async: re.promises.access
2932
+ sync: fs$1.accessSync,
2933
+ async: fs$1.promises.access
2934
2934
  });
2935
2935
  /**
2936
2936
  * @link https://nodejs.org/api/fs.html#fspromisesstatpath-options
2937
2937
  */
2938
2938
  const stat$1 = quansync$1({
2939
- sync: re.statSync,
2940
- async: re.promises.stat
2939
+ sync: fs$1.statSync,
2940
+ async: fs$1.promises.stat
2941
2941
  });
2942
2942
  const lstat = quansync$1({
2943
- sync: re.lstatSync,
2944
- async: re.promises.lstat
2943
+ sync: fs$1.lstatSync,
2944
+ async: fs$1.promises.lstat
2945
2945
  });
2946
2946
  quansync$1({
2947
- sync: re.copyFileSync,
2948
- async: re.promises.copyFile
2947
+ sync: fs$1.copyFileSync,
2948
+ async: fs$1.promises.copyFile
2949
2949
  });
2950
2950
  quansync$1({
2951
- sync: re.rmSync,
2952
- async: re.promises.rm
2951
+ sync: fs$1.rmSync,
2952
+ async: fs$1.promises.rm
2953
2953
  });
2954
2954
  quansync$1({
2955
- sync: re.mkdirSync,
2956
- async: re.promises.mkdir
2955
+ sync: fs$1.mkdirSync,
2956
+ async: fs$1.promises.mkdir
2957
2957
  });
2958
2958
  quansync$1({
2959
- sync: re.renameSync,
2960
- async: re.promises.rename
2959
+ sync: fs$1.renameSync,
2960
+ async: fs$1.promises.rename
2961
2961
  });
2962
2962
  quansync$1({
2963
- sync: re.readdirSync,
2964
- async: re.promises.readdir
2963
+ sync: fs$1.readdirSync,
2964
+ async: fs$1.promises.readdir
2965
2965
  });
2966
2966
  quansync$1({
2967
- sync: re.realpathSync,
2968
- async: re.promises.realpath
2967
+ sync: fs$1.realpathSync,
2968
+ async: fs$1.promises.realpath
2969
2969
  });
2970
2970
  quansync$1({
2971
- sync: re.readlinkSync,
2972
- async: re.promises.readlink
2971
+ sync: fs$1.readlinkSync,
2972
+ async: fs$1.promises.readlink
2973
2973
  });
2974
2974
  quansync$1({
2975
- sync: re.symlinkSync,
2976
- async: re.promises.symlink
2975
+ sync: fs$1.symlinkSync,
2976
+ async: fs$1.promises.symlink
2977
2977
  });
2978
2978
  quansync$1({
2979
- sync: re.chownSync,
2980
- async: re.promises.chown
2979
+ sync: fs$1.chownSync,
2980
+ async: fs$1.promises.chown
2981
2981
  });
2982
2982
  quansync$1({
2983
- sync: re.lchownSync,
2984
- async: re.promises.lchown
2983
+ sync: fs$1.lchownSync,
2984
+ async: fs$1.promises.lchown
2985
2985
  });
2986
2986
  quansync$1({
2987
- sync: re.chmodSync,
2988
- async: re.promises.chmod
2987
+ sync: fs$1.chmodSync,
2988
+ async: fs$1.promises.chmod
2989
2989
  });
2990
2990
  quansync$1({
2991
- sync: re.utimesSync,
2992
- async: re.promises.utimes
2991
+ sync: fs$1.utimesSync,
2992
+ async: fs$1.promises.utimes
2993
2993
  });
2994
2994
  quansync$1({
2995
- sync: re.lutimesSync,
2996
- async: re.promises.lutimes
2995
+ sync: fs$1.lutimesSync,
2996
+ async: fs$1.promises.lutimes
2997
2997
  });
2998
2998
  quansync$1({
2999
- sync: re.mkdtempSync,
3000
- async: re.promises.mkdtemp
2999
+ sync: fs$1.mkdtempSync,
3000
+ async: fs$1.promises.mkdtemp
3001
3001
  });
3002
3002
  //#endregion
3003
3003
  //#region ../../node_modules/.pnpm/unconfig-core@7.5.0/node_modules/unconfig-core/dist/index.mjs
@@ -3076,7 +3076,7 @@ function createConfigCoreLoader(options) {
3076
3076
  };
3077
3077
  }
3078
3078
  //#endregion
3079
- //#region ../../node_modules/.pnpm/tsdown@0.21.2_@arethetypeswrong+core@0.18.2_@tsdown+css@0.21.2_@tsdown+exe@0.21.2_@type_059aa640a91d945cefc9d8c8db7a9cd0/node_modules/tsdown/dist/options--36H_-x3.mjs
3079
+ //#region ../../node_modules/.pnpm/tsdown@0.21.4_@arethetypeswrong+core@0.18.2_@tsdown+css@0.21.4_@tsdown+exe@0.21.4_@type_17eb19013b58e1a32121480e0690eafa/node_modules/tsdown/dist/options-DoRzOC0d.mjs
3080
3080
  const __cjs_require$1 = createRequire(import.meta.url);
3081
3081
  const picomatch = __cjs_require$1("./npm_entry_picomatch.cjs");
3082
3082
  const satisfies$1 = __cjs_require$1("./npm_entry_semver_functions_satisfies.cjs");
@@ -3148,7 +3148,7 @@ function isGlobEntry(entry) {
3148
3148
  return Object.keys(entry).some((key) => key.includes("*"));
3149
3149
  }
3150
3150
  async function resolveObjectEntry(entries, cwd) {
3151
- return [Object.fromEntries((await Promise.all(Object.entries(entries).map(async ([key, value]) => {
3151
+ const entry = Object.fromEntries((await Promise.all(Object.entries(entries).map(async ([key, value]) => {
3152
3152
  if (!key.includes("*")) {
3153
3153
  if (Array.isArray(value)) throw new TypeError(`Object entry "${key}" cannot have an array value when the key is not a glob pattern.`);
3154
3154
  return [[key, value]];
@@ -3168,7 +3168,8 @@ async function resolveObjectEntry(entries, cwd) {
3168
3168
  }
3169
3169
  if (valueGlobBase === void 0) throw new Error(`Cannot determine base directory for value glob patterns of key "${key}".`);
3170
3170
  return files.map((file) => [slash(key.replaceAll("*", stripExtname(path.relative(valueGlobBase, file)))), path.resolve(cwd, file)]);
3171
- }))).flat()), cwd];
3171
+ }))).flat());
3172
+ return [entry, lowestCommonAncestor(...Object.values(entry))];
3172
3173
  }
3173
3174
  async function resolveArrayEntry(entries, cwd, root) {
3174
3175
  const stringEntries = [];
@@ -3249,7 +3250,7 @@ async function buildSingleExe(config, bundledFile, outputFile, executable, targe
3249
3250
  await writeFile(seaConfigPath, JSON.stringify(seaConfig));
3250
3251
  debug$3$2("Wrote sea-config.json: %O -> %s", seaConfig, seaConfigPath);
3251
3252
  debug$3$2("Running: %s --build-sea %s", process$1.execPath, seaConfigPath);
3252
- await K(process$1.execPath, ["--build-sea", seaConfigPath], {
3253
+ await R(process$1.execPath, ["--build-sea", seaConfigPath], {
3253
3254
  nodeOptions: { stdio: [
3254
3255
  "ignore",
3255
3256
  "ignore",
@@ -3262,7 +3263,7 @@ async function buildSingleExe(config, bundledFile, outputFile, executable, targe
3262
3263
  else await fsRemove(tempDir);
3263
3264
  }
3264
3265
  if ((target?.platform || process$1.platform) === "darwin") try {
3265
- await K("codesign", [
3266
+ await R("codesign", [
3266
3267
  "--sign",
3267
3268
  "-",
3268
3269
  outputPath
@@ -3294,6 +3295,7 @@ async function writeExports(options, chunks, inlinedDeps) {
3294
3295
  }
3295
3296
  const original = readFileSync(pkg.packageJsonPath, "utf8");
3296
3297
  let contents = JSON.stringify(updatedPkg, null, detectIndentation(original));
3298
+ if (original.includes("\r\n")) contents = contents.replaceAll("\n", "\r\n");
3297
3299
  if (original.endsWith("\n")) contents += "\n";
3298
3300
  if (contents !== original) writeFileSync(pkg.packageJsonPath, contents, "utf8");
3299
3301
  }
@@ -3638,7 +3640,7 @@ async function nativeImport(id) {
3638
3640
  return mod.default || mod;
3639
3641
  }
3640
3642
  async function unrunImport(id) {
3641
- const { unrun } = await import("./dist-DceV6s_v.js");
3643
+ const { unrun } = await import("./dist-BWGgEAtQ.js");
3642
3644
  const { module } = await unrun({ path: pathToFileURL(id).href });
3643
3645
  return module;
3644
3646
  }
@@ -3831,7 +3833,51 @@ function filterConfig(filter, configCwd, name) {
3831
3833
  return toArray(filter).some((value) => name && name === value || cwd === value);
3832
3834
  }
3833
3835
  //#endregion
3834
- //#region ../../node_modules/.pnpm/tsdown@0.21.2_@arethetypeswrong+core@0.18.2_@tsdown+css@0.21.2_@tsdown+exe@0.21.2_@type_059aa640a91d945cefc9d8c8db7a9cd0/node_modules/tsdown/dist/watch-seL2bosb.mjs
3836
+ //#region ../../node_modules/.pnpm/tsdown@0.21.4_@arethetypeswrong+core@0.18.2_@tsdown+css@0.21.4_@tsdown+exe@0.21.4_@type_17eb19013b58e1a32121480e0690eafa/node_modules/tsdown/dist/watch-CS1xCZMR.mjs
3837
+ async function copy(options) {
3838
+ if (!options.copy) return;
3839
+ const resolved = await resolveCopyEntries(options);
3840
+ await Promise.all(resolved.map(({ from, to, verbose }) => {
3841
+ if (verbose) options.logger.info(options.nameLabel, `Copying files from ${path.relative(options.cwd, from)} to ${path.relative(options.cwd, to)}`);
3842
+ return fsCopy(from, to);
3843
+ }));
3844
+ }
3845
+ async function resolveCopyEntries(options) {
3846
+ const copy = toArray(typeof options.copy === "function" ? await options.copy(options) : options.copy);
3847
+ if (!copy.length) return [];
3848
+ const resolved = (await Promise.all(copy.map(async (entry) => {
3849
+ if (typeof entry === "string") entry = { from: [entry] };
3850
+ let from = toArray(entry.from);
3851
+ if (from.some((f) => isDynamicPattern(f))) from = await glob(from, {
3852
+ cwd: options.cwd,
3853
+ onlyFiles: true,
3854
+ expandDirectories: false
3855
+ });
3856
+ return from.map((file) => resolveCopyEntry({
3857
+ ...entry,
3858
+ from: file
3859
+ }, options.cwd, options.outDir));
3860
+ }))).flat();
3861
+ if (!resolved.length) options.logger.warn(options.nameLabel, `No files matched for copying.`);
3862
+ return resolved;
3863
+ }
3864
+ function resolveCopyEntry(entry, cwd, outDir) {
3865
+ const { flatten = true, rename } = entry;
3866
+ const from = path.resolve(cwd, entry.from);
3867
+ const to = entry.to ? path.resolve(cwd, entry.to) : outDir;
3868
+ const { base, dir } = path.parse(path.relative(cwd, from));
3869
+ const destFolder = flatten || !flatten && !dir ? to : dir.replace(dir.split(path.sep)[0], to);
3870
+ const dest = path.join(destFolder, rename ? renameTarget(base, rename, from) : base);
3871
+ return {
3872
+ ...entry,
3873
+ from,
3874
+ to: dest
3875
+ };
3876
+ }
3877
+ function renameTarget(target, rename, src) {
3878
+ const parsedPath = path.parse(target);
3879
+ return typeof rename === "string" ? rename : rename(parsedPath.name, parsedPath.ext.replace(".", ""), src);
3880
+ }
3835
3881
  /**
3836
3882
  * The `node:` protocol was added in Node.js v14.18.0.
3837
3883
  * @see https://nodejs.org/api/esm.html#node-imports
@@ -3977,11 +4023,15 @@ function WatchPlugin(configFiles, { config, chunks }) {
3977
4023
  inputOptions.watch.exclude = toArray(inputOptions.watch.exclude);
3978
4024
  inputOptions.watch.exclude.push(...config.ignoreWatch);
3979
4025
  } : void 0,
3980
- buildStart() {
4026
+ async buildStart() {
3981
4027
  config.tsconfig && this.addWatchFile(config.tsconfig);
3982
4028
  for (const file of configFiles) this.addWatchFile(file);
3983
4029
  if (typeof config.watch !== "boolean") for (const file of resolveComma(toArray(config.watch))) this.addWatchFile(file);
3984
4030
  if (config.pkg) this.addWatchFile(config.pkg.packageJsonPath);
4031
+ if (config.copy) {
4032
+ const resolvedEntries = await resolveCopyEntries(config);
4033
+ for (const entry of resolvedEntries) this.addWatchFile(entry.from);
4034
+ }
3985
4035
  },
3986
4036
  generateBundle: {
3987
4037
  order: "post",
@@ -3992,7 +4042,7 @@ function WatchPlugin(configFiles, { config, chunks }) {
3992
4042
  };
3993
4043
  }
3994
4044
  //#endregion
3995
- //#region ../../node_modules/.pnpm/hookable@6.0.1/node_modules/hookable/dist/index.mjs
4045
+ //#region ../../node_modules/.pnpm/hookable@6.1.0/node_modules/hookable/dist/index.mjs
3996
4046
  function flatHooks(configHooks, hooks = {}, parentName) {
3997
4047
  for (const key in configHooks) {
3998
4048
  const subHook = configHooks[key];
@@ -4094,6 +4144,9 @@ var Hookable = class {
4094
4144
  if (hooks.length === 0) this._hooks[name] = void 0;
4095
4145
  }
4096
4146
  }
4147
+ clearHook(name) {
4148
+ this._hooks[name] = void 0;
4149
+ }
4097
4150
  deprecateHook(name, deprecated) {
4098
4151
  this._deprecatedHooks[name] = typeof deprecated === "string" ? { to: deprecated } : deprecated;
4099
4152
  const _hooks = this._hooks[name] || [];
@@ -4160,7 +4213,7 @@ var Hookable = class {
4160
4213
  }
4161
4214
  };
4162
4215
  //#endregion
4163
- //#region ../../node_modules/.pnpm/tsdown@0.21.2_@arethetypeswrong+core@0.18.2_@tsdown+css@0.21.2_@tsdown+exe@0.21.2_@type_059aa640a91d945cefc9d8c8db7a9cd0/node_modules/tsdown/dist/build-CpOl_krN.mjs
4216
+ //#region ../../node_modules/.pnpm/tsdown@0.21.4_@arethetypeswrong+core@0.18.2_@tsdown+css@0.21.4_@tsdown+exe@0.21.4_@type_17eb19013b58e1a32121480e0690eafa/node_modules/tsdown/dist/build-CoLhkNXE.mjs
4164
4217
  const __cjs_require = createRequire(import.meta.url);
4165
4218
  const satisfies = __cjs_require("./npm_entry_semver_functions_satisfies.cjs");
4166
4219
  const coerce = __cjs_require("./npm_entry_semver_functions_coerce.cjs");
@@ -4251,49 +4304,6 @@ function warnLegacyCJS(config) {
4251
4304
  return version && satisfies(version, "^20.19.0 || >=22.12.0");
4252
4305
  })) config.logger.warnOnce("We recommend using the ESM format instead of CommonJS.\nThe ESM format is compatible with modern platforms and runtimes, and most new libraries are now distributed only in ESM format.\nLearn more at https://nodejs.org/en/learn/modules/publishing-a-package#how-did-we-get-here");
4253
4306
  }
4254
- async function copy(options) {
4255
- if (!options.copy) return;
4256
- const copy = toArray(typeof options.copy === "function" ? await options.copy(options) : options.copy);
4257
- if (!copy.length) return;
4258
- const resolved = (await Promise.all(copy.map(async (entry) => {
4259
- if (typeof entry === "string") entry = { from: [entry] };
4260
- let from = toArray(entry.from);
4261
- if (from.some((f) => isDynamicPattern(f))) from = await glob(from, {
4262
- cwd: options.cwd,
4263
- onlyFiles: true,
4264
- expandDirectories: false
4265
- });
4266
- return from.map((file) => resolveCopyEntry({
4267
- ...entry,
4268
- from: file
4269
- }));
4270
- }))).flat();
4271
- if (!resolved.length) {
4272
- options.logger.warn(options.nameLabel, `No files matched for copying.`);
4273
- return;
4274
- }
4275
- await Promise.all(resolved.map(({ from, to, verbose }) => {
4276
- if (verbose) options.logger.info(options.nameLabel, `Copying files from ${path.relative(options.cwd, from)} to ${path.relative(options.cwd, to)}`);
4277
- return fsCopy(from, to);
4278
- }));
4279
- function resolveCopyEntry(entry) {
4280
- const { flatten = true, rename } = entry;
4281
- const from = path.resolve(options.cwd, entry.from);
4282
- const to = entry.to ? path.resolve(options.cwd, entry.to) : options.outDir;
4283
- const { base, dir } = path.parse(path.relative(options.cwd, from));
4284
- const destFolder = flatten || !flatten && !dir ? to : dir.replace(dir.split(path.sep)[0], to);
4285
- const dest = path.join(destFolder, rename ? renameTarget(base, rename, from) : base);
4286
- return {
4287
- ...entry,
4288
- from,
4289
- to: dest
4290
- };
4291
- }
4292
- }
4293
- function renameTarget(target, rename, src) {
4294
- const parsedPath = path.parse(target);
4295
- return typeof rename === "string" ? rename : rename(parsedPath.name, parsedPath.ext.replace(".", ""), src);
4296
- }
4297
4307
  async function startDevtoolsUI(config) {
4298
4308
  const { start } = await importWithError("@vitejs/devtools/cli-commands");
4299
4309
  await start({
@@ -4318,7 +4328,7 @@ function executeOnSuccess(config) {
4318
4328
  if (!config.onSuccess) return;
4319
4329
  const ab = new AbortController();
4320
4330
  if (typeof config.onSuccess === "string") {
4321
- const p = q(config.onSuccess, [], { nodeOptions: {
4331
+ const p = z(config.onSuccess, [], { nodeOptions: {
4322
4332
  shell: true,
4323
4333
  stdio: "inherit",
4324
4334
  cwd: config.cwd
@@ -4496,15 +4506,11 @@ async function bundleDone(bundleByPkg, bundle) {
4496
4506
  async function packTarball(packageJsonPath) {
4497
4507
  const pkgDir = path.dirname(packageJsonPath);
4498
4508
  const destination = await mkdtemp(path.join(tmpdir(), "tsdown-pack-"));
4499
- const [{ detect }, { pack }] = await Promise.all([import("./detect-J1_Vd1yf-BnOcNWHf.js"), import("./index-node-Bpsmc0eX-CRDsfhY9.js")]);
4509
+ const { detect } = await import("./detect-DN3DXXYt-BiiMP_XL.js");
4500
4510
  try {
4501
4511
  const detected = await detect({ cwd: pkgDir });
4502
4512
  if (detected?.name === "deno") throw new Error(`Cannot pack tarball for Deno projects at ${pkgDir}`);
4503
- return readFile(await pack(pkgDir, {
4504
- destination,
4505
- packageManager: detected?.name,
4506
- ignoreScripts: true
4507
- }));
4513
+ return readFile(await pack(pkgDir, detected, destination, true));
4508
4514
  } finally {
4509
4515
  await fsRemove(destination);
4510
4516
  }
@@ -4528,11 +4534,50 @@ function mergeInlinedDeps(bundles) {
4528
4534
  if (!merged.has(pkgName)) merged.set(pkgName, /* @__PURE__ */ new Set());
4529
4535
  for (const v of versions) merged.get(pkgName).add(v);
4530
4536
  }
4531
- if (!merged.size) return void 0;
4537
+ if (!merged.size) return;
4538
+ const sorted = [...merged.entries()].toSorted(([a], [b]) => a.localeCompare(b));
4532
4539
  const result = {};
4533
- for (const [pkgName, versions] of merged) result[pkgName] = versions.size === 1 ? [...versions][0] : [...versions].toSorted();
4540
+ for (const [pkgName, versions] of sorted) result[pkgName] = versions.size === 1 ? [...versions][0] : [...versions].toSorted();
4534
4541
  return result;
4535
4542
  }
4543
+ async function pack(dir, pm, destination, ignoreScripts) {
4544
+ pm ||= {
4545
+ name: "npm",
4546
+ agent: "npm"
4547
+ };
4548
+ if (pm.name === "deno") throw new Error(`Cannot pack tarball for Deno projects at ${dir}`);
4549
+ const command = pm.name;
4550
+ const args = ["pack"];
4551
+ if (pm.name === "bun") args.unshift("pm");
4552
+ const outFile = path.join(destination, "package.tgz");
4553
+ if (destination) switch (pm.agent) {
4554
+ case "yarn":
4555
+ args.push("-f", outFile);
4556
+ break;
4557
+ case "yarn@berry":
4558
+ args.push("-o", outFile);
4559
+ break;
4560
+ case "bun":
4561
+ args.push("--destination", destination);
4562
+ break;
4563
+ default:
4564
+ args.push("--pack-destination", destination);
4565
+ break;
4566
+ }
4567
+ if (ignoreScripts) switch (pm.agent) {
4568
+ case "pnpm":
4569
+ args.push("--config.ignore-scripts=true");
4570
+ break;
4571
+ case "yarn@berry": break;
4572
+ default:
4573
+ args.push("--ignore-scripts");
4574
+ break;
4575
+ }
4576
+ const output = await R(command, args, { nodeOptions: { cwd: dir } });
4577
+ const tarballFile = await readdir(destination).then((files) => files.find((file) => file.endsWith(".tgz")));
4578
+ if (!tarballFile) throw new Error(`Failed to find packed tarball file in ${destination}. Command output:\n${JSON.stringify(output, null, 2)}`);
4579
+ return path.join(destination, tarballFile);
4580
+ }
4536
4581
  function resolveJsOutputExtension(packageType, format, fixedExtension) {
4537
4582
  switch (format) {
4538
4583
  case "es": return !fixedExtension && packageType === "module" ? "js" : "mjs";
@@ -4597,7 +4642,7 @@ async function resolveInputOptions(config, format, configFiles, bundle, cjsDts,
4597
4642
  if (nodeProtocol) plugins.push(NodeProtocolPlugin(nodeProtocol));
4598
4643
  if (config.pkg || config.deps.skipNodeModulesBundle) plugins.push(DepPlugin(config, bundle));
4599
4644
  if (dts) {
4600
- const { dts: dtsPlugin } = await import("./dist-CtF_Stv5.js");
4645
+ const { dts: dtsPlugin } = await import("./dist-dJp148cE.js");
4601
4646
  const options = {
4602
4647
  tsconfig,
4603
4648
  ...dts
@@ -1,5 +1,5 @@
1
- import "./main-4fHWraTN.js";
1
+ import "./main-JovZVvCY.js";
2
2
  import "./node-B3Gdtau1.js";
3
- import { t as build$1 } from "./build-CpOl_krN-DrIRjiqJ.js";
3
+ import { t as build$1 } from "./build-CoLhkNXE-DtR1EaBG.js";
4
4
  import "./filename-UU7z2A9Z.js";
5
5
  export { build$1 as build };
@@ -1,6 +1,6 @@
1
- import { C as resolveComma, E as toArray } from "./main-4fHWraTN.js";
1
+ import { C as resolveComma, E as toArray } from "./main-JovZVvCY.js";
2
2
  import { n as enable, r as namespaces, t as createDebug } from "./node-B3Gdtau1.js";
3
- //#region ../../node_modules/.pnpm/tsdown@0.21.2_@arethetypeswrong+core@0.18.2_@tsdown+css@0.21.2_@tsdown+exe@0.21.2_@type_059aa640a91d945cefc9d8c8db7a9cd0/node_modules/tsdown/dist/debug-C4FmgzkJ.mjs
3
+ //#region ../../node_modules/.pnpm/tsdown@0.21.4_@arethetypeswrong+core@0.18.2_@tsdown+css@0.21.4_@tsdown+exe@0.21.4_@type_17eb19013b58e1a32121480e0690eafa/node_modules/tsdown/dist/debug-C4FmgzkJ.mjs
4
4
  const debugLog = createDebug("tsdown:debug");
5
5
  function enableDebug(debug) {
6
6
  if (!debug) return;
@@ -1,7 +1,7 @@
1
1
  import process from "node:process";
2
2
  import path from "node:path";
3
3
  import fs from "node:fs/promises";
4
- //#region ../../node_modules/.pnpm/tsdown@0.21.2_@arethetypeswrong+core@0.18.2_@tsdown+css@0.21.2_@tsdown+exe@0.21.2_@type_059aa640a91d945cefc9d8c8db7a9cd0/node_modules/tsdown/dist/detect-J1_Vd1yf.mjs
4
+ //#region ../../node_modules/.pnpm/tsdown@0.21.4_@arethetypeswrong+core@0.18.2_@tsdown+css@0.21.4_@tsdown+exe@0.21.4_@type_17eb19013b58e1a32121480e0690eafa/node_modules/tsdown/dist/detect-DN3DXXYt.mjs
5
5
  const AGENTS = [
6
6
  "npm",
7
7
  "yarn",
@@ -40,12 +40,6 @@ async function pathExists(path2, type) {
40
40
  return false;
41
41
  }
42
42
  }
43
- function getUserAgent() {
44
- const userAgent = process.env.npm_config_user_agent;
45
- if (!userAgent) return null;
46
- const name = userAgent.split("/")[0];
47
- return AGENTS.includes(name) ? name : null;
48
- }
49
43
  function* lookup(cwd = process.cwd()) {
50
44
  let directory = path.resolve(cwd);
51
45
  const { root } = path.parse(directory);
@@ -160,4 +154,4 @@ function isMetadataYarnClassic(metadataPath) {
160
154
  return metadataPath.endsWith(".yarn_integrity");
161
155
  }
162
156
  //#endregion
163
- export { detect, getUserAgent };
157
+ export { detect };