vite-plus 1.3.0 → 1.5.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.
Files changed (106) hide show
  1. package/AGENTS.md +4 -0
  2. package/LICENSE +1 -878
  3. package/README.md +1 -1
  4. package/bin/vpx +9 -0
  5. package/binding/index.cjs +59 -54
  6. package/binding/index.d.cts +159 -2
  7. package/dist/{agent-97KmGCyL.js → agent-DkQD3xqe.js} +5 -7
  8. package/dist/bin.js +35 -34
  9. package/dist/{cli-parse-DHE8NrBU.js → cli-parse-aeUeFDlC.js} +2 -3
  10. package/dist/command-TjS_6y9O.js +1 -0
  11. package/dist/{command-CdMBoZFD.js → command-rY79K5NI.js} +28 -30
  12. package/dist/{comparison-CmVirWIW-DUGaiYqF.js → comparison-CmVirWIW-UlEf2maz.js} +1 -2
  13. package/dist/config/bin.js +8 -10
  14. package/dist/{constants-DR55DpRm.js → constants-D2P2aVKb.js} +8 -6
  15. package/dist/create/bin.d.ts +4 -8
  16. package/dist/create/bin.js +151 -120
  17. package/dist/{define-config-Bexdd6RZ.d.ts → define-config-BrvHRi-G.d.ts} +31 -13
  18. package/dist/{define-config-BxDc_9BK.cjs → define-config-CwtQqYC1.cjs} +41 -14
  19. package/dist/{define-config-CvE5pHqB.js → define-config-wR57OZG_.js} +34 -12
  20. package/dist/define-config.cjs +2 -1
  21. package/dist/define-config.d.ts +2 -2
  22. package/dist/define-config.js +1 -1
  23. package/dist/{dist-DIpm7mot.js → dist-Bs0SObNC.js} +73 -145
  24. package/dist/{dist-Cqz8OtiO.js → dist-CdkMvIiQ.js} +11 -5
  25. package/dist/dist-zDZV5eEc.js +3 -0
  26. package/dist/{documentation-DqcZSthV.js → documentation-cv_y0Auv.js} +1 -2
  27. package/dist/{editor-CtJGQP7C.js → editor-aOy1T15H.js} +2735 -5072
  28. package/dist/{help-BmKpeOP9.js → help-B03t_iQ4.js} +1 -2
  29. package/dist/hooks/bin.js +4 -5
  30. package/dist/{hooks-DhwsWb46.js → hooks-w_e2whkQ.js} +45 -25
  31. package/dist/index.cjs +5 -5
  32. package/dist/index.d.ts +2 -2
  33. package/dist/index.js +2 -2
  34. package/dist/{json-JP24qHUF.js → json-kl84kDyH.js} +9 -18
  35. package/dist/lint-plugins.cjs +1 -1
  36. package/dist/migration/bin.js +1782 -256
  37. package/dist/migration/compat/worker.js +4 -6
  38. package/dist/{oxlint-plugin-config-BIzrO2y2.js → oxlint-plugin-config-CHsI_zKo.js} +3 -4
  39. package/dist/oxlint-plugin.d.ts +0 -2
  40. package/dist/oxlint-plugin.js +33 -9
  41. package/dist/{pack-BK38MLVZ.d.ts → pack-ARPFMefW.d.ts} +0 -2
  42. package/dist/pack-bin.d.ts +1 -3
  43. package/dist/pack-bin.js +4 -5
  44. package/dist/pack.d.ts +1 -1
  45. package/dist/{package-CQDXTm6j.js → package-DfFo6-E-.js} +10 -95
  46. package/dist/{package-overrides-D1RcXSFl.js → package-overrides-Ci8GXouY.js} +5 -8
  47. package/dist/picomatch-DEUoj81q.js +1916 -0
  48. package/dist/{prompts-1xNz_ne0.js → prompts-C7DI63WP.js} +30 -50
  49. package/dist/{protocol-D99W10Qi.js → protocol-CkNmY-Mr.js} +1 -2
  50. package/dist/register.d.ts +1 -0
  51. package/dist/register.js +12 -0
  52. package/dist/{report-NhQk8VHb.js → report-BEdpIQvC.js} +4 -2
  53. package/dist/resolve-vite-config-33bzSaeT.js +1 -0
  54. package/dist/{resolve-vite-config-BVr1SUNg.js → resolve-vite-config-Cx3cnVVI.js} +9 -25
  55. package/dist/{rolldown-runtime-kJ_i4yPo.js → rolldown-runtime-DegdyBIC.js} +1 -2
  56. package/dist/script-esm-hooks.d.ts +11 -0
  57. package/dist/script-esm-hooks.js +27 -0
  58. package/dist/script-hooks-9Fof5UMY.js +176 -0
  59. package/dist/script-preload.cjs +491 -0
  60. package/dist/script-register.d.ts +1 -0
  61. package/dist/script-register.js +27 -0
  62. package/dist/script-watch.d.ts +1 -0
  63. package/dist/script-watch.js +2002 -0
  64. package/dist/staged/bin.js +53 -2011
  65. package/dist/sync-versions/bin.js +26 -48
  66. package/dist/sync-versions/bin.mjs +109 -217
  67. package/dist/{terminal-MKGAuy-p.js → terminal-BcuPUy-j.js} +1 -2
  68. package/dist/toolchain.js +38 -12
  69. package/dist/toolchain.json +38 -12
  70. package/dist/{tsconfig-zWgHiQ3X.js → tsconfig-BE3Wj9OX.js} +1 -1
  71. package/dist/{tsconfig-BZu7kl-x.js → tsconfig-shNmmCE_.js} +8 -10
  72. package/dist/version.d.ts +1 -3
  73. package/dist/version.js +5 -6
  74. package/dist/versions.js +7 -7
  75. package/dist/{vitest-ecosystem-BU0AqZq-.js → vitest-ecosystem-BeEYz-qF.js} +1 -2
  76. package/dist/{vitest-v5-entry-points-DthU1e_O.js → vitest-v5-entry-points-NyJsFeux.js} +1 -2
  77. package/dist/vpx-bin.d.ts +1 -0
  78. package/dist/vpx-bin.js +232 -0
  79. package/dist/vpx-script-EXgV5QOf.js +434 -0
  80. package/docs/config/check.md +2 -0
  81. package/docs/config/fmt.md +1 -1
  82. package/docs/config/lint.md +1 -1
  83. package/docs/config/run.md +10 -2
  84. package/docs/config/staged.md +1 -1
  85. package/docs/guide/check.md +6 -1
  86. package/docs/guide/ci.md +13 -3
  87. package/docs/guide/create.md +1 -1
  88. package/docs/guide/env.md +11 -4
  89. package/docs/guide/global-cli.md +59 -3
  90. package/docs/guide/homebrew.md +127 -0
  91. package/docs/guide/ide-integration.md +1 -3
  92. package/docs/guide/implode.md +5 -3
  93. package/docs/guide/local-cli.md +21 -0
  94. package/docs/guide/migrate-rules.md +120 -18
  95. package/docs/guide/migrate.md +9 -9
  96. package/docs/guide/package-management.md +1 -1
  97. package/docs/guide/run.md +23 -1
  98. package/docs/guide/test.md +1 -1
  99. package/docs/guide/troubleshooting.md +1 -1
  100. package/docs/guide/upgrade.md +12 -6
  101. package/docs/guide/vitest-v5.md +2 -2
  102. package/docs/guide/vpx.md +210 -9
  103. package/package.json +43 -34
  104. package/dist/command-DVTILtS-.js +0 -1
  105. package/dist/dist-Dhu07wmN.js +0 -3
  106. package/dist/resolve-vite-config-7WDtXO4G.js +0 -1
@@ -1,7 +1,7 @@
1
- import { n as addMigrationWarning, r as createMigrationReport } from "../../report-NhQk8VHb.js";
2
- import { t as ROLLDOWN_COMPAT_RESULT_PREFIX } from "../../protocol-D99W10Qi.js";
1
+ import { n as addMigrationWarning, r as createMigrationReport } from "../../report-BEdpIQvC.js";
2
+ import { t as ROLLDOWN_COMPAT_RESULT_PREFIX } from "../../protocol-CkNmY-Mr.js";
3
3
  import { writeSync } from "node:fs";
4
- //#region src/migration/compat/manual-chunks.ts
4
+ // src/migration/compat/manual-chunks.ts
5
5
  /**
6
6
  * Check for Rolldown-incompatible manualChunks config patterns.
7
7
  */
@@ -12,8 +12,7 @@ function checkManualChunksCompat(output, report) {
12
12
  break;
13
13
  }
14
14
  }
15
- //#endregion
16
- //#region src/migration/compat/worker.ts
15
+ // src/migration/compat/worker.ts
17
16
  async function main() {
18
17
  const rootDir = process.argv[2];
19
18
  if (!rootDir) return;
@@ -31,5 +30,4 @@ async function main() {
31
30
  } catch {}
32
31
  }
33
32
  main().then(() => process.exit(0), () => process.exit(0));
34
- //#endregion
35
33
  export {};
@@ -1,5 +1,5 @@
1
- import { u as VITE_PLUS_NAME } from "./constants-DR55DpRm.js";
2
- //#region src/oxlint-plugin-config.ts
1
+ import { u as VITE_PLUS_NAME } from "./constants-D2P2aVKb.js";
2
+ // src/oxlint-plugin-config.ts
3
3
  const VITE_PLUS_OXLINT_PLUGIN_NAME = VITE_PLUS_NAME;
4
4
  const VITE_PLUS_OXLINT_PLUGIN_SPECIFIER = `${VITE_PLUS_NAME}/oxlint-plugin`;
5
5
  const PREFER_VITE_PLUS_IMPORTS_RULE_NAME = "prefer-vite-plus-imports";
@@ -33,5 +33,4 @@ function createDefaultVitePlusLintConfig(options) {
33
33
  };
34
34
  return config;
35
35
  }
36
- //#endregion
37
- export { ensureVitePlusImportRuleDefaults as i, VITE_PLUS_OXLINT_PLUGIN_NAME as n, createDefaultVitePlusLintConfig as r, PREFER_VITE_PLUS_IMPORTS_RULE_NAME as t };
36
+ export { ensureVitePlusImportRuleDefaults as a, createDefaultVitePlusLintConfig as i, PREFER_VITE_PLUS_IMPORTS_RULE_NAME as n, VITE_PLUS_OXLINT_PLUGIN_NAME as r, PREFER_VITE_PLUS_IMPORTS_RULE as t };
@@ -1,6 +1,4 @@
1
- //#region src/oxlint-plugin.d.ts
2
1
  declare function rewriteVitePlusImportSpecifier(specifier: string): string | null;
3
2
  export declare const preferVitePlusImportsRule: import("@oxlint/plugins").Rule;
4
3
  declare const plugin: import("@oxlint/plugins").Plugin;
5
- //#endregion
6
4
  export { plugin as default, rewriteVitePlusImportSpecifier };
@@ -1,10 +1,10 @@
1
- import { v as exports } from "./constants-DR55DpRm.js";
2
- import { n as VITE_PLUS_OXLINT_PLUGIN_NAME, t as PREFER_VITE_PLUS_IMPORTS_RULE_NAME } from "./oxlint-plugin-config-BIzrO2y2.js";
3
- import { t as vitest_v5_entry_points_default } from "./vitest-v5-entry-points-DthU1e_O.js";
1
+ import { v as exports } from "./constants-D2P2aVKb.js";
2
+ import { n as PREFER_VITE_PLUS_IMPORTS_RULE_NAME, r as VITE_PLUS_OXLINT_PLUGIN_NAME } from "./oxlint-plugin-config-CHsI_zKo.js";
3
+ import { t as vitest_v5_entry_points_default } from "./vitest-v5-entry-points-NyJsFeux.js";
4
4
  import path from "node:path";
5
5
  import fs from "node:fs";
6
6
  import { definePlugin, defineRule } from "@oxlint/plugins";
7
- //#region src/vite-config-entry-basenames.json
7
+ // src/vite-config-entry-basenames.json
8
8
  var vite_config_entry_basenames_default = [
9
9
  "vite.config.ts",
10
10
  "vite.config.mts",
@@ -19,8 +19,7 @@ var vite_config_entry_basenames_default = [
19
19
  "vitest.config.mjs",
20
20
  "vitest.config.cjs"
21
21
  ];
22
- //#endregion
23
- //#region src/oxlint-plugin.ts
22
+ // src/oxlint-plugin.ts
24
23
  function isVitestFamilyDeclareModuleSpecifier(specifier) {
25
24
  return specifier === "vitest" || specifier.startsWith("vitest/") || specifier === "@vitest/browser" || specifier.startsWith("@vitest/browser/") || specifier.startsWith("@vitest/browser-");
26
25
  }
@@ -54,6 +53,7 @@ const OXLINT_CONFIG_SURFACE_EXPORTS = /* @__PURE__ */ new Set([
54
53
  ]);
55
54
  function rewriteVitePlusImportSpecifier(specifier) {
56
55
  if (specifier === "vite") return "vite-plus";
56
+ if (specifier === "vite/rolldown" || specifier.startsWith("vite/rolldown/")) return null;
57
57
  if (specifier.startsWith("vite/")) return `vite-plus/${specifier.slice(5)}`;
58
58
  if (specifier === "vitest/config") return "vite-plus";
59
59
  if (specifier === "vitest") return "vite-plus/test";
@@ -93,9 +93,14 @@ function quoteSpecifier(literal, replacement) {
93
93
  }
94
94
  const nuxtTestUtilsPackageCache = /* @__PURE__ */ new Map();
95
95
  const oxlintOwnerPackageCache = /* @__PURE__ */ new Map();
96
+ const viteKeeperPackageCache = /* @__PURE__ */ new Map();
97
+ const vitestKeeperPackageCache = /* @__PURE__ */ new Map();
96
98
  function isUpstreamVitestSpecifier(specifier) {
97
99
  return specifier === "vitest" || specifier.startsWith("vitest/");
98
100
  }
101
+ function isVitestFamilySpecifier(specifier) {
102
+ return isUpstreamVitestSpecifier(specifier) || specifier.startsWith("@vitest/") || specifier in vitest_v5_entry_points_default;
103
+ }
99
104
  function nearestPackageMatches(filename, cache, matchesPackage) {
100
105
  if (!path.isAbsolute(filename)) return false;
101
106
  let directory = path.dirname(filename);
@@ -130,6 +135,20 @@ function nearestPackageUsesNuxtTestUtils(filename) {
130
135
  pkg.optionalDependencies
131
136
  ].some((dependencies) => dependencies?.["@nuxt/test-utils"] !== void 0));
132
137
  }
138
+ function dependsOnAtRuntime(pkg, name) {
139
+ return [pkg.dependencies, pkg.peerDependencies].some((dependencies) => dependencies?.[name] !== void 0);
140
+ }
141
+ function isPublishedVitePluginName(name) {
142
+ if (name === void 0) return false;
143
+ const unscoped = name.startsWith("@") ? name.split("/")[1] : name;
144
+ return unscoped !== void 0 && /^(vite-plugin|unplugin)-/.test(unscoped);
145
+ }
146
+ function nearestPackageKeepsVite(filename) {
147
+ return nearestPackageMatches(filename, viteKeeperPackageCache, (pkg) => dependsOnAtRuntime(pkg, "vite") || isPublishedVitePluginName(pkg.name));
148
+ }
149
+ function nearestPackageKeepsVitest(filename) {
150
+ return nearestPackageMatches(filename, vitestKeeperPackageCache, (pkg) => dependsOnAtRuntime(pkg, "vitest"));
151
+ }
133
152
  function nearestPackageOwnsOxlintApi(filename) {
134
153
  return nearestPackageMatches(filename, oxlintOwnerPackageCache, (pkg) => pkg.optionalDependencies?.[OXLINT_PLUGINS_PACKAGE] !== void 0 || [pkg.dependencies, pkg.peerDependencies].some((dependencies) => dependencies?.[OXLINT_PACKAGE] !== void 0 || dependencies?.[OXLINT_PLUGINS_PACKAGE] !== void 0));
135
154
  }
@@ -149,9 +168,11 @@ function reportSpecifier(context, literal, replacement) {
149
168
  function isOxlintApiSpecifier(specifier) {
150
169
  return specifier === OXLINT_PLUGINS_PACKAGE || specifier === OXLINT_PLUGINS_DEV_SUBPATH;
151
170
  }
152
- function maybeReportLiteral(context, literal, { preserveUpstreamVitest, fileIsViteConfig, ownsOxlintApi }) {
171
+ function maybeReportLiteral(context, literal, { preserveUpstreamVitest, fileIsViteConfig, ownsOxlintApi, keepsVite, keepsVitest }) {
153
172
  if (!literal || literal.type !== "Literal" || typeof literal.value !== "string") return;
154
173
  if (preserveUpstreamVitest && isUpstreamVitestSpecifier(literal.value)) return;
174
+ if (keepsVite && isViteSpecifier(literal.value)) return;
175
+ if (keepsVitest && isVitestFamilySpecifier(literal.value)) return;
155
176
  if (!fileIsViteConfig && isViteSpecifier(literal.value)) return;
156
177
  const replacement = rewriteVitePlusImportSpecifier(literal.value);
157
178
  if (!replacement) return;
@@ -185,13 +206,17 @@ const preferVitePlusImportsRule = defineRule({
185
206
  const options = {
186
207
  preserveUpstreamVitest: false,
187
208
  fileIsViteConfig: false,
188
- ownsOxlintApi: false
209
+ ownsOxlintApi: false,
210
+ keepsVite: false,
211
+ keepsVitest: false
189
212
  };
190
213
  return {
191
214
  Program() {
192
215
  options.preserveUpstreamVitest = nearestPackageUsesNuxtTestUtils(context.filename);
193
216
  options.fileIsViteConfig = isViteConfigFile(context.filename);
194
217
  options.ownsOxlintApi = nearestPackageOwnsOxlintApi(context.filename);
218
+ options.keepsVite = nearestPackageKeepsVite(context.filename);
219
+ options.keepsVitest = nearestPackageKeepsVitest(context.filename);
195
220
  },
196
221
  ImportDeclaration(node) {
197
222
  maybeReportLiteral(context, node.source, options);
@@ -227,5 +252,4 @@ const plugin = definePlugin({
227
252
  meta: { name: VITE_PLUS_OXLINT_PLUGIN_NAME },
228
253
  rules: { [PREFER_VITE_PLUS_IMPORTS_RULE_NAME]: preferVitePlusImportsRule }
229
254
  });
230
- //#endregion
231
255
  export { plugin as default, preferVitePlusImportsRule, rewriteVitePlusImportSpecifier };
@@ -1,5 +1,4 @@
1
1
  import { UserConfig } from "vite/pack";
2
- //#region src/pack.d.ts
3
2
  interface PackUserConfig extends UserConfig {
4
3
  /**
5
4
  * When loading env variables from `envFile`, only include variables with these prefixes.
@@ -7,5 +6,4 @@ interface PackUserConfig extends UserConfig {
7
6
  */
8
7
  envPrefix?: string | string[];
9
8
  }
10
- //#endregion
11
9
  export { PackUserConfig as t };
@@ -1,3 +1 @@
1
- //#region src/pack-bin.d.ts
2
- export declare function runCLI(): Promise<void>;
3
- //#endregion
1
+ export declare function runCLI(): Promise<void>;
package/dist/pack-bin.js CHANGED
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env node
2
- import { t as cac } from "./dist-Cqz8OtiO.js";
3
- import { o as resolveViteConfig } from "./resolve-vite-config-BVr1SUNg.js";
2
+ import { t as cac } from "./dist-CdkMvIiQ.js";
3
+ import { a as resolveViteConfig } from "./resolve-vite-config-Cx3cnVVI.js";
4
4
  import module from "node:module";
5
5
  import path from "node:path";
6
6
  import { buildWithConfigs, enableDebug, globalLogger, resolveUserConfig } from "vite/pack";
7
- //#region src/pack-bin.ts
7
+ // src/pack-bin.ts
8
8
  const RE_DTS = /\.d\.[cm]?ts$/;
9
9
  const EXTERNAL_DTS_PKG_RE = /^(?:postcss|lightningcss|vitest|@vitest\/[^/]+|vite-plus)(?:\/|$)/;
10
10
  /**
@@ -64,7 +64,7 @@ const DEFAULT_ENV_PREFIXES = ["VITE_PACK_", "TSDOWN_"];
64
64
  cli.command("[...files]", "Bundle files", {
65
65
  ignoreOptionDefaultValue: true,
66
66
  allowUnknownOptions: true
67
- }).option("--config-loader <loader>", "Config loader to use: auto, native, tsx, unrun", { default: "auto" }).option("--no-config", "Disable config file").option("-f, --format <format>", "Bundle format: esm, cjs, iife, umd", { default: "esm" }).option("--clean", "Clean output directory, --no-clean to disable").option("--deps.never-bundle <module>", "Mark dependencies as external").option("--minify", "Minify output").option("--devtools", "Enable devtools integration").option("--debug [feat]", "Show debug logs").option("--target <target>", "Bundle target, e.g \"es2015\", \"esnext\"").option("-l, --logLevel <level>", "Set log level: info, warn, error, silent").option("--fail-on-warn", "Fail on warnings", { default: true }).option("--no-write", "Disable writing files to disk, incompatible with watch mode").option("-d, --out-dir <dir>", "Output directory", { default: "dist" }).option("--treeshake", "Tree-shake bundle", { default: true }).option("--sourcemap", "Generate source map", { default: false }).option("--shims", "Enable cjs and esm shims", { default: false }).option("--platform <platform>", "Target platform", { default: "node" }).option("--dts", "Generate dts files").option("--publint", "Enable publint", { default: false }).option("--attw", "Enable Are the types wrong integration", { default: false }).option("--unused", "Enable unused dependencies check", { default: false }).option("-w, --watch [path]", "Watch mode").option("--ignore-watch <path>", "Ignore custom paths in watch mode").option("--from-vite [vitest]", "Reuse config from Vite or Vitest").option("--report", "Size report", { default: true }).option("--env.* <value>", "Define compile-time env variables").option("--env-file <file>", "Load environment variables from a file, when used together with --env, variables in --env take precedence").option("--env-prefix <prefix>", "Prefix for env variables to inject into the bundle", { default: DEFAULT_ENV_PREFIXES }).option("--on-success <command>", "Command to run on success").option("--copy <dir>", "Copy files to output dir").option("--tsconfig <tsconfig>", "Set tsconfig path").option("--unbundle", "Unbundle mode").option("--root <dir>", "Root directory of input files").option("--exe", "Bundle as executable").option("-W, --workspace [dir]", "Enable workspace mode").option("--concurrency <count>", "Maximum number of Rolldown builds to run in parallel").option("-F, --filter <pattern>", "Filter configs (cwd or name), e.g. /pkg-name$/ or pkg-name").option("--exports", "Generate export-related metadata for package.json (experimental)").action(async (input, flags) => {
67
+ }).option("--config-loader <loader>", "Config loader to use: auto, native, tsx, unrun", { default: "auto" }).option("--no-config", "Disable config file").option("-f, --format <format>", "Bundle format: esm, cjs, iife, umd", { default: "esm" }).option("--clean", "Clean output directory, --no-clean to disable").option("--deps.never-bundle <module>", "Mark dependencies as external").option("--minify", "Minify output").option("--devtools", "Enable devtools integration").option("--debug [feat]", "Show debug logs").option("--target <target>", "Bundle target, e.g \"es2015\", \"esnext\"").option("-l, --logLevel <level>", "Set log level: info, warn, error, silent").option("--fail-on-warn", "Fail on warnings", { default: true }).option("--no-write", "Disable writing files to disk, incompatible with watch mode").option("-d, --out-dir <dir>", "Output directory", { default: "dist" }).option("--treeshake", "Tree-shake bundle", { default: true }).option("--sourcemap", "Generate source map", { default: false }).option("--shims", "Enable cjs and esm shims", { default: false }).option("--platform <platform>", "Target platform", { default: "node" }).option("--dts", "Generate dts files").option("--publint", "Enable publint", { default: false }).option("--attw", "Enable Are the types wrong integration", { default: false }).option("--unused", "Enable unused dependencies check", { default: false }).option("-w, --watch [path]", "Watch mode").option("--ignore-watch <path>", "Ignore custom paths in watch mode").option("--from-vite [vitest]", "Reuse config from Vite or Vitest").option("--report", "Size report", { default: true }).option("--env.* <value>", "Define compile-time env variables").option("--env-file <file>", "Load environment variables from a file, can be repeated").option("--env-prefix <prefix>", "Prefix for env variables to inject into the bundle", { default: DEFAULT_ENV_PREFIXES }).option("--on-success <command>", "Command to run on success").option("--copy <dir>", "Copy files to output dir").option("--tsconfig <tsconfig>", "Set tsconfig path").option("--unbundle", "Unbundle mode").option("--root <dir>", "Root directory of input files").option("--exe", "Bundle as executable").option("-W, --workspace [dir]", "Enable workspace mode").option("--concurrency <count>", "Maximum number of Rolldown builds to run in parallel").option("-F, --filter <pattern>", "Filter configs (cwd or name), e.g. /pkg-name$/ or pkg-name").option("--exports", "Generate export-related metadata for package.json (experimental)").action(async (input, flags) => {
68
68
  if (input.length > 0) flags.entry = input;
69
69
  if (flags.envPrefix === void 0) flags.envPrefix = DEFAULT_ENV_PREFIXES;
70
70
  async function runBuild() {
@@ -99,5 +99,4 @@ async function runCLI() {
99
99
  }
100
100
  if (module.enableCompileCache) module.enableCompileCache();
101
101
  await runCLI();
102
- //#endregion
103
102
  export { runCLI };
package/dist/pack.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { t as PackUserConfig } from "./pack-BK38MLVZ.js";
1
+ import { t as PackUserConfig } from "./pack-ARPFMefW.js";
2
2
  export * from "vite/pack";
3
3
  export { PackUserConfig };
@@ -1,63 +1,10 @@
1
- import "./constants-DR55DpRm.js";
2
- import { i as readJsonFile } from "./json-JP24qHUF.js";
1
+ import "./constants-D2P2aVKb.js";
2
+ import { i as readJsonFile } from "./json-kl84kDyH.js";
3
3
  import { createRequire } from "node:module";
4
4
  import path from "node:path";
5
+ import { resolveNpmAuthorization, resolveNpmRegistry } from "../binding/index.js";
5
6
  import fs from "node:fs";
6
- import os from "node:os";
7
- //#region src/utils/npm-config.ts
8
- function expandNpmrcValue(raw) {
9
- let value = raw.trim();
10
- if (value.startsWith("\"") && value.endsWith("\"") || value.startsWith("'") && value.endsWith("'")) value = value.slice(1, -1);
11
- return value.replaceAll(/\$\{([A-Z0-9_]+)\}/gi, (_, name) => process.env[name] ?? "");
12
- }
13
- function parseNpmrc(contents, into) {
14
- for (const rawLine of contents.split(/\r?\n/)) {
15
- const line = rawLine.trim();
16
- if (!line || line.startsWith("#") || line.startsWith(";")) continue;
17
- const eq = line.indexOf("=");
18
- if (eq === -1) continue;
19
- const key = line.slice(0, eq).trim();
20
- const value = expandNpmrcValue(line.slice(eq + 1));
21
- if (key) into.set(key, value);
22
- }
23
- }
24
- function loadFileInto(filePath, config) {
25
- try {
26
- parseNpmrc(fs.readFileSync(filePath, "utf8"), config);
27
- } catch {}
28
- }
29
- /**
30
- * Rebuilt on every call so tests that mutate `process.env` mid-run see
31
- * fresh config. Each `vp create` hits this ≤4 times (registry + auth on
32
- * packument + auth on tarball), which is cheap enough vs. the network
33
- * work that a cache isn't worth the test-determinism cost.
34
- */
35
- function getNpmConfig() {
36
- const config = /* @__PURE__ */ new Map();
37
- const homeNpmrc = path.resolve(os.homedir(), ".npmrc");
38
- loadFileInto(homeNpmrc, config);
39
- const projectRcs = [];
40
- let dir = path.resolve(process.cwd());
41
- const seen = /* @__PURE__ */ new Set();
42
- while (dir && !seen.has(dir)) {
43
- seen.add(dir);
44
- const candidate = path.resolve(dir, ".npmrc");
45
- if (candidate !== homeNpmrc && fs.existsSync(candidate)) projectRcs.push(candidate);
46
- const parent = path.dirname(dir);
47
- if (parent === dir) break;
48
- dir = parent;
49
- }
50
- for (let i = projectRcs.length - 1; i >= 0; i -= 1) loadFileInto(projectRcs[i], config);
51
- for (const [envKey, envValue] of Object.entries(process.env)) {
52
- if (envValue === void 0) continue;
53
- if (envKey.startsWith("npm_config_")) config.set(envKey.slice(11), envValue);
54
- else if (envKey.startsWith("NPM_CONFIG_")) config.set(envKey.slice(11).toLowerCase(), envValue);
55
- }
56
- return config;
57
- }
58
- function normalizeRegistryUrl(url) {
59
- return url.replace(/\/+$/, "");
60
- }
7
+ // src/utils/npm-config.ts
61
8
  /**
62
9
  * Resolve the npm registry base URL for the given scope (or the default
63
10
  * registry when `scope` is omitted). Honors `@scope:registry=...` entries
@@ -65,45 +12,15 @@ function normalizeRegistryUrl(url) {
65
12
  * vars so private / mirrored registries work for org manifest fetches.
66
13
  */
67
14
  function getNpmRegistry(scope) {
68
- const config = getNpmConfig();
69
- if (scope) {
70
- const normalizedScope = scope.startsWith("@") ? scope : `@${scope}`;
71
- const scoped = config.get(`${normalizedScope}:registry`);
72
- if (scoped) return normalizeRegistryUrl(scoped);
73
- }
74
- return normalizeRegistryUrl(config.get("registry") || "https://registry.npmjs.org");
15
+ return resolveNpmRegistry(process.cwd(), scope?.replace(/^@/, ""));
75
16
  }
76
17
  /**
77
- * Build the `Authorization` header value for a registry URL by matching
78
- * the URL against `//host[/path]/:_authToken=...` / `:_auth=...` entries
79
- * in `.npmrc`. Returns `undefined` when no credential is configured.
18
+ * Build the `Authorization` header value for a registry URL from the
19
+ * matching `//host[/path]/:_authToken=...` / `:_auth=...` entries in
20
+ * `.npmrc`. Returns `undefined` when no credential is configured.
80
21
  */
81
22
  function getNpmAuthHeader(registryOrUrl) {
82
- let parsed;
83
- try {
84
- parsed = new URL(registryOrUrl);
85
- } catch {
86
- return;
87
- }
88
- const config = getNpmConfig();
89
- const segments = parsed.pathname.split("/").filter(Boolean);
90
- const candidates = [];
91
- for (let i = segments.length; i >= 0; i -= 1) {
92
- const subPath = i === 0 ? "/" : `/${segments.slice(0, i).join("/")}/`;
93
- candidates.push(`//${parsed.host}${subPath}`);
94
- }
95
- for (const prefix of candidates) {
96
- const token = config.get(`${prefix}:_authToken`);
97
- if (token) return `Bearer ${token}`;
98
- const basic = config.get(`${prefix}:_auth`);
99
- if (basic) return `Basic ${basic}`;
100
- const username = config.get(`${prefix}:username`);
101
- const passwordB64 = config.get(`${prefix}:_password`);
102
- if (username && passwordB64) {
103
- const password = Buffer.from(passwordB64, "base64").toString("utf8");
104
- return `Basic ${Buffer.from(`${username}:${password}`).toString("base64")}`;
105
- }
106
- }
23
+ return resolveNpmAuthorization(process.cwd(), registryOrUrl) ?? void 0;
107
24
  }
108
25
  /**
109
26
  * `fetch` wrapper for npm registry URLs that retries with an
@@ -132,8 +49,7 @@ async function fetchNpmResource(url, init) {
132
49
  signal: AbortSignal.timeout(timeoutMs)
133
50
  });
134
51
  }
135
- //#endregion
136
- //#region src/utils/package.ts
52
+ // src/utils/package.ts
137
53
  function getScopeFromPackageName(packageName) {
138
54
  if (packageName.startsWith("@")) return packageName.split("/")[0];
139
55
  return "";
@@ -243,5 +159,4 @@ async function checkNpmPackageExists(packageName) {
243
159
  return true;
244
160
  }
245
161
  }
246
- //#endregion
247
162
  export { hasVitePlusDependency as a, getNpmRegistry as c, hasPackageManagerDeclaration as i, detectPackageMetadata as n, readNearestPackageJson as o, getScopeFromPackageName as r, fetchNpmResource as s, checkNpmPackageExists as t };
@@ -1,5 +1,5 @@
1
- import { a as GREATER_LESS_THAN, b as safeRegex, c as LOOSE_PLAIN, d as XRANGE_PLAIN, f as XRANGE_PLAIN_LOOSE, g as formatComparableVersion, i as FULL_PLAIN, m as compareParsed, o as LONE_CARET, s as LONE_TILDE, t as BUILD, x as tryParse, y as parse } from "./comparison-CmVirWIW-DUGaiYqF.js";
2
- //#region ../../node_modules/.pnpm/verkit@0.5.0/node_modules/verkit/dist/set-BGFWKKE8.js
1
+ import { a as GREATER_LESS_THAN, b as safeRegex, c as LOOSE_PLAIN, d as XRANGE_PLAIN, f as XRANGE_PLAIN_LOOSE, g as formatComparableVersion, i as FULL_PLAIN, m as compareParsed, o as LONE_CARET, s as LONE_TILDE, t as BUILD, x as tryParse, y as parse } from "./comparison-CmVirWIW-UlEf2maz.js";
2
+ // ../../node_modules/.pnpm/verkit@0.5.0/node_modules/verkit/dist/set-BGFWKKE8.js
3
3
  const STRICT_COMPARATOR = safeRegex(String.raw`^${GREATER_LESS_THAN}\s*(${FULL_PLAIN})$|^$`);
4
4
  const LOOSE_COMPARATOR$1 = safeRegex(String.raw`^${GREATER_LESS_THAN}\s*(${LOOSE_PLAIN})$|^$`);
5
5
  function formatComparator(comparator) {
@@ -53,8 +53,7 @@ function parsedComparatorsIntersect(left, right, options = {}) {
53
53
  if (comparison < 0 && left.operator.startsWith(">") && right.operator.startsWith("<")) return true;
54
54
  return comparison > 0 && left.operator.startsWith("<") && right.operator.startsWith(">");
55
55
  }
56
- //#endregion
57
- //#region ../../node_modules/.pnpm/verkit@0.5.0/node_modules/verkit/dist/range-C5wjdo9a.js
56
+ // ../../node_modules/.pnpm/verkit@0.5.0/node_modules/verkit/dist/range-C5wjdo9a.js
58
57
  function formatRange(range) {
59
58
  return range.sets.map((set) => set.map(formatComparator).join(" ")).join("||");
60
59
  }
@@ -391,15 +390,14 @@ function isRangeSubset(subset, superset, options = {}) {
391
390
  }
392
391
  return true;
393
392
  }
394
- //#endregion
395
- //#region src/utils/package-overrides.ts
393
+ // src/utils/package-overrides.ts
396
394
  function extractOverrideTargetName(key) {
397
395
  let target = key.trim();
398
396
  for (let delimiter = target.search(/[^ |@]>/); delimiter !== -1; delimiter = target.search(/[^ |@]>/)) target = target.slice(delimiter + 2).trim();
399
397
  if (!target) return target;
400
398
  if (target.includes("/")) {
401
399
  const segments = target.split("/");
402
- const last = segments[segments.length - 1];
400
+ const last = segments.at(-1);
403
401
  const scope = segments[segments.length - 2];
404
402
  target = scope?.startsWith("@") ? `${scope}/${last}` : last;
405
403
  }
@@ -407,5 +405,4 @@ function extractOverrideTargetName(key) {
407
405
  const versionAt = target.indexOf("@", nameStart);
408
406
  return versionAt > 0 ? target.slice(0, versionAt) : target;
409
407
  }
410
- //#endregion
411
408
  export { rangeToComparators as a, normalizeRange as i, findMinimumForRange as n, rangesIntersect as o, isRangeSubset as r, satisfies as s, extractOverrideTargetName as t };