vite 4.0.0-alpha.3 → 4.0.0-alpha.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 fs$l, { promises as promises$2 } from 'node:fs';
2
- import path$o, { posix as posix$1, isAbsolute as isAbsolute$2, resolve as resolve$6, join as join$2, relative as relative$2, dirname as dirname$2, basename as basename$2, extname as extname$1 } from 'node:path';
3
- import { URL as URL$3, URLSearchParams, parse as parse$j, pathToFileURL as pathToFileURL$1 } from 'node:url';
2
+ import path$o, { posix as posix$1, isAbsolute as isAbsolute$2, join as join$2, relative as relative$2, dirname as dirname$2, basename as basename$2, extname as extname$1 } from 'node:path';
3
+ import { URL as URL$3, URLSearchParams, parse as parse$j, pathToFileURL } from 'node:url';
4
4
  import { performance } from 'node:perf_hooks';
5
5
  import { createRequire as createRequire$1, builtinModules } from 'node:module';
6
6
  import require$$0$3 from 'tty';
@@ -12,7 +12,7 @@ import require$$0$5 from 'events';
12
12
  import assert$1 from 'assert';
13
13
  import require$$0$6, { format as format$2, inspect } from 'util';
14
14
  import require$$3$1 from 'net';
15
- import require$$0$9, { pathToFileURL } from 'url';
15
+ import require$$0$9 from 'url';
16
16
  import require$$1$1 from 'http';
17
17
  import require$$0$7 from 'stream';
18
18
  import require$$2 from 'os';
@@ -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, NULL_BYTE_PLACEHOLDER, FS_PREFIX, CLIENT_PUBLIC_PATH, ENV_PUBLIC_PATH, ENV_ENTRY, DEFAULT_MAIN_FIELDS, SPECIAL_QUERY_RE, DEP_VERSION_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';
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, SPECIAL_QUERY_RE, DEP_VERSION_RE, KNOWN_ASSET_TYPES, CLIENT_DIR, JS_TYPES_RE, ESBUILD_MODULES_TARGET, VERSION as VERSION$1, VITE_PACKAGE_DIR, DEFAULT_ASSETS_RE, DEFAULT_CONFIG_FILES } from '../constants.js';
26
26
  import require$$5 from 'crypto';
27
27
  import { Buffer as Buffer$1 } from 'node:buffer';
28
28
  import require$$0$8, { createRequire as createRequire$2 } from 'module';
@@ -32,6 +32,7 @@ import require$$1$2 from 'https';
32
32
  import require$$4 from 'tls';
33
33
  import { STATUS_CODES } from 'node:http';
34
34
  import { createServer as createServer$2 } from 'node:https';
35
+ import { VERSION } from 'rollup';
35
36
  import * as qs from 'querystring';
36
37
  import readline from 'node:readline';
37
38
  import { execSync } from 'node:child_process';
@@ -12671,21 +12672,21 @@ function buildReporterPlugin(config) {
12671
12672
  const chunkLimit = config.build.chunkSizeWarningLimit;
12672
12673
  function isLarge(code) {
12673
12674
  // bail out on particularly large chunks
12674
- return code.length / 1024 > chunkLimit;
12675
+ return code.length / 1000 > chunkLimit;
12675
12676
  }
12676
12677
  async function getCompressedSize(code) {
12677
12678
  if (config.build.ssr || !config.build.reportCompressedSize) {
12678
12679
  return '';
12679
12680
  }
12680
- return ` / gzip: ${((await compress(typeof code === 'string' ? code : Buffer.from(code)))
12681
- .length / 1024).toFixed(2)} KiB`;
12681
+ return ` / gzip: ${displaySize((await compress(typeof code === 'string' ? code : Buffer.from(code)))
12682
+ .length / 1000)}`;
12682
12683
  }
12683
12684
  function printFileInfo(filePath, content, type, maxLength, outDir = config.build.outDir, compressedSize = '') {
12684
12685
  outDir =
12685
12686
  normalizePath$3(path$o.relative(config.root, path$o.resolve(config.root, outDir))) + '/';
12686
- const kibs = content.length / 1024;
12687
- const sizeColor = kibs > chunkLimit ? picocolors.exports.yellow : picocolors.exports.dim;
12688
- config.logger.info(`${picocolors.exports.gray(picocolors.exports.white(picocolors.exports.dim(outDir)))}${writeColors[type](filePath.padEnd(maxLength + 2))} ${sizeColor(`${kibs.toFixed(2)} KiB${compressedSize}`)}`);
12687
+ const kB = content.length / 1000;
12688
+ const sizeColor = kB > chunkLimit ? picocolors.exports.yellow : picocolors.exports.dim;
12689
+ config.logger.info(`${picocolors.exports.gray(picocolors.exports.white(picocolors.exports.dim(outDir)))}${writeColors[type](filePath.padEnd(maxLength + 2))} ${sizeColor(`${displaySize(kB)}${compressedSize}`)}`);
12689
12690
  }
12690
12691
  const tty = process.stdout.isTTY && !process.env.CI;
12691
12692
  const shouldLogInfo = LogLevels[config.logLevel || 'info'] >= LogLevels.info;
@@ -12792,14 +12793,14 @@ function buildReporterPlugin(config) {
12792
12793
  else {
12793
12794
  hasLargeChunks = Object.keys(output).some((file) => {
12794
12795
  const chunk = output[file];
12795
- return chunk.type === 'chunk' && chunk.code.length / 1024 > chunkLimit;
12796
+ return chunk.type === 'chunk' && chunk.code.length / 1000 > chunkLimit;
12796
12797
  });
12797
12798
  }
12798
12799
  if (hasLargeChunks &&
12799
12800
  config.build.minify &&
12800
12801
  !config.build.lib &&
12801
12802
  !config.build.ssr) {
12802
- config.logger.warn(picocolors.exports.yellow(`\n(!) Some chunks are larger than ${chunkLimit} KiB after minification. Consider:\n` +
12803
+ config.logger.warn(picocolors.exports.yellow(`\n(!) Some chunks are larger than ${chunkLimit} kBs after minification. Consider:\n` +
12803
12804
  `- Using dynamic import() to code-split the application\n` +
12804
12805
  `- Use build.rollupOptions.output.manualChunks to improve chunking: https://rollupjs.org/guide/en/#outputmanualchunks\n` +
12805
12806
  `- Adjust chunk size limit for this warning via build.chunkSizeWarningLimit.`));
@@ -12828,6 +12829,12 @@ function throttle(fn) {
12828
12829
  }, 100);
12829
12830
  };
12830
12831
  }
12832
+ function displaySize(kB) {
12833
+ return `${kB.toLocaleString('en', {
12834
+ maximumFractionDigits: 2,
12835
+ minimumFractionDigits: 2
12836
+ })} kB`;
12837
+ }
12831
12838
 
12832
12839
  var __defProp = Object.defineProperty;
12833
12840
  var __defProps = Object.defineProperties;
@@ -20457,43 +20464,6 @@ var acorn = {
20457
20464
  version: version
20458
20465
  };
20459
20466
 
20460
- const HASH_RE = /#/g;
20461
- const AMPERSAND_RE = /&/g;
20462
- const EQUAL_RE = /=/g;
20463
- const PLUS_RE = /\+/g;
20464
- const ENC_BRACKET_OPEN_RE = /%5B/gi;
20465
- const ENC_BRACKET_CLOSE_RE = /%5D/gi;
20466
- const ENC_CARET_RE = /%5E/gi;
20467
- const ENC_BACKTICK_RE = /%60/gi;
20468
- const ENC_CURLY_OPEN_RE = /%7B/gi;
20469
- const ENC_PIPE_RE = /%7C/gi;
20470
- const ENC_CURLY_CLOSE_RE = /%7D/gi;
20471
- const ENC_SPACE_RE = /%20/gi;
20472
- function encode(text) {
20473
- return encodeURI("" + text).replace(ENC_PIPE_RE, "|").replace(ENC_BRACKET_OPEN_RE, "[").replace(ENC_BRACKET_CLOSE_RE, "]");
20474
- }
20475
- function encodeQueryValue(text) {
20476
- return encode(text).replace(PLUS_RE, "%2B").replace(ENC_SPACE_RE, "+").replace(HASH_RE, "%23").replace(AMPERSAND_RE, "%26").replace(ENC_BACKTICK_RE, "`").replace(ENC_CURLY_OPEN_RE, "{").replace(ENC_CURLY_CLOSE_RE, "}").replace(ENC_CARET_RE, "^");
20477
- }
20478
- function encodeQueryKey(text) {
20479
- return encodeQueryValue(text).replace(EQUAL_RE, "%3D");
20480
- }
20481
- function encodeQueryItem(key, val) {
20482
- if (typeof val === "number" || typeof val === "boolean") {
20483
- val = String(val);
20484
- }
20485
- if (!val) {
20486
- return encodeQueryKey(key);
20487
- }
20488
- if (Array.isArray(val)) {
20489
- return val.map((_val) => `${encodeQueryKey(key)}=${encodeQueryValue(_val)}`).join("&");
20490
- }
20491
- return `${encodeQueryKey(key)}=${encodeQueryValue(val)}`;
20492
- }
20493
- function stringifyQuery(query) {
20494
- return Object.keys(query).map((k) => encodeQueryItem(k, query[k])).join("&");
20495
- }
20496
-
20497
20467
  function matchAll(regex, string, addition) {
20498
20468
  const matches = [];
20499
20469
  for (const match of string.matchAll(regex)) {
@@ -20699,22 +20669,22 @@ function getMessage(key, args, self) {
20699
20669
  Object.freeze(["node", "import"]);
20700
20670
  pathToFileURL(process.cwd());
20701
20671
 
20702
- const ESM_STATIC_IMPORT_RE = /(?<=\s|^|;)import\s*(["'\s]*(?<imports>[\w*${}\n\r\t, /]+)from\s*)?["']\s*(?<specifier>(?<="\s*)[^"]*[^"\s](?=\s*")|(?<='\s*)[^']*[^'\s](?=\s*'))\s*["'][\s;]*/gm;
20672
+ const ESM_STATIC_IMPORT_RE = /(?<=\s|^|;)import\s*([\s"']*(?<imports>[\w\t\n\r $*,/{}]+)from\s*)?["']\s*(?<specifier>(?<="\s*)[^"]*[^\s"](?=\s*")|(?<='\s*)[^']*[^\s'](?=\s*'))\s*["'][\s;]*/gm;
20703
20673
  function findStaticImports(code) {
20704
20674
  return matchAll(ESM_STATIC_IMPORT_RE, code, { type: "static" });
20705
20675
  }
20706
20676
  function parseStaticImport(matched) {
20707
20677
  const cleanedImports = (matched.imports || "").replace(/(\/\/[^\n]*\n|\/\*.*\*\/)/g, "").replace(/\s+/g, " ");
20708
20678
  const namedImports = {};
20709
- for (const namedImport of cleanedImports.match(/\{([^}]*)\}/)?.[1]?.split(",") || []) {
20710
- const [, source = namedImport.trim(), importName = source] = namedImport.match(/^\s*([^\s]*) as ([^\s]*)\s*$/) || [];
20679
+ for (const namedImport of cleanedImports.match(/{([^}]*)}/)?.[1]?.split(",") || []) {
20680
+ const [, source = namedImport.trim(), importName = source] = namedImport.match(/^\s*(\S*) as (\S*)\s*$/) || [];
20711
20681
  if (source) {
20712
20682
  namedImports[source] = importName;
20713
20683
  }
20714
20684
  }
20715
- const topLevelImports = cleanedImports.replace(/\{([^}]*)\}/, "");
20716
- const namespacedImport = topLevelImports.match(/\* as \s*([^\s]*)/)?.[1];
20717
- const defaultImport = topLevelImports.split(",").find((i) => !i.match(/[*{}]/))?.trim() || void 0;
20685
+ const topLevelImports = cleanedImports.replace(/{([^}]*)}/, "");
20686
+ const namespacedImport = topLevelImports.match(/\* as \s*(\S*)/)?.[1];
20687
+ const defaultImport = topLevelImports.split(",").find((index) => !/[*{}]/.test(index))?.trim() || void 0;
20718
20688
  return {
20719
20689
  ...matched,
20720
20690
  defaultImport,
@@ -20723,7 +20693,7 @@ function parseStaticImport(matched) {
20723
20693
  };
20724
20694
  }
20725
20695
 
20726
- const ESM_RE = /([\s;]|^)(import[\w,{}\s*]*from|import\s*['"*{]|export\b\s*(?:[*{]|default|class|type|function|const|var|let|async function)|import\.meta\b)/m;
20696
+ const ESM_RE = /([\s;]|^)(import[\s\w*,{}]*from|import\s*["'*{]|export\b\s*(?:[*{]|default|class|type|function|const|var|let|async function)|import\.meta\b)/m;
20727
20697
  function hasESMSyntax(code) {
20728
20698
  return ESM_RE.test(code);
20729
20699
  }
@@ -20884,9 +20854,9 @@ async function bundleWorkerEntry(config, id, query) {
20884
20854
  : workerOutputConfig
20885
20855
  : {};
20886
20856
  const { output: [outputChunk, ...outputChunks] } = await bundle.generate({
20887
- entryFileNames: path$o.posix.join(config.build.assetsDir, '[name].[hash].js'),
20888
- chunkFileNames: path$o.posix.join(config.build.assetsDir, '[name].[hash].js'),
20889
- assetFileNames: path$o.posix.join(config.build.assetsDir, '[name].[hash].[ext]'),
20857
+ entryFileNames: path$o.posix.join(config.build.assetsDir, '[name]-[hash].js'),
20858
+ chunkFileNames: path$o.posix.join(config.build.assetsDir, '[name]-[hash].js'),
20859
+ assetFileNames: path$o.posix.join(config.build.assetsDir, '[name]-[hash].[ext]'),
20890
20860
  ...workerConfig,
20891
20861
  format,
20892
20862
  sourcemap: config.build.sourcemap
@@ -35190,7 +35160,7 @@ function traverseNodes(node, visitor) {
35190
35160
  }
35191
35161
  async function traverseHtml(html, filePath, visitor) {
35192
35162
  // lazy load compiler
35193
- const { parse } = await import('./dep-adb60dd8.js');
35163
+ const { parse } = await import('./dep-31fe3c68.js');
35194
35164
  const ast = parse(html, {
35195
35165
  sourceCodeLocationInfo: true,
35196
35166
  onParseError: (e) => {
@@ -36451,7 +36421,7 @@ async function compileCSS(id, code, config, urlReplacer) {
36451
36421
  }));
36452
36422
  }
36453
36423
  if (isModule) {
36454
- postcssPlugins.unshift((await import('./dep-b522a97d.js').then(function (n) { return n.i; })).default({
36424
+ postcssPlugins.unshift((await import('./dep-72c42a3f.js').then(function (n) { return n.i; })).default({
36455
36425
  ...modulesOptions,
36456
36426
  localsConvention: modulesOptions?.localsConvention,
36457
36427
  getJSON(cssFileName, _modules, outputFileName) {
@@ -36460,9 +36430,9 @@ async function compileCSS(id, code, config, urlReplacer) {
36460
36430
  modulesOptions.getJSON(cssFileName, _modules, outputFileName);
36461
36431
  }
36462
36432
  },
36463
- async resolve(id) {
36433
+ async resolve(id, importer) {
36464
36434
  for (const key of getCssResolversKeys(atImportResolvers)) {
36465
- const resolved = await atImportResolvers[key](id);
36435
+ const resolved = await atImportResolvers[key](id, importer);
36466
36436
  if (resolved) {
36467
36437
  return path$o.resolve(resolved);
36468
36438
  }
@@ -37153,6 +37123,43 @@ function getCssDialect(lang) {
37153
37123
  return lang === 'sss' ? 'sss' : 'css';
37154
37124
  }
37155
37125
 
37126
+ const HASH_RE = /#/g;
37127
+ const AMPERSAND_RE = /&/g;
37128
+ const EQUAL_RE = /=/g;
37129
+ const PLUS_RE = /\+/g;
37130
+ const ENC_BRACKET_OPEN_RE = /%5B/gi;
37131
+ const ENC_BRACKET_CLOSE_RE = /%5D/gi;
37132
+ const ENC_CARET_RE = /%5E/gi;
37133
+ const ENC_BACKTICK_RE = /%60/gi;
37134
+ const ENC_CURLY_OPEN_RE = /%7B/gi;
37135
+ const ENC_PIPE_RE = /%7C/gi;
37136
+ const ENC_CURLY_CLOSE_RE = /%7D/gi;
37137
+ const ENC_SPACE_RE = /%20/gi;
37138
+ function encode(text) {
37139
+ return encodeURI("" + text).replace(ENC_PIPE_RE, "|").replace(ENC_BRACKET_OPEN_RE, "[").replace(ENC_BRACKET_CLOSE_RE, "]");
37140
+ }
37141
+ function encodeQueryValue(text) {
37142
+ return encode(text).replace(PLUS_RE, "%2B").replace(ENC_SPACE_RE, "+").replace(HASH_RE, "%23").replace(AMPERSAND_RE, "%26").replace(ENC_BACKTICK_RE, "`").replace(ENC_CURLY_OPEN_RE, "{").replace(ENC_CURLY_CLOSE_RE, "}").replace(ENC_CARET_RE, "^");
37143
+ }
37144
+ function encodeQueryKey(text) {
37145
+ return encodeQueryValue(text).replace(EQUAL_RE, "%3D");
37146
+ }
37147
+ function encodeQueryItem(key, val) {
37148
+ if (typeof val === "number" || typeof val === "boolean") {
37149
+ val = String(val);
37150
+ }
37151
+ if (!val) {
37152
+ return encodeQueryKey(key);
37153
+ }
37154
+ if (Array.isArray(val)) {
37155
+ return val.map((_val) => `${encodeQueryKey(key)}=${encodeQueryValue(_val)}`).join("&");
37156
+ }
37157
+ return `${encodeQueryKey(key)}=${encodeQueryValue(val)}`;
37158
+ }
37159
+ function stringifyQuery(query) {
37160
+ return Object.keys(query).map((k) => encodeQueryItem(k, query[k])).join("&");
37161
+ }
37162
+
37156
37163
  const { isMatch: isMatch$1, scan } = micromatch_1;
37157
37164
  function getAffectedGlobModules(file, server) {
37158
37165
  const modules = [];
@@ -37616,7 +37623,7 @@ async function handleHMRUpdate(file, server) {
37616
37623
  }
37617
37624
  updateModules(shortFile, hmrContext.modules, timestamp, server);
37618
37625
  }
37619
- function updateModules(file, modules, timestamp, { config, ws }) {
37626
+ function updateModules(file, modules, timestamp, { config, ws }, afterInvalidation) {
37620
37627
  const updates = [];
37621
37628
  const invalidatedModules = new Set();
37622
37629
  let needFullReload = false;
@@ -37643,7 +37650,7 @@ function updateModules(file, modules, timestamp, { config, ws }) {
37643
37650
  }
37644
37651
  if (needFullReload) {
37645
37652
  config.logger.info(picocolors.exports.green(`page reload `) + picocolors.exports.dim(file), {
37646
- clear: true,
37653
+ clear: !afterInvalidation,
37647
37654
  timestamp: true
37648
37655
  });
37649
37656
  ws.send({
@@ -37656,7 +37663,7 @@ function updateModules(file, modules, timestamp, { config, ws }) {
37656
37663
  return;
37657
37664
  }
37658
37665
  config.logger.info(picocolors.exports.green(`hmr update `) +
37659
- picocolors.exports.dim([...new Set(updates.map((u) => u.path))].join(', ')), { clear: true, timestamp: true });
37666
+ picocolors.exports.dim([...new Set(updates.map((u) => u.path))].join(', ')), { clear: !afterInvalidation, timestamp: true });
37660
37667
  ws.send({
37661
37668
  type: 'update',
37662
37669
  updates
@@ -38992,7 +38999,7 @@ function importAnalysisPlugin(config) {
38992
38999
  // properly finish the request with a 504 sent to the browser.
38993
39000
  throwOutdatedRequest(importer);
38994
39001
  }
38995
- if (!imports.length) {
39002
+ if (!imports.length && !this._addedImports) {
38996
39003
  importerModule.isSelfAccepting = false;
38997
39004
  isDebug$1 &&
38998
39005
  debug$9(`${timeFrom(start)} ${picocolors.exports.dim(`[no imports] ${prettyImporter}`)}`);
@@ -39013,7 +39020,7 @@ function importAnalysisPlugin(config) {
39013
39020
  ? new Map()
39014
39021
  : null;
39015
39022
  const toAbsoluteUrl = (url) => path$o.posix.resolve(path$o.posix.dirname(importerModule.url), url);
39016
- const normalizeUrl = async (url, pos) => {
39023
+ const normalizeUrl = async (url, pos, forceSkipImportAnalysis = false) => {
39017
39024
  url = stripBase(url, base);
39018
39025
  let importerFile = importer;
39019
39026
  const optimizeDeps = getDepOptimizationConfig(config, ssr);
@@ -39091,7 +39098,7 @@ function importAnalysisPlugin(config) {
39091
39098
  // up-to-date version of this module.
39092
39099
  try {
39093
39100
  // delay setting `isSelfAccepting` until the file is actually used (#7870)
39094
- const depModule = await moduleGraph.ensureEntryFromUrl(unwrapId(url), ssr, canSkipImportAnalysis(url));
39101
+ const depModule = await moduleGraph.ensureEntryFromUrl(unwrapId(url), ssr, canSkipImportAnalysis(url) || forceSkipImportAnalysis);
39095
39102
  if (depModule.lastHMRTimestamp > 0) {
39096
39103
  url = injectQuery(url, `t=${depModule.lastHMRTimestamp}`);
39097
39104
  }
@@ -39306,7 +39313,7 @@ function importAnalysisPlugin(config) {
39306
39313
  // attached by pluginContainer.addWatchFile
39307
39314
  const pluginImports = this._addedImports;
39308
39315
  if (pluginImports) {
39309
- (await Promise.all([...pluginImports].map((id) => normalizeUrl(id, 0)))).forEach(([url]) => importedUrls.add(url));
39316
+ (await Promise.all([...pluginImports].map((id) => normalizeUrl(id, 0, true)))).forEach(([url]) => importedUrls.add(url));
39310
39317
  }
39311
39318
  // HMR transforms are no-ops in SSR, so an `accept` call will
39312
39319
  // never be injected. Avoid updating the `isSelfAccepting`
@@ -42032,14 +42039,9 @@ async function createPluginContainer(config, moduleGraph, watcher) {
42032
42039
  });
42033
42040
  // ---------------------------------------------------------------------------
42034
42041
  const watchFiles = new Set();
42035
- // TODO: use import()
42036
- const _require = createRequire$1(import.meta.url);
42037
- // get rollup version
42038
- const rollupPkgPath = resolve$6(_require.resolve('rollup'), '../../package.json');
42039
42042
  const minimalContext = {
42040
42043
  meta: {
42041
- rollupVersion: JSON.parse(fs$l.readFileSync(rollupPkgPath, 'utf-8'))
42042
- .version,
42044
+ rollupVersion: VERSION,
42043
42045
  watchMode: true
42044
42046
  }
42045
42047
  };
@@ -45215,7 +45217,7 @@ async function doBuild(inlineConfig = {}) {
45215
45217
  const options = config.build;
45216
45218
  const ssr = !!options.ssr;
45217
45219
  const libOptions = options.lib;
45218
- config.logger.info(picocolors.exports.cyan(`vite v${VERSION} ${picocolors.exports.green(`building ${ssr ? `SSR bundle ` : ``}for ${config.mode}...`)}`));
45220
+ config.logger.info(picocolors.exports.cyan(`vite v${VERSION$1} ${picocolors.exports.green(`building ${ssr ? `SSR bundle ` : ``}for ${config.mode}...`)}`));
45219
45221
  const resolve = (p) => path$o.resolve(config.root, p);
45220
45222
  const input = libOptions
45221
45223
  ? options.rollupOptions?.input ||
@@ -45304,13 +45306,13 @@ async function doBuild(inlineConfig = {}) {
45304
45306
  ? `[name].${jsExt}`
45305
45307
  : libOptions
45306
45308
  ? ({ name }) => resolveLibFilename(libOptions, format, name, config.root, jsExt)
45307
- : path$o.posix.join(options.assetsDir, `[name].[hash].${jsExt}`),
45309
+ : path$o.posix.join(options.assetsDir, `[name]-[hash].${jsExt}`),
45308
45310
  chunkFileNames: libOptions
45309
- ? `[name].[hash].${jsExt}`
45310
- : path$o.posix.join(options.assetsDir, `[name].[hash].${jsExt}`),
45311
+ ? `[name]-[hash].${jsExt}`
45312
+ : path$o.posix.join(options.assetsDir, `[name]-[hash].${jsExt}`),
45311
45313
  assetFileNames: libOptions
45312
45314
  ? `[name].[ext]`
45313
- : path$o.posix.join(options.assetsDir, `[name].[hash].[ext]`),
45315
+ : path$o.posix.join(options.assetsDir, `[name]-[hash].[ext]`),
45314
45316
  inlineDynamicImports: output.format === 'umd' ||
45315
45317
  output.format === 'iife' ||
45316
45318
  (ssrWorkerBuild &&
@@ -52951,7 +52953,7 @@ async function instantiateModule(url, server, context = { global }, urlStack = [
52951
52953
  mod.ssrModule = ssrModule;
52952
52954
  const ssrImportMeta = {
52953
52955
  // The filesystem URL, matching native Node.js modules
52954
- url: pathToFileURL$1(mod.file).toString()
52956
+ url: pathToFileURL(mod.file).toString()
52955
52957
  };
52956
52958
  urlStack = urlStack.concat(url);
52957
52959
  const isCircular = (url) => urlStack.includes(url);
@@ -53097,7 +53099,7 @@ async function nodeImport(id, importer, resolveOptions) {
53097
53099
  ? { ...resolveOptions, tryEsmOnly: true }
53098
53100
  : resolveOptions);
53099
53101
  if (usingDynamicImport) {
53100
- url = pathToFileURL$1(url).toString();
53102
+ url = pathToFileURL(url).toString();
53101
53103
  }
53102
53104
  }
53103
53105
  try {
@@ -59780,11 +59782,6 @@ function proxyMiddleware(httpServer, options, config) {
59780
59782
  debug$1(`bypass: ${req.url} -> ${bypassResult}`);
59781
59783
  return next();
59782
59784
  }
59783
- else if (isObject$1(bypassResult)) {
59784
- Object.assign(options, bypassResult);
59785
- debug$1(`bypass: ${req.url} use modified options: %O`, options);
59786
- return next();
59787
- }
59788
59785
  else if (bypassResult === false) {
59789
59786
  debug$1(`bypass: ${req.url} -> 404`);
59790
59787
  return res.end(404);
@@ -59940,16 +59937,12 @@ function htmlFallbackMiddleware(root, spaFallback) {
59940
59937
  rewrites: [
59941
59938
  {
59942
59939
  from: /\/$/,
59943
- to({ parsedUrl }) {
59940
+ to({ parsedUrl, request }) {
59944
59941
  const rewritten = decodeURIComponent(parsedUrl.pathname) + 'index.html';
59945
59942
  if (fs$l.existsSync(path$o.join(root, rewritten))) {
59946
59943
  return rewritten;
59947
59944
  }
59948
- else {
59949
- if (spaFallback) {
59950
- return `/index.html`;
59951
- }
59952
- }
59945
+ return spaFallback ? `/index.html` : request.url;
59953
59946
  }
59954
59947
  }
59955
59948
  ]
@@ -60164,14 +60157,15 @@ const processNodeUrl = (attr, sourceCodeLocation, s, config, htmlPath, originalU
60164
60157
  const devBase = config.base;
60165
60158
  if (startsWithSingleSlashRE.test(url)) {
60166
60159
  // prefix with base (dev only, base is never relative)
60167
- const fullUrl = joinUrlSegments(devBase, url);
60160
+ const fullUrl = path$o.posix.join(devBase, url);
60168
60161
  overwriteAttrValue(s, sourceCodeLocation, fullUrl);
60169
60162
  }
60170
60163
  else if (url.startsWith('.') &&
60171
60164
  originalUrl &&
60172
60165
  originalUrl !== '/' &&
60173
60166
  htmlPath === '/index.html') {
60174
- const replacer = (url) => path$o.posix.join(devBase, path$o.posix.relative(originalUrl, devBase), url.slice(1));
60167
+ // prefix with base (dev only, base is never relative)
60168
+ const replacer = (url) => path$o.posix.join(devBase, url);
60175
60169
  // #3230 if some request url (localhost:3000/a/b) return to fallback html, the relative assets
60176
60170
  // path will add `/a/` prefix, it will caused 404.
60177
60171
  // rewrite before `./index.js` -> `localhost:5173/a/index.js`.
@@ -61794,11 +61788,14 @@ async function createServer(inlineConfig = {}) {
61794
61788
  watcher.on('unlink', (file) => {
61795
61789
  handleFileAddUnlink(normalizePath$3(file), server);
61796
61790
  });
61797
- ws.on('vite:invalidate', async ({ path }) => {
61791
+ ws.on('vite:invalidate', async ({ path, message }) => {
61798
61792
  const mod = moduleGraph.urlToModuleMap.get(path);
61799
61793
  if (mod && mod.isSelfAccepting && mod.lastHMRTimestamp > 0) {
61794
+ config.logger.info(picocolors.exports.yellow(`hmr invalidate `) +
61795
+ picocolors.exports.dim(path) +
61796
+ (message ? ` ${message}` : ''), { timestamp: true });
61800
61797
  const file = getShortName(mod.file, config.root);
61801
- updateModules(file, [...mod.importers], mod.lastHMRTimestamp, server);
61798
+ updateModules(file, [...mod.importers], mod.lastHMRTimestamp, server, true);
61802
61799
  }
61803
61800
  });
61804
61801
  if (!middlewareMode && httpServer) {
@@ -62427,7 +62424,8 @@ async function resolveConfig(inlineConfig, command, defaultMode = 'development')
62427
62424
  : pkgPath
62428
62425
  ? path$o.join(path$o.dirname(pkgPath), `node_modules/.vite`)
62429
62426
  : path$o.join(resolvedRoot, `.vite`);
62430
- const assetsFilter = config.assetsInclude
62427
+ const assetsFilter = config.assetsInclude &&
62428
+ (!Array.isArray(config.assetsInclude) || config.assetsInclude.length)
62431
62429
  ? createFilter(config.assetsInclude)
62432
62430
  : () => false;
62433
62431
  // create an internal resolver to be used in special scenarios, e.g.
@@ -62772,7 +62770,7 @@ async function bundleConfigFile(fileName, isESM) {
62772
62770
  }
62773
62771
  let idFsPath = tryNodeResolve(id, importer, options, false)?.id;
62774
62772
  if (idFsPath && (isESM || kind === 'dynamic-import')) {
62775
- idFsPath = pathToFileURL$1(idFsPath).href;
62773
+ idFsPath = pathToFileURL(idFsPath).href;
62776
62774
  }
62777
62775
  return {
62778
62776
  path: idFsPath,
@@ -62788,7 +62786,7 @@ async function bundleConfigFile(fileName, isESM) {
62788
62786
  const contents = await fs$l.promises.readFile(args.path, 'utf8');
62789
62787
  const injectValues = `const ${dirnameVarName} = ${JSON.stringify(path$o.dirname(args.path))};` +
62790
62788
  `const ${filenameVarName} = ${JSON.stringify(args.path)};` +
62791
- `const ${importMetaUrlVarName} = ${JSON.stringify(pathToFileURL$1(args.path).href)};`;
62789
+ `const ${importMetaUrlVarName} = ${JSON.stringify(pathToFileURL(args.path).href)};`;
62792
62790
  return {
62793
62791
  loader: args.path.endsWith('ts') ? 'ts' : 'js',
62794
62792
  contents: injectValues + contents
@@ -62812,7 +62810,7 @@ async function loadConfigFromBundledFile(fileName, bundledCode, isESM) {
62812
62810
  if (isESM) {
62813
62811
  const fileBase = `${fileName}.timestamp-${Date.now()}`;
62814
62812
  const fileNameTmp = `${fileBase}.mjs`;
62815
- const fileUrl = `${pathToFileURL$1(fileBase)}.mjs`;
62813
+ const fileUrl = `${pathToFileURL(fileBase)}.mjs`;
62816
62814
  fs$l.writeFileSync(fileNameTmp, bundledCode);
62817
62815
  try {
62818
62816
  return (await dynamicImport(fileUrl)).default;
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 { z as picocolors, v as createLogger, g as resolveConfig } from './chunks/dep-f5aa12ea.js';
5
+ import { z as picocolors, v as createLogger, g as resolveConfig } from './chunks/dep-fadb3c21.js';
6
6
  import { VERSION } from './constants.js';
7
7
  import 'node:url';
8
8
  import 'node:module';
@@ -32,6 +32,7 @@ import 'https';
32
32
  import 'tls';
33
33
  import 'node:http';
34
34
  import 'node:https';
35
+ import 'rollup';
35
36
  import 'querystring';
36
37
  import 'node:readline';
37
38
  import 'node:child_process';
@@ -719,7 +720,7 @@ cli
719
720
  filterDuplicateOptions(options);
720
721
  // output structure is preserved even after bundling so require()
721
722
  // is ok here
722
- const { createServer } = await import('./chunks/dep-f5aa12ea.js').then(function (n) { return n.D; });
723
+ const { createServer } = await import('./chunks/dep-fadb3c21.js').then(function (n) { return n.D; });
723
724
  try {
724
725
  const server = await createServer({
725
726
  root,
@@ -772,7 +773,7 @@ cli
772
773
  .option('-w, --watch', `[boolean] rebuilds when modules have changed on disk`)
773
774
  .action(async (root, options) => {
774
775
  filterDuplicateOptions(options);
775
- const { build } = await import('./chunks/dep-f5aa12ea.js').then(function (n) { return n.C; });
776
+ const { build } = await import('./chunks/dep-fadb3c21.js').then(function (n) { return n.C; });
776
777
  const buildOptions = cleanOptions(options);
777
778
  try {
778
779
  await build({
@@ -800,7 +801,7 @@ cli
800
801
  .option('--force', `[boolean] force the optimizer to ignore the cache and re-bundle`)
801
802
  .action(async (root, options) => {
802
803
  filterDuplicateOptions(options);
803
- const { optimizeDeps } = await import('./chunks/dep-f5aa12ea.js').then(function (n) { return n.B; });
804
+ const { optimizeDeps } = await import('./chunks/dep-fadb3c21.js').then(function (n) { return n.B; });
804
805
  try {
805
806
  const config = await resolveConfig({
806
807
  root,
@@ -825,7 +826,7 @@ cli
825
826
  .option('--outDir <dir>', `[string] output directory (default: dist)`)
826
827
  .action(async (root, options) => {
827
828
  filterDuplicateOptions(options);
828
- const { preview } = await import('./chunks/dep-f5aa12ea.js').then(function (n) { return n.E; });
829
+ const { preview } = await import('./chunks/dep-fadb3c21.js').then(function (n) { return n.E; });
829
830
  try {
830
831
  const server = await preview({
831
832
  root,
@@ -1,4 +1,4 @@
1
- export { b as build, q as createFilter, v as createLogger, c as createServer, e as defineConfig, f as formatPostcssSourceMap, i as getDepOptimizationConfig, j as isDepsOptimizerEnabled, l as loadConfigFromFile, x as loadEnv, k as mergeAlias, m as mergeConfig, n as normalizePath, o as optimizeDeps, a as preprocessCSS, p as preview, h as resolveBaseUrl, g as resolveConfig, y as resolveEnvPrefix, d as resolvePackageData, r as resolvePackageEntry, w as searchForWorkspaceRoot, u as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-f5aa12ea.js';
1
+ export { b as build, q as createFilter, v as createLogger, c as createServer, e as defineConfig, f as formatPostcssSourceMap, i as getDepOptimizationConfig, j as isDepsOptimizerEnabled, l as loadConfigFromFile, x as loadEnv, k as mergeAlias, m as mergeConfig, n as normalizePath, o as optimizeDeps, a as preprocessCSS, p as preview, h as resolveBaseUrl, g as resolveConfig, y as resolveEnvPrefix, d as resolvePackageData, r as resolvePackageEntry, w as searchForWorkspaceRoot, u as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-fadb3c21.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-alpha.3",
3
+ "version": "4.0.0-alpha.5",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Evan You",
@@ -76,7 +76,7 @@
76
76
  "@rollup/plugin-dynamic-import-vars": "^2.0.1",
77
77
  "@rollup/plugin-json": "^5.0.1",
78
78
  "@rollup/plugin-node-resolve": "15.0.1",
79
- "@rollup/plugin-typescript": "^8.5.0",
79
+ "@rollup/plugin-typescript": "^9.0.2",
80
80
  "@rollup/pluginutils": "^4.2.1",
81
81
  "acorn": "^8.8.1",
82
82
  "cac": "^6.7.14",
@@ -99,17 +99,17 @@
99
99
  "launch-editor-middleware": "^2.6.0",
100
100
  "magic-string": "^0.26.7",
101
101
  "micromatch": "^4.0.5",
102
- "mlly": "^0.5.16",
102
+ "mlly": "^0.5.17",
103
103
  "mrmime": "^1.0.1",
104
104
  "okie": "^1.0.1",
105
105
  "open": "^8.4.0",
106
- "parse5": "^7.1.1",
106
+ "parse5": "^7.1.2",
107
107
  "periscopic": "^3.0.4",
108
108
  "picocolors": "^1.0.0",
109
109
  "picomatch": "^2.3.1",
110
110
  "postcss-import": "^15.0.0",
111
111
  "postcss-load-config": "^4.0.1",
112
- "postcss-modules": "^5.0.0",
112
+ "postcss-modules": "^6.0.0",
113
113
  "resolve.exports": "^1.1.0",
114
114
  "sirv": "^2.0.2",
115
115
  "source-map-js": "^1.0.2",
@@ -16,6 +16,7 @@ export interface CustomEventMap {
16
16
 
17
17
  export interface InvalidatePayload {
18
18
  path: string
19
+ message: string | undefined
19
20
  }
20
21
 
21
22
  export type InferCustomEventPayload<T extends string> =
package/types/hot.d.ts CHANGED
@@ -23,7 +23,7 @@ export interface ViteHotContext {
23
23
 
24
24
  dispose(cb: (data: any) => void): void
25
25
  decline(): void
26
- invalidate(): void
26
+ invalidate(message?: string): void
27
27
 
28
28
  on<T extends string>(
29
29
  event: T,