vite 4.0.0-beta.4 → 4.0.0-beta.5

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,6 +1,6 @@
1
1
  import require$$0__default from 'fs';
2
2
  import require$$0 from 'postcss';
3
- import { C as commonjsGlobal } from './dep-3f45d7c9.js';
3
+ import { C as commonjsGlobal } from './dep-4fae821a.js';
4
4
  import require$$0$1 from 'path';
5
5
  import require$$5 from 'crypto';
6
6
  import require$$0$2 from 'util';
@@ -12597,8 +12597,9 @@ function printServerUrls(urls, optionsHost, info) {
12597
12597
  info(` ${picocolors.exports.green('➜')} ${picocolors.exports.bold('Network')}: ${colorUrl(url)}`);
12598
12598
  }
12599
12599
  if (urls.network.length === 0 && optionsHost === undefined) {
12600
- const note = `use ${picocolors.exports.reset(picocolors.exports.bold('--host'))} to expose`;
12601
- info(picocolors.exports.dim(` ${picocolors.exports.green('➜')} ${picocolors.exports.bold('Network')}: ${note}`));
12600
+ info(picocolors.exports.dim(` ${picocolors.exports.green('➜')} ${picocolors.exports.bold('Network')}: use `) +
12601
+ picocolors.exports.bold('--host') +
12602
+ picocolors.exports.dim(' to expose'));
12602
12603
  }
12603
12604
  }
12604
12605
 
@@ -37612,7 +37613,7 @@ async function compileCSS(id, code, config, urlReplacer) {
37612
37613
  }));
37613
37614
  }
37614
37615
  if (isModule) {
37615
- postcssPlugins.unshift((await import('./dep-504e6b2a.js').then(function (n) { return n.i; })).default({
37616
+ postcssPlugins.unshift((await import('./dep-05d1f315.js').then(function (n) { return n.i; })).default({
37616
37617
  ...modulesOptions,
37617
37618
  localsConvention: modulesOptions?.localsConvention,
37618
37619
  getJSON(cssFileName, _modules, outputFileName) {
@@ -42672,16 +42673,19 @@ async function scanImports(config) {
42672
42673
  const container = await createPluginContainer(config);
42673
42674
  const plugin = esbuildScanPlugin(config, container, deps, missing, entries);
42674
42675
  const { plugins = [], ...esbuildOptions } = config.optimizeDeps?.esbuildOptions ?? {};
42675
- await Promise.all(entries.map((entry) => build$3({
42676
+ await build$3({
42676
42677
  absWorkingDir: process.cwd(),
42677
42678
  write: false,
42678
- entryPoints: [entry],
42679
+ stdin: {
42680
+ contents: entries.map((e) => `import ${JSON.stringify(e)}`).join('\n'),
42681
+ loader: 'js',
42682
+ },
42679
42683
  bundle: true,
42680
42684
  format: 'esm',
42681
42685
  logLevel: 'error',
42682
42686
  plugins: [...plugins, plugin],
42683
42687
  ...esbuildOptions,
42684
- })));
42688
+ });
42685
42689
  debug$8(`Scan completed in ${(performance.now() - start).toFixed(2)}ms:`, deps);
42686
42690
  return {
42687
42691
  // Ensure a fixed order so hashes are stable and improve logs
@@ -43127,15 +43131,14 @@ async function createDepsOptimizer(config, server) {
43127
43131
  // If there wasn't a cache or it is outdated, we need to prepare a first run
43128
43132
  let firstRunCalled = !!cachedMetadata;
43129
43133
  let postScanOptimizationResult;
43130
- let discoverProjectDependenciesPromise;
43131
43134
  let optimizingNewDeps;
43132
43135
  async function close() {
43133
43136
  closed = true;
43134
- await discoverProjectDependenciesPromise?.catch(() => {
43135
- /* ignore error for scanner because it's not important */
43136
- });
43137
- await postScanOptimizationResult;
43138
- await optimizingNewDeps;
43137
+ await Promise.allSettled([
43138
+ depsOptimizer.scanProcessing,
43139
+ postScanOptimizationResult,
43140
+ optimizingNewDeps,
43141
+ ]);
43139
43142
  }
43140
43143
  if (!cachedMetadata) {
43141
43144
  // Enter processing state until crawl of static imports ends
@@ -43153,43 +43156,41 @@ async function createDepsOptimizer(config, server) {
43153
43156
  }
43154
43157
  if (!isBuild) {
43155
43158
  // Important, the scanner is dev only
43156
- const scanPhaseProcessing = newDepOptimizationProcessing();
43157
- depsOptimizer.scanProcessing = scanPhaseProcessing.promise;
43158
- // Ensure server listen is called before the scanner
43159
- setTimeout(async () => {
43160
- try {
43161
- debuggerViteDeps(picocolors.exports.green(`scanning for dependencies...`));
43162
- discoverProjectDependenciesPromise =
43163
- discoverProjectDependencies(config);
43164
- const deps = await discoverProjectDependenciesPromise;
43165
- debuggerViteDeps(picocolors.exports.green(Object.keys(deps).length > 0
43166
- ? `dependencies found by scanner: ${depsLogString(Object.keys(deps))}`
43167
- : `no dependencies found by scanner`));
43168
- // Add these dependencies to the discovered list, as these are currently
43169
- // used by the preAliasPlugin to support aliased and optimized deps.
43170
- // This is also used by the CJS externalization heuristics in legacy mode
43171
- for (const id of Object.keys(deps)) {
43172
- if (!metadata.discovered[id]) {
43173
- addMissingDep(id, deps[id]);
43159
+ depsOptimizer.scanProcessing = new Promise((resolve) => {
43160
+ // Ensure server listen is called before the scanner
43161
+ setTimeout(async () => {
43162
+ try {
43163
+ debuggerViteDeps(picocolors.exports.green(`scanning for dependencies...`));
43164
+ const deps = await discoverProjectDependencies(config);
43165
+ debuggerViteDeps(picocolors.exports.green(Object.keys(deps).length > 0
43166
+ ? `dependencies found by scanner: ${depsLogString(Object.keys(deps))}`
43167
+ : `no dependencies found by scanner`));
43168
+ // Add these dependencies to the discovered list, as these are currently
43169
+ // used by the preAliasPlugin to support aliased and optimized deps.
43170
+ // This is also used by the CJS externalization heuristics in legacy mode
43171
+ for (const id of Object.keys(deps)) {
43172
+ if (!metadata.discovered[id]) {
43173
+ addMissingDep(id, deps[id]);
43174
+ }
43175
+ }
43176
+ if (!isBuild) {
43177
+ const knownDeps = prepareKnownDeps();
43178
+ // For dev, we run the scanner and the first optimization
43179
+ // run on the background, but we wait until crawling has ended
43180
+ // to decide if we send this result to the browser or we need to
43181
+ // do another optimize step
43182
+ postScanOptimizationResult = runOptimizeDeps(config, knownDeps);
43174
43183
  }
43175
43184
  }
43176
- if (!isBuild) {
43177
- const knownDeps = prepareKnownDeps();
43178
- // For dev, we run the scanner and the first optimization
43179
- // run on the background, but we wait until crawling has ended
43180
- // to decide if we send this result to the browser or we need to
43181
- // do another optimize step
43182
- postScanOptimizationResult = runOptimizeDeps(config, knownDeps);
43185
+ catch (e) {
43186
+ logger.error(e.message);
43183
43187
  }
43184
- }
43185
- catch (e) {
43186
- logger.error(e.message);
43187
- }
43188
- finally {
43189
- scanPhaseProcessing.resolve();
43190
- depsOptimizer.scanProcessing = undefined;
43191
- }
43192
- }, 0);
43188
+ finally {
43189
+ resolve();
43190
+ depsOptimizer.scanProcessing = undefined;
43191
+ }
43192
+ }, 0);
43193
+ });
43193
43194
  }
43194
43195
  }
43195
43196
  function startNextDiscoveredBatch() {
@@ -54447,11 +54448,13 @@ function bindShortcuts(server, opts) {
54447
54448
  if (actionRunning)
54448
54449
  return;
54449
54450
  if (input === 'h') {
54450
- server.config.logger.info(shortcuts
54451
- .map((shortcut) => picocolors.exports.dim(' press ') +
54452
- picocolors.exports.bold(shortcut.key) +
54453
- picocolors.exports.dim(` to ${shortcut.description}`))
54454
- .join('\n'));
54451
+ server.config.logger.info([
54452
+ '',
54453
+ picocolors.exports.bold(' Shortcuts'),
54454
+ ...shortcuts.map((shortcut) => picocolors.exports.dim(' press ') +
54455
+ picocolors.exports.bold(shortcut.key) +
54456
+ picocolors.exports.dim(` to ${shortcut.description}`)),
54457
+ ].join('\n'));
54455
54458
  }
54456
54459
  const shortcut = shortcuts.find((shortcut) => shortcut.key === input);
54457
54460
  if (!shortcut)
@@ -61944,7 +61947,7 @@ async function createServer(inlineConfig = {}) {
61944
61947
  process.stdin.off('end', exitProcess);
61945
61948
  }
61946
61949
  }
61947
- await Promise.all([
61950
+ await Promise.allSettled([
61948
61951
  watcher.close(),
61949
61952
  ws.close(),
61950
61953
  container.close(),
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 { A as picocolors, B as bindShortcuts, w as createLogger, h as resolveConfig } from './chunks/dep-3f45d7c9.js';
5
+ import { A as picocolors, B as bindShortcuts, w as createLogger, h as resolveConfig } from './chunks/dep-4fae821a.js';
6
6
  import { VERSION } from './constants.js';
7
7
  import 'node:url';
8
8
  import 'node:module';
@@ -725,7 +725,7 @@ cli
725
725
  filterDuplicateOptions(options);
726
726
  // output structure is preserved even after bundling so require()
727
727
  // is ok here
728
- const { createServer } = await import('./chunks/dep-3f45d7c9.js').then(function (n) { return n.F; });
728
+ const { createServer } = await import('./chunks/dep-4fae821a.js').then(function (n) { return n.F; });
729
729
  try {
730
730
  const server = await createServer({
731
731
  root,
@@ -804,7 +804,7 @@ cli
804
804
  .option('-w, --watch', `[boolean] rebuilds when modules have changed on disk`)
805
805
  .action(async (root, options) => {
806
806
  filterDuplicateOptions(options);
807
- const { build } = await import('./chunks/dep-3f45d7c9.js').then(function (n) { return n.E; });
807
+ const { build } = await import('./chunks/dep-4fae821a.js').then(function (n) { return n.E; });
808
808
  const buildOptions = cleanOptions(options);
809
809
  try {
810
810
  await build({
@@ -832,7 +832,7 @@ cli
832
832
  .option('--force', `[boolean] force the optimizer to ignore the cache and re-bundle`)
833
833
  .action(async (root, options) => {
834
834
  filterDuplicateOptions(options);
835
- const { optimizeDeps } = await import('./chunks/dep-3f45d7c9.js').then(function (n) { return n.D; });
835
+ const { optimizeDeps } = await import('./chunks/dep-4fae821a.js').then(function (n) { return n.D; });
836
836
  try {
837
837
  const config = await resolveConfig({
838
838
  root,
@@ -857,7 +857,7 @@ cli
857
857
  .option('--outDir <dir>', `[string] output directory (default: dist)`)
858
858
  .action(async (root, options) => {
859
859
  filterDuplicateOptions(options);
860
- const { preview } = await import('./chunks/dep-3f45d7c9.js').then(function (n) { return n.G; });
860
+ const { preview } = await import('./chunks/dep-4fae821a.js').then(function (n) { return n.G; });
861
861
  try {
862
862
  const server = await preview({
863
863
  root,
@@ -1,4 +1,4 @@
1
- export { b as build, e as buildErrorMessage, u as createFilter, w as createLogger, c as createServer, g as defineConfig, f as formatPostcssSourceMap, j as getDepOptimizationConfig, k as isDepsOptimizerEnabled, l as loadConfigFromFile, y as loadEnv, q as mergeAlias, m as mergeConfig, n as normalizePath, o as optimizeDeps, a as preprocessCSS, p as preview, i as resolveBaseUrl, h as resolveConfig, z as resolveEnvPrefix, d as resolvePackageData, r as resolvePackageEntry, x as searchForWorkspaceRoot, v as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-3f45d7c9.js';
1
+ export { b as build, e as buildErrorMessage, u as createFilter, w as createLogger, c as createServer, g as defineConfig, f as formatPostcssSourceMap, j as getDepOptimizationConfig, k as isDepsOptimizerEnabled, l as loadConfigFromFile, y as loadEnv, q as mergeAlias, m as mergeConfig, n as normalizePath, o as optimizeDeps, a as preprocessCSS, p as preview, i as resolveBaseUrl, h as resolveConfig, z as resolveEnvPrefix, d as resolvePackageData, r as resolvePackageEntry, x as searchForWorkspaceRoot, v as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-4fae821a.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';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite",
3
- "version": "4.0.0-beta.4",
3
+ "version": "4.0.0-beta.5",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Evan You",