vite 3.1.2 → 3.1.4

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-cff57044.js';
2
+ import { z as commonjsGlobal } from './dep-6b3a5aff.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, '_')
@@ -13350,6 +13363,7 @@ function esbuildPlugin(options = {}) {
13350
13363
  // Remove optimization options for dev as we only need to transpile them,
13351
13364
  // and for build as the final optimization is in `buildEsbuildPlugin`
13352
13365
  const transformOptions = {
13366
+ target: 'esnext',
13353
13367
  ...options,
13354
13368
  minify: false,
13355
13369
  minifyIdentifiers: false,
@@ -37596,8 +37610,7 @@ function importAnalysisPlugin(config) {
37596
37610
  // prefix it to make it valid. We will strip this before feeding it
37597
37611
  // back into the transform pipeline
37598
37612
  if (!url.startsWith('.') && !url.startsWith('/')) {
37599
- url =
37600
- VALID_ID_PREFIX + resolved.id.replace('\0', NULL_BYTE_PLACEHOLDER);
37613
+ url = wrapId(resolved.id);
37601
37614
  }
37602
37615
  // make the URL browser-valid if not SSR
37603
37616
  if (!ssr) {
@@ -37621,7 +37634,7 @@ function importAnalysisPlugin(config) {
37621
37634
  // up-to-date version of this module.
37622
37635
  try {
37623
37636
  // delay setting `isSelfAccepting` until the file is actually used (#7870)
37624
- const depModule = await moduleGraph.ensureEntryFromUrl(url, ssr, canSkipImportAnalysis(url));
37637
+ const depModule = await moduleGraph.ensureEntryFromUrl(unwrapId(url), ssr, canSkipImportAnalysis(url));
37625
37638
  if (depModule.lastHMRTimestamp > 0) {
37626
37639
  url = injectQuery(url, `t=${depModule.lastHMRTimestamp}`);
37627
37640
  }
@@ -37749,15 +37762,15 @@ function importAnalysisPlugin(config) {
37749
37762
  }
37750
37763
  }
37751
37764
  // record for HMR import chain analysis
37752
- // make sure to normalize away base
37753
- const urlWithoutBase = url.replace(base, '/');
37754
- importedUrls.add(urlWithoutBase);
37765
+ // make sure to unwrap and normalize away base
37766
+ const hmrUrl = unwrapId(url.replace(base, '/'));
37767
+ importedUrls.add(hmrUrl);
37755
37768
  if (enablePartialAccept && importedBindings) {
37756
37769
  extractImportedBindings(resolvedId, source, imports[index], importedBindings);
37757
37770
  }
37758
37771
  if (!isDynamicImport) {
37759
37772
  // for pre-transforming
37760
- staticImportedUrls.add({ url: urlWithoutBase, id: resolvedId });
37773
+ staticImportedUrls.add({ url: hmrUrl, id: resolvedId });
37761
37774
  }
37762
37775
  }
37763
37776
  else if (!importer.startsWith(clientDir)) {
@@ -37864,7 +37877,7 @@ function importAnalysisPlugin(config) {
37864
37877
  // by the deps optimizer
37865
37878
  if (config.server.preTransformRequests && staticImportedUrls.size) {
37866
37879
  staticImportedUrls.forEach(({ url, id }) => {
37867
- url = unwrapId(removeImportQuery(url)).replace(NULL_BYTE_PLACEHOLDER, '\0');
37880
+ url = removeImportQuery(url);
37868
37881
  transformRequest(url, server, { ssr }).catch((e) => {
37869
37882
  if (e?.code === ERR_OUTDATED_OPTIMIZED_DEP) {
37870
37883
  // This are expected errors
@@ -42582,8 +42595,20 @@ function stringifyDepsOptimizerMetadata(metadata, depsCacheDir) {
42582
42595
  }, 2);
42583
42596
  }
42584
42597
  function esbuildOutputFromId(outputs, id, cacheDirOutputPath) {
42598
+ const cwd = process.cwd();
42585
42599
  const flatId = flattenId(id) + '.js';
42586
- return outputs[normalizePath$3(path$n.relative(process.cwd(), path$n.join(cacheDirOutputPath, flatId)))];
42600
+ const normalizedOutputPath = normalizePath$3(path$n.relative(cwd, path$n.join(cacheDirOutputPath, flatId)));
42601
+ const output = outputs[normalizedOutputPath];
42602
+ if (output) {
42603
+ return output;
42604
+ }
42605
+ // If the root dir was symlinked, esbuild could return output keys as `../cwd/`
42606
+ // Normalize keys to support this case too
42607
+ for (const [key, value] of Object.entries(outputs)) {
42608
+ if (normalizePath$3(path$n.relative(cwd, key)) === normalizedOutputPath) {
42609
+ return value;
42610
+ }
42611
+ }
42587
42612
  }
42588
42613
  async function extractExportsData(filePath, config, ssr) {
42589
42614
  await init;
@@ -44487,7 +44512,7 @@ async function compileCSS(id, code, config, urlReplacer, atImportResolvers, serv
44487
44512
  logger: config.logger
44488
44513
  }));
44489
44514
  if (isModule) {
44490
- postcssPlugins.unshift((await import('./dep-b9b42dbd.js').then(function (n) { return n.i; })).default({
44515
+ postcssPlugins.unshift((await import('./dep-55b95cd5.js').then(function (n) { return n.i; })).default({
44491
44516
  ...modulesOptions,
44492
44517
  getJSON(cssFileName, _modules, outputFileName) {
44493
44518
  modules = _modules;
@@ -45644,7 +45669,7 @@ async function doBuild(inlineConfig = {}) {
45644
45669
  config.logger.info(picocolors.exports.cyan(`vite v${VERSION} ${picocolors.exports.green(`building ${ssr ? `SSR bundle ` : ``}for ${config.mode}...`)}`));
45645
45670
  const resolve = (p) => path$n.resolve(config.root, p);
45646
45671
  const input = libOptions
45647
- ? resolve(libOptions.entry)
45672
+ ? options.rollupOptions?.input || resolve(libOptions.entry)
45648
45673
  : typeof options.ssr === 'string'
45649
45674
  ? resolve(options.ssr)
45650
45675
  : options.rollupOptions?.input || resolve('index.html');
@@ -53276,7 +53301,7 @@ function rebindErrorStacktrace(e, stacktrace) {
53276
53301
  const pendingModules = new Map();
53277
53302
  const pendingImports = new Map();
53278
53303
  async function ssrLoadModule(url, server, context = { global }, urlStack = [], fixStacktrace) {
53279
- url = unwrapId(url).replace(NULL_BYTE_PLACEHOLDER, '\0');
53304
+ url = unwrapId(url);
53280
53305
  // when we instantiate multiple dependency modules in parallel, they may
53281
53306
  // point to shared modules. We need to avoid duplicate instantiation attempts
53282
53307
  // by register every module as pending synchronously so that all subsequent
@@ -53346,7 +53371,7 @@ async function instantiateModule(url, server, context = { global }, urlStack = [
53346
53371
  return nodeImport(dep, mod.file, resolveOptions);
53347
53372
  }
53348
53373
  // convert to rollup URL because `pendingImports`, `moduleGraph.urlToModuleMap` requires that
53349
- dep = unwrapId(dep).replace(NULL_BYTE_PLACEHOLDER, '\0');
53374
+ dep = unwrapId(dep);
53350
53375
  if (!isCircular(dep) && !pendingImports.get(dep)?.some(isCircular)) {
53351
53376
  pendingDeps.push(dep);
53352
53377
  if (pendingDeps.length === 1) {
@@ -60557,7 +60582,7 @@ const devHtmlHook = async (html, { path: htmlPath, filename, server, originalUrl
60557
60582
  // and ids are properly handled
60558
60583
  const validPath = `${htmlPath}${trailingSlash ? 'index.html' : ''}`;
60559
60584
  proxyModulePath = `\0${validPath}`;
60560
- proxyModuleUrl = `${VALID_ID_PREFIX}${NULL_BYTE_PLACEHOLDER}${validPath}`;
60585
+ proxyModuleUrl = wrapId(proxyModulePath);
60561
60586
  }
60562
60587
  const s = new MagicString(html);
60563
60588
  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-cff57044.js';
3
+ import { y as picocolors, u as createLogger, e as resolveConfig } from './chunks/dep-6b3a5aff.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-cff57044.js').then(function (n) { return n.C; });
698
+ const { createServer } = await import('./chunks/dep-6b3a5aff.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-cff57044.js').then(function (n) { return n.B; });
745
+ const { build } = await import('./chunks/dep-6b3a5aff.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-cff57044.js').then(function (n) { return n.A; });
769
+ const { optimizeDeps } = await import('./chunks/dep-6b3a5aff.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-cff57044.js').then(function (n) { return n.D; });
792
+ const { preview } = await import('./chunks/dep-6b3a5aff.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.2";
4
+ var version = "3.1.4";
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-cff57044.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-6b3a5aff.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.2";
34
+ var version = "3.1.4";
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.2",
3
+ "version": "3.1.4",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Evan You",