vite 4.3.0-beta.6 → 4.3.0-beta.7

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.

Potentially problematic release.


This version of vite might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  import require$$0__default from 'fs';
2
2
  import require$$0 from 'postcss';
3
- import { D as commonjsGlobal } from './dep-631467cd.js';
3
+ import { D as commonjsGlobal } from './dep-f1f8facc.js';
4
4
  import require$$0$1 from 'path';
5
5
  import require$$5 from 'crypto';
6
6
  import require$$0$2 from 'util';
@@ -28652,6 +28652,7 @@ function optimizedDepsBuildPlugin(config) {
28652
28652
  depsOptimizer.delayDepsOptimizerUntil(resolved.id, async () => {
28653
28653
  await this.load(resolved);
28654
28654
  });
28655
+ return resolved;
28655
28656
  }
28656
28657
  }
28657
28658
  },
@@ -37834,8 +37835,14 @@ function cssPlugin(config) {
37834
37835
  return fileToUrl(resolved, config, this);
37835
37836
  }
37836
37837
  if (config.command === 'build') {
37837
- // #9800 If we cannot resolve the css url, leave a warning.
37838
- config.logger.warnOnce(`\n${url} referenced in ${id} didn't resolve at build time, it will remain unchanged to be resolved at runtime`);
37838
+ const isExternal = config.build.rollupOptions.external
37839
+ ? resolveUserExternal(config.build.rollupOptions.external, url, // use URL as id since id could not be resolved
37840
+ id, false)
37841
+ : false;
37842
+ if (!isExternal) {
37843
+ // #9800 If we cannot resolve the css url, leave a warning.
37844
+ config.logger.warnOnce(`\n${url} referenced in ${id} didn't resolve at build time, it will remain unchanged to be resolved at runtime`);
37845
+ }
37839
37846
  }
37840
37847
  return url;
37841
37848
  };
@@ -38498,7 +38505,7 @@ function createCachedImport(imp) {
38498
38505
  };
38499
38506
  }
38500
38507
  const importPostcssImport = createCachedImport(() => import('./dep-e3f470e2.js').then(function (n) { return n.i; }));
38501
- const importPostcssModules = createCachedImport(() => import('./dep-9ae8857c.js').then(function (n) { return n.i; }));
38508
+ const importPostcssModules = createCachedImport(() => import('./dep-1a577c21.js').then(function (n) { return n.i; }));
38502
38509
  const importPostcss = createCachedImport(() => import('postcss'));
38503
38510
  /**
38504
38511
  * @experimental
@@ -43836,18 +43843,17 @@ async function createDepsOptimizer(config, server) {
43836
43843
  crawlEndFinder?.ensureFirstRun();
43837
43844
  }
43838
43845
  }
43839
- const runOptimizerIfIdleAfterMs = 50;
43846
+ const callCrawlEndIfIdleAfterMs = 50;
43840
43847
  function setupOnCrawlEnd(onCrawlEnd) {
43841
- let registeredIds = [];
43848
+ const registeredIds = new Set();
43842
43849
  const seenIds = new Set();
43843
43850
  const workersSources = new Set();
43844
- const waitingOn = new Map();
43845
- let firstRunEnsured = false;
43846
- let crawlEndCalled = false;
43851
+ let timeoutHandle;
43847
43852
  let cancelled = false;
43848
43853
  function cancel() {
43849
43854
  cancelled = true;
43850
43855
  }
43856
+ let crawlEndCalled = false;
43851
43857
  function callOnCrawlEnd() {
43852
43858
  if (!cancelled && !crawlEndCalled) {
43853
43859
  crawlEndCalled = true;
@@ -43857,13 +43863,14 @@ function setupOnCrawlEnd(onCrawlEnd) {
43857
43863
  // If all the inputs are dependencies, we aren't going to get any
43858
43864
  // delayDepsOptimizerUntil(id) calls. We need to guard against this
43859
43865
  // by forcing a rerun if no deps have been registered
43866
+ let firstRunEnsured = false;
43860
43867
  function ensureFirstRun() {
43861
43868
  if (!firstRunEnsured && seenIds.size === 0) {
43862
43869
  setTimeout(() => {
43863
43870
  if (seenIds.size === 0) {
43864
43871
  callOnCrawlEnd();
43865
43872
  }
43866
- }, runOptimizerIfIdleAfterMs);
43873
+ }, 200);
43867
43874
  }
43868
43875
  firstRunEnsured = true;
43869
43876
  }
@@ -43871,60 +43878,35 @@ function setupOnCrawlEnd(onCrawlEnd) {
43871
43878
  workersSources.add(id);
43872
43879
  // Avoid waiting for this id, as it may be blocked by the rollup
43873
43880
  // bundling process of the worker that also depends on the optimizer
43874
- registeredIds = registeredIds.filter((registered) => registered.id !== id);
43875
- const resolve = waitingOn.get(id);
43876
- // Forced resolve to avoid waiting for the bundling of the worker to finish
43877
- resolve?.();
43881
+ registeredIds.delete(id);
43882
+ checkIfCrawlEndAfterTimeout();
43878
43883
  }
43879
43884
  function delayDepsOptimizerUntil(id, done) {
43880
43885
  if (!seenIds.has(id)) {
43881
43886
  seenIds.add(id);
43882
- registeredIds.push({ id, done });
43883
- callOnCrawlEndWhenIdle();
43887
+ if (!workersSources.has(id)) {
43888
+ registeredIds.add(id);
43889
+ done()
43890
+ .catch(() => { })
43891
+ .finally(() => markIdAsDone(id));
43892
+ }
43884
43893
  }
43885
43894
  }
43895
+ function markIdAsDone(id) {
43896
+ registeredIds.delete(id);
43897
+ checkIfCrawlEndAfterTimeout();
43898
+ }
43899
+ function checkIfCrawlEndAfterTimeout() {
43900
+ if (cancelled || registeredIds.size > 0)
43901
+ return;
43902
+ if (timeoutHandle)
43903
+ clearTimeout(timeoutHandle);
43904
+ timeoutHandle = setTimeout(callOnCrawlEndWhenIdle, callCrawlEndIfIdleAfterMs);
43905
+ }
43886
43906
  async function callOnCrawlEndWhenIdle() {
43887
- if (cancelled || waitingOn.size > 0)
43907
+ if (cancelled || registeredIds.size > 0)
43888
43908
  return;
43889
- const processingRegisteredIds = registeredIds;
43890
- registeredIds = [];
43891
- const donePromises = processingRegisteredIds.map(async (registeredId) => {
43892
- // During build, we need to cancel workers
43893
- let resolve;
43894
- const waitUntilDone = new Promise((_resolve) => {
43895
- resolve = _resolve;
43896
- registeredId
43897
- .done()
43898
- .catch(() => {
43899
- // Ignore errors
43900
- })
43901
- .finally(() => resolve());
43902
- });
43903
- waitingOn.set(registeredId.id, () => resolve());
43904
- await waitUntilDone;
43905
- waitingOn.delete(registeredId.id);
43906
- });
43907
- const afterLoad = () => {
43908
- if (cancelled)
43909
- return;
43910
- if (registeredIds.length > 0 &&
43911
- registeredIds.every((registeredId) => workersSources.has(registeredId.id))) {
43912
- return;
43913
- }
43914
- if (registeredIds.length > 0) {
43915
- callOnCrawlEndWhenIdle();
43916
- }
43917
- else {
43918
- callOnCrawlEnd();
43919
- }
43920
- };
43921
- await Promise.allSettled(donePromises);
43922
- if (registeredIds.length > 0) {
43923
- afterLoad();
43924
- }
43925
- else {
43926
- setTimeout(afterLoad, runOptimizerIfIdleAfterMs);
43927
- }
43909
+ callOnCrawlEnd();
43928
43910
  }
43929
43911
  return {
43930
43912
  ensureFirstRun,
@@ -44038,22 +44020,18 @@ function addOptimizedDepInfo(metadata, type, depInfo) {
44038
44020
  metadata.depInfoList.push(depInfo);
44039
44021
  return depInfo;
44040
44022
  }
44023
+ let firstLoadCachedDepOptimizationMetadata = true;
44041
44024
  /**
44042
44025
  * Creates the initial dep optimization metadata, loading it from the deps cache
44043
44026
  * if it exists and pre-bundling isn't forced
44044
44027
  */
44045
44028
  async function loadCachedDepOptimizationMetadata(config, ssr, force = config.optimizeDeps.force, asCommand = false) {
44046
44029
  const log = asCommand ? config.logger.info : debug$7;
44047
- setTimeout(() => {
44048
- // Before Vite 2.9, dependencies were cached in the root of the cacheDir
44049
- // For compat, we remove the cache if we find the old structure
44050
- if (fs$l.existsSync(path$o.join(config.cacheDir, '_metadata.json'))) {
44051
- emptyDir(config.cacheDir);
44052
- }
44053
- // Fire a clean up of stale cache dirs, in case old processes didn't
44054
- // terminate correctly
44055
- cleanupDepsCacheStaleDirs(config);
44056
- }, 100);
44030
+ if (firstLoadCachedDepOptimizationMetadata) {
44031
+ firstLoadCachedDepOptimizationMetadata = false;
44032
+ // Fire up a clean up of stale processing deps dirs if older process exited early
44033
+ setTimeout(() => cleanupDepsCacheStaleDirs(config), 0);
44034
+ }
44057
44035
  const depsCacheDir = getDepsCacheDir(config, ssr);
44058
44036
  if (!force) {
44059
44037
  let cachedMetadata;
@@ -44300,7 +44278,7 @@ async function prepareEsbuildOptimizerRun(resolvedConfig, depsInfo, ssr, process
44300
44278
  const idToExports = {};
44301
44279
  const optimizeDeps = getDepOptimizationConfig(config, ssr);
44302
44280
  const { plugins: pluginsFromConfig = [], ...esbuildOptions } = optimizeDeps?.esbuildOptions ?? {};
44303
- for (const id in depsInfo) {
44281
+ await Promise.all(Object.keys(depsInfo).map(async (id) => {
44304
44282
  const src = depsInfo[id].src;
44305
44283
  const exportsData = await (depsInfo[id].exportsData ??
44306
44284
  extractExportsData(src, config, ssr));
@@ -44315,7 +44293,7 @@ async function prepareEsbuildOptimizerRun(resolvedConfig, depsInfo, ssr, process
44315
44293
  const flatId = flattenId(id);
44316
44294
  flatIdDeps[flatId] = src;
44317
44295
  idToExports[id] = exportsData;
44318
- }
44296
+ }));
44319
44297
  if (optimizerContext.cancelled)
44320
44298
  return { context: undefined, idToExports };
44321
44299
  // esbuild automatically replaces process.env.NODE_ENV for platform 'browser'
@@ -46307,6 +46285,7 @@ var build$1 = {
46307
46285
  resolveBuildOutputs: resolveBuildOutputs,
46308
46286
  resolveBuildPlugins: resolveBuildPlugins,
46309
46287
  resolveLibFilename: resolveLibFilename,
46288
+ resolveUserExternal: resolveUserExternal,
46310
46289
  toOutputFilePathInCss: toOutputFilePathInCss,
46311
46290
  toOutputFilePathInHtml: toOutputFilePathInHtml,
46312
46291
  toOutputFilePathInJS: toOutputFilePathInJS,
@@ -63689,7 +63668,7 @@ function compression() {
63689
63668
  // disable Brotli on Node<12.7 where it is unsupported:
63690
63669
  if (!zlib$1.createBrotliCompress)
63691
63670
  brotli = false;
63692
- return (req, res, next = noop) => {
63671
+ return function viteCompressionMiddleware(req, res, next = noop) {
63693
63672
  const accept = req.headers['accept-encoding'] + '';
63694
63673
  const encoding = ((brotli && accept.match(/\bbr\b/)) ||
63695
63674
  (accept.match(/\bgzip\b/)) ||
@@ -63846,7 +63825,7 @@ async function preview(inlineConfig = {}) {
63846
63825
  const previewBase = config.base === './' || config.base === '' ? '/' : config.base;
63847
63826
  // static assets
63848
63827
  const headers = config.preview.headers;
63849
- const assetServer = sirv(distDir, {
63828
+ const viteAssetMiddleware = (...args) => sirv(distDir, {
63850
63829
  etag: true,
63851
63830
  dev: true,
63852
63831
  single: config.appType === 'spa',
@@ -63860,8 +63839,8 @@ async function preview(inlineConfig = {}) {
63860
63839
  shouldServe(filePath) {
63861
63840
  return shouldServeFile(filePath, distDir);
63862
63841
  },
63863
- });
63864
- app.use(previewBase, assetServer);
63842
+ })(...args);
63843
+ app.use(previewBase, viteAssetMiddleware);
63865
63844
  // apply post server hooks from plugins
63866
63845
  postHooks.forEach((fn) => fn && fn());
63867
63846
  const hostname = await resolveHostname(options.host);
package/dist/node/cli.js CHANGED
@@ -2,7 +2,7 @@ import path from 'node:path';
2
2
  import fs from 'node:fs';
3
3
  import { performance } from 'node:perf_hooks';
4
4
  import { EventEmitter } from 'events';
5
- import { B as picocolorsExports, C as bindShortcuts, x as createLogger, h as resolveConfig } from './chunks/dep-631467cd.js';
5
+ import { B as picocolorsExports, C as bindShortcuts, x as createLogger, h as resolveConfig } from './chunks/dep-f1f8facc.js';
6
6
  import { VERSION } from './constants.js';
7
7
  import 'node:fs/promises';
8
8
  import 'node:url';
@@ -728,7 +728,7 @@ cli
728
728
  filterDuplicateOptions(options);
729
729
  // output structure is preserved even after bundling so require()
730
730
  // is ok here
731
- const { createServer } = await import('./chunks/dep-631467cd.js').then(function (n) { return n.G; });
731
+ const { createServer } = await import('./chunks/dep-f1f8facc.js').then(function (n) { return n.G; });
732
732
  try {
733
733
  const server = await createServer({
734
734
  root,
@@ -806,7 +806,7 @@ cli
806
806
  .option('-w, --watch', `[boolean] rebuilds when modules have changed on disk`)
807
807
  .action(async (root, options) => {
808
808
  filterDuplicateOptions(options);
809
- const { build } = await import('./chunks/dep-631467cd.js').then(function (n) { return n.F; });
809
+ const { build } = await import('./chunks/dep-f1f8facc.js').then(function (n) { return n.F; });
810
810
  const buildOptions = cleanOptions(options);
811
811
  try {
812
812
  await build({
@@ -834,7 +834,7 @@ cli
834
834
  .option('--force', `[boolean] force the optimizer to ignore the cache and re-bundle`)
835
835
  .action(async (root, options) => {
836
836
  filterDuplicateOptions(options);
837
- const { optimizeDeps } = await import('./chunks/dep-631467cd.js').then(function (n) { return n.E; });
837
+ const { optimizeDeps } = await import('./chunks/dep-f1f8facc.js').then(function (n) { return n.E; });
838
838
  try {
839
839
  const config = await resolveConfig({
840
840
  root,
@@ -860,7 +860,7 @@ cli
860
860
  .option('--outDir <dir>', `[string] output directory (default: dist)`)
861
861
  .action(async (root, options) => {
862
862
  filterDuplicateOptions(options);
863
- const { preview } = await import('./chunks/dep-631467cd.js').then(function (n) { return n.H; });
863
+ const { preview } = await import('./chunks/dep-f1f8facc.js').then(function (n) { return n.H; });
864
864
  try {
865
865
  const server = await preview({
866
866
  root,
@@ -1,5 +1,5 @@
1
- import { i as isInNodeModules } from './chunks/dep-631467cd.js';
2
- export { b as build, e as buildErrorMessage, v as createFilter, x as createLogger, c as createServer, g as defineConfig, f as formatPostcssSourceMap, k as getDepOptimizationConfig, m as isDepsOptimizerEnabled, l as loadConfigFromFile, z as loadEnv, u as mergeAlias, q as mergeConfig, n as normalizePath, o as optimizeDeps, a as preprocessCSS, p as preview, j as resolveBaseUrl, h as resolveConfig, A as resolveEnvPrefix, d as resolvePackageData, r as resolvePackageEntry, y as searchForWorkspaceRoot, w as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-631467cd.js';
1
+ import { i as isInNodeModules } from './chunks/dep-f1f8facc.js';
2
+ export { b as build, e as buildErrorMessage, v as createFilter, x as createLogger, c as createServer, g as defineConfig, f as formatPostcssSourceMap, k as getDepOptimizationConfig, m as isDepsOptimizerEnabled, l as loadConfigFromFile, z as loadEnv, u as mergeAlias, q as mergeConfig, n as normalizePath, o as optimizeDeps, a as preprocessCSS, p as preview, j as resolveBaseUrl, h as resolveConfig, A as resolveEnvPrefix, d as resolvePackageData, r as resolvePackageEntry, y as searchForWorkspaceRoot, w as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-f1f8facc.js';
3
3
  export { VERSION as version } from './constants.js';
4
4
  export { version as esbuildVersion } from 'esbuild';
5
5
  export { VERSION as rollupVersion } from 'rollup';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite",
3
- "version": "4.3.0-beta.6",
3
+ "version": "4.3.0-beta.7",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Evan You",