vite 3.1.1 → 3.1.3

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.
@@ -1,5 +1,5 @@
1
1
  import require$$0$1 from 'postcss';
2
- import { z as commonjsGlobal } from './dep-a713b95d.js';
2
+ import { z as commonjsGlobal } from './dep-557f29e6.js';
3
3
  import require$$0 from 'path';
4
4
  import require$$5 from 'crypto';
5
5
  import require$$0__default from 'fs';
@@ -22,7 +22,7 @@ import { createHash as createHash$2 } from 'node:crypto';
22
22
  import { promisify as promisify$4 } from 'node:util';
23
23
  import { promises } from 'node:dns';
24
24
  import resolve$5 from 'resolve';
25
- import { CLIENT_ENTRY, OPTIMIZABLE_ENTRY_RE, DEFAULT_EXTENSIONS as DEFAULT_EXTENSIONS$1, wildcardHosts, loopbackHosts, VALID_ID_PREFIX, FS_PREFIX, CLIENT_PUBLIC_PATH, ENV_PUBLIC_PATH, ENV_ENTRY, DEFAULT_MAIN_FIELDS, DEP_VERSION_RE, SPECIAL_QUERY_RE, KNOWN_ASSET_TYPES, CLIENT_DIR, NULL_BYTE_PLACEHOLDER, JS_TYPES_RE, ESBUILD_MODULES_TARGET, VERSION, VITE_PACKAGE_DIR, DEFAULT_ASSETS_RE, DEFAULT_CONFIG_FILES } from '../constants.js';
25
+ import { CLIENT_ENTRY, OPTIMIZABLE_ENTRY_RE, DEFAULT_EXTENSIONS as DEFAULT_EXTENSIONS$1, wildcardHosts, loopbackHosts, VALID_ID_PREFIX, NULL_BYTE_PLACEHOLDER, FS_PREFIX, CLIENT_PUBLIC_PATH, ENV_PUBLIC_PATH, ENV_ENTRY, DEFAULT_MAIN_FIELDS, DEP_VERSION_RE, SPECIAL_QUERY_RE, KNOWN_ASSET_TYPES, CLIENT_DIR, JS_TYPES_RE, ESBUILD_MODULES_TARGET, VERSION, VITE_PACKAGE_DIR, DEFAULT_ASSETS_RE, DEFAULT_CONFIG_FILES } from '../constants.js';
26
26
  import require$$5 from 'crypto';
27
27
  import require$$0$a from 'buffer';
28
28
  import { Buffer as Buffer$1 } from 'node:buffer';
@@ -7569,7 +7569,7 @@ function normalize (path) {
7569
7569
  }
7570
7570
 
7571
7571
  const isWrappedId = (id, suffix) => id.endsWith(suffix);
7572
- const wrapId = (id, suffix) => `\0${id}${suffix}`;
7572
+ const wrapId$1 = (id, suffix) => `\0${id}${suffix}`;
7573
7573
  const unwrapId$1 = (wrappedId, suffix) => wrappedId.slice(1, -suffix.length);
7574
7574
 
7575
7575
  const PROXY_SUFFIX = '?commonjs-proxy';
@@ -7848,7 +7848,7 @@ function getResolveId(extensions, isPossibleCjsId) {
7848
7848
  return resolved.id + ENTRY_SUFFIX;
7849
7849
  }
7850
7850
  if (isCommonJS === IS_WRAPPED_COMMONJS) {
7851
- return { id: wrapId(resolved.id, ES_IMPORT_SUFFIX), meta: { commonjs: { resolved } } };
7851
+ return { id: wrapId$1(resolved.id, ES_IMPORT_SUFFIX), meta: { commonjs: { resolved } } };
7852
7852
  }
7853
7853
  }
7854
7854
  }
@@ -8024,11 +8024,11 @@ function getRequireResolver(extensions, detectCyclesAndConditional, currentlyRes
8024
8024
  })) || resolveExtensions(source, parentId, extensions);
8025
8025
  currentlyResolvingForParent.delete(source);
8026
8026
  if (!resolved) {
8027
- return { id: wrapId(source, EXTERNAL_SUFFIX), allowProxy: false };
8027
+ return { id: wrapId$1(source, EXTERNAL_SUFFIX), allowProxy: false };
8028
8028
  }
8029
8029
  const childId = resolved.id;
8030
8030
  if (resolved.external) {
8031
- return { id: wrapId(childId, EXTERNAL_SUFFIX), allowProxy: false };
8031
+ return { id: wrapId$1(childId, EXTERNAL_SUFFIX), allowProxy: false };
8032
8032
  }
8033
8033
  parentMeta.requires.push({ resolved, isConditional });
8034
8034
  await analyzeRequiredModule(parentId, resolved, isConditional, rollupContext.load);
@@ -8047,8 +8047,8 @@ function getRequireResolver(extensions, detectCyclesAndConditional, currentlyRes
8047
8047
  source: sources[index].source,
8048
8048
  id: allowProxy
8049
8049
  ? isCommonJS === IS_WRAPPED_COMMONJS
8050
- ? wrapId(dependencyId, WRAPPED_SUFFIX)
8051
- : wrapId(dependencyId, PROXY_SUFFIX)
8050
+ ? wrapId$1(dependencyId, WRAPPED_SUFFIX)
8051
+ : wrapId$1(dependencyId, PROXY_SUFFIX)
8052
8052
  : dependencyId,
8053
8053
  isCommonJS
8054
8054
  };
@@ -8549,12 +8549,12 @@ function getRequireHandlers() {
8549
8549
  if (exportMode === 'module') {
8550
8550
  imports.push(
8551
8551
  `import { __module as ${moduleName}, exports as ${exportsName} } from ${JSON.stringify(
8552
- wrapId(id, MODULE_SUFFIX)
8552
+ wrapId$1(id, MODULE_SUFFIX)
8553
8553
  )}`
8554
8554
  );
8555
8555
  } else if (exportMode === 'exports') {
8556
8556
  imports.push(
8557
- `import { __exports as ${exportsName} } from ${JSON.stringify(wrapId(id, EXPORTS_SUFFIX))}`
8557
+ `import { __exports as ${exportsName} } from ${JSON.stringify(wrapId$1(id, EXPORTS_SUFFIX))}`
8558
8558
  );
8559
8559
  }
8560
8560
  const requiresBySource = collectSources(requireExpressions);
@@ -11623,10 +11623,23 @@ const createFilter = createFilter$1;
11623
11623
  function slash$1(p) {
11624
11624
  return p.replace(/\\/g, '/');
11625
11625
  }
11626
- // Strip valid id prefix. This is prepended to resolved Ids that are
11627
- // not valid browser import specifiers by the importAnalysis plugin.
11626
+ /**
11627
+ * Prepend `/@id/` and replace null byte so the id is URL-safe.
11628
+ * This is prepended to resolved ids that are not valid browser
11629
+ * import specifiers by the importAnalysis plugin.
11630
+ */
11631
+ function wrapId(id) {
11632
+ return id.startsWith(VALID_ID_PREFIX)
11633
+ ? id
11634
+ : VALID_ID_PREFIX + id.replace('\0', NULL_BYTE_PLACEHOLDER);
11635
+ }
11636
+ /**
11637
+ * Undo {@link wrapId}'s `/@id/` and null byte replacements.
11638
+ */
11628
11639
  function unwrapId(id) {
11629
- return id.startsWith(VALID_ID_PREFIX) ? id.slice(VALID_ID_PREFIX.length) : id;
11640
+ return id.startsWith(VALID_ID_PREFIX)
11641
+ ? id.slice(VALID_ID_PREFIX.length).replace(NULL_BYTE_PLACEHOLDER, '\0')
11642
+ : id;
11630
11643
  }
11631
11644
  const flattenId = (id) => id
11632
11645
  .replace(/[\/:]/g, '_')
@@ -34236,7 +34249,7 @@ function resolvePlugin(resolveOptions) {
34236
34249
  nodeModulesInPathRE.test(normalizePath$3(resolved));
34237
34250
  if (isNodeModule && !resolved.match(DEP_VERSION_RE)) {
34238
34251
  const versionHash = depsOptimizer.metadata.browserHash;
34239
- if (versionHash && OPTIMIZABLE_ENTRY_RE.test(resolved)) {
34252
+ if (versionHash && isOptimizable(resolved, depsOptimizer.options)) {
34240
34253
  resolved = injectQuery(resolved, `v=${versionHash}`);
34241
34254
  }
34242
34255
  }
@@ -34629,7 +34642,9 @@ function tryNodeResolve(id, importer, options, targetWeb, depsOptimizer, ssr, ex
34629
34642
  return { id: resolved };
34630
34643
  }
34631
34644
  // if we reach here, it's a valid dep import that hasn't been optimized.
34632
- const isJsType = OPTIMIZABLE_ENTRY_RE.test(resolved);
34645
+ const isJsType = depsOptimizer
34646
+ ? isOptimizable(resolved, depsOptimizer.options)
34647
+ : OPTIMIZABLE_ENTRY_RE.test(resolved);
34633
34648
  let exclude = depsOptimizer?.options.exclude;
34634
34649
  let include = depsOptimizer?.options.exclude;
34635
34650
  if (options.ssrOptimizeCheck) {
@@ -37594,8 +37609,7 @@ function importAnalysisPlugin(config) {
37594
37609
  // prefix it to make it valid. We will strip this before feeding it
37595
37610
  // back into the transform pipeline
37596
37611
  if (!url.startsWith('.') && !url.startsWith('/')) {
37597
- url =
37598
- VALID_ID_PREFIX + resolved.id.replace('\0', NULL_BYTE_PLACEHOLDER);
37612
+ url = wrapId(resolved.id);
37599
37613
  }
37600
37614
  // make the URL browser-valid if not SSR
37601
37615
  if (!ssr) {
@@ -37619,7 +37633,7 @@ function importAnalysisPlugin(config) {
37619
37633
  // up-to-date version of this module.
37620
37634
  try {
37621
37635
  // delay setting `isSelfAccepting` until the file is actually used (#7870)
37622
- const depModule = await moduleGraph.ensureEntryFromUrl(url, ssr, canSkipImportAnalysis(url));
37636
+ const depModule = await moduleGraph.ensureEntryFromUrl(unwrapId(url), ssr, canSkipImportAnalysis(url));
37623
37637
  if (depModule.lastHMRTimestamp > 0) {
37624
37638
  url = injectQuery(url, `t=${depModule.lastHMRTimestamp}`);
37625
37639
  }
@@ -37747,15 +37761,15 @@ function importAnalysisPlugin(config) {
37747
37761
  }
37748
37762
  }
37749
37763
  // record for HMR import chain analysis
37750
- // make sure to normalize away base
37751
- const urlWithoutBase = url.replace(base, '/');
37752
- importedUrls.add(urlWithoutBase);
37764
+ // make sure to unwrap and normalize away base
37765
+ const hmrUrl = unwrapId(url.replace(base, '/'));
37766
+ importedUrls.add(hmrUrl);
37753
37767
  if (enablePartialAccept && importedBindings) {
37754
37768
  extractImportedBindings(resolvedId, source, imports[index], importedBindings);
37755
37769
  }
37756
37770
  if (!isDynamicImport) {
37757
37771
  // for pre-transforming
37758
- staticImportedUrls.add({ url: urlWithoutBase, id: resolvedId });
37772
+ staticImportedUrls.add({ url: hmrUrl, id: resolvedId });
37759
37773
  }
37760
37774
  }
37761
37775
  else if (!importer.startsWith(clientDir)) {
@@ -37862,7 +37876,7 @@ function importAnalysisPlugin(config) {
37862
37876
  // by the deps optimizer
37863
37877
  if (config.server.preTransformRequests && staticImportedUrls.size) {
37864
37878
  staticImportedUrls.forEach(({ url, id }) => {
37865
- url = unwrapId(removeImportQuery(url)).replace(NULL_BYTE_PLACEHOLDER, '\0');
37879
+ url = removeImportQuery(url);
37866
37880
  transformRequest(url, server, { ssr }).catch((e) => {
37867
37881
  if (e?.code === ERR_OUTDATED_OPTIMIZED_DEP) {
37868
37882
  // This are expected errors
@@ -42580,8 +42594,20 @@ function stringifyDepsOptimizerMetadata(metadata, depsCacheDir) {
42580
42594
  }, 2);
42581
42595
  }
42582
42596
  function esbuildOutputFromId(outputs, id, cacheDirOutputPath) {
42597
+ const cwd = process.cwd();
42583
42598
  const flatId = flattenId(id) + '.js';
42584
- return outputs[normalizePath$3(path$n.relative(process.cwd(), path$n.join(cacheDirOutputPath, flatId)))];
42599
+ const normalizedOutputPath = normalizePath$3(path$n.relative(cwd, path$n.join(cacheDirOutputPath, flatId)));
42600
+ const output = outputs[normalizedOutputPath];
42601
+ if (output) {
42602
+ return output;
42603
+ }
42604
+ // If the root dir was symlinked, esbuild could return output keys as `../cwd/`
42605
+ // Normalize keys to support this case too
42606
+ for (const [key, value] of Object.entries(outputs)) {
42607
+ if (normalizePath$3(path$n.relative(cwd, key)) === normalizedOutputPath) {
42608
+ return value;
42609
+ }
42610
+ }
42585
42611
  }
42586
42612
  async function extractExportsData(filePath, config, ssr) {
42587
42613
  await init;
@@ -44485,7 +44511,7 @@ async function compileCSS(id, code, config, urlReplacer, atImportResolvers, serv
44485
44511
  logger: config.logger
44486
44512
  }));
44487
44513
  if (isModule) {
44488
- postcssPlugins.unshift((await import('./dep-57f3662c.js').then(function (n) { return n.i; })).default({
44514
+ postcssPlugins.unshift((await import('./dep-0fc42251.js').then(function (n) { return n.i; })).default({
44489
44515
  ...modulesOptions,
44490
44516
  getJSON(cssFileName, _modules, outputFileName) {
44491
44517
  modules = _modules;
@@ -45642,7 +45668,7 @@ async function doBuild(inlineConfig = {}) {
45642
45668
  config.logger.info(picocolors.exports.cyan(`vite v${VERSION} ${picocolors.exports.green(`building ${ssr ? `SSR bundle ` : ``}for ${config.mode}...`)}`));
45643
45669
  const resolve = (p) => path$n.resolve(config.root, p);
45644
45670
  const input = libOptions
45645
- ? resolve(libOptions.entry)
45671
+ ? options.rollupOptions?.input || resolve(libOptions.entry)
45646
45672
  : typeof options.ssr === 'string'
45647
45673
  ? resolve(options.ssr)
45648
45674
  : options.rollupOptions?.input || resolve('index.html');
@@ -53274,7 +53300,7 @@ function rebindErrorStacktrace(e, stacktrace) {
53274
53300
  const pendingModules = new Map();
53275
53301
  const pendingImports = new Map();
53276
53302
  async function ssrLoadModule(url, server, context = { global }, urlStack = [], fixStacktrace) {
53277
- url = unwrapId(url).replace(NULL_BYTE_PLACEHOLDER, '\0');
53303
+ url = unwrapId(url);
53278
53304
  // when we instantiate multiple dependency modules in parallel, they may
53279
53305
  // point to shared modules. We need to avoid duplicate instantiation attempts
53280
53306
  // by register every module as pending synchronously so that all subsequent
@@ -53344,7 +53370,7 @@ async function instantiateModule(url, server, context = { global }, urlStack = [
53344
53370
  return nodeImport(dep, mod.file, resolveOptions);
53345
53371
  }
53346
53372
  // convert to rollup URL because `pendingImports`, `moduleGraph.urlToModuleMap` requires that
53347
- dep = unwrapId(dep).replace(NULL_BYTE_PLACEHOLDER, '\0');
53373
+ dep = unwrapId(dep);
53348
53374
  if (!isCircular(dep) && !pendingImports.get(dep)?.some(isCircular)) {
53349
53375
  pendingDeps.push(dep);
53350
53376
  if (pendingDeps.length === 1) {
@@ -60555,7 +60581,7 @@ const devHtmlHook = async (html, { path: htmlPath, filename, server, originalUrl
60555
60581
  // and ids are properly handled
60556
60582
  const validPath = `${htmlPath}${trailingSlash ? 'index.html' : ''}`;
60557
60583
  proxyModulePath = `\0${validPath}`;
60558
- proxyModuleUrl = `${VALID_ID_PREFIX}${NULL_BYTE_PLACEHOLDER}${validPath}`;
60584
+ proxyModuleUrl = wrapId(proxyModulePath);
60559
60585
  }
60560
60586
  const s = new MagicString(html);
60561
60587
  let inlineModuleIndex = -1;
package/dist/node/cli.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { performance } from 'node:perf_hooks';
2
2
  import { EventEmitter } from 'events';
3
- import { y as picocolors, u as createLogger, e as resolveConfig } from './chunks/dep-a713b95d.js';
3
+ import { y as picocolors, u as createLogger, e as resolveConfig } from './chunks/dep-557f29e6.js';
4
4
  import { VERSION } from './constants.js';
5
5
  import 'node:fs';
6
6
  import 'node:path';
@@ -695,7 +695,7 @@ cli
695
695
  .action(async (root, options) => {
696
696
  // output structure is preserved even after bundling so require()
697
697
  // is ok here
698
- const { createServer } = await import('./chunks/dep-a713b95d.js').then(function (n) { return n.C; });
698
+ const { createServer } = await import('./chunks/dep-557f29e6.js').then(function (n) { return n.C; });
699
699
  try {
700
700
  const server = await createServer({
701
701
  root,
@@ -742,7 +742,7 @@ cli
742
742
  .option('--emptyOutDir', `[boolean] force empty outDir when it's outside of root`)
743
743
  .option('-w, --watch', `[boolean] rebuilds when modules have changed on disk`)
744
744
  .action(async (root, options) => {
745
- const { build } = await import('./chunks/dep-a713b95d.js').then(function (n) { return n.B; });
745
+ const { build } = await import('./chunks/dep-557f29e6.js').then(function (n) { return n.B; });
746
746
  const buildOptions = cleanOptions(options);
747
747
  try {
748
748
  await build({
@@ -766,7 +766,7 @@ cli
766
766
  .command('optimize [root]', 'pre-bundle dependencies')
767
767
  .option('--force', `[boolean] force the optimizer to ignore the cache and re-bundle`)
768
768
  .action(async (root, options) => {
769
- const { optimizeDeps } = await import('./chunks/dep-a713b95d.js').then(function (n) { return n.A; });
769
+ const { optimizeDeps } = await import('./chunks/dep-557f29e6.js').then(function (n) { return n.A; });
770
770
  try {
771
771
  const config = await resolveConfig({
772
772
  root,
@@ -789,7 +789,7 @@ cli
789
789
  .option('--https', `[boolean] use TLS + HTTP/2`)
790
790
  .option('--open [path]', `[boolean | string] open browser on startup`)
791
791
  .action(async (root, options) => {
792
- const { preview } = await import('./chunks/dep-a713b95d.js').then(function (n) { return n.D; });
792
+ const { preview } = await import('./chunks/dep-557f29e6.js').then(function (n) { return n.D; });
793
793
  try {
794
794
  const server = await preview({
795
795
  root,
@@ -1,7 +1,7 @@
1
1
  import path, { resolve } from 'node:path';
2
2
  import { fileURLToPath } from 'node:url';
3
3
 
4
- var version = "3.1.1";
4
+ var version = "3.1.3";
5
5
 
6
6
  const VERSION = version;
7
7
  const DEFAULT_MAIN_FIELDS = [
@@ -1,4 +1,4 @@
1
- export { b as build, k as createFilter, u as createLogger, c as createServer, d as defineConfig, f as formatPostcssSourceMap, h as getDepOptimizationConfig, i as isDepsOptimizerEnabled, l as loadConfigFromFile, w as loadEnv, j as mergeAlias, m as mergeConfig, n as normalizePath, o as optimizeDeps, p as preview, g as resolveBaseUrl, e as resolveConfig, x as resolveEnvPrefix, a as resolvePackageData, r as resolvePackageEntry, v as searchForWorkspaceRoot, q as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-a713b95d.js';
1
+ export { b as build, k as createFilter, u as createLogger, c as createServer, d as defineConfig, f as formatPostcssSourceMap, h as getDepOptimizationConfig, i as isDepsOptimizerEnabled, l as loadConfigFromFile, w as loadEnv, j as mergeAlias, m as mergeConfig, n as normalizePath, o as optimizeDeps, p as preview, g as resolveBaseUrl, e as resolveConfig, x as resolveEnvPrefix, a as resolvePackageData, r as resolvePackageEntry, v as searchForWorkspaceRoot, q as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-557f29e6.js';
2
2
  export { VERSION as version } from './constants.js';
3
3
  export { version as esbuildVersion } from 'esbuild';
4
4
  export { VERSION as rollupVersion } from 'rollup';
@@ -31,7 +31,7 @@ var require$$1__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$1$1);
31
31
  var readline__default = /*#__PURE__*/_interopDefaultLegacy(readline);
32
32
  var require$$2__default = /*#__PURE__*/_interopDefaultLegacy(require$$2);
33
33
 
34
- var version = "3.1.1";
34
+ var version = "3.1.3";
35
35
 
36
36
  const VERSION = version;
37
37
  const VITE_PACKAGE_DIR = path$3.resolve(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite",
3
- "version": "3.1.1",
3
+ "version": "3.1.3",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Evan You",