vite 5.0.0-beta.16 → 5.0.0-beta.18

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.
@@ -20,11 +20,11 @@ import require$$1$1 from 'http';
20
20
  import require$$0$7 from 'stream';
21
21
  import require$$2 from 'os';
22
22
  import require$$2$1 from 'child_process';
23
- import { CLIENT_ENTRY, VALID_ID_PREFIX, NULL_BYTE_PLACEHOLDER, OPTIMIZABLE_ENTRY_RE, FS_PREFIX, wildcardHosts, loopbackHosts, CLIENT_PUBLIC_PATH, ENV_PUBLIC_PATH, ENV_ENTRY, DEP_VERSION_RE, SPECIAL_QUERY_RE, DEFAULT_MAIN_FIELDS, DEFAULT_EXTENSIONS, CSS_LANGS_RE, ESBUILD_MODULES_TARGET, KNOWN_ASSET_TYPES, VITE_PACKAGE_DIR, ASYNC_DISPOSE, DEFAULT_DEV_PORT, CLIENT_DIR, JS_TYPES_RE, VERSION as VERSION$1, DEFAULT_PREVIEW_PORT, DEFAULT_ASSETS_RE, DEFAULT_CONFIG_FILES } from '../constants.js';
24
23
  import os$4 from 'node:os';
25
24
  import { exec } from 'node:child_process';
26
25
  import { createHash as createHash$2 } from 'node:crypto';
27
26
  import { promises } from 'node:dns';
27
+ import { CLIENT_ENTRY, VALID_ID_PREFIX, NULL_BYTE_PLACEHOLDER, OPTIMIZABLE_ENTRY_RE, FS_PREFIX, wildcardHosts, loopbackHosts, CLIENT_PUBLIC_PATH, ENV_PUBLIC_PATH, ENV_ENTRY, DEP_VERSION_RE, SPECIAL_QUERY_RE, DEFAULT_MAIN_FIELDS, DEFAULT_EXTENSIONS, CSS_LANGS_RE, ESBUILD_MODULES_TARGET, KNOWN_ASSET_TYPES, VITE_PACKAGE_DIR, DEFAULT_DEV_PORT, CLIENT_DIR, JS_TYPES_RE, VERSION as VERSION$1, DEFAULT_PREVIEW_PORT, DEFAULT_ASSETS_RE, DEFAULT_CONFIG_FILES } from '../constants.js';
28
28
  import require$$0$a from 'crypto';
29
29
  import { Buffer as Buffer$1 } from 'node:buffer';
30
30
  import require$$0$8, { createRequire as createRequire$2 } from 'module';
@@ -12712,9 +12712,6 @@ const requireResolveFromRootWithFallback = (root, id) => {
12712
12712
  function emptyCssComments(raw) {
12713
12713
  return raw.replace(multilineCommentsRE$1, (s) => ' '.repeat(s.length));
12714
12714
  }
12715
- function removeComments(raw) {
12716
- return raw.replace(multilineCommentsRE$1, '').replace(singlelineCommentsRE$1, '');
12717
- }
12718
12715
  function backwardCompatibleWorkerPlugins(plugins) {
12719
12716
  if (Array.isArray(plugins)) {
12720
12717
  return plugins;
@@ -13091,6 +13088,7 @@ function buildReporterPlugin(config) {
13091
13088
  let chunkCount = 0;
13092
13089
  let compressedCount = 0;
13093
13090
  let startTime = Date.now();
13091
+ let buildFailed = false;
13094
13092
  async function getCompressedSize(code) {
13095
13093
  if (config.build.ssr || !config.build.reportCompressedSize) {
13096
13094
  return null;
@@ -13139,10 +13137,11 @@ function buildReporterPlugin(config) {
13139
13137
  buildStart() {
13140
13138
  transformedCount = 0;
13141
13139
  },
13142
- buildEnd() {
13140
+ buildEnd(error) {
13141
+ buildFailed = !!error;
13143
13142
  if (shouldLogInfo) {
13144
13143
  if (tty) {
13145
- clearLine();
13144
+ clearLine$1();
13146
13145
  }
13147
13146
  config.logger.info(`${colors$1.green(`✓`)} ${transformedCount} modules transformed.`);
13148
13147
  }
@@ -13187,7 +13186,7 @@ function buildReporterPlugin(config) {
13187
13186
  },
13188
13187
  generateBundle() {
13189
13188
  if (shouldLogInfo && tty)
13190
- clearLine();
13189
+ clearLine$1();
13191
13190
  },
13192
13191
  async writeBundle({ dir: outDir }, output) {
13193
13192
  let hasLargeChunks = false;
@@ -13219,7 +13218,7 @@ function buildReporterPlugin(config) {
13219
13218
  }
13220
13219
  }))).filter(isDefined);
13221
13220
  if (tty)
13222
- clearLine();
13221
+ clearLine$1();
13223
13222
  let longest = 0;
13224
13223
  let biggestSize = 0;
13225
13224
  let biggestMap = 0;
@@ -13287,14 +13286,14 @@ function buildReporterPlugin(config) {
13287
13286
  }
13288
13287
  },
13289
13288
  closeBundle() {
13290
- if (shouldLogInfo && !config.build.watch) {
13289
+ if (shouldLogInfo && !config.build.watch && !buildFailed) {
13291
13290
  config.logger.info(`${colors$1.green(`✓ built in ${displayTime(Date.now() - startTime)}`)}`);
13292
13291
  }
13293
13292
  },
13294
13293
  };
13295
13294
  }
13296
13295
  function writeLine(output) {
13297
- clearLine();
13296
+ clearLine$1();
13298
13297
  if (output.length < process.stdout.columns) {
13299
13298
  process.stdout.write(output);
13300
13299
  }
@@ -13302,7 +13301,7 @@ function writeLine(output) {
13302
13301
  process.stdout.write(output.substring(0, process.stdout.columns - 1));
13303
13302
  }
13304
13303
  }
13305
- function clearLine() {
13304
+ function clearLine$1() {
13306
13305
  process.stdout.clearLine(0);
13307
13306
  process.stdout.cursorTo(0);
13308
13307
  }
@@ -15712,15 +15711,17 @@ async function urlToBuiltUrl(url, importer, config, pluginContext) {
15712
15711
  // Inspired by https://github.com/iconify/iconify/blob/main/packages/utils/src/svg/url.ts
15713
15712
  function svgToDataURL(content) {
15714
15713
  const stringContent = content.toString();
15715
- // If the SVG contains some text, any transformation is unsafe, and given that double quotes would then
15714
+ // If the SVG contains some text or HTML, any transformation is unsafe, and given that double quotes would then
15716
15715
  // need to be escaped, the gain to use a data URI would be ridiculous if not negative
15717
- if (stringContent.includes('<text')) {
15716
+ if (stringContent.includes('<text') ||
15717
+ stringContent.includes('<foreignObject')) {
15718
15718
  return `data:image/svg+xml;base64,${content.toString('base64')}`;
15719
15719
  }
15720
15720
  else {
15721
15721
  return ('data:image/svg+xml,' +
15722
15722
  stringContent
15723
15723
  .trim()
15724
+ .replaceAll(/>\s+</g, '><')
15724
15725
  .replaceAll('"', "'")
15725
15726
  .replaceAll('%', '%25')
15726
15727
  .replaceAll('#', '%23')
@@ -15743,18 +15744,7 @@ function manifestPlugin(config) {
15743
15744
  },
15744
15745
  generateBundle({ format }, bundle) {
15745
15746
  function getChunkName(chunk) {
15746
- if (chunk.facadeModuleId) {
15747
- let name = normalizePath$3(path$o.relative(config.root, chunk.facadeModuleId));
15748
- if (format === 'system' && !chunk.name.includes('-legacy')) {
15749
- const ext = path$o.extname(name);
15750
- const endPos = ext.length !== 0 ? -ext.length : undefined;
15751
- name = name.slice(0, endPos) + `-legacy` + ext;
15752
- }
15753
- return name.replace(/\0/g, '');
15754
- }
15755
- else {
15756
- return `_` + path$o.basename(chunk.fileName);
15757
- }
15747
+ return getChunkOriginalFileName(chunk, config.root, format);
15758
15748
  }
15759
15749
  function getInternalImports(imports) {
15760
15750
  const filteredImports = [];
@@ -15825,6 +15815,10 @@ function manifestPlugin(config) {
15825
15815
  const assetMeta = fileNameToAssetMeta.get(chunk.fileName);
15826
15816
  const src = assetMeta?.originalName ?? chunk.name;
15827
15817
  const asset = createAsset(chunk, src, assetMeta?.isEntry);
15818
+ // If JS chunk and asset chunk are both generated from the same source file,
15819
+ // prioritize JS chunk as it contains more information
15820
+ if (manifest[src]?.file.endsWith('.js'))
15821
+ continue;
15828
15822
  manifest[src] = asset;
15829
15823
  fileNameToAsset.set(chunk.fileName, asset);
15830
15824
  }
@@ -15854,6 +15848,20 @@ function manifestPlugin(config) {
15854
15848
  },
15855
15849
  };
15856
15850
  }
15851
+ function getChunkOriginalFileName(chunk, root, format) {
15852
+ if (chunk.facadeModuleId) {
15853
+ let name = normalizePath$3(path$o.relative(root, chunk.facadeModuleId));
15854
+ if (format === 'system' && !chunk.name.includes('-legacy')) {
15855
+ const ext = path$o.extname(name);
15856
+ const endPos = ext.length !== 0 ? -ext.length : undefined;
15857
+ name = name.slice(0, endPos) + `-legacy` + ext;
15858
+ }
15859
+ return name.replace(/\0/g, '');
15860
+ }
15861
+ else {
15862
+ return `_` + path$o.basename(chunk.fileName);
15863
+ }
15864
+ }
15857
15865
 
15858
15866
  // This is based on @rollup/plugin-data-uri
15859
15867
  // MIT Licensed https://github.com/rollup/plugins/blob/master/LICENSE
@@ -15903,8 +15911,8 @@ function dataURIPlugin() {
15903
15911
  };
15904
15912
  }
15905
15913
 
15906
- /* es-module-lexer 1.3.1 */
15907
- const A=1===new Uint8Array(new Uint16Array([1]).buffer)[0];function parse$e(E,g="@"){if(!C)return init.then((()=>parse$e(E)));const I=E.length+1,o=(C.__heap_base.value||C.__heap_base)+4*I-C.memory.buffer.byteLength;o>0&&C.memory.grow(Math.ceil(o/65536));const K=C.sa(I-1);if((A?B:Q)(E,new Uint16Array(C.memory.buffer,K,I)),!C.parse())throw Object.assign(new Error(`Parse error ${g}:${E.slice(0,C.e()).split("\n").length}:${C.e()-E.lastIndexOf("\n",C.e()-1)}`),{idx:C.e()});const D=[],k=[];for(;C.ri();){const A=C.is(),Q=C.ie(),B=C.ai(),g=C.id(),I=C.ss(),o=C.se();let K;C.ip()&&(K=J(E.slice(-1===g?A-1:A,-1===g?Q+1:Q))),D.push({n:K,s:A,e:Q,ss:I,se:o,d:g,a:B});}for(;C.re();){const A=C.es(),Q=C.ee(),B=C.els(),g=C.ele(),I=E.slice(A,Q),o=I[0],K=B<0?void 0:E.slice(B,g),D=K?K[0]:"";k.push({s:A,e:Q,ls:B,le:g,n:'"'===o||"'"===o?J(I):I,ln:'"'===D||"'"===D?J(K):K});}function J(A){try{return (0, eval)(A)}catch(A){}}return [D,k,!!C.f()]}function Q(A,Q){const B=A.length;let C=0;for(;C<B;){const B=A.charCodeAt(C);Q[C++]=(255&B)<<8|B>>>8;}}function B(A,Q){const B=A.length;let C=0;for(;C<B;)Q[C]=A.charCodeAt(C++);}let C;const init=WebAssembly.compile((E="AGFzbQEAAAABKghgAX8Bf2AEf39/fwBgAAF/YAAAYAF/AGADf39/AX9gAn9/AX9gAn9/AAMvLgABAQICAgICAgICAgICAgICAgIAAwMDBAQAAAADAAAAAAMDAAUGAAAABwAGAgUEBQFwAQEBBQMBAAEGDwJ/AUGw8gALfwBBsPIACwdwEwZtZW1vcnkCAAJzYQAAAWUAAwJpcwAEAmllAAU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qAKIQAMAQsLQQAoAuQJIgEgAjYCECABQQAoAqAKQQJqNgIMC20BAn8CQAJAA0ACQCAAQf//A3EiAUF3aiICQRdLDQBBASACdEGfgIAEcQ0CCyABQaABRg0BIAAhAiABECYNAkEAIQJBAEEAKAKgCiIAQQJqNgKgCiAALwECIgANAAwCCwsgACECCyACQf//A3ELqwEBBH8CQAJAQQAoAqAKIgIvAQAiA0HhAEYNACABIQQgACEFDAELQQAgAkEEajYCoApBARAnIQJBACgCoAohBQJAAkAgAkEiRg0AIAJBJ0YNACACECoaQQAoAqAKIQQMAQsgAhAYQQBBACgCoApBAmoiBDYCoAoLQQEQJyEDQQAoAqAKIQILAkAgAiAFRg0AIAUgBEEAIAAgACABRiICG0EAIAEgAhsQAgsgAwtyAQR/QQAoAqAKIQBBACgCpAohAQJAAkADQCAAQQJqIQIgACABTw0BAkACQCACLwEAIgNBpH9qDgIBBAALIAIhACADQXZqDgQCAQECAQsgAEEEaiEADAALC0EAIAI2AqAKECJBAA8LQQAgAjYCoApB3QALSQEDf0EAIQMCQCACRQ0AAkADQCAALQAAIgQgAS0AACIFRw0BIAFBAWohASAAQQFqIQAgAkF/aiICDQAMAgsLIAQgBWshAwsgAwsL4gECAEGACAvEAQAAeABwAG8AcgB0AG0AcABvAHIAdABlAHQAYQByAG8AbQB1AG4AYwB0AGkAbwBuAHMAcwBlAHIAdAB2AG8AeQBpAGUAZABlAGwAZQBjAG8AbgB0AGkAbgBpAG4AcwB0AGEAbgB0AHkAYgByAGUAYQByAGUAdAB1AHIAZABlAGIAdQBnAGcAZQBhAHcAYQBpAHQAaAByAHcAaABpAGwAZQBmAG8AcgBpAGYAYwBhAHQAYwBmAGkAbgBhAGwAbABlAGwAcwAAQcQJCxABAAAAAgAAAAAEAAAwOQAA","undefined"!=typeof Buffer?Buffer.from(E,"base64"):Uint8Array.from(atob(E),(A=>A.charCodeAt(0))))).then(WebAssembly.instantiate).then((({exports:A})=>{C=A;}));var E;
15914
+ /* es-module-lexer 1.4.0 */
15915
+ const A=1===new Uint8Array(new Uint16Array([1]).buffer)[0];function parse$e(E,g="@"){if(!C)return init.then((()=>parse$e(E)));const I=E.length+1,o=(C.__heap_base.value||C.__heap_base)+4*I-C.memory.buffer.byteLength;o>0&&C.memory.grow(Math.ceil(o/65536));const k=C.sa(I-1);if((A?B:Q)(E,new Uint16Array(C.memory.buffer,k,I)),!C.parse())throw Object.assign(new Error(`Parse error ${g}:${E.slice(0,C.e()).split("\n").length}:${C.e()-E.lastIndexOf("\n",C.e()-1)}`),{idx:C.e()});const D=[],K=[];for(;C.ri();){const A=C.is(),Q=C.ie(),B=C.ai(),g=C.id(),I=C.ss(),o=C.se();let k;C.ip()&&(k=w(E.slice(-1===g?A-1:A,-1===g?Q+1:Q))),D.push({n:k,s:A,e:Q,ss:I,se:o,d:g,a:B});}for(;C.re();){const A=C.es(),Q=C.ee(),B=C.els(),g=C.ele(),I=E.slice(A,Q),o=I[0],k=B<0?void 0:E.slice(B,g),D=k?k[0]:"";K.push({s:A,e:Q,ls:B,le:g,n:'"'===o||"'"===o?w(I):I,ln:'"'===D||"'"===D?w(k):k});}function w(A){try{return (0, eval)(A)}catch(A){}}return [D,K,!!C.f(),!!C.ms()]}function Q(A,Q){const B=A.length;let C=0;for(;C<B;){const B=A.charCodeAt(C);Q[C++]=(255&B)<<8|B>>>8;}}function B(A,Q){const B=A.length;let C=0;for(;C<B;)Q[C]=A.charCodeAt(C++);}let C;const init=WebAssembly.compile((E="AGFzbQEAAAABKghgAX8Bf2AEf39/fwBgAAF/YAAAYAF/AGADf39/AX9gAn9/AX9gAn9/AAMwLwABAQICAgICAgICAgICAgICAgICAAMDAwQEAAAAAwAAAAADAwAFBgAAAAcABgIFBAUBcAEBAQUDAQABBg8CfwFBsPIAC38AQbDyAAsHdRQGbWVtb3J5AgACc2EAAAFlAAMCaXMABAJpZQAFAnNzAAYCc2UABwJhaQAIAmlkAAkCaXAACgJlcwALAmVlAAwDZWxzAA0DZWxlAA4CcmkADwJ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5AkiASACNgIQIAFBACgCpApBAmo2AgwLbQECfwJAAkADQAJAIABB//8DcSIBQXdqIgJBF0sNAEEBIAJ0QZ+AgARxDQILIAFBoAFGDQEgACECIAEQJw0CQQAhAkEAQQAoAqQKIgBBAmo2AqQKIAAvAQIiAA0ADAILCyAAIQILIAJB//8DcQurAQEEfwJAAkBBACgCpAoiAi8BACIDQeEARg0AIAEhBCAAIQUMAQtBACACQQRqNgKkCkEBECghAkEAKAKkCiEFAkACQCACQSJGDQAgAkEnRg0AIAIQKxpBACgCpAohBAwBCyACEBlBAEEAKAKkCkECaiIENgKkCgtBARAoIQNBACgCpAohAgsCQCACIAVGDQAgBSAEQQAgACAAIAFGIgIbQQAgASACGxACCyADC3IBBH9BACgCpAohAEEAKAKoCiEBAkACQANAIABBAmohAiAAIAFPDQECQAJAIAIvAQAiA0Gkf2oOAgEEAAsgAiEAIANBdmoOBAIBAQIBCyAAQQRqIQAMAAsLQQAgAjYCpAoQI0EADwtBACACNgKkCkHdAAtJAQN/QQAhAwJAIAJFDQACQANAIAAtAAAiBCABLQAAIgVHDQEgAUEBaiEBIABBAWohACACQX9qIgINAAwCCwsgBCAFayEDCyADCwviAQIAQYAIC8QBAAB4AHAAbwByAHQAbQBwAG8AcgB0AGUAdABhAHIAbwBtAHUAbgBjAHQAaQBvAG4AcwBzAGUAcgB0AHYAbwB5AGkAZQBkAGUAbABlAGMAbwBuAHQAaQBuAGkAbgBzAHQAYQBuAHQAeQBiAHIAZQBhAHIAZQB0AHUAcgBkAGUAYgB1AGcAZwBlAGEAdwBhAGkAdABoAHIAdwBoAGkAbABlAGYAbwByAGkAZgBjAGEAdABjAGYAaQBuAGEAbABsAGUAbABzAABBxAkLEAEAAAACAAAAAAQAADA5AAA=","undefined"!=typeof Buffer?Buffer.from(E,"base64"):Uint8Array.from(atob(E),(A=>A.charCodeAt(0))))).then(WebAssembly.instantiate).then((({exports:A})=>{C=A;}));var E;
15908
15916
 
15909
15917
  var convertSourceMap$1 = {};
15910
15918
 
@@ -36951,10 +36959,7 @@ function buildHtmlPlugin(config) {
36951
36959
  preHooks.push(htmlEnvHook(config));
36952
36960
  postHooks.push(postImportMapHook());
36953
36961
  const processedHtml = new Map();
36954
- const isExcludedUrl = (url) => url[0] === '#' ||
36955
- isExternalUrl(url) ||
36956
- isDataUrl(url) ||
36957
- checkPublicFile(url, config);
36962
+ const isExcludedUrl = (url) => url[0] === '#' || isExternalUrl(url) || isDataUrl(url);
36958
36963
  // Same reason with `htmlInlineProxyPlugin`
36959
36964
  isAsyncScriptMap.set(config, new Map());
36960
36965
  return {
@@ -36998,13 +37003,33 @@ function buildHtmlPlugin(config) {
36998
37003
  });
36999
37004
  let js = '';
37000
37005
  const s = new MagicString(html);
37001
- const assetUrls = [];
37002
37006
  const scriptUrls = [];
37003
37007
  const styleUrls = [];
37004
37008
  let inlineModuleIndex = -1;
37005
37009
  let everyScriptIsAsync = true;
37006
37010
  let someScriptsAreAsync = false;
37007
37011
  let someScriptsAreDefer = false;
37012
+ const assetUrlsPromises = [];
37013
+ // for each encountered asset url, rewrite original html so that it
37014
+ // references the post-build location, ignoring empty attributes and
37015
+ // attributes that directly reference named output.
37016
+ const namedOutput = Object.keys(config?.build?.rollupOptions?.input || {});
37017
+ const processAssetUrl = async (url) => {
37018
+ if (url !== '' && // Empty attribute
37019
+ !namedOutput.includes(url) && // Direct reference to named output
37020
+ !namedOutput.includes(removeLeadingSlash(url)) // Allow for absolute references as named output can't be an absolute path
37021
+ ) {
37022
+ try {
37023
+ return await urlToBuiltUrl(url, id, config, this);
37024
+ }
37025
+ catch (e) {
37026
+ if (e.code !== 'ENOENT') {
37027
+ throw e;
37028
+ }
37029
+ }
37030
+ }
37031
+ return url;
37032
+ };
37008
37033
  await traverseHtml(html, id, (node) => {
37009
37034
  if (!nodeIsElement(node)) {
37010
37035
  return;
@@ -37021,7 +37046,7 @@ function buildHtmlPlugin(config) {
37021
37046
  }
37022
37047
  if (isModule) {
37023
37048
  inlineModuleIndex++;
37024
- if (url && !isExcludedUrl(url)) {
37049
+ if (url && !isExcludedUrl(url) && !isPublicFile) {
37025
37050
  // <script type="module" src="..."/>
37026
37051
  // add it as an import
37027
37052
  js += `\nimport ${JSON.stringify(url)}`;
@@ -37059,34 +37084,51 @@ function buildHtmlPlugin(config) {
37059
37084
  for (const p of node.attrs) {
37060
37085
  const attrKey = getAttrKey(p);
37061
37086
  if (p.value && assetAttrs.includes(attrKey)) {
37062
- const attrSourceCodeLocation = node.sourceCodeLocation.attrs[attrKey];
37063
- // assetsUrl may be encodeURI
37064
- const url = decodeURI(p.value);
37065
- if (!isExcludedUrl(url)) {
37066
- if (node.nodeName === 'link' &&
37067
- isCSSRequest(url) &&
37068
- // should not be converted if following attributes are present (#6748)
37069
- !node.attrs.some((p) => p.prefix === undefined &&
37070
- (p.name === 'media' || p.name === 'disabled'))) {
37071
- // CSS references, convert to import
37072
- const importExpression = `\nimport ${JSON.stringify(url)}`;
37073
- styleUrls.push({
37074
- url,
37075
- start: nodeStartWithLeadingWhitespace(node),
37076
- end: node.sourceCodeLocation.endOffset,
37087
+ if (attrKey === 'srcset') {
37088
+ assetUrlsPromises.push((async () => {
37089
+ const processedUrl = await processSrcSet(p.value, async ({ url }) => {
37090
+ const decodedUrl = decodeURI(url);
37091
+ if (!isExcludedUrl(decodedUrl)) {
37092
+ const result = await processAssetUrl(url);
37093
+ return result !== decodedUrl ? result : url;
37094
+ }
37095
+ return url;
37077
37096
  });
37078
- js += importExpression;
37097
+ if (processedUrl !== p.value) {
37098
+ overwriteAttrValue(s, getAttrSourceCodeLocation(node, attrKey), processedUrl);
37099
+ }
37100
+ })());
37101
+ }
37102
+ else {
37103
+ const url = decodeURI(p.value);
37104
+ if (checkPublicFile(url, config)) {
37105
+ overwriteAttrValue(s, getAttrSourceCodeLocation(node, attrKey), toOutputPublicFilePath(url));
37079
37106
  }
37080
- else {
37081
- assetUrls.push({
37082
- attr: p,
37083
- sourceCodeLocation: attrSourceCodeLocation,
37084
- });
37107
+ else if (!isExcludedUrl(url)) {
37108
+ if (node.nodeName === 'link' &&
37109
+ isCSSRequest(url) &&
37110
+ // should not be converted if following attributes are present (#6748)
37111
+ !node.attrs.some((p) => p.prefix === undefined &&
37112
+ (p.name === 'media' || p.name === 'disabled'))) {
37113
+ // CSS references, convert to import
37114
+ const importExpression = `\nimport ${JSON.stringify(url)}`;
37115
+ styleUrls.push({
37116
+ url,
37117
+ start: nodeStartWithLeadingWhitespace(node),
37118
+ end: node.sourceCodeLocation.endOffset,
37119
+ });
37120
+ js += importExpression;
37121
+ }
37122
+ else {
37123
+ assetUrlsPromises.push((async () => {
37124
+ const processedUrl = await processAssetUrl(url);
37125
+ if (processedUrl !== url) {
37126
+ overwriteAttrValue(s, getAttrSourceCodeLocation(node, attrKey), processedUrl);
37127
+ }
37128
+ })());
37129
+ }
37085
37130
  }
37086
37131
  }
37087
- else if (checkPublicFile(url, config)) {
37088
- overwriteAttrValue(s, attrSourceCodeLocation, toOutputPublicFilePath(url));
37089
- }
37090
37132
  }
37091
37133
  }
37092
37134
  }
@@ -37127,38 +37169,15 @@ function buildHtmlPlugin(config) {
37127
37169
  if (someScriptsAreAsync && someScriptsAreDefer) {
37128
37170
  config.logger.warn(`\nMixed async and defer script modules in ${id}, output script will fallback to defer. Every script, including inline ones, need to be marked as async for your output script to be async.`);
37129
37171
  }
37130
- // for each encountered asset url, rewrite original html so that it
37131
- // references the post-build location, ignoring empty attributes and
37132
- // attributes that directly reference named output.
37133
- const namedOutput = Object.keys(config?.build?.rollupOptions?.input || {});
37134
- for (const { attr, sourceCodeLocation } of assetUrls) {
37135
- // assetsUrl may be encodeURI
37136
- const content = decodeURI(attr.value);
37137
- if (content !== '' && // Empty attribute
37138
- !namedOutput.includes(content) && // Direct reference to named output
37139
- !namedOutput.includes(removeLeadingSlash(content)) // Allow for absolute references as named output can't be an absolute path
37140
- ) {
37141
- try {
37142
- const url = attr.prefix === undefined && attr.name === 'srcset'
37143
- ? await processSrcSet(content, ({ url }) => urlToBuiltUrl(url, id, config, this))
37144
- : await urlToBuiltUrl(content, id, config, this);
37145
- overwriteAttrValue(s, sourceCodeLocation, url);
37146
- }
37147
- catch (e) {
37148
- if (e.code !== 'ENOENT') {
37149
- throw e;
37150
- }
37151
- }
37152
- }
37153
- }
37172
+ await Promise.all(assetUrlsPromises);
37154
37173
  // emit <script>import("./aaa")</script> asset
37155
37174
  for (const { start, end, url } of scriptUrls) {
37156
- if (!isExcludedUrl(url)) {
37157
- s.update(start, end, await urlToBuiltUrl(url, id, config, this));
37158
- }
37159
- else if (checkPublicFile(url, config)) {
37175
+ if (checkPublicFile(url, config)) {
37160
37176
  s.update(start, end, toOutputPublicFilePath(url));
37161
37177
  }
37178
+ else if (!isExcludedUrl(url)) {
37179
+ s.update(start, end, await urlToBuiltUrl(url, id, config, this));
37180
+ }
37162
37181
  }
37163
37182
  // ignore <link rel="stylesheet"> if its url can't be resolved
37164
37183
  const resolvedStyleUrls = await Promise.all(styleUrls.map(async (styleUrl) => ({
@@ -37669,20 +37688,22 @@ function incrementIndent(indent = '') {
37669
37688
  function getAttrKey(attr) {
37670
37689
  return attr.prefix === undefined ? attr.name : `${attr.prefix}:${attr.name}`;
37671
37690
  }
37691
+ function getAttrSourceCodeLocation(node, attrKey) {
37692
+ return node.sourceCodeLocation.attrs[attrKey];
37693
+ }
37672
37694
 
37673
37695
  function resolveCSSOptions(options) {
37674
- if (options?.lightningcss) {
37696
+ if (options?.transformer === 'lightningcss') {
37675
37697
  return {
37676
37698
  ...options,
37677
37699
  lightningcss: {
37678
37700
  ...options.lightningcss,
37679
- targets: options.lightningcss.targets ??
37701
+ targets: options.lightningcss?.targets ??
37680
37702
  convertTargets(ESBUILD_MODULES_TARGET),
37681
37703
  },
37682
37704
  };
37683
37705
  }
37684
- // TS doesn't narrow the type with the previous if :/
37685
- return options;
37706
+ return { ...options, lightningcss: undefined };
37686
37707
  }
37687
37708
  const cssModuleRE = new RegExp(`\\.module${CSS_LANGS_RE.source}`);
37688
37709
  const directRequestRE = /[?&]direct\b/;
@@ -38001,11 +38022,8 @@ function cssPostPlugin(config) {
38001
38022
  }
38002
38023
  if (opts.format === 'es' || opts.format === 'cjs') {
38003
38024
  const isEntry = chunk.isEntry && isPureCssChunk;
38004
- const cssAssetName = normalizePath$3(!isEntry && chunk.facadeModuleId
38005
- ? path$o.relative(config.root, chunk.facadeModuleId)
38006
- : chunk.name);
38007
- const lang = path$o.extname(cssAssetName).slice(1);
38008
- const cssFileName = ensureFileExt(cssAssetName, '.css');
38025
+ const cssAssetName = ensureFileExt(chunk.name, '.css');
38026
+ const originalFilename = getChunkOriginalFileName(chunk, config.root, opts.format);
38009
38027
  chunkCSS = resolveAssetUrlsInCss(chunkCSS, cssAssetName);
38010
38028
  const previousTask = emitTasks[emitTasks.length - 1];
38011
38029
  // finalizeCss is async which makes `emitFile` non-deterministic, so
@@ -38022,14 +38040,13 @@ function cssPostPlugin(config) {
38022
38040
  await thisTask;
38023
38041
  // emit corresponding css file
38024
38042
  const referenceId = this.emitFile({
38025
- name: path$o.basename(cssFileName),
38043
+ name: cssAssetName,
38026
38044
  type: 'asset',
38027
38045
  source: chunkCSS,
38028
38046
  });
38029
- const originalName = isPreProcessor(lang) ? cssAssetName : cssFileName;
38030
38047
  generatedAssets
38031
38048
  .get(config)
38032
- .set(referenceId, { originalName, isEntry });
38049
+ .set(referenceId, { originalName: originalFilename, isEntry });
38033
38050
  chunk.viteMetadata.importedCss.add(this.getFileName(referenceId));
38034
38051
  if (emitTasksLength === emitTasks.length) {
38035
38052
  // this is the last task, clear `emitTasks` to free up memory
@@ -38479,8 +38496,8 @@ function createCachedImport(imp) {
38479
38496
  return cached;
38480
38497
  };
38481
38498
  }
38482
- const importPostcssImport = createCachedImport(() => import('./dep-ayAPZ1OT.js').then(function (n) { return n.i; }));
38483
- const importPostcssModules = createCachedImport(() => import('./dep-wO2juHOz.js').then(function (n) { return n.i; }));
38499
+ const importPostcssImport = createCachedImport(() => import('./dep-qfw-A_Gb.js').then(function (n) { return n.i; }));
38500
+ const importPostcssModules = createCachedImport(() => import('./dep-faMUqRRE.js').then(function (n) { return n.i; }));
38484
38501
  const importPostcss = createCachedImport(() => import('postcss'));
38485
38502
  /**
38486
38503
  * @experimental
@@ -39187,7 +39204,9 @@ async function compileLightningCSS(id, src, config, urlReplacer) {
39187
39204
  },
39188
39205
  },
39189
39206
  minify: config.isProduction && !!config.build.cssMinify,
39190
- sourceMap: config.css?.devSourcemap,
39207
+ sourceMap: config.command === 'build'
39208
+ ? !!config.build.sourcemap
39209
+ : config.css?.devSourcemap,
39191
39210
  analyzeDependencies: true,
39192
39211
  cssModules: cssModuleRE.test(id)
39193
39212
  ? config.css?.lightningcss?.cssModules ?? true
@@ -47404,7 +47423,7 @@ function sirv (dir, opts={}) {
47404
47423
  }
47405
47424
 
47406
47425
  const knownJavascriptExtensionRE = /\.[tj]sx?$/;
47407
- const sirvOptions = ({ headers, shouldServe, }) => {
47426
+ const sirvOptions = ({ getHeaders, shouldServe, }) => {
47408
47427
  return {
47409
47428
  dev: true,
47410
47429
  etag: true,
@@ -47418,6 +47437,7 @@ const sirvOptions = ({ headers, shouldServe, }) => {
47418
47437
  if (knownJavascriptExtensionRE.test(pathname)) {
47419
47438
  res.setHeader('Content-Type', 'application/javascript');
47420
47439
  }
47440
+ const headers = getHeaders();
47421
47441
  if (headers) {
47422
47442
  for (const name in headers) {
47423
47443
  res.setHeader(name, headers[name]);
@@ -47427,9 +47447,10 @@ const sirvOptions = ({ headers, shouldServe, }) => {
47427
47447
  shouldServe,
47428
47448
  };
47429
47449
  };
47430
- function servePublicMiddleware(dir, headers) {
47450
+ function servePublicMiddleware(server) {
47451
+ const dir = server.config.publicDir;
47431
47452
  const serve = sirv(dir, sirvOptions({
47432
- headers,
47453
+ getHeaders: () => server.config.server.headers,
47433
47454
  shouldServe: (filePath) => shouldServeFile(filePath, dir),
47434
47455
  }));
47435
47456
  // Keep the named function. The name is visible in debug logs via `DEBUG=connect:dispatcher ...`
@@ -47441,9 +47462,10 @@ function servePublicMiddleware(dir, headers) {
47441
47462
  serve(req, res, next);
47442
47463
  };
47443
47464
  }
47444
- function serveStaticMiddleware(dir, server) {
47465
+ function serveStaticMiddleware(server) {
47466
+ const dir = server.config.root;
47445
47467
  const serve = sirv(dir, sirvOptions({
47446
- headers: server.config.server.headers,
47468
+ getHeaders: () => server.config.server.headers,
47447
47469
  }));
47448
47470
  // Keep the named function. The name is visible in debug logs via `DEBUG=connect:dispatcher ...`
47449
47471
  return function viteServeStaticMiddleware(req, res, next) {
@@ -47493,7 +47515,7 @@ function serveStaticMiddleware(dir, server) {
47493
47515
  };
47494
47516
  }
47495
47517
  function serveRawFsMiddleware(server) {
47496
- const serveFromRoot = sirv('/', sirvOptions({ headers: server.config.server.headers }));
47518
+ const serveFromRoot = sirv('/', sirvOptions({ getHeaders: () => server.config.server.headers }));
47497
47519
  // Keep the named function. The name is visible in debug logs via `DEBUG=connect:dispatcher ...`
47498
47520
  return function viteServeRawFsMiddleware(req, res, next) {
47499
47521
  const url = new URL(req.url.replace(/^\/{2,}/, '/'), 'http://example.com');
@@ -54913,9 +54935,6 @@ function createWebSocketServer(server, config, httpsOptions) {
54913
54935
  });
54914
54936
  });
54915
54937
  },
54916
- [ASYNC_DISPOSE]() {
54917
- return this.close();
54918
- },
54919
54938
  };
54920
54939
  }
54921
54940
 
@@ -57230,7 +57249,6 @@ function send(req, res, content, type, options) {
57230
57249
  const debugCache = createDebugger('vite:cache');
57231
57250
  const knownIgnoreList = new Set(['/', '/favicon.ico']);
57232
57251
  function transformMiddleware(server) {
57233
- const { config: { root, logger }, moduleGraph, } = server;
57234
57252
  // Keep the named function. The name is visible in debug logs via `DEBUG=connect:dispatcher ...`
57235
57253
  return async function viteTransformMiddleware(req, res, next) {
57236
57254
  if (req.method !== 'GET' || knownIgnoreList.has(req.url)) {
@@ -57254,10 +57272,10 @@ function transformMiddleware(server) {
57254
57272
  // means that the dependency has already been pre-bundled and loaded
57255
57273
  const sourcemapPath = url.startsWith(FS_PREFIX)
57256
57274
  ? fsPathFromId(url)
57257
- : normalizePath$3(path$o.resolve(root, url.slice(1)));
57275
+ : normalizePath$3(path$o.resolve(server.config.root, url.slice(1)));
57258
57276
  try {
57259
57277
  const map = JSON.parse(await fsp.readFile(sourcemapPath, 'utf-8'));
57260
- applySourcemapIgnoreList(map, sourcemapPath, server.config.server.sourcemapIgnoreList, logger);
57278
+ applySourcemapIgnoreList(map, sourcemapPath, server.config.server.sourcemapIgnoreList, server.config.logger);
57261
57279
  return send(req, res, JSON.stringify(map), 'json', {
57262
57280
  headers: server.config.server.headers,
57263
57281
  });
@@ -57282,8 +57300,7 @@ function transformMiddleware(server) {
57282
57300
  }
57283
57301
  else {
57284
57302
  const originalUrl = url.replace(/\.map($|\?)/, '$1');
57285
- const map = (await moduleGraph.getModuleByUrl(originalUrl, false))
57286
- ?.transformResult?.map;
57303
+ const map = (await server.moduleGraph.getModuleByUrl(originalUrl, false))?.transformResult?.map;
57287
57304
  if (map) {
57288
57305
  return send(req, res, JSON.stringify(map), 'json', {
57289
57306
  headers: server.config.server.headers,
@@ -57321,7 +57338,7 @@ function transformMiddleware(server) {
57321
57338
  `Files in the public directory are served at the root path.\n` +
57322
57339
  `Instead of ${colors$1.cyan(url)}, use ${colors$1.cyan(url.replace(publicPath, '/'))}.`;
57323
57340
  }
57324
- logger.warn(colors$1.yellow(warning));
57341
+ server.config.logger.warn(colors$1.yellow(warning));
57325
57342
  }
57326
57343
  }
57327
57344
  if (isJSRequest(url) ||
@@ -57343,9 +57360,9 @@ function transformMiddleware(server) {
57343
57360
  // check if we can return 304 early
57344
57361
  const ifNoneMatch = req.headers['if-none-match'];
57345
57362
  if (ifNoneMatch &&
57346
- (await moduleGraph.getModuleByUrl(url, false))?.transformResult
57363
+ (await server.moduleGraph.getModuleByUrl(url, false))?.transformResult
57347
57364
  ?.etag === ifNoneMatch) {
57348
- debugCache?.(`[304] ${prettifyUrl(url, root)}`);
57365
+ debugCache?.(`[304] ${prettifyUrl(url, server.config.root)}`);
57349
57366
  res.statusCode = 304;
57350
57367
  return res.end();
57351
57368
  }
@@ -57376,7 +57393,7 @@ function transformMiddleware(server) {
57376
57393
  res.end();
57377
57394
  }
57378
57395
  // This timeout is unexpected
57379
- logger.error(e.message);
57396
+ server.config.logger.error(e.message);
57380
57397
  return;
57381
57398
  }
57382
57399
  if (e?.code === ERR_OUTDATED_OPTIMIZED_DEP) {
@@ -57419,13 +57436,13 @@ function transformMiddleware(server) {
57419
57436
  };
57420
57437
  }
57421
57438
 
57422
- function createDevHtmlTransformFn(server) {
57423
- const [preHooks, normalHooks, postHooks] = resolveHtmlTransforms(server.config.plugins, server.config.logger);
57424
- return (url, html, originalUrl) => {
57439
+ function createDevHtmlTransformFn(config) {
57440
+ const [preHooks, normalHooks, postHooks] = resolveHtmlTransforms(config.plugins, config.logger);
57441
+ return (server, url, html, originalUrl) => {
57425
57442
  return applyHtmlTransforms(html, [
57426
- preImportMapHook(server.config),
57443
+ preImportMapHook(config),
57427
57444
  ...preHooks,
57428
- htmlEnvHook(server.config),
57445
+ htmlEnvHook(config),
57429
57446
  devHtmlHook,
57430
57447
  ...normalHooks,
57431
57448
  ...postHooks,
@@ -57452,39 +57469,42 @@ function shouldPreTransform(url, config) {
57452
57469
  const wordCharRE = /\w/;
57453
57470
  const isSrcSet = (attr) => attr.name === 'srcset' && attr.prefix === undefined;
57454
57471
  const processNodeUrl = (url, useSrcSetReplacer, config, htmlPath, originalUrl, server) => {
57455
- if (server?.moduleGraph) {
57456
- const mod = server.moduleGraph.urlToModuleMap.get(url);
57457
- if (mod && mod.lastHMRTimestamp > 0) {
57458
- url = injectQuery(url, `t=${mod.lastHMRTimestamp}`);
57459
- }
57460
- }
57461
- if ((url[0] === '/' && url[1] !== '/') ||
57462
- // #3230 if some request url (localhost:3000/a/b) return to fallback html, the relative assets
57463
- // path will add `/a/` prefix, it will caused 404.
57464
- //
57465
- // skip if url contains `:` as it implies a url protocol or Windows path that we don't want to replace.
57466
- //
57467
- // rewrite `./index.js` -> `localhost:5173/a/index.js`.
57468
- // rewrite `../index.js` -> `localhost:5173/index.js`.
57469
- // rewrite `relative/index.js` -> `localhost:5173/a/relative/index.js`.
57470
- ((url[0] === '.' || (wordCharRE.test(url[0]) && !url.includes(':'))) &&
57471
- originalUrl &&
57472
- originalUrl !== '/' &&
57473
- htmlPath === '/index.html')) {
57474
- // prefix with base (dev only, base is never relative)
57475
- const replacer = (url) => {
57472
+ // prefix with base (dev only, base is never relative)
57473
+ const replacer = (url) => {
57474
+ if (server?.moduleGraph) {
57475
+ const mod = server.moduleGraph.urlToModuleMap.get(url);
57476
+ if (mod && mod.lastHMRTimestamp > 0) {
57477
+ url = injectQuery(url, `t=${mod.lastHMRTimestamp}`);
57478
+ }
57479
+ }
57480
+ if ((url[0] === '/' && url[1] !== '/') ||
57481
+ // #3230 if some request url (localhost:3000/a/b) return to fallback html, the relative assets
57482
+ // path will add `/a/` prefix, it will caused 404.
57483
+ //
57484
+ // skip if url contains `:` as it implies a url protocol or Windows path that we don't want to replace.
57485
+ //
57486
+ // rewrite `./index.js` -> `localhost:5173/a/index.js`.
57487
+ // rewrite `../index.js` -> `localhost:5173/index.js`.
57488
+ // rewrite `relative/index.js` -> `localhost:5173/a/relative/index.js`.
57489
+ ((url[0] === '.' || (wordCharRE.test(url[0]) && !url.includes(':'))) &&
57490
+ originalUrl &&
57491
+ originalUrl !== '/' &&
57492
+ htmlPath === '/index.html')) {
57476
57493
  const devBase = config.base;
57477
57494
  const fullUrl = path$o.posix.join(devBase, url);
57478
57495
  if (server && shouldPreTransform(url, config)) {
57479
57496
  preTransformRequest(server, fullUrl, devBase);
57480
57497
  }
57481
57498
  return fullUrl;
57482
- };
57483
- const processedUrl = useSrcSetReplacer
57484
- ? processSrcSetSync(url, ({ url }) => replacer(url))
57485
- : replacer(url);
57486
- return processedUrl;
57487
- }
57499
+ }
57500
+ else {
57501
+ return url;
57502
+ }
57503
+ };
57504
+ const processedUrl = useSrcSetReplacer
57505
+ ? processSrcSetSync(url, ({ url }) => replacer(url))
57506
+ : replacer(url);
57507
+ return processedUrl;
57488
57508
  };
57489
57509
  const devHtmlHook = async (html, { path: htmlPath, filename, server, originalUrl }) => {
57490
57510
  const { config, moduleGraph, watcher } = server;
@@ -57545,7 +57565,7 @@ const devHtmlHook = async (html, { path: htmlPath, filename, server, originalUrl
57545
57565
  const { src, sourceCodeLocation, isModule } = getScriptInfo(node);
57546
57566
  if (src) {
57547
57567
  const processedUrl = processNodeUrl(src.value, isSrcSet(src), config, htmlPath, originalUrl, server);
57548
- if (processedUrl) {
57568
+ if (processedUrl !== src.value) {
57549
57569
  overwriteAttrValue(s, sourceCodeLocation, processedUrl);
57550
57570
  }
57551
57571
  }
@@ -57556,7 +57576,7 @@ const devHtmlHook = async (html, { path: htmlPath, filename, server, originalUrl
57556
57576
  const scriptNode = node.childNodes[node.childNodes.length - 1];
57557
57577
  for (const { url, start, end, } of extractImportExpressionFromClassicScript(scriptNode)) {
57558
57578
  const processedUrl = processNodeUrl(url, false, config, htmlPath, originalUrl);
57559
- if (processedUrl) {
57579
+ if (processedUrl !== url) {
57560
57580
  s.update(start, end, processedUrl);
57561
57581
  }
57562
57582
  }
@@ -57586,7 +57606,7 @@ const devHtmlHook = async (html, { path: htmlPath, filename, server, originalUrl
57586
57606
  const attrKey = getAttrKey(p);
57587
57607
  if (p.value && assetAttrs.includes(attrKey)) {
57588
57608
  const processedUrl = processNodeUrl(p.value, isSrcSet(p), config, htmlPath, originalUrl);
57589
- if (processedUrl) {
57609
+ if (processedUrl !== p.value) {
57590
57610
  overwriteAttrValue(s, node.sourceCodeLocation.attrs[attrKey], processedUrl);
57591
57611
  }
57592
57612
  }
@@ -57642,9 +57662,6 @@ const devHtmlHook = async (html, { path: htmlPath, filename, server, originalUrl
57642
57662
  };
57643
57663
  function indexHtmlMiddleware(root, server) {
57644
57664
  const isDev = isDevServer(server);
57645
- const headers = isDev
57646
- ? server.config.server.headers
57647
- : server.config.preview.headers;
57648
57665
  // Keep the named function. The name is visible in debug logs via `DEBUG=connect:dispatcher ...`
57649
57666
  return async function viteIndexHtmlMiddleware(req, res, next) {
57650
57667
  if (res.writableEnded) {
@@ -57661,6 +57678,9 @@ function indexHtmlMiddleware(root, server) {
57661
57678
  filePath = path$o.join(root, decodeURIComponent(url));
57662
57679
  }
57663
57680
  if (fs$l.existsSync(filePath)) {
57681
+ const headers = isDev
57682
+ ? server.config.server.headers
57683
+ : server.config.preview.headers;
57664
57684
  try {
57665
57685
  let html = await fsp.readFile(filePath, 'utf-8');
57666
57686
  if (isDev) {
@@ -57807,7 +57827,9 @@ class ModuleGraph {
57807
57827
  });
57808
57828
  }
57809
57829
  }
57810
- invalidateModule(mod, seen = new Set(), timestamp = Date.now(), isHmr = false, hmrBoundaries = [], softInvalidate = false) {
57830
+ invalidateModule(mod, seen = new Set(), timestamp = Date.now(), isHmr = false,
57831
+ /** @internal */
57832
+ softInvalidate = false) {
57811
57833
  const prevInvalidationState = mod.invalidationState;
57812
57834
  const prevSsrInvalidationState = mod.ssrInvalidationState;
57813
57835
  // Handle soft invalidation before the `seen` check, as consecutive soft/hard invalidations can
@@ -57844,14 +57866,6 @@ class ModuleGraph {
57844
57866
  mod.ssrTransformResult = null;
57845
57867
  mod.ssrModule = null;
57846
57868
  mod.ssrError = null;
57847
- // https://github.com/vitejs/vite/issues/3033
57848
- // Given b.js -> c.js -> b.js (arrow means top-level import), if c.js self-accepts
57849
- // and refetches itself, the execution order becomes c.js -> b.js -> c.js. The import
57850
- // order matters here as it will fail. The workaround for now is to not hmr invalidate
57851
- // b.js so that c.js refetches the already cached b.js, skipping the import loop.
57852
- if (hmrBoundaries.includes(mod)) {
57853
- return;
57854
- }
57855
57869
  mod.importers.forEach((importer) => {
57856
57870
  if (!importer.acceptedHmrDeps.has(mod)) {
57857
57871
  // If the importer statically imports the current module, we can soft-invalidate the importer
@@ -57859,7 +57873,7 @@ class ModuleGraph {
57859
57873
  // we can only soft invalidate if the current module was also soft-invalidated. A soft-invalidation
57860
57874
  // doesn't need to trigger a re-load and re-transform of the importer.
57861
57875
  const shouldSoftInvalidateImporter = importer.staticImportedUrls?.has(mod.url) || softInvalidate;
57862
- this.invalidateModule(importer, seen, timestamp, isHmr, undefined, shouldSoftInvalidateImporter);
57876
+ this.invalidateModule(importer, seen, timestamp, isHmr, shouldSoftInvalidateImporter);
57863
57877
  }
57864
57878
  });
57865
57879
  }
@@ -57878,7 +57892,9 @@ class ModuleGraph {
57878
57892
  * @param staticImportedUrls Subset of `importedModules` where they're statically imported in code.
57879
57893
  * This is only used for soft invalidations so `undefined` is fine but may cause more runtime processing.
57880
57894
  */
57881
- async updateModuleInfo(mod, importedModules, importedBindings, acceptedModules, acceptedExports, isSelfAccepting, ssr, staticImportedUrls) {
57895
+ async updateModuleInfo(mod, importedModules, importedBindings, acceptedModules, acceptedExports, isSelfAccepting, ssr,
57896
+ /** @internal */
57897
+ staticImportedUrls) {
57882
57898
  mod.isSelfAccepting = isSelfAccepting;
57883
57899
  const prevImports = ssr ? mod.ssrImportedModules : mod.clientImportedModules;
57884
57900
  let noLongerImported;
@@ -58324,7 +58340,8 @@ async function _createServer(inlineConfig = {}, options) {
58324
58340
  const container = await createPluginContainer(config, moduleGraph, watcher);
58325
58341
  const closeHttpServer = createServerCloseFn(httpServer);
58326
58342
  let exitProcess;
58327
- const server = {
58343
+ const devHtmlTransformFn = createDevHtmlTransformFn(config);
58344
+ let server = {
58328
58345
  config,
58329
58346
  middlewares,
58330
58347
  httpServer,
@@ -58353,7 +58370,9 @@ async function _createServer(inlineConfig = {}, options) {
58353
58370
  });
58354
58371
  });
58355
58372
  },
58356
- transformIndexHtml: null,
58373
+ transformIndexHtml(url, html, originalUrl) {
58374
+ return devHtmlTransformFn(server, url, html, originalUrl);
58375
+ },
58357
58376
  async ssrLoadModule(url, opts) {
58358
58377
  if (isDepsOptimizerEnabled(config, true)) {
58359
58378
  await initDevSsrDepsOptimizer(config, server);
@@ -58442,9 +58461,6 @@ async function _createServer(inlineConfig = {}, options) {
58442
58461
  }
58443
58462
  server.resolvedUrls = null;
58444
58463
  },
58445
- [ASYNC_DISPOSE]() {
58446
- return this.close();
58447
- },
58448
58464
  printUrls() {
58449
58465
  if (server.resolvedUrls) {
58450
58466
  printServerUrls(server.resolvedUrls, serverConfig.host, config.logger.info);
@@ -58469,6 +58485,11 @@ async function _createServer(inlineConfig = {}, options) {
58469
58485
  }
58470
58486
  return server._restartPromise;
58471
58487
  },
58488
+ _setInternalServer(_server) {
58489
+ // Rebind internal the server variable so functions reference the user
58490
+ // server instance after a restart
58491
+ server = _server;
58492
+ },
58472
58493
  _restartPromise: null,
58473
58494
  _importGlobMap: new Map(),
58474
58495
  _forceOptimizeOnRestart: false,
@@ -58476,7 +58497,6 @@ async function _createServer(inlineConfig = {}, options) {
58476
58497
  _fsDenyGlob: picomatch$4(config.server.fs.deny, { matchBase: true }),
58477
58498
  _shortcutsOptions: undefined,
58478
58499
  };
58479
- server.transformIndexHtml = createDevHtmlTransformFn(server);
58480
58500
  if (!middlewareMode) {
58481
58501
  exitProcess = async () => {
58482
58502
  try {
@@ -58575,13 +58595,13 @@ async function _createServer(inlineConfig = {}, options) {
58575
58595
  // this applies before the transform middleware so that these files are served
58576
58596
  // as-is without transforms.
58577
58597
  if (config.publicDir) {
58578
- middlewares.use(servePublicMiddleware(config.publicDir, config.server.headers));
58598
+ middlewares.use(servePublicMiddleware(server));
58579
58599
  }
58580
58600
  // main transform middleware
58581
58601
  middlewares.use(transformMiddleware(server));
58582
58602
  // serve static files
58583
58603
  middlewares.use(serveRawFsMiddleware(server));
58584
- middlewares.use(serveStaticMiddleware(root, server));
58604
+ middlewares.use(serveStaticMiddleware(server));
58585
58605
  // html fallback
58586
58606
  if (config.appType === 'spa' || config.appType === 'mpa') {
58587
58607
  middlewares.use(htmlFallbackMiddleware(root, config.appType === 'spa'));
@@ -58650,14 +58670,22 @@ async function startServer(server, inlinePort) {
58650
58670
  throw new Error('Cannot call server.listen in middleware mode.');
58651
58671
  }
58652
58672
  const options = server.config.server;
58653
- const port = inlinePort ?? options.port ?? DEFAULT_DEV_PORT;
58654
58673
  const hostname = await resolveHostname(options.host);
58655
- await httpServerStart(httpServer, {
58674
+ const configPort = inlinePort ?? options.port;
58675
+ // When using non strict port for the dev server, the running port can be different from the config one.
58676
+ // When restarting, the original port may be available but to avoid a switch of URL for the running
58677
+ // browser tabs, we enforce the previously used port, expect if the config port changed.
58678
+ const port = (!configPort || configPort === server._configServerPort
58679
+ ? server._currentServerPort
58680
+ : configPort) ?? DEFAULT_DEV_PORT;
58681
+ server._configServerPort = configPort;
58682
+ const serverPort = await httpServerStart(httpServer, {
58656
58683
  port,
58657
58684
  strictPort: options.strictPort,
58658
58685
  host: hostname.host,
58659
58686
  logger: server.config.logger,
58660
58687
  });
58688
+ server._currentServerPort = serverPort;
58661
58689
  }
58662
58690
  function createServerCloseFn(server) {
58663
58691
  if (!server) {
@@ -58750,7 +58778,11 @@ async function restartServer(server) {
58750
58778
  }
58751
58779
  await server.close();
58752
58780
  // Assign new server props to existing server instance
58781
+ newServer._configServerPort = server._configServerPort;
58782
+ newServer._currentServerPort = server._currentServerPort;
58753
58783
  Object.assign(server, newServer);
58784
+ // Rebind internal server variable so functions reference the user server
58785
+ newServer._setInternalServer(server);
58754
58786
  const { logger, server: { port, middlewareMode }, } = server.config;
58755
58787
  if (!middlewareMode) {
58756
58788
  await server.listen(port, true);
@@ -58878,12 +58910,12 @@ function updateModules(file, modules, timestamp, { config, ws, moduleGraph }, af
58878
58910
  for (const mod of modules) {
58879
58911
  const boundaries = [];
58880
58912
  const hasDeadEnd = propagateUpdate(mod, traversedModules, boundaries);
58881
- moduleGraph.invalidateModule(mod, invalidatedModules, timestamp, true, boundaries.map((b) => b.boundary));
58913
+ moduleGraph.invalidateModule(mod, invalidatedModules, timestamp, true);
58882
58914
  if (needFullReload) {
58883
58915
  continue;
58884
58916
  }
58885
58917
  if (hasDeadEnd) {
58886
- needFullReload = true;
58918
+ needFullReload = hasDeadEnd;
58887
58919
  continue;
58888
58920
  }
58889
58921
  updates.push(...boundaries.map(({ boundary, acceptedVia }) => ({
@@ -58897,10 +58929,10 @@ function updateModules(file, modules, timestamp, { config, ws, moduleGraph }, af
58897
58929
  })));
58898
58930
  }
58899
58931
  if (needFullReload) {
58900
- config.logger.info(colors$1.green(`page reload `) + colors$1.dim(file), {
58901
- clear: !afterInvalidation,
58902
- timestamp: true,
58903
- });
58932
+ const reason = typeof needFullReload === 'string'
58933
+ ? colors$1.dim(` (${needFullReload})`)
58934
+ : '';
58935
+ config.logger.info(colors$1.green(`page reload `) + colors$1.dim(file) + reason, { clear: !afterInvalidation, timestamp: true });
58904
58936
  ws.send({
58905
58937
  type: 'full-reload',
58906
58938
  });
@@ -58953,6 +58985,9 @@ function propagateUpdate(node, traversedModules, boundaries, currentChain = [nod
58953
58985
  }
58954
58986
  if (node.isSelfAccepting) {
58955
58987
  boundaries.push({ boundary: node, acceptedVia: node });
58988
+ const result = isNodeWithinCircularImports(node, currentChain);
58989
+ if (result)
58990
+ return result;
58956
58991
  // additionally check for CSS importers, since a PostCSS plugin like
58957
58992
  // Tailwind JIT may register any file as a dependency to a CSS file.
58958
58993
  for (const importer of node.importers) {
@@ -58969,6 +59004,9 @@ function propagateUpdate(node, traversedModules, boundaries, currentChain = [nod
58969
59004
  // so that they do get the fresh imported module when/if they are reloaded.
58970
59005
  if (node.acceptedHmrExports) {
58971
59006
  boundaries.push({ boundary: node, acceptedVia: node });
59007
+ const result = isNodeWithinCircularImports(node, currentChain);
59008
+ if (result)
59009
+ return result;
58972
59010
  }
58973
59011
  else {
58974
59012
  if (!node.importers.size) {
@@ -58986,6 +59024,9 @@ function propagateUpdate(node, traversedModules, boundaries, currentChain = [nod
58986
59024
  const subChain = currentChain.concat(importer);
58987
59025
  if (importer.acceptedHmrDeps.has(node)) {
58988
59026
  boundaries.push({ boundary: importer, acceptedVia: node });
59027
+ const result = isNodeWithinCircularImports(importer, subChain);
59028
+ if (result)
59029
+ return result;
58989
59030
  continue;
58990
59031
  }
58991
59032
  if (node.id && node.acceptedHmrExports && importer.importedBindings) {
@@ -58995,12 +59036,67 @@ function propagateUpdate(node, traversedModules, boundaries, currentChain = [nod
58995
59036
  continue;
58996
59037
  }
58997
59038
  }
58998
- if (currentChain.includes(importer)) {
58999
- // circular deps is considered dead end
59039
+ if (!currentChain.includes(importer) &&
59040
+ propagateUpdate(importer, traversedModules, boundaries, subChain)) {
59000
59041
  return true;
59001
59042
  }
59002
- if (propagateUpdate(importer, traversedModules, boundaries, subChain)) {
59003
- return true;
59043
+ }
59044
+ return false;
59045
+ }
59046
+ /**
59047
+ * Check importers recursively if it's an import loop. An accepted module within
59048
+ * an import loop cannot recover its execution order and should be reloaded.
59049
+ *
59050
+ * @param node The node that accepts HMR and is a boundary
59051
+ * @param nodeChain The chain of nodes/imports that lead to the node.
59052
+ * (The last node in the chain imports the `node` parameter)
59053
+ * @param currentChain The current chain tracked from the `node` parameter
59054
+ */
59055
+ function isNodeWithinCircularImports(node, nodeChain, currentChain = [node]) {
59056
+ // To help visualize how each parameters work, imagine this import graph:
59057
+ //
59058
+ // A -> B -> C -> ACCEPTED -> D -> E -> NODE
59059
+ // ^--------------------------|
59060
+ //
59061
+ // ACCEPTED: the node that accepts HMR. the `node` parameter.
59062
+ // NODE : the initial node that triggered this HMR.
59063
+ //
59064
+ // This function will return true in the above graph, which:
59065
+ // `node` : ACCEPTED
59066
+ // `nodeChain` : [NODE, E, D, ACCEPTED]
59067
+ // `currentChain` : [ACCEPTED, C, B]
59068
+ //
59069
+ // It works by checking if any `node` importers are within `nodeChain`, which
59070
+ // means there's an import loop with a HMR-accepted module in it.
59071
+ for (const importer of node.importers) {
59072
+ // Node may import itself which is safe
59073
+ if (importer === node)
59074
+ continue;
59075
+ // Check circular imports
59076
+ const importerIndex = nodeChain.indexOf(importer);
59077
+ if (importerIndex > -1) {
59078
+ // Log extra debug information so users can fix and remove the circular imports
59079
+ if (debugHmr) {
59080
+ // Following explanation above:
59081
+ // `importer` : E
59082
+ // `currentChain` reversed : [B, C, ACCEPTED]
59083
+ // `nodeChain` sliced & reversed : [D, E]
59084
+ // Combined : [E, B, C, ACCEPTED, D, E]
59085
+ const importChain = [
59086
+ importer,
59087
+ ...[...currentChain].reverse(),
59088
+ ...nodeChain.slice(importerIndex, -1).reverse(),
59089
+ ];
59090
+ debugHmr(colors$1.yellow(`circular imports detected: `) +
59091
+ importChain.map((m) => colors$1.dim(m.url)).join(' -> '));
59092
+ }
59093
+ return 'circular imports';
59094
+ }
59095
+ // Continue recursively
59096
+ if (!currentChain.includes(importer)) {
59097
+ const result = isNodeWithinCircularImports(importer, nodeChain, currentChain.concat(importer));
59098
+ if (result)
59099
+ return result;
59004
59100
  }
59005
59101
  }
59006
59102
  return false;
@@ -59360,6 +59456,324 @@ function canJsonParse(value) {
59360
59456
  }
59361
59457
  }
59362
59458
 
59459
+ const WORKER_FILE_ID = 'worker_file';
59460
+ const workerCache = new WeakMap();
59461
+ function saveEmitWorkerAsset(config, asset) {
59462
+ const fileName = asset.fileName;
59463
+ const workerMap = workerCache.get(config.mainConfig || config);
59464
+ workerMap.assets.set(fileName, asset);
59465
+ }
59466
+ async function bundleWorkerEntry(config, id, query) {
59467
+ // bundle the file as entry to support imports
59468
+ const { rollup } = await import('rollup');
59469
+ const { plugins, rollupOptions, format } = config.worker;
59470
+ const bundle = await rollup({
59471
+ ...rollupOptions,
59472
+ input: cleanUrl(id),
59473
+ plugins: await plugins(),
59474
+ onwarn(warning, warn) {
59475
+ onRollupWarning(warning, warn, config);
59476
+ },
59477
+ preserveEntrySignatures: false,
59478
+ });
59479
+ let chunk;
59480
+ try {
59481
+ const workerOutputConfig = config.worker.rollupOptions.output;
59482
+ const workerConfig = workerOutputConfig
59483
+ ? Array.isArray(workerOutputConfig)
59484
+ ? workerOutputConfig[0] || {}
59485
+ : workerOutputConfig
59486
+ : {};
59487
+ const { output: [outputChunk, ...outputChunks], } = await bundle.generate({
59488
+ entryFileNames: path$o.posix.join(config.build.assetsDir, '[name]-[hash].js'),
59489
+ chunkFileNames: path$o.posix.join(config.build.assetsDir, '[name]-[hash].js'),
59490
+ assetFileNames: path$o.posix.join(config.build.assetsDir, '[name]-[hash].[ext]'),
59491
+ ...workerConfig,
59492
+ format,
59493
+ sourcemap: config.build.sourcemap,
59494
+ });
59495
+ chunk = outputChunk;
59496
+ outputChunks.forEach((outputChunk) => {
59497
+ if (outputChunk.type === 'asset') {
59498
+ saveEmitWorkerAsset(config, outputChunk);
59499
+ }
59500
+ else if (outputChunk.type === 'chunk') {
59501
+ saveEmitWorkerAsset(config, {
59502
+ fileName: outputChunk.fileName,
59503
+ source: outputChunk.code,
59504
+ type: 'asset',
59505
+ });
59506
+ }
59507
+ });
59508
+ }
59509
+ finally {
59510
+ await bundle.close();
59511
+ }
59512
+ return emitSourcemapForWorkerEntry(config, query, chunk);
59513
+ }
59514
+ function emitSourcemapForWorkerEntry(config, query, chunk) {
59515
+ const { map: sourcemap } = chunk;
59516
+ if (sourcemap) {
59517
+ if (config.build.sourcemap === 'hidden' ||
59518
+ config.build.sourcemap === true) {
59519
+ const data = sourcemap.toString();
59520
+ const mapFileName = chunk.fileName + '.map';
59521
+ saveEmitWorkerAsset(config, {
59522
+ fileName: mapFileName,
59523
+ type: 'asset',
59524
+ source: data,
59525
+ });
59526
+ }
59527
+ }
59528
+ return chunk;
59529
+ }
59530
+ const workerAssetUrlRE = /__VITE_WORKER_ASSET__([a-z\d]{8})__/g;
59531
+ function encodeWorkerAssetFileName(fileName, workerCache) {
59532
+ const { fileNameHash } = workerCache;
59533
+ const hash = getHash(fileName);
59534
+ if (!fileNameHash.get(hash)) {
59535
+ fileNameHash.set(hash, fileName);
59536
+ }
59537
+ return `__VITE_WORKER_ASSET__${hash}__`;
59538
+ }
59539
+ async function workerFileToUrl(config, id, query) {
59540
+ const workerMap = workerCache.get(config.mainConfig || config);
59541
+ let fileName = workerMap.bundle.get(id);
59542
+ if (!fileName) {
59543
+ const outputChunk = await bundleWorkerEntry(config, id, query);
59544
+ fileName = outputChunk.fileName;
59545
+ saveEmitWorkerAsset(config, {
59546
+ fileName,
59547
+ source: outputChunk.code,
59548
+ type: 'asset',
59549
+ });
59550
+ workerMap.bundle.set(id, fileName);
59551
+ }
59552
+ return encodeWorkerAssetFileName(fileName, workerMap);
59553
+ }
59554
+ function webWorkerPostPlugin() {
59555
+ return {
59556
+ name: 'vite:worker-post',
59557
+ resolveImportMeta(property, { chunkId, format }) {
59558
+ // document is undefined in the worker, so we need to avoid it in iife
59559
+ if (property === 'url' && format === 'iife') {
59560
+ return 'self.location.href';
59561
+ }
59562
+ return null;
59563
+ },
59564
+ };
59565
+ }
59566
+ function webWorkerPlugin(config) {
59567
+ const isBuild = config.command === 'build';
59568
+ let server;
59569
+ const isWorker = config.isWorker;
59570
+ const isWorkerQueryId = (id) => {
59571
+ const parsedQuery = parseRequest(id);
59572
+ if (parsedQuery &&
59573
+ (parsedQuery.worker ?? parsedQuery.sharedworker) != null) {
59574
+ return true;
59575
+ }
59576
+ return false;
59577
+ };
59578
+ return {
59579
+ name: 'vite:worker',
59580
+ configureServer(_server) {
59581
+ server = _server;
59582
+ },
59583
+ buildStart() {
59584
+ if (isWorker) {
59585
+ return;
59586
+ }
59587
+ workerCache.set(config, {
59588
+ assets: new Map(),
59589
+ bundle: new Map(),
59590
+ fileNameHash: new Map(),
59591
+ });
59592
+ },
59593
+ load(id) {
59594
+ if (isBuild && isWorkerQueryId(id)) {
59595
+ return '';
59596
+ }
59597
+ },
59598
+ shouldTransformCachedModule({ id }) {
59599
+ if (isBuild && config.build.watch && isWorkerQueryId(id)) {
59600
+ return true;
59601
+ }
59602
+ },
59603
+ async transform(raw, id, options) {
59604
+ const ssr = options?.ssr === true;
59605
+ const query = parseRequest(id);
59606
+ if (query && query[WORKER_FILE_ID] != null) {
59607
+ // if import worker by worker constructor will have query.type
59608
+ // other type will be import worker by esm
59609
+ const workerType = query['type'];
59610
+ let injectEnv = '';
59611
+ const scriptPath = JSON.stringify(path$o.posix.join(config.base, ENV_PUBLIC_PATH));
59612
+ if (workerType === 'classic') {
59613
+ injectEnv = `importScripts(${scriptPath})\n`;
59614
+ }
59615
+ else if (workerType === 'module') {
59616
+ injectEnv = `import ${scriptPath}\n`;
59617
+ }
59618
+ else if (workerType === 'ignore') {
59619
+ if (isBuild) {
59620
+ injectEnv = '';
59621
+ }
59622
+ else if (server) {
59623
+ // dynamic worker type we can't know how import the env
59624
+ // so we copy /@vite/env code of server transform result into file header
59625
+ const { moduleGraph } = server;
59626
+ const module = moduleGraph.getModuleById(ENV_ENTRY);
59627
+ injectEnv = module?.transformResult?.code || '';
59628
+ }
59629
+ }
59630
+ if (injectEnv) {
59631
+ const s = new MagicString(raw);
59632
+ s.prepend(injectEnv);
59633
+ return {
59634
+ code: s.toString(),
59635
+ map: s.generateMap({ hires: 'boundary' }),
59636
+ };
59637
+ }
59638
+ return;
59639
+ }
59640
+ if (query == null ||
59641
+ (query && (query.worker ?? query.sharedworker) == null)) {
59642
+ return;
59643
+ }
59644
+ // stringified url or `new URL(...)`
59645
+ let url;
59646
+ const { format } = config.worker;
59647
+ const workerConstructor = query.sharedworker != null ? 'SharedWorker' : 'Worker';
59648
+ const workerType = isBuild
59649
+ ? format === 'es'
59650
+ ? 'module'
59651
+ : 'classic'
59652
+ : 'module';
59653
+ const workerTypeOption = `{
59654
+ ${workerType === 'module' ? `type: "module",` : ''}
59655
+ name: options?.name
59656
+ }`;
59657
+ if (isBuild) {
59658
+ getDepsOptimizer(config, ssr)?.registerWorkersSource(id);
59659
+ if (query.inline != null) {
59660
+ const chunk = await bundleWorkerEntry(config, id, query);
59661
+ const encodedJs = `const encodedJs = "${Buffer.from(chunk.code).toString('base64')}";`;
59662
+ const code =
59663
+ // Using blob URL for SharedWorker results in multiple instances of a same worker
59664
+ workerConstructor === 'Worker'
59665
+ ? `${encodedJs}
59666
+ const blob = typeof window !== "undefined" && window.Blob && new Blob([${workerType === 'classic'
59667
+ ? ''
59668
+ : // `URL` is always available, in `Worker[type="module"]`
59669
+ `'URL.revokeObjectURL(import.meta.url);'+`}atob(encodedJs)], { type: "text/javascript;charset=utf-8" });
59670
+ export default function WorkerWrapper(options) {
59671
+ let objURL;
59672
+ try {
59673
+ objURL = blob && (window.URL || window.webkitURL).createObjectURL(blob);
59674
+ if (!objURL) throw ''
59675
+ const worker = new ${workerConstructor}(objURL, ${workerTypeOption});
59676
+ worker.addEventListener("error", () => {
59677
+ (window.URL || window.webkitURL).revokeObjectURL(objURL);
59678
+ });
59679
+ return worker;
59680
+ } catch(e) {
59681
+ return new ${workerConstructor}(
59682
+ "data:application/javascript;base64," + encodedJs,
59683
+ ${workerTypeOption}
59684
+ );
59685
+ }${
59686
+ // For module workers, we should not revoke the URL until the worker runs,
59687
+ // otherwise the worker fails to run
59688
+ workerType === 'classic'
59689
+ ? ` finally {
59690
+ objURL && (window.URL || window.webkitURL).revokeObjectURL(objURL);
59691
+ }`
59692
+ : ''}
59693
+ }`
59694
+ : `${encodedJs}
59695
+ export default function WorkerWrapper(options) {
59696
+ return new ${workerConstructor}(
59697
+ "data:application/javascript;base64," + encodedJs,
59698
+ ${workerTypeOption}
59699
+ );
59700
+ }
59701
+ `;
59702
+ return {
59703
+ code,
59704
+ // Empty sourcemap to suppress Rollup warning
59705
+ map: { mappings: '' },
59706
+ };
59707
+ }
59708
+ else {
59709
+ url = await workerFileToUrl(config, id, query);
59710
+ }
59711
+ }
59712
+ else {
59713
+ url = await fileToUrl$1(cleanUrl(id), config, this);
59714
+ url = injectQuery(url, WORKER_FILE_ID);
59715
+ url = injectQuery(url, `type=${workerType}`);
59716
+ }
59717
+ if (query.url != null) {
59718
+ return {
59719
+ code: `export default ${JSON.stringify(url)}`,
59720
+ map: { mappings: '' }, // Empty sourcemap to suppress Rollup warning
59721
+ };
59722
+ }
59723
+ return {
59724
+ code: `export default function WorkerWrapper(options) {
59725
+ return new ${workerConstructor}(
59726
+ ${JSON.stringify(url)},
59727
+ ${workerTypeOption}
59728
+ );
59729
+ }`,
59730
+ map: { mappings: '' }, // Empty sourcemap to suppress Rollup warning
59731
+ };
59732
+ },
59733
+ renderChunk(code, chunk, outputOptions) {
59734
+ let s;
59735
+ const result = () => {
59736
+ return (s && {
59737
+ code: s.toString(),
59738
+ map: config.build.sourcemap
59739
+ ? s.generateMap({ hires: 'boundary' })
59740
+ : null,
59741
+ });
59742
+ };
59743
+ if (code.match(workerAssetUrlRE)) {
59744
+ const toRelativeRuntime = createToImportMetaURLBasedRelativeRuntime(outputOptions.format, config.isWorker);
59745
+ let match;
59746
+ s = new MagicString(code);
59747
+ workerAssetUrlRE.lastIndex = 0;
59748
+ // Replace "__VITE_WORKER_ASSET__5aa0ddc0__" using relative paths
59749
+ const workerMap = workerCache.get(config.mainConfig || config);
59750
+ const { fileNameHash } = workerMap;
59751
+ while ((match = workerAssetUrlRE.exec(code))) {
59752
+ const [full, hash] = match;
59753
+ const filename = fileNameHash.get(hash);
59754
+ const replacement = toOutputFilePathInJS(filename, 'asset', chunk.fileName, 'js', config, toRelativeRuntime);
59755
+ const replacementString = typeof replacement === 'string'
59756
+ ? JSON.stringify(replacement).slice(1, -1)
59757
+ : `"+${replacement.runtime}+"`;
59758
+ s.update(match.index, match.index + full.length, replacementString);
59759
+ }
59760
+ }
59761
+ return result();
59762
+ },
59763
+ generateBundle(opts) {
59764
+ // @ts-expect-error asset emits are skipped in legacy bundle
59765
+ if (opts.__vite_skip_asset_emit__ || isWorker) {
59766
+ return;
59767
+ }
59768
+ const workerMap = workerCache.get(config);
59769
+ workerMap.assets.forEach((asset) => {
59770
+ this.emitFile(asset);
59771
+ workerMap.assets.delete(asset.fileName);
59772
+ });
59773
+ },
59774
+ };
59775
+ }
59776
+
59363
59777
  const debug$4 = createDebugger('vite:import-analysis');
59364
59778
  const clientDir = normalizePath$3(CLIENT_DIR);
59365
59779
  const skipRE = /\.(?:map|json)(?:$|\?)/;
@@ -59368,7 +59782,6 @@ const optimizedDepChunkRE$1 = /\/chunk-[A-Z\d]{8}\.js/;
59368
59782
  const optimizedDepDynamicRE$1 = /-[A-Z\d]{8}\.js/;
59369
59783
  const hasImportInQueryParamsRE = /[?&]import=?\b/;
59370
59784
  const hasViteIgnoreRE = /\/\*\s*@vite-ignore\s*\*\//;
59371
- const cleanUpRawUrlRE = /\/\*[\s\S]*?\*\/|([^\\:]|^)\/\/.*$/gm;
59372
59785
  const urlIsStringRE = /^(?:'.*'|".*"|`.*`)$/;
59373
59786
  const templateLiteralRE = /^\s*`(.*)`\s*$/;
59374
59787
  function isExplicitImportRequired(url) {
@@ -59498,7 +59911,8 @@ function importAnalysisPlugin(config) {
59498
59911
  try {
59499
59912
  [imports, exports] = parse$e(source);
59500
59913
  }
59501
- catch (e) {
59914
+ catch (_e) {
59915
+ const e = _e;
59502
59916
  const { message, showCodeFrame } = createParseErrorInfo(importer, source);
59503
59917
  this.error(message, showCodeFrame ? e.idx : undefined);
59504
59918
  }
@@ -59792,11 +60206,10 @@ function importAnalysisPlugin(config) {
59792
60206
  }
59793
60207
  }
59794
60208
  if (!ssr) {
59795
- const url = rawUrl.replace(cleanUpRawUrlRE, '').trim();
59796
- if (!urlIsStringRE.test(url) ||
59797
- isExplicitImportRequired(url.slice(1, -1))) {
60209
+ if (!urlIsStringRE.test(rawUrl) ||
60210
+ isExplicitImportRequired(rawUrl.slice(1, -1))) {
59798
60211
  needQueryInjectHelper = true;
59799
- str().overwrite(start, end, `__vite__injectQuery(${url}, 'import')`, { contentOnly: true });
60212
+ str().overwrite(start, end, `__vite__injectQuery(${rawUrl}, 'import')`, { contentOnly: true });
59800
60213
  }
59801
60214
  }
59802
60215
  }
@@ -59809,11 +60222,14 @@ function importAnalysisPlugin(config) {
59809
60222
  const staticImportedUrls = new Set(_orderedImportedUrls);
59810
60223
  const acceptedUrls = mergeAcceptedUrls(orderedAcceptedUrls);
59811
60224
  const acceptedExports = mergeAcceptedUrls(orderedAcceptedExports);
59812
- if (hasEnv) {
60225
+ // While we always expect to work with ESM, a classic worker is the only
60226
+ // case where it's not ESM and we need to avoid injecting ESM-specific code
60227
+ const isClassicWorker = importer.includes(WORKER_FILE_ID) && importer.includes('type=classic');
60228
+ if (hasEnv && !isClassicWorker) {
59813
60229
  // inject import.meta.env
59814
60230
  str().prepend(getEnv(ssr));
59815
60231
  }
59816
- if (hasHMR && !ssr) {
60232
+ if (hasHMR && !ssr && !isClassicWorker) {
59817
60233
  debugHmr?.(`${isSelfAccepting
59818
60234
  ? `[self-accepts]`
59819
60235
  : isPartiallySelfAccepting
@@ -59826,7 +60242,12 @@ function importAnalysisPlugin(config) {
59826
60242
  `import.meta.hot = __vite__createHotContext(${JSON.stringify(normalizeHmrUrl(importerModule.url))});`);
59827
60243
  }
59828
60244
  if (needQueryInjectHelper) {
59829
- str().prepend(`import { injectQuery as __vite__injectQuery } from "${clientPublicPath}";`);
60245
+ if (isClassicWorker) {
60246
+ str().append('\n' + __vite__injectQuery.toString());
60247
+ }
60248
+ else {
60249
+ str().prepend(`import { injectQuery as __vite__injectQuery } from "${clientPublicPath}";`);
60250
+ }
59830
60251
  }
59831
60252
  // normalize and rewrite accepted urls
59832
60253
  const normalizedAcceptedUrls = new Set();
@@ -60023,6 +60444,17 @@ function transformCjsImport(importExp, url, rawUrl, importIndex, importer, confi
60023
60444
  return lines.join('; ');
60024
60445
  }
60025
60446
  }
60447
+ // Copied from `client/client.ts`. Only needed so we can inline inject this function for classic workers.
60448
+ function __vite__injectQuery(url, queryToInject) {
60449
+ // skip urls that won't be handled by vite
60450
+ if (url[0] !== '.' && url[0] !== '/') {
60451
+ return url;
60452
+ }
60453
+ // can't use pathname from URL since it may be relative like ../
60454
+ const pathname = url.replace(/[?#].*$/s, '');
60455
+ const { search, hash } = new URL(url, 'http://vitejs.dev');
60456
+ return `${pathname}?${queryToInject}${search ? `&` + search.slice(1) : ''}${hash || ''}`;
60457
+ }
60026
60458
 
60027
60459
  // ids in transform are normalized to unix style
60028
60460
  const normalizedClientEntry = normalizePath$3(CLIENT_ENTRY);
@@ -60201,324 +60633,6 @@ const wasmFallbackPlugin = () => {
60201
60633
  };
60202
60634
  };
60203
60635
 
60204
- const WORKER_FILE_ID = 'worker_file';
60205
- const workerCache = new WeakMap();
60206
- function saveEmitWorkerAsset(config, asset) {
60207
- const fileName = asset.fileName;
60208
- const workerMap = workerCache.get(config.mainConfig || config);
60209
- workerMap.assets.set(fileName, asset);
60210
- }
60211
- async function bundleWorkerEntry(config, id, query) {
60212
- // bundle the file as entry to support imports
60213
- const { rollup } = await import('rollup');
60214
- const { plugins, rollupOptions, format } = config.worker;
60215
- const bundle = await rollup({
60216
- ...rollupOptions,
60217
- input: cleanUrl(id),
60218
- plugins: await plugins(),
60219
- onwarn(warning, warn) {
60220
- onRollupWarning(warning, warn, config);
60221
- },
60222
- preserveEntrySignatures: false,
60223
- });
60224
- let chunk;
60225
- try {
60226
- const workerOutputConfig = config.worker.rollupOptions.output;
60227
- const workerConfig = workerOutputConfig
60228
- ? Array.isArray(workerOutputConfig)
60229
- ? workerOutputConfig[0] || {}
60230
- : workerOutputConfig
60231
- : {};
60232
- const { output: [outputChunk, ...outputChunks], } = await bundle.generate({
60233
- entryFileNames: path$o.posix.join(config.build.assetsDir, '[name]-[hash].js'),
60234
- chunkFileNames: path$o.posix.join(config.build.assetsDir, '[name]-[hash].js'),
60235
- assetFileNames: path$o.posix.join(config.build.assetsDir, '[name]-[hash].[ext]'),
60236
- ...workerConfig,
60237
- format,
60238
- sourcemap: config.build.sourcemap,
60239
- });
60240
- chunk = outputChunk;
60241
- outputChunks.forEach((outputChunk) => {
60242
- if (outputChunk.type === 'asset') {
60243
- saveEmitWorkerAsset(config, outputChunk);
60244
- }
60245
- else if (outputChunk.type === 'chunk') {
60246
- saveEmitWorkerAsset(config, {
60247
- fileName: outputChunk.fileName,
60248
- source: outputChunk.code,
60249
- type: 'asset',
60250
- });
60251
- }
60252
- });
60253
- }
60254
- finally {
60255
- await bundle.close();
60256
- }
60257
- return emitSourcemapForWorkerEntry(config, query, chunk);
60258
- }
60259
- function emitSourcemapForWorkerEntry(config, query, chunk) {
60260
- const { map: sourcemap } = chunk;
60261
- if (sourcemap) {
60262
- if (config.build.sourcemap === 'hidden' ||
60263
- config.build.sourcemap === true) {
60264
- const data = sourcemap.toString();
60265
- const mapFileName = chunk.fileName + '.map';
60266
- saveEmitWorkerAsset(config, {
60267
- fileName: mapFileName,
60268
- type: 'asset',
60269
- source: data,
60270
- });
60271
- }
60272
- }
60273
- return chunk;
60274
- }
60275
- const workerAssetUrlRE = /__VITE_WORKER_ASSET__([a-z\d]{8})__/g;
60276
- function encodeWorkerAssetFileName(fileName, workerCache) {
60277
- const { fileNameHash } = workerCache;
60278
- const hash = getHash(fileName);
60279
- if (!fileNameHash.get(hash)) {
60280
- fileNameHash.set(hash, fileName);
60281
- }
60282
- return `__VITE_WORKER_ASSET__${hash}__`;
60283
- }
60284
- async function workerFileToUrl(config, id, query) {
60285
- const workerMap = workerCache.get(config.mainConfig || config);
60286
- let fileName = workerMap.bundle.get(id);
60287
- if (!fileName) {
60288
- const outputChunk = await bundleWorkerEntry(config, id, query);
60289
- fileName = outputChunk.fileName;
60290
- saveEmitWorkerAsset(config, {
60291
- fileName,
60292
- source: outputChunk.code,
60293
- type: 'asset',
60294
- });
60295
- workerMap.bundle.set(id, fileName);
60296
- }
60297
- return encodeWorkerAssetFileName(fileName, workerMap);
60298
- }
60299
- function webWorkerPostPlugin() {
60300
- return {
60301
- name: 'vite:worker-post',
60302
- resolveImportMeta(property, { chunkId, format }) {
60303
- // document is undefined in the worker, so we need to avoid it in iife
60304
- if (property === 'url' && format === 'iife') {
60305
- return 'self.location.href';
60306
- }
60307
- return null;
60308
- },
60309
- };
60310
- }
60311
- function webWorkerPlugin(config) {
60312
- const isBuild = config.command === 'build';
60313
- let server;
60314
- const isWorker = config.isWorker;
60315
- const isWorkerQueryId = (id) => {
60316
- const parsedQuery = parseRequest(id);
60317
- if (parsedQuery &&
60318
- (parsedQuery.worker ?? parsedQuery.sharedworker) != null) {
60319
- return true;
60320
- }
60321
- return false;
60322
- };
60323
- return {
60324
- name: 'vite:worker',
60325
- configureServer(_server) {
60326
- server = _server;
60327
- },
60328
- buildStart() {
60329
- if (isWorker) {
60330
- return;
60331
- }
60332
- workerCache.set(config, {
60333
- assets: new Map(),
60334
- bundle: new Map(),
60335
- fileNameHash: new Map(),
60336
- });
60337
- },
60338
- load(id) {
60339
- if (isBuild && isWorkerQueryId(id)) {
60340
- return '';
60341
- }
60342
- },
60343
- shouldTransformCachedModule({ id }) {
60344
- if (isBuild && config.build.watch && isWorkerQueryId(id)) {
60345
- return true;
60346
- }
60347
- },
60348
- async transform(raw, id, options) {
60349
- const ssr = options?.ssr === true;
60350
- const query = parseRequest(id);
60351
- if (query && query[WORKER_FILE_ID] != null) {
60352
- // if import worker by worker constructor will have query.type
60353
- // other type will be import worker by esm
60354
- const workerType = query['type'];
60355
- let injectEnv = '';
60356
- const scriptPath = JSON.stringify(path$o.posix.join(config.base, ENV_PUBLIC_PATH));
60357
- if (workerType === 'classic') {
60358
- injectEnv = `importScripts(${scriptPath})\n`;
60359
- }
60360
- else if (workerType === 'module') {
60361
- injectEnv = `import ${scriptPath}\n`;
60362
- }
60363
- else if (workerType === 'ignore') {
60364
- if (isBuild) {
60365
- injectEnv = '';
60366
- }
60367
- else if (server) {
60368
- // dynamic worker type we can't know how import the env
60369
- // so we copy /@vite/env code of server transform result into file header
60370
- const { moduleGraph } = server;
60371
- const module = moduleGraph.getModuleById(ENV_ENTRY);
60372
- injectEnv = module?.transformResult?.code || '';
60373
- }
60374
- }
60375
- if (injectEnv) {
60376
- const s = new MagicString(raw);
60377
- s.prepend(injectEnv);
60378
- return {
60379
- code: s.toString(),
60380
- map: s.generateMap({ hires: 'boundary' }),
60381
- };
60382
- }
60383
- return;
60384
- }
60385
- if (query == null ||
60386
- (query && (query.worker ?? query.sharedworker) == null)) {
60387
- return;
60388
- }
60389
- // stringified url or `new URL(...)`
60390
- let url;
60391
- const { format } = config.worker;
60392
- const workerConstructor = query.sharedworker != null ? 'SharedWorker' : 'Worker';
60393
- const workerType = isBuild
60394
- ? format === 'es'
60395
- ? 'module'
60396
- : 'classic'
60397
- : 'module';
60398
- const workerTypeOption = `{
60399
- ${workerType === 'module' ? `type: "module",` : ''}
60400
- name: options?.name
60401
- }`;
60402
- if (isBuild) {
60403
- getDepsOptimizer(config, ssr)?.registerWorkersSource(id);
60404
- if (query.inline != null) {
60405
- const chunk = await bundleWorkerEntry(config, id, query);
60406
- const encodedJs = `const encodedJs = "${Buffer.from(chunk.code).toString('base64')}";`;
60407
- const code =
60408
- // Using blob URL for SharedWorker results in multiple instances of a same worker
60409
- workerConstructor === 'Worker'
60410
- ? `${encodedJs}
60411
- const blob = typeof window !== "undefined" && window.Blob && new Blob([${workerType === 'classic'
60412
- ? ''
60413
- : // `URL` is always available, in `Worker[type="module"]`
60414
- `'URL.revokeObjectURL(import.meta.url);'+`}atob(encodedJs)], { type: "text/javascript;charset=utf-8" });
60415
- export default function WorkerWrapper(options) {
60416
- let objURL;
60417
- try {
60418
- objURL = blob && (window.URL || window.webkitURL).createObjectURL(blob);
60419
- if (!objURL) throw ''
60420
- const worker = new ${workerConstructor}(objURL, ${workerTypeOption});
60421
- worker.addEventListener("error", () => {
60422
- (window.URL || window.webkitURL).revokeObjectURL(objURL);
60423
- });
60424
- return worker;
60425
- } catch(e) {
60426
- return new ${workerConstructor}(
60427
- "data:application/javascript;base64," + encodedJs,
60428
- ${workerTypeOption}
60429
- );
60430
- }${
60431
- // For module workers, we should not revoke the URL until the worker runs,
60432
- // otherwise the worker fails to run
60433
- workerType === 'classic'
60434
- ? ` finally {
60435
- objURL && (window.URL || window.webkitURL).revokeObjectURL(objURL);
60436
- }`
60437
- : ''}
60438
- }`
60439
- : `${encodedJs}
60440
- export default function WorkerWrapper(options) {
60441
- return new ${workerConstructor}(
60442
- "data:application/javascript;base64," + encodedJs,
60443
- ${workerTypeOption}
60444
- );
60445
- }
60446
- `;
60447
- return {
60448
- code,
60449
- // Empty sourcemap to suppress Rollup warning
60450
- map: { mappings: '' },
60451
- };
60452
- }
60453
- else {
60454
- url = await workerFileToUrl(config, id, query);
60455
- }
60456
- }
60457
- else {
60458
- url = await fileToUrl$1(cleanUrl(id), config, this);
60459
- url = injectQuery(url, WORKER_FILE_ID);
60460
- url = injectQuery(url, `type=${workerType}`);
60461
- }
60462
- if (query.url != null) {
60463
- return {
60464
- code: `export default ${JSON.stringify(url)}`,
60465
- map: { mappings: '' }, // Empty sourcemap to suppress Rollup warning
60466
- };
60467
- }
60468
- return {
60469
- code: `export default function WorkerWrapper(options) {
60470
- return new ${workerConstructor}(
60471
- ${JSON.stringify(url)},
60472
- ${workerTypeOption}
60473
- );
60474
- }`,
60475
- map: { mappings: '' }, // Empty sourcemap to suppress Rollup warning
60476
- };
60477
- },
60478
- renderChunk(code, chunk, outputOptions) {
60479
- let s;
60480
- const result = () => {
60481
- return (s && {
60482
- code: s.toString(),
60483
- map: config.build.sourcemap
60484
- ? s.generateMap({ hires: 'boundary' })
60485
- : null,
60486
- });
60487
- };
60488
- if (code.match(workerAssetUrlRE)) {
60489
- const toRelativeRuntime = createToImportMetaURLBasedRelativeRuntime(outputOptions.format, config.isWorker);
60490
- let match;
60491
- s = new MagicString(code);
60492
- workerAssetUrlRE.lastIndex = 0;
60493
- // Replace "__VITE_WORKER_ASSET__5aa0ddc0__" using relative paths
60494
- const workerMap = workerCache.get(config.mainConfig || config);
60495
- const { fileNameHash } = workerMap;
60496
- while ((match = workerAssetUrlRE.exec(code))) {
60497
- const [full, hash] = match;
60498
- const filename = fileNameHash.get(hash);
60499
- const replacement = toOutputFilePathInJS(filename, 'asset', chunk.fileName, 'js', config, toRelativeRuntime);
60500
- const replacementString = typeof replacement === 'string'
60501
- ? JSON.stringify(replacement).slice(1, -1)
60502
- : `"+${replacement.runtime}+"`;
60503
- s.update(match.index, match.index + full.length, replacementString);
60504
- }
60505
- }
60506
- return result();
60507
- },
60508
- generateBundle(opts) {
60509
- // @ts-expect-error asset emits are skipped in legacy bundle
60510
- if (opts.__vite_skip_asset_emit__ || isWorker) {
60511
- return;
60512
- }
60513
- const workerMap = workerCache.get(config);
60514
- workerMap.assets.forEach((asset) => {
60515
- this.emitFile(asset);
60516
- workerMap.assets.delete(asset.fileName);
60517
- });
60518
- },
60519
- };
60520
- }
60521
-
60522
60636
  /**
60523
60637
  * A plugin to avoid an aliased AND optimized dep from being aliased in src
60524
60638
  */
@@ -61192,13 +61306,7 @@ function dynamicImportVarsPlugin(config) {
61192
61306
  s ||= new MagicString(source);
61193
61307
  let result;
61194
61308
  try {
61195
- // When import string is using backticks, es-module-lexer `end` captures
61196
- // until the closing parenthesis, instead of the closing backtick.
61197
- // There may be inline comments between the backtick and the closing
61198
- // parenthesis, so we manually remove them for now.
61199
- // See https://github.com/guybedford/es-module-lexer/issues/118
61200
- const importSource = removeComments(source.slice(start, end)).trim();
61201
- result = await transformDynamicImport(importSource, importer, resolve, config.root);
61309
+ result = await transformDynamicImport(source.slice(start, end), importer, resolve, config.root);
61202
61310
  }
61203
61311
  catch (error) {
61204
61312
  if (warnOnError) {
@@ -61827,6 +61935,9 @@ async function createPluginContainer(config, moduleGraph, watcher) {
61827
61935
  return result;
61828
61936
  }
61829
61937
  }
61938
+ watchFiles.add(id);
61939
+ if (watcher)
61940
+ ensureWatchedFile(watcher, id, root);
61830
61941
  return null;
61831
61942
  },
61832
61943
  async transform(code, id, options) {
@@ -61889,9 +62000,6 @@ async function createPluginContainer(config, moduleGraph, watcher) {
61889
62000
  await hookParallel('buildEnd', () => ctx, () => []);
61890
62001
  await hookParallel('closeBundle', () => ctx, () => []);
61891
62002
  },
61892
- [ASYNC_DISPOSE]() {
61893
- return this.close();
61894
- },
61895
62003
  };
61896
62004
  return container;
61897
62005
  }
@@ -62605,9 +62713,6 @@ async function createDepsOptimizer(config, server) {
62605
62713
  resetRegisteredIds,
62606
62714
  ensureFirstRun,
62607
62715
  close,
62608
- [ASYNC_DISPOSE]() {
62609
- return this.close();
62610
- },
62611
62716
  options: getDepOptimizationConfig(config, ssr),
62612
62717
  };
62613
62718
  depsOptimizerMap.set(config, depsOptimizer);
@@ -63142,7 +63247,6 @@ async function createDevSsrDepsOptimizer(config) {
63142
63247
  resetRegisteredIds: () => { },
63143
63248
  ensureFirstRun: () => { },
63144
63249
  close: async () => { },
63145
- [ASYNC_DISPOSE]: async () => { },
63146
63250
  options: config.ssr.optimizeDeps,
63147
63251
  };
63148
63252
  devSsrDepsOptimizerMap.set(config, depsOptimizer);
@@ -64158,7 +64262,8 @@ function buildImportAnalysisPlugin(config) {
64158
64262
  try {
64159
64263
  imports = parse$e(source)[0];
64160
64264
  }
64161
- catch (e) {
64265
+ catch (_e) {
64266
+ const e = _e;
64162
64267
  const { message, showCodeFrame } = createParseErrorInfo(importer, source);
64163
64268
  this.error(message, showCodeFrame ? e.idx : undefined);
64164
64269
  }
@@ -64547,7 +64652,8 @@ function ssrManifestPlugin(config) {
64547
64652
  try {
64548
64653
  imports = parse$e(code)[0].filter((i) => i.n && i.d > -1);
64549
64654
  }
64550
- catch (e) {
64655
+ catch (_e) {
64656
+ const e = _e;
64551
64657
  const loc = numberToPos(code, e.idx);
64552
64658
  this.error({
64553
64659
  name: e.name,
@@ -64797,6 +64903,16 @@ async function build(inlineConfig = {}) {
64797
64903
  throw new Error(`rollupOptions.input should not be an html file when building for SSR. ` +
64798
64904
  `Please specify a dedicated SSR entry.`);
64799
64905
  }
64906
+ if (config.build.cssCodeSplit === false) {
64907
+ const inputs = typeof input === 'string'
64908
+ ? [input]
64909
+ : Array.isArray(input)
64910
+ ? input
64911
+ : Object.values(input);
64912
+ if (inputs.some((input) => input.endsWith('.css'))) {
64913
+ throw new Error(`When "build.cssCodeSplit: false" is set, "rollupOptions.input" should not include CSS files.`);
64914
+ }
64915
+ }
64800
64916
  const outDir = resolve(options.outDir);
64801
64917
  // inject ssr arg to plugin load/transform hooks
64802
64918
  const plugins = (ssr ? config.plugins.map((p) => injectSsrFlagToHooks(p)) : config.plugins);
@@ -64826,6 +64942,7 @@ async function build(inlineConfig = {}) {
64826
64942
  if (e.frame) {
64827
64943
  msg += `\n` + colors$1.yellow(e.frame);
64828
64944
  }
64945
+ clearLine();
64829
64946
  config.logger.error(msg, { error: e });
64830
64947
  };
64831
64948
  let bundle;
@@ -64837,6 +64954,14 @@ async function build(inlineConfig = {}) {
64837
64954
  `This is deprecated and will override all Vite.js default output options. ` +
64838
64955
  `Please use "rollupOptions.output" instead.`);
64839
64956
  }
64957
+ if (output.file) {
64958
+ throw new Error(`Vite does not support "rollupOptions.output.file". ` +
64959
+ `Please use "rollupOptions.output.dir" and "rollupOptions.output.entryFileNames" instead.`);
64960
+ }
64961
+ if (output.sourcemap) {
64962
+ config.logger.warnOnce(colors$1.yellow(`Vite does not support "rollupOptions.output.sourcemap". ` +
64963
+ `Please use "build.sourcemap" instead.`));
64964
+ }
64840
64965
  const ssrNodeBuild = ssr && config.ssr.target === 'node';
64841
64966
  const ssrWorkerBuild = ssr && config.ssr.target === 'webworker';
64842
64967
  const format = output.format || 'es';
@@ -65039,6 +65164,13 @@ const dynamicImportWarningIgnoreList = [
65039
65164
  `Unsupported expression`,
65040
65165
  `statically analyzed`,
65041
65166
  ];
65167
+ function clearLine() {
65168
+ const tty = process.stdout.isTTY && !process.env.CI;
65169
+ if (tty) {
65170
+ process.stdout.clearLine(0);
65171
+ process.stdout.cursorTo(0);
65172
+ }
65173
+ }
65042
65174
  function onRollupWarning(warning, warn, config) {
65043
65175
  const viteWarn = (warnLog) => {
65044
65176
  let warning;
@@ -65076,11 +65208,7 @@ function onRollupWarning(warning, warn, config) {
65076
65208
  }
65077
65209
  warn(warnLog);
65078
65210
  };
65079
- const tty = process.stdout.isTTY && !process.env.CI;
65080
- if (tty) {
65081
- process.stdout.clearLine(0);
65082
- process.stdout.cursorTo(0);
65083
- }
65211
+ clearLine();
65084
65212
  const userOnWarn = config.build.rollupOptions?.onwarn;
65085
65213
  if (userOnWarn) {
65086
65214
  userOnWarn(warning, viteWarn);