vite 3.0.2 → 3.0.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.
@@ -33,7 +33,7 @@ import { STATUS_CODES } from 'node:http';
33
33
  import { createServer as createServer$2 } from 'node:https';
34
34
  import require$$1$1 from 'worker_threads';
35
35
  import * as qs from 'querystring';
36
- import readline from 'readline';
36
+ import readline from 'node:readline';
37
37
  import { execSync } from 'node:child_process';
38
38
  import zlib$1, { gzip } from 'node:zlib';
39
39
 
@@ -7255,7 +7255,7 @@ function isReference(node, parent) {
7255
7255
  return false;
7256
7256
  }
7257
7257
 
7258
- var version$1 = "22.0.1";
7258
+ var version$1 = "22.0.2";
7259
7259
  var peerDependencies = {
7260
7260
  rollup: "^2.68.0"
7261
7261
  };
@@ -8213,7 +8213,7 @@ function hasDefineEsmProperty(node) {
8213
8213
  });
8214
8214
  }
8215
8215
 
8216
- function wrapCode(magicString, uses, moduleName, exportsName) {
8216
+ function wrapCode(magicString, uses, moduleName, exportsName, indentExclusionRanges) {
8217
8217
  const args = [];
8218
8218
  const passedArgs = [];
8219
8219
  if (uses.module) {
@@ -8226,7 +8226,7 @@ function wrapCode(magicString, uses, moduleName, exportsName) {
8226
8226
  }
8227
8227
  magicString
8228
8228
  .trim()
8229
- .indent('\t')
8229
+ .indent('\t', { exclude: indentExclusionRanges })
8230
8230
  .prepend(`(function (${args.join(', ')}) {\n`)
8231
8231
  .append(`\n} (${passedArgs.join(', ')}));`);
8232
8232
  }
@@ -8724,6 +8724,7 @@ async function transformCommonjs(
8724
8724
  const replacedGlobal = [];
8725
8725
  const replacedDynamicRequires = [];
8726
8726
  const importedVariables = new Set();
8727
+ const indentExclusionRanges = [];
8727
8728
 
8728
8729
  walk$3(ast, {
8729
8730
  enter(node, parent) {
@@ -9022,6 +9023,11 @@ async function transformCommonjs(
9022
9023
  if (!scope.parent) {
9023
9024
  topLevelDeclarations.push(node);
9024
9025
  }
9026
+ return;
9027
+ case 'TemplateElement':
9028
+ if (node.value.raw.includes('\n')) {
9029
+ indentExclusionRanges.push([node.start, node.end]);
9030
+ }
9025
9031
  }
9026
9032
  },
9027
9033
 
@@ -9154,11 +9160,13 @@ async function transformCommonjs(
9154
9160
  );
9155
9161
 
9156
9162
  if (shouldWrap) {
9157
- wrapCode(magicString, uses, moduleName, exportsName);
9163
+ wrapCode(magicString, uses, moduleName, exportsName, indentExclusionRanges);
9158
9164
  }
9159
9165
 
9160
9166
  if (usesRequireWrapper) {
9161
- magicString.trim().indent('\t');
9167
+ magicString.trim().indent('\t', {
9168
+ exclude: indentExclusionRanges
9169
+ });
9162
9170
  magicString.prepend(
9163
9171
  `var ${isRequiredName};
9164
9172
 
@@ -11754,7 +11762,7 @@ const dataUrlRE = /^\s*data:/i;
11754
11762
  const isDataUrl = (url) => dataUrlRE.test(url);
11755
11763
  const virtualModuleRE = /^virtual-module:.*/;
11756
11764
  const virtualModulePrefix = 'virtual-module:';
11757
- const knownJsSrcRE = /\.((j|t)sx?|mjs|vue|marko|svelte|astro)($|\?)/;
11765
+ const knownJsSrcRE = /\.((j|t)sx?|m[jt]s|vue|marko|svelte|astro)($|\?)/;
11758
11766
  const isJSRequest = (url) => {
11759
11767
  url = cleanUrl(url);
11760
11768
  if (knownJsSrcRE.test(url)) {
@@ -12318,6 +12326,9 @@ function gracefulRemoveDir(dir, cb) {
12318
12326
  function emptyCssComments(raw) {
12319
12327
  return raw.replace(multilineCommentsRE$1, (s) => ' '.repeat(s.length));
12320
12328
  }
12329
+ function removeComments(raw) {
12330
+ return raw.replace(multilineCommentsRE$1, '').replace(singlelineCommentsRE$1, '');
12331
+ }
12321
12332
  function mergeConfigRecursively(defaults, overrides, rootPath) {
12322
12333
  const merged = { ...defaults };
12323
12334
  for (const key in overrides) {
@@ -13244,12 +13255,15 @@ async function transformWithEsbuild(code, filename, options, inMap) {
13244
13255
  if (ext === 'cjs' || ext === 'mjs') {
13245
13256
  loader = 'js';
13246
13257
  }
13258
+ else if (ext === 'cts' || ext === 'mts') {
13259
+ loader = 'ts';
13260
+ }
13247
13261
  else {
13248
13262
  loader = ext;
13249
13263
  }
13250
13264
  }
13251
13265
  let tsconfigRaw = options?.tsconfigRaw;
13252
- // if options provide tsconfigraw in string, it takes highest precedence
13266
+ // if options provide tsconfigRaw in string, it takes highest precedence
13253
13267
  if (typeof tsconfigRaw !== 'string') {
13254
13268
  // these fields would affect the compilation result
13255
13269
  // https://esbuild.github.io/content-types/#tsconfig-json
@@ -13329,7 +13343,7 @@ async function transformWithEsbuild(code, filename, options, inMap) {
13329
13343
  }
13330
13344
  }
13331
13345
  function esbuildPlugin(options = {}) {
13332
- const filter = createFilter(options.include || /\.(tsx?|jsx)$/, options.exclude || /\.js$/);
13346
+ const filter = createFilter(options.include || /\.(m?ts|[jt]sx)$/, options.exclude || /\.js$/);
13333
13347
  // Remove optimization options for dev as we only need to transpile them,
13334
13348
  // and for build as the final optimization is in `buildEsbuildPlugin`
13335
13349
  const transformOptions = {
@@ -13563,7 +13577,7 @@ function reloadOnTsconfigChange(changedFile) {
13563
13577
  if (path$n.basename(changedFile) === 'tsconfig.json' ||
13564
13578
  (changedFile.endsWith('.json') &&
13565
13579
  tsconfckParseOptions?.cache?.has(changedFile))) {
13566
- server.config.logger.info(`changed tsconfig file detected: ${changedFile} - Clearing cache and forcing full-reload to ensure typescript is compiled with updated config values.`, { clear: server.config.clearScreen, timestamp: true });
13580
+ server.config.logger.info(`changed tsconfig file detected: ${changedFile} - Clearing cache and forcing full-reload to ensure TypeScript is compiled with updated config values.`, { clear: server.config.clearScreen, timestamp: true });
13567
13581
  // clear module graph to remove code compiled with outdated config
13568
13582
  server.moduleGraph.invalidateAll();
13569
13583
  // reset tsconfck so that recompile works with up2date configs
@@ -27478,10 +27492,10 @@ function getLineInfo(input, offset) {
27478
27492
  var defaultOptions = {
27479
27493
  // `ecmaVersion` indicates the ECMAScript version to parse. Must be
27480
27494
  // either 3, 5, 6 (or 2015), 7 (2016), 8 (2017), 9 (2018), 10
27481
- // (2019), 11 (2020), 12 (2021), 13 (2022), or `"latest"` (the
27482
- // latest version the library supports). This influences support
27483
- // for strict mode, the set of reserved words, and support for
27484
- // new syntax features.
27495
+ // (2019), 11 (2020), 12 (2021), 13 (2022), 14 (2023), or `"latest"`
27496
+ // (the latest version the library supports). This influences
27497
+ // support for strict mode, the set of reserved words, and support
27498
+ // for new syntax features.
27485
27499
  ecmaVersion: null,
27486
27500
  // `sourceType` indicates the mode the code should be parsed in.
27487
27501
  // Can be either `"script"` or `"module"`. This influences global
@@ -27515,8 +27529,9 @@ var defaultOptions = {
27515
27529
  // When enabled, super identifiers are not constrained to
27516
27530
  // appearing in methods and do not raise an error when they appear elsewhere.
27517
27531
  allowSuperOutsideMethod: null,
27518
- // When enabled, hashbang directive in the beginning of file
27519
- // is allowed and treated as a line comment.
27532
+ // When enabled, hashbang directive in the beginning of file is
27533
+ // allowed and treated as a line comment. Enabled by default when
27534
+ // `ecmaVersion` >= 2023.
27520
27535
  allowHashBang: false,
27521
27536
  // When `locations` is on, `loc` properties holding objects with
27522
27537
  // `start` and `end` properties in `{line, column}` form (with
@@ -27591,6 +27606,9 @@ function getOptions(opts) {
27591
27606
  if (options.allowReserved == null)
27592
27607
  { options.allowReserved = options.ecmaVersion < 5; }
27593
27608
 
27609
+ if (opts.allowHashBang == null)
27610
+ { options.allowHashBang = options.ecmaVersion >= 14; }
27611
+
27594
27612
  if (isArray(options.onToken)) {
27595
27613
  var tokens = options.onToken;
27596
27614
  options.onToken = function (token) { return tokens.push(token); };
@@ -27921,7 +27939,7 @@ pp$9.checkPatternErrors = function(refDestructuringErrors, isAssign) {
27921
27939
  if (refDestructuringErrors.trailingComma > -1)
27922
27940
  { this.raiseRecoverable(refDestructuringErrors.trailingComma, "Comma is not permitted after the rest element"); }
27923
27941
  var parens = isAssign ? refDestructuringErrors.parenthesizedAssign : refDestructuringErrors.parenthesizedBind;
27924
- if (parens > -1) { this.raiseRecoverable(parens, "Parenthesized pattern"); }
27942
+ if (parens > -1) { this.raiseRecoverable(parens, isAssign ? "Assigning to rvalue" : "Parenthesized pattern"); }
27925
27943
  };
27926
27944
 
27927
27945
  pp$9.checkExpressionErrors = function(refDestructuringErrors, andThrow) {
@@ -29017,6 +29035,7 @@ pp$8.adaptDirectivePrologue = function(statements) {
29017
29035
  };
29018
29036
  pp$8.isDirectiveCandidate = function(statement) {
29019
29037
  return (
29038
+ this.options.ecmaVersion >= 5 &&
29020
29039
  statement.type === "ExpressionStatement" &&
29021
29040
  statement.expression.type === "Literal" &&
29022
29041
  typeof statement.expression.value === "string" &&
@@ -29427,7 +29446,8 @@ pp$6.updateContext = function(prevType) {
29427
29446
  { this.exprAllowed = type.beforeExpr; }
29428
29447
  };
29429
29448
 
29430
- // Used to handle egde case when token context could not be inferred correctly in tokenize phase
29449
+ // Used to handle egde cases when token context could not be inferred correctly during tokenization phase
29450
+
29431
29451
  pp$6.overrideContext = function(tokenCtx) {
29432
29452
  if (this.curContext() !== tokenCtx) {
29433
29453
  this.context[this.context.length - 1] = tokenCtx;
@@ -30243,15 +30263,6 @@ pp$5.parseProperty = function(isPattern, refDestructuringErrors) {
30243
30263
  }
30244
30264
  return this.finishNode(prop, "RestElement")
30245
30265
  }
30246
- // To disallow parenthesized identifier via `this.toAssignable()`.
30247
- if (this.type === types$1.parenL && refDestructuringErrors) {
30248
- if (refDestructuringErrors.parenthesizedAssign < 0) {
30249
- refDestructuringErrors.parenthesizedAssign = this.start;
30250
- }
30251
- if (refDestructuringErrors.parenthesizedBind < 0) {
30252
- refDestructuringErrors.parenthesizedBind = this.start;
30253
- }
30254
- }
30255
30266
  // Parse argument.
30256
30267
  prop.argument = this.parseMaybeAssign(false, refDestructuringErrors);
30257
30268
  // To disallow trailing comma via `this.toAssignable()`.
@@ -32681,7 +32692,7 @@ pp.readWord = function() {
32681
32692
 
32682
32693
  // Acorn is a tiny, fast JavaScript parser written in JavaScript.
32683
32694
 
32684
- var version = "8.7.1";
32695
+ var version = "8.8.0";
32685
32696
 
32686
32697
  Parser.acorn = {
32687
32698
  Parser: Parser,
@@ -33300,11 +33311,6 @@ function assetPlugin(config) {
33300
33311
  renderChunk(code, chunk) {
33301
33312
  let match;
33302
33313
  let s;
33303
- const toRelative = (filename, importer) => {
33304
- return {
33305
- runtime: `new URL(${JSON.stringify(path$n.posix.relative(path$n.dirname(importer), filename))},import.meta.url).href`
33306
- };
33307
- };
33308
33314
  // Urls added with JS using e.g.
33309
33315
  // imgElement.src = "__VITE_ASSET__5aa0ddc0__" are using quotes
33310
33316
  // Urls added in CSS that is imported in JS end up like
@@ -33318,7 +33324,7 @@ function assetPlugin(config) {
33318
33324
  const file = getAssetFilename(hash, config) || this.getFileName(hash);
33319
33325
  chunk.viteMetadata.importedAssets.add(cleanUrl(file));
33320
33326
  const filename = file + postfix;
33321
- const replacement = toOutputFilePathInString(filename, 'asset', chunk.fileName, 'js', config, toRelative);
33327
+ const replacement = toOutputFilePathInString(filename, 'asset', chunk.fileName, 'js', config);
33322
33328
  const replacementString = typeof replacement === 'string'
33323
33329
  ? JSON.stringify(replacement).slice(1, -1)
33324
33330
  : `"+${replacement.runtime}+"`;
@@ -33332,7 +33338,7 @@ function assetPlugin(config) {
33332
33338
  s = s || (s = new MagicString(code));
33333
33339
  const [full, hash] = match;
33334
33340
  const publicUrl = publicAssetUrlMap.get(hash).slice(1);
33335
- const replacement = toOutputFilePathInString(publicUrl, 'public', chunk.fileName, 'js', config, toRelative);
33341
+ const replacement = toOutputFilePathInString(publicUrl, 'public', chunk.fileName, 'js', config);
33336
33342
  const replacementString = typeof replacement === 'string'
33337
33343
  ? JSON.stringify(replacement).slice(1, -1)
33338
33344
  : `"+${replacement.runtime}+"`;
@@ -33407,6 +33413,9 @@ function fileToDevUrl(id, config) {
33407
33413
  function getAssetFilename(hash, config) {
33408
33414
  return assetHashToFilenameMap.get(config)?.get(hash);
33409
33415
  }
33416
+ function getPublicAssetFilename(hash, config) {
33417
+ return publicAssetUrlCache.get(config)?.get(hash);
33418
+ }
33410
33419
  function resolveAssetFileNames(config) {
33411
33420
  const output = config.build?.rollupOptions?.output;
33412
33421
  const defaultAssetFileNames = path$n.posix.join(config.build.assetsDir, '[name].[hash][extname]');
@@ -33821,10 +33830,6 @@ function resolvePlugin(resolveOptions) {
33821
33830
  if (id.startsWith(browserExternalId)) {
33822
33831
  return id;
33823
33832
  }
33824
- // fast path for commonjs proxy modules
33825
- if (/\?commonjs/.test(id) || id === 'commonjsHelpers.js') {
33826
- return;
33827
- }
33828
33833
  const targetWeb = !ssr || ssrTarget === 'webworker';
33829
33834
  // this is passed by @rollup/plugin-commonjs
33830
33835
  const isRequire = resolveOpts?.custom?.['node-resolve']?.isRequire ?? false;
@@ -34095,7 +34100,7 @@ function tryResolveFile(file, postfix, options, tryIndex, targetWeb, tryPrefix,
34095
34100
  }
34096
34101
  }
34097
34102
  const idToPkgMap = new Map();
34098
- function tryNodeResolve(id, importer, options, targetWeb, depsOptimizer, ssr, externalize) {
34103
+ function tryNodeResolve(id, importer, options, targetWeb, depsOptimizer, ssr, externalize, allowLinkedExternal = true) {
34099
34104
  const { root, dedupe, isBuild, preserveSymlinks, packageCache } = options;
34100
34105
  ssr ?? (ssr = false);
34101
34106
  // split id by last '>' for nested selected packages, for example:
@@ -34179,14 +34184,20 @@ function tryNodeResolve(id, importer, options, targetWeb, depsOptimizer, ssr, ex
34179
34184
  if (!externalize) {
34180
34185
  return resolved;
34181
34186
  }
34187
+ // don't external symlink packages
34188
+ if (!allowLinkedExternal && !resolved.id.includes('node_modules')) {
34189
+ return resolved;
34190
+ }
34182
34191
  const resolvedExt = path$n.extname(resolved.id);
34192
+ // don't external non-js imports
34193
+ if (resolvedExt &&
34194
+ resolvedExt !== '.js' &&
34195
+ resolvedExt !== '.mjs' &&
34196
+ resolvedExt !== '.cjs') {
34197
+ return resolved;
34198
+ }
34183
34199
  let resolvedId = id;
34184
34200
  if (isDeepImport) {
34185
- // check ext before externalizing - only externalize
34186
- // extension-less imports and explicit .js imports
34187
- if (resolvedExt && !resolved.id.match(/(.js|.mjs|.cjs)$/)) {
34188
- return;
34189
- }
34190
34201
  if (!pkg?.data.exports && path$n.extname(id) !== resolvedExt) {
34191
34202
  resolvedId += resolvedExt;
34192
34203
  }
@@ -34537,6 +34548,8 @@ const externalTypes = [
34537
34548
  'stylus',
34538
34549
  'pcss',
34539
34550
  'postcss',
34551
+ // wasm
34552
+ 'wasm',
34540
34553
  // known SFC types
34541
34554
  'vue',
34542
34555
  'svelte',
@@ -35383,10 +35396,6 @@ function importGlobPlugin(config) {
35383
35396
  if (server) {
35384
35397
  const allGlobs = result.matches.map((i) => i.globsResolved);
35385
35398
  server._importGlobMap.set(id, allGlobs);
35386
- result.files.forEach((file) => {
35387
- // update watcher
35388
- server.watcher.add(dirname(file));
35389
- });
35390
35399
  }
35391
35400
  return transformStableResult(result.s, id, config);
35392
35401
  }
@@ -35454,6 +35463,10 @@ async function parseImportGlob(code, importer, root, resolveId) {
35454
35463
  }
35455
35464
  if (ast.type === 'SequenceExpression')
35456
35465
  ast = ast.expressions[0];
35466
+ // immediate property access, call expression is nested
35467
+ // import.meta.glob(...)['prop']
35468
+ if (ast.type === 'MemberExpression')
35469
+ ast = ast.object;
35457
35470
  if (ast.type !== 'CallExpression')
35458
35471
  throw err(`Expect CallExpression, got ${ast.type}`);
35459
35472
  if (ast.arguments.length < 1 || ast.arguments.length > 2)
@@ -35461,24 +35474,31 @@ async function parseImportGlob(code, importer, root, resolveId) {
35461
35474
  const arg1 = ast.arguments[0];
35462
35475
  const arg2 = ast.arguments[1];
35463
35476
  const globs = [];
35464
- if (arg1.type === 'ArrayExpression') {
35465
- for (const element of arg1.elements) {
35466
- if (!element)
35467
- continue;
35468
- if (element.type !== 'Literal')
35469
- throw err('Could only use literals');
35477
+ const validateLiteral = (element) => {
35478
+ if (!element)
35479
+ return;
35480
+ if (element.type === 'Literal') {
35470
35481
  if (typeof element.value !== 'string')
35471
35482
  throw err(`Expected glob to be a string, but got "${typeof element.value}"`);
35472
35483
  globs.push(element.value);
35473
35484
  }
35474
- }
35475
- else if (arg1.type === 'Literal') {
35476
- if (typeof arg1.value !== 'string')
35477
- throw err(`Expected glob to be a string, but got "${typeof arg1.value}"`);
35478
- globs.push(arg1.value);
35485
+ else if (element.type === 'TemplateLiteral') {
35486
+ if (element.expressions.length !== 0) {
35487
+ throw err(`Expected glob to be a string, but got dynamic template literal`);
35488
+ }
35489
+ globs.push(element.quasis[0].value.raw);
35490
+ }
35491
+ else {
35492
+ throw err('Could only use literals');
35493
+ }
35494
+ };
35495
+ if (arg1.type === 'ArrayExpression') {
35496
+ for (const element of arg1.elements) {
35497
+ validateLiteral(element);
35498
+ }
35479
35499
  }
35480
35500
  else {
35481
- throw err('Could only use literals');
35501
+ validateLiteral(arg1);
35482
35502
  }
35483
35503
  // arg2
35484
35504
  const options = {};
@@ -35651,7 +35671,7 @@ async function transformGlobImport(code, id, root, resolveId, restoreQueryExtens
35651
35671
  }
35652
35672
  });
35653
35673
  files.forEach((i) => matchedFiles.add(i));
35654
- const replacement = `Object.assign({${objectProps.join(',')}})`;
35674
+ const replacement = `/* #__PURE__ */ Object.assign({${objectProps.join(',')}})`;
35655
35675
  s.overwrite(start, end, replacement);
35656
35676
  return staticImports;
35657
35677
  }))).flat();
@@ -35985,14 +36005,18 @@ function esbuildScanPlugin(config, container, depImports, missing, entries) {
35985
36005
  build.onResolve({
35986
36006
  // avoid matching windows volume
35987
36007
  filter: /^[\w@][^:]/
35988
- }, async ({ path: id, importer }) => {
36008
+ }, async ({ path: id, importer, pluginData }) => {
35989
36009
  if (moduleListContains(exclude, id)) {
35990
36010
  return externalUnlessEntry({ path: id });
35991
36011
  }
35992
36012
  if (depImports[id]) {
35993
36013
  return externalUnlessEntry({ path: id });
35994
36014
  }
35995
- const resolved = await resolve(id, importer);
36015
+ const resolved = await resolve(id, importer, {
36016
+ custom: {
36017
+ depScan: { loader: pluginData?.htmlType?.loader }
36018
+ }
36019
+ });
35996
36020
  if (resolved) {
35997
36021
  if (shouldExternalizeDep(resolved, id)) {
35998
36022
  return externalUnlessEntry({ path: id });
@@ -36025,9 +36049,9 @@ function esbuildScanPlugin(config, container, depImports, missing, entries) {
36025
36049
  // should be faster than doing it in the catch-all via js
36026
36050
  // they are done after the bare import resolve because a package name
36027
36051
  // may end with these extensions
36028
- // css & json
36052
+ // css & json & wasm
36029
36053
  build.onResolve({
36030
- filter: /\.(css|less|sass|scss|styl|stylus|pcss|postcss|json)$/
36054
+ filter: /\.(css|less|sass|scss|styl|stylus|pcss|postcss|json|wasm)$/
36031
36055
  }, externalUnlessEntry);
36032
36056
  // known asset types
36033
36057
  build.onResolve({
@@ -36271,11 +36295,11 @@ async function createDepsOptimizer(config, server) {
36271
36295
  // promises are going to be resolved once a rerun is committed
36272
36296
  depOptimizationProcessingQueue.push(depOptimizationProcessing);
36273
36297
  // Create a new promise for the next rerun, discovered missing
36274
- // dependencies will be asigned this promise from this point
36298
+ // dependencies will be assigned this promise from this point
36275
36299
  depOptimizationProcessing = newDepOptimizationProcessing();
36276
36300
  }
36277
36301
  async function optimizeNewDeps() {
36278
- // a succesful completion of the optimizeDeps rerun will end up
36302
+ // a successful completion of the optimizeDeps rerun will end up
36279
36303
  // creating new bundled version of all current and discovered deps
36280
36304
  // in the cache dir and a new metadata info object assigned
36281
36305
  // to _metadata. A fullReload is only issued if the previous bundled
@@ -36384,7 +36408,7 @@ async function createDepsOptimizer(config, server) {
36384
36408
  else {
36385
36409
  if (newDepsDiscovered) {
36386
36410
  // There are newly discovered deps, and another rerun is about to be
36387
- // excecuted. Avoid the current full reload discarding this rerun result
36411
+ // executed. Avoid the current full reload discarding this rerun result
36388
36412
  // We don't resolve the processing promise, as they will be resolved
36389
36413
  // once a rerun is committed
36390
36414
  processingResult.cancel();
@@ -36481,7 +36505,7 @@ async function createDepsOptimizer(config, server) {
36481
36505
  src: resolved,
36482
36506
  // Assing a browserHash to this missing dependency that is unique to
36483
36507
  // the current state of known + missing deps. If its optimizeDeps run
36484
- // doesn't alter the bundled files of previous known dependendencies,
36508
+ // doesn't alter the bundled files of previous known dependencies,
36485
36509
  // we don't need a full reload and this browserHash will be kept
36486
36510
  browserHash: getDiscoveredBrowserHash(metadata.hash, depsFromOptimizedDepInfo(metadata.optimized), depsFromOptimizedDepInfo(metadata.discovered)),
36487
36511
  // loading of this pre-bundled dep needs to await for its processing
@@ -37233,7 +37257,7 @@ function needsInterop(config, ssr, id, exportsData, output) {
37233
37257
  return true;
37234
37258
  }
37235
37259
  if (output) {
37236
- // if a peer dependency used require() on a ESM dependency, esbuild turns the
37260
+ // if a peer dependency used require() on an ESM dependency, esbuild turns the
37237
37261
  // ESM dependency's entry chunk into a single default export... detect
37238
37262
  // such cases by checking exports mismatch, and force interop.
37239
37263
  const generatedExports = output.exports;
@@ -37359,79 +37383,97 @@ function matchAll(regex, string, addition) {
37359
37383
  return matches;
37360
37384
  }
37361
37385
 
37362
- 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;
37363
- function findStaticImports(code) {
37364
- return matchAll(ESM_STATIC_IMPORT_RE, code, { type: "static" });
37365
- }
37366
- function parseStaticImport(matched) {
37367
- const cleanedImports = (matched.imports || "").replace(/(\/\/[^\n]*\n|\/\*.*\*\/)/g, "").replace(/\s+/g, " ");
37368
- const namedImports = {};
37369
- for (const namedImport of cleanedImports.match(/\{([^}]*)\}/)?.[1]?.split(",") || []) {
37370
- const [, source = namedImport.trim(), importName = source] = namedImport.match(/^\s*([^\s]*) as ([^\s]*)\s*$/) || [];
37371
- if (source) {
37372
- namedImports[source] = importName;
37373
- }
37374
- }
37375
- const topLevelImports = cleanedImports.replace(/\{([^}]*)\}/, "");
37376
- const namespacedImport = topLevelImports.match(/\* as \s*([^\s]*)/)?.[1];
37377
- const defaultImport = topLevelImports.split(",").find((i) => !i.match(/[*{}]/))?.trim() || void 0;
37378
- return {
37379
- ...matched,
37380
- defaultImport,
37381
- namespacedImport,
37382
- namedImports
37383
- };
37384
- }
37385
-
37386
37386
  const isWindows$3 = process.platform === "win32";
37387
37387
  const own$1 = {}.hasOwnProperty;
37388
37388
  const messages = /* @__PURE__ */ new Map();
37389
37389
  const nodeInternalPrefix = "__node_internal_";
37390
37390
  let userStackTraceLimit;
37391
- createError("ERR_INVALID_MODULE_SPECIFIER", (request, reason, base = void 0) => {
37392
- return `Invalid module "${request}" ${reason}${base ? ` imported from ${base}` : ""}`;
37393
- }, TypeError);
37394
- createError("ERR_INVALID_PACKAGE_CONFIG", (path, base, message) => {
37395
- return `Invalid package config ${path}${base ? ` while importing ${base}` : ""}${message ? `. ${message}` : ""}`;
37396
- }, Error);
37397
- createError("ERR_INVALID_PACKAGE_TARGET", (pkgPath, key, target, isImport = false, base = void 0) => {
37398
- const relError = typeof target === "string" && !isImport && target.length > 0 && !target.startsWith("./");
37399
- if (key === ".") {
37400
- assert$1(isImport === false);
37401
- return `Invalid "exports" main target ${JSON.stringify(target)} defined in the package config ${pkgPath}package.json${base ? ` imported from ${base}` : ""}${relError ? '; targets must start with "./"' : ""}`;
37402
- }
37403
- return `Invalid "${isImport ? "imports" : "exports"}" target ${JSON.stringify(target)} defined for '${key}' in the package config ${pkgPath}package.json${base ? ` imported from ${base}` : ""}${relError ? '; targets must start with "./"' : ""}`;
37404
- }, Error);
37405
- createError("ERR_MODULE_NOT_FOUND", (path, base, type = "package") => {
37406
- return `Cannot find ${type} '${path}' imported from ${base}`;
37407
- }, Error);
37408
- createError("ERR_PACKAGE_IMPORT_NOT_DEFINED", (specifier, packagePath, base) => {
37409
- return `Package import specifier "${specifier}" is not defined${packagePath ? ` in package ${packagePath}package.json` : ""} imported from ${base}`;
37410
- }, TypeError);
37411
- createError("ERR_PACKAGE_PATH_NOT_EXPORTED", (pkgPath, subpath, base = void 0) => {
37412
- if (subpath === ".") {
37413
- return `No "exports" main defined in ${pkgPath}package.json${base ? ` imported from ${base}` : ""}`;
37414
- }
37415
- return `Package subpath '${subpath}' is not defined by "exports" in ${pkgPath}package.json${base ? ` imported from ${base}` : ""}`;
37416
- }, Error);
37417
- createError("ERR_UNSUPPORTED_DIR_IMPORT", "Directory import '%s' is not supported resolving ES modules imported from %s", Error);
37418
- createError("ERR_UNKNOWN_FILE_EXTENSION", 'Unknown file extension "%s" for %s', TypeError);
37419
- createError("ERR_INVALID_ARG_VALUE", (name, value, reason = "is invalid") => {
37420
- let inspected = inspect(value);
37421
- if (inspected.length > 128) {
37422
- inspected = `${inspected.slice(0, 128)}...`;
37423
- }
37424
- const type = name.includes(".") ? "property" : "argument";
37425
- return `The ${type} '${name}' ${reason}. Received ${inspected}`;
37426
- }, TypeError);
37427
- createError("ERR_UNSUPPORTED_ESM_URL_SCHEME", (url) => {
37428
- let message = "Only file and data URLs are supported by the default ESM loader";
37429
- if (isWindows$3 && url.protocol.length === 2) {
37430
- message += ". On Windows, absolute paths must be valid file:// URLs";
37431
- }
37432
- message += `. Received protocol '${url.protocol}'`;
37433
- return message;
37434
- }, Error);
37391
+ createError(
37392
+ "ERR_INVALID_MODULE_SPECIFIER",
37393
+ (request, reason, base = void 0) => {
37394
+ return `Invalid module "${request}" ${reason}${base ? ` imported from ${base}` : ""}`;
37395
+ },
37396
+ TypeError
37397
+ );
37398
+ createError(
37399
+ "ERR_INVALID_PACKAGE_CONFIG",
37400
+ (path, base, message) => {
37401
+ return `Invalid package config ${path}${base ? ` while importing ${base}` : ""}${message ? `. ${message}` : ""}`;
37402
+ },
37403
+ Error
37404
+ );
37405
+ createError(
37406
+ "ERR_INVALID_PACKAGE_TARGET",
37407
+ (pkgPath, key, target, isImport = false, base = void 0) => {
37408
+ const relError = typeof target === "string" && !isImport && target.length > 0 && !target.startsWith("./");
37409
+ if (key === ".") {
37410
+ assert$1(isImport === false);
37411
+ return `Invalid "exports" main target ${JSON.stringify(target)} defined in the package config ${pkgPath}package.json${base ? ` imported from ${base}` : ""}${relError ? '; targets must start with "./"' : ""}`;
37412
+ }
37413
+ return `Invalid "${isImport ? "imports" : "exports"}" target ${JSON.stringify(
37414
+ target
37415
+ )} defined for '${key}' in the package config ${pkgPath}package.json${base ? ` imported from ${base}` : ""}${relError ? '; targets must start with "./"' : ""}`;
37416
+ },
37417
+ Error
37418
+ );
37419
+ createError(
37420
+ "ERR_MODULE_NOT_FOUND",
37421
+ (path, base, type = "package") => {
37422
+ return `Cannot find ${type} '${path}' imported from ${base}`;
37423
+ },
37424
+ Error
37425
+ );
37426
+ createError(
37427
+ "ERR_PACKAGE_IMPORT_NOT_DEFINED",
37428
+ (specifier, packagePath, base) => {
37429
+ return `Package import specifier "${specifier}" is not defined${packagePath ? ` in package ${packagePath}package.json` : ""} imported from ${base}`;
37430
+ },
37431
+ TypeError
37432
+ );
37433
+ createError(
37434
+ "ERR_PACKAGE_PATH_NOT_EXPORTED",
37435
+ (pkgPath, subpath, base = void 0) => {
37436
+ if (subpath === ".") {
37437
+ return `No "exports" main defined in ${pkgPath}package.json${base ? ` imported from ${base}` : ""}`;
37438
+ }
37439
+ return `Package subpath '${subpath}' is not defined by "exports" in ${pkgPath}package.json${base ? ` imported from ${base}` : ""}`;
37440
+ },
37441
+ Error
37442
+ );
37443
+ createError(
37444
+ "ERR_UNSUPPORTED_DIR_IMPORT",
37445
+ "Directory import '%s' is not supported resolving ES modules imported from %s",
37446
+ Error
37447
+ );
37448
+ createError(
37449
+ "ERR_UNKNOWN_FILE_EXTENSION",
37450
+ 'Unknown file extension "%s" for %s',
37451
+ TypeError
37452
+ );
37453
+ createError(
37454
+ "ERR_INVALID_ARG_VALUE",
37455
+ (name, value, reason = "is invalid") => {
37456
+ let inspected = inspect(value);
37457
+ if (inspected.length > 128) {
37458
+ inspected = `${inspected.slice(0, 128)}...`;
37459
+ }
37460
+ const type = name.includes(".") ? "property" : "argument";
37461
+ return `The ${type} '${name}' ${reason}. Received ${inspected}`;
37462
+ },
37463
+ TypeError
37464
+ );
37465
+ createError(
37466
+ "ERR_UNSUPPORTED_ESM_URL_SCHEME",
37467
+ (url) => {
37468
+ let message = "Only file and data URLs are supported by the default ESM loader";
37469
+ if (isWindows$3 && url.protocol.length === 2) {
37470
+ message += ". On Windows, absolute paths must be valid file:// URLs";
37471
+ }
37472
+ message += `. Received protocol '${url.protocol}'`;
37473
+ return message;
37474
+ },
37475
+ Error
37476
+ );
37435
37477
  function createError(sym, value, def) {
37436
37478
  messages.set(sym, value);
37437
37479
  return makeNodeErrorWithCode(def, sym);
@@ -37467,20 +37509,22 @@ function makeNodeErrorWithCode(Base, key) {
37467
37509
  return error;
37468
37510
  }
37469
37511
  }
37470
- const addCodeToName = hideStackFrames(function(error, name, code) {
37471
- error = captureLargerStackTrace(error);
37472
- error.name = `${name} [${code}]`;
37473
- if (name === "SystemError") {
37474
- Object.defineProperty(error, "name", {
37475
- value: name,
37476
- enumerable: false,
37477
- writable: true,
37478
- configurable: true
37479
- });
37480
- } else {
37481
- delete error.name;
37512
+ const addCodeToName = hideStackFrames(
37513
+ function(error, name, code) {
37514
+ error = captureLargerStackTrace(error);
37515
+ error.name = `${name} [${code}]`;
37516
+ if (name === "SystemError") {
37517
+ Object.defineProperty(error, "name", {
37518
+ value: name,
37519
+ enumerable: false,
37520
+ writable: true,
37521
+ configurable: true
37522
+ });
37523
+ } else {
37524
+ delete error.name;
37525
+ }
37482
37526
  }
37483
- });
37527
+ );
37484
37528
  function isErrorStackTraceLimitWritable() {
37485
37529
  const desc = Object.getOwnPropertyDescriptor(Error, "stackTraceLimit");
37486
37530
  if (desc === void 0) {
@@ -37493,26 +37537,34 @@ function hideStackFrames(fn) {
37493
37537
  Object.defineProperty(fn, "name", { value: hidden });
37494
37538
  return fn;
37495
37539
  }
37496
- const captureLargerStackTrace = hideStackFrames(function(error) {
37497
- const stackTraceLimitIsWritable = isErrorStackTraceLimitWritable();
37498
- if (stackTraceLimitIsWritable) {
37499
- userStackTraceLimit = Error.stackTraceLimit;
37500
- Error.stackTraceLimit = Number.POSITIVE_INFINITY;
37501
- }
37502
- Error.captureStackTrace(error);
37503
- if (stackTraceLimitIsWritable) {
37504
- Error.stackTraceLimit = userStackTraceLimit;
37540
+ const captureLargerStackTrace = hideStackFrames(
37541
+ function(error) {
37542
+ const stackTraceLimitIsWritable = isErrorStackTraceLimitWritable();
37543
+ if (stackTraceLimitIsWritable) {
37544
+ userStackTraceLimit = Error.stackTraceLimit;
37545
+ Error.stackTraceLimit = Number.POSITIVE_INFINITY;
37546
+ }
37547
+ Error.captureStackTrace(error);
37548
+ if (stackTraceLimitIsWritable) {
37549
+ Error.stackTraceLimit = userStackTraceLimit;
37550
+ }
37551
+ return error;
37505
37552
  }
37506
- return error;
37507
- });
37553
+ );
37508
37554
  function getMessage(key, args, self) {
37509
37555
  const message = messages.get(key);
37510
37556
  if (typeof message === "function") {
37511
- assert$1(message.length <= args.length, `Code: ${key}; The provided arguments length (${args.length}) does not match the required ones (${message.length}).`);
37557
+ assert$1(
37558
+ message.length <= args.length,
37559
+ `Code: ${key}; The provided arguments length (${args.length}) does not match the required ones (${message.length}).`
37560
+ );
37512
37561
  return Reflect.apply(message, self, args);
37513
37562
  }
37514
37563
  const expectedLength = (message.match(/%[dfijoOs]/g) || []).length;
37515
- assert$1(expectedLength === args.length, `Code: ${key}; The provided arguments length (${args.length}) does not match the required ones (${expectedLength}).`);
37564
+ assert$1(
37565
+ expectedLength === args.length,
37566
+ `Code: ${key}; The provided arguments length (${args.length}) does not match the required ones (${expectedLength}).`
37567
+ );
37516
37568
  if (args.length === 0) {
37517
37569
  return message;
37518
37570
  }
@@ -37522,6 +37574,30 @@ function getMessage(key, args, self) {
37522
37574
  Object.freeze(["node", "import"]);
37523
37575
  pathToFileURL$1(process.cwd());
37524
37576
 
37577
+ 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;
37578
+ function findStaticImports(code) {
37579
+ return matchAll(ESM_STATIC_IMPORT_RE, code, { type: "static" });
37580
+ }
37581
+ function parseStaticImport(matched) {
37582
+ const cleanedImports = (matched.imports || "").replace(/(\/\/[^\n]*\n|\/\*.*\*\/)/g, "").replace(/\s+/g, " ");
37583
+ const namedImports = {};
37584
+ for (const namedImport of cleanedImports.match(/\{([^}]*)\}/)?.[1]?.split(",") || []) {
37585
+ const [, source = namedImport.trim(), importName = source] = namedImport.match(/^\s*([^\s]*) as ([^\s]*)\s*$/) || [];
37586
+ if (source) {
37587
+ namedImports[source] = importName;
37588
+ }
37589
+ }
37590
+ const topLevelImports = cleanedImports.replace(/\{([^}]*)\}/, "");
37591
+ const namespacedImport = topLevelImports.match(/\* as \s*([^\s]*)/)?.[1];
37592
+ const defaultImport = topLevelImports.split(",").find((i) => !i.match(/[*{}]/))?.trim() || void 0;
37593
+ return {
37594
+ ...matched,
37595
+ defaultImport,
37596
+ namespacedImport,
37597
+ namedImports
37598
+ };
37599
+ }
37600
+
37525
37601
  const debugHmr = createDebugger('vite:hmr');
37526
37602
  const normalizedClientDir = normalizePath$3(CLIENT_DIR);
37527
37603
  function getShortName(file, root) {
@@ -37976,22 +38052,56 @@ function shouldExternalizeForSSR(id, config) {
37976
38052
  return isSsrExternal(id);
37977
38053
  }
37978
38054
  function createIsConfiguredAsSsrExternal(config) {
37979
- const { ssr } = config;
38055
+ const { ssr, root } = config;
37980
38056
  const noExternal = ssr?.noExternal;
37981
38057
  const noExternalFilter = noExternal !== 'undefined' &&
37982
38058
  typeof noExternal !== 'boolean' &&
37983
38059
  createFilter(undefined, noExternal, { resolve: false });
38060
+ const resolveOptions = {
38061
+ root,
38062
+ preserveSymlinks: config.resolve.preserveSymlinks,
38063
+ isProduction: false,
38064
+ isBuild: true
38065
+ };
38066
+ const isExternalizable = (id, configuredAsExternal) => {
38067
+ if (!bareImportRE.test(id) || id.includes('\0')) {
38068
+ return false;
38069
+ }
38070
+ try {
38071
+ return !!tryNodeResolve(id, undefined, resolveOptions, ssr?.target === 'webworker', undefined, true,
38072
+ // try to externalize, will return undefined or an object without
38073
+ // a external flag if it isn't externalizable
38074
+ true,
38075
+ // Allow linked packages to be externalized if they are explicitly
38076
+ // configured as external
38077
+ !!configuredAsExternal)?.external;
38078
+ }
38079
+ catch (e) {
38080
+ debug$9(`Failed to node resolve "${id}". Skipping externalizing it by default.`);
38081
+ // may be an invalid import that's resolved by a plugin
38082
+ return false;
38083
+ }
38084
+ };
37984
38085
  // Returns true if it is configured as external, false if it is filtered
37985
38086
  // by noExternal and undefined if it isn't affected by the explicit config
37986
38087
  return (id) => {
37987
38088
  const { ssr } = config;
37988
38089
  if (ssr) {
38090
+ if (
38091
+ // If this id is defined as external, force it as external
38092
+ // Note that individual package entries are allowed in ssr.external
38093
+ ssr.external?.includes(id)) {
38094
+ return true;
38095
+ }
37989
38096
  const pkgName = getNpmPackageName(id);
37990
38097
  if (!pkgName) {
37991
- return undefined;
38098
+ return isExternalizable(id);
37992
38099
  }
37993
- if (ssr.external?.includes(pkgName)) {
37994
- return true;
38100
+ if (
38101
+ // A package name in ssr.external externalizes every
38102
+ // externalizable package entry
38103
+ ssr.external?.includes(pkgName)) {
38104
+ return isExternalizable(id, true);
37995
38105
  }
37996
38106
  if (typeof noExternal === 'boolean') {
37997
38107
  return !noExternal;
@@ -38000,34 +38110,19 @@ function createIsConfiguredAsSsrExternal(config) {
38000
38110
  return false;
38001
38111
  }
38002
38112
  }
38003
- return undefined;
38113
+ return isExternalizable(id);
38004
38114
  };
38005
38115
  }
38006
38116
  function createIsSsrExternal(config) {
38007
38117
  const processedIds = new Map();
38008
- const { ssr, root } = config;
38009
38118
  const isConfiguredAsExternal = createIsConfiguredAsSsrExternal(config);
38010
- const resolveOptions = {
38011
- root,
38012
- preserveSymlinks: config.resolve.preserveSymlinks,
38013
- isProduction: false,
38014
- isBuild: true
38015
- };
38016
- const isValidPackageEntry = (id) => {
38017
- if (!bareImportRE.test(id) || id.includes('\0')) {
38018
- return false;
38019
- }
38020
- return !!tryNodeResolve(id, undefined, resolveOptions, ssr?.target === 'webworker', undefined, true, true // try to externalize, will return undefined if not possible
38021
- );
38022
- };
38023
38119
  return (id) => {
38024
38120
  if (processedIds.has(id)) {
38025
38121
  return processedIds.get(id);
38026
38122
  }
38027
38123
  let external = false;
38028
38124
  if (!id.startsWith('.') && !path$n.isAbsolute(id)) {
38029
- external =
38030
- isBuiltin(id) || (isConfiguredAsExternal(id) ?? isValidPackageEntry(id));
38125
+ external = isBuiltin(id) || isConfiguredAsExternal(id);
38031
38126
  }
38032
38127
  processedIds.set(id, external);
38033
38128
  return external;
@@ -38849,7 +38944,7 @@ async function ssrTransformScript(code, inMap, url, originalCode) {
38849
38944
  function defineImport(node, source) {
38850
38945
  deps.add(source);
38851
38946
  const importId = `__vite_ssr_import_${uid++}__`;
38852
- s.appendLeft(node.start, `const ${importId} = await ${ssrImportKey}(${JSON.stringify(source)});\n`);
38947
+ s.appendRight(node.start, `const ${importId} = await ${ssrImportKey}(${JSON.stringify(source)});\n`);
38853
38948
  return importId;
38854
38949
  }
38855
38950
  function defineExport(position, name, local = name) {
@@ -38862,6 +38957,7 @@ async function ssrTransformScript(code, inMap, url, originalCode) {
38862
38957
  // import { baz } from 'foo' --> baz -> __import_foo__.baz
38863
38958
  // import * as ok from 'foo' --> ok -> __import_foo__
38864
38959
  if (node.type === 'ImportDeclaration') {
38960
+ s.remove(node.start, node.end);
38865
38961
  const importId = defineImport(node, node.source.value);
38866
38962
  for (const spec of node.specifiers) {
38867
38963
  if (spec.type === 'ImportSpecifier') {
@@ -38875,7 +38971,6 @@ async function ssrTransformScript(code, inMap, url, originalCode) {
38875
38971
  idToImportMap.set(spec.local.name, importId);
38876
38972
  }
38877
38973
  }
38878
- s.remove(node.start, node.end);
38879
38974
  }
38880
38975
  }
38881
38976
  // 2. check all export statements and define exports
@@ -38939,14 +39034,12 @@ async function ssrTransformScript(code, inMap, url, originalCode) {
38939
39034
  }
38940
39035
  // export * from './foo'
38941
39036
  if (node.type === 'ExportAllDeclaration') {
39037
+ s.remove(node.start, node.end);
39038
+ const importId = defineImport(node, node.source.value);
38942
39039
  if (node.exported) {
38943
- const importId = defineImport(node, node.source.value);
38944
- s.remove(node.start, node.end);
38945
39040
  defineExport(node.end, node.exported.name, `${importId}`);
38946
39041
  }
38947
39042
  else {
38948
- const importId = defineImport(node, node.source.value);
38949
- s.remove(node.start, node.end);
38950
39043
  s.appendLeft(node.end, `${ssrExportAllKey}(${importId});`);
38951
39044
  }
38952
39045
  }
@@ -39584,7 +39677,7 @@ function ensureServingAccess(url, server, res, next) {
39584
39677
  const hintMessage = `
39585
39678
  ${server.config.server.fs.allow.map((i) => `- ${i}`).join('\n')}
39586
39679
 
39587
- Refer to docs https://vitejs.dev/config/#server-fs-allow for configurations and more details.`;
39680
+ Refer to docs https://vitejs.dev/config/server-options.html#server-fs-allow for configurations and more details.`;
39588
39681
  server.config.logger.error(urlMessage);
39589
39682
  server.config.logger.warnOnce(hintMessage + '\n');
39590
39683
  res.statusCode = 403;
@@ -40818,7 +40911,7 @@ function buildImportAnalysisPlugin(config) {
40818
40911
  // dynamic import to constant json may get inlined.
40819
40912
  if (chunk.type === 'chunk' && chunk.code.indexOf(preloadMarker) > -1) {
40820
40913
  const code = chunk.code;
40821
- let imports;
40914
+ let imports = [];
40822
40915
  try {
40823
40916
  imports = parse$b(code)[0].filter((i) => i.d > -1);
40824
40917
  }
@@ -40945,8 +41038,7 @@ function modulePreloadPolyfillPlugin(config) {
40945
41038
  return '';
40946
41039
  }
40947
41040
  if (!polyfillString) {
40948
- polyfillString =
40949
- `const p = ${polyfill.toString()};` + `${isModernFlag}&&p();`;
41041
+ polyfillString = `${isModernFlag}&&(${polyfill.toString()}());`;
40950
41042
  }
40951
41043
  return polyfillString;
40952
41044
  }
@@ -40997,7 +41089,7 @@ function polyfill() {
40997
41089
  }
40998
41090
  }
40999
41091
 
41000
- const htmlProxyRE$1 = /\?html-proxy=?[&inline\-css]*&index=(\d+)\.(js|css)$/;
41092
+ const htmlProxyRE$1 = /\?html-proxy=?(?:&inline-css)?&index=(\d+)\.(js|css)$/;
41001
41093
  const inlineCSSRE$1 = /__VITE_INLINE_CSS__([a-z\d]{8}_\d+)__/g;
41002
41094
  // Do not allow preceding '.', but do allow preceding '...' for spread operations
41003
41095
  const inlineImportRE = /(?<!(?<!\.\.)\.)\bimport\s*\(("([^"]|(?<=\\)")*"|'([^']|(?<=\\)')*')\)/g;
@@ -41063,7 +41155,7 @@ const assetAttrsConfig = {
41063
41155
  const isAsyncScriptMap = new WeakMap();
41064
41156
  async function traverseHtml(html, filePath, visitor) {
41065
41157
  // lazy load compiler
41066
- const { parse, transform } = await import('./dep-3f457808.js').then(function (n) { return n.c; });
41158
+ const { parse, transform } = await import('./dep-b58adab6.js').then(function (n) { return n.c; });
41067
41159
  // @vue/compiler-core doesn't like lowercase doctypes
41068
41160
  html = html.replace(/<!doctype\s/i, '<!DOCTYPE ');
41069
41161
  try {
@@ -41225,7 +41317,10 @@ function buildHtmlPlugin(config) {
41225
41317
  // assetsUrl may be encodeURI
41226
41318
  const url = decodeURI(p.value.content);
41227
41319
  if (!isExcludedUrl(url)) {
41228
- if (node.tag === 'link' && isCSSRequest(url)) {
41320
+ if (node.tag === 'link' &&
41321
+ isCSSRequest(url) &&
41322
+ // should not be converted if following attributes are present (#6748)
41323
+ !node.props.some((p) => p.name === 'media' || p.name === 'disabled')) {
41229
41324
  // CSS references, convert to import
41230
41325
  const importExpression = `\nimport ${JSON.stringify(url)}`;
41231
41326
  styleUrls.push({
@@ -41409,14 +41504,16 @@ function buildHtmlPlugin(config) {
41409
41504
  for (const [id, html] of processedHtml) {
41410
41505
  const relativeUrlPath = path$n.posix.relative(config.root, id);
41411
41506
  const assetsBase = getBaseInHTML(relativeUrlPath, config);
41412
- const toOutputAssetFilePath = (filename) => {
41507
+ const toOutputFilePath = (filename, type) => {
41413
41508
  if (isExternalUrl(filename)) {
41414
41509
  return filename;
41415
41510
  }
41416
41511
  else {
41417
- return toOutputFilePathInHtml(filename, 'asset', relativeUrlPath, 'html', config, (filename, importer) => assetsBase + filename);
41512
+ return toOutputFilePathInHtml(filename, type, relativeUrlPath, 'html', config, (filename, importer) => assetsBase + filename);
41418
41513
  }
41419
41514
  };
41515
+ const toOutputAssetFilePath = (filename) => toOutputFilePath(filename, 'asset');
41516
+ const toOutputPublicAssetFilePath = (filename) => toOutputFilePath(filename, 'public');
41420
41517
  const isAsync = isAsyncScriptMap.get(config).get(id);
41421
41518
  let result = html;
41422
41519
  // find corresponding entry chunk
@@ -41481,11 +41578,14 @@ function buildHtmlPlugin(config) {
41481
41578
  result = result.replace(assetUrlRE, (_, fileHash, postfix = '') => {
41482
41579
  return (toOutputAssetFilePath(getAssetFilename(fileHash, config)) + postfix);
41483
41580
  });
41581
+ result = result.replace(publicAssetUrlRE, (_, fileHash) => {
41582
+ return normalizePath$3(toOutputPublicAssetFilePath(getPublicAssetFilename(fileHash, config)));
41583
+ });
41484
41584
  if (chunk && canInlineEntry) {
41485
41585
  // all imports from entry have been inlined to html, prevent rollup from outputting it
41486
41586
  delete bundle[chunk.fileName];
41487
41587
  }
41488
- const shortEmitName = path$n.relative(config.root, id);
41588
+ const shortEmitName = normalizePath$3(path$n.relative(config.root, id));
41489
41589
  this.emitFile({
41490
41590
  type: 'asset',
41491
41591
  fileName: shortEmitName,
@@ -41963,7 +42063,7 @@ function cssPostPlugin(config) {
41963
42063
  return chunkCSS;
41964
42064
  }
41965
42065
  function ensureFileExt(name, ext) {
41966
- return path$n.format({ ...path$n.parse(name), base: undefined, ext });
42066
+ return normalizePath$3(path$n.format({ ...path$n.parse(name), base: undefined, ext }));
41967
42067
  }
41968
42068
  if (config.build.cssCodeSplit) {
41969
42069
  if (isPureCssChunk) {
@@ -42174,7 +42274,7 @@ async function compileCSS(id, code, config, urlReplacer, atImportResolvers, serv
42174
42274
  const postcssOptions = (postcssConfig && postcssConfig.options) || {};
42175
42275
  const postcssPlugins = postcssConfig && postcssConfig.plugins ? postcssConfig.plugins.slice() : [];
42176
42276
  if (needInlineImport) {
42177
- postcssPlugins.unshift((await import('./dep-41eb528c.js').then(function (n) { return n.i; })).default({
42277
+ postcssPlugins.unshift((await import('./dep-94c1417a.js').then(function (n) { return n.i; })).default({
42178
42278
  async resolve(id, basedir) {
42179
42279
  const publicFile = checkPublicFile(id, config);
42180
42280
  if (publicFile) {
@@ -42193,7 +42293,7 @@ async function compileCSS(id, code, config, urlReplacer, atImportResolvers, serv
42193
42293
  logger: config.logger
42194
42294
  }));
42195
42295
  if (isModule) {
42196
- postcssPlugins.unshift((await import('./dep-f07a4e2f.js').then(function (n) { return n.i; })).default({
42296
+ postcssPlugins.unshift((await import('./dep-0f192b10.js').then(function (n) { return n.i; })).default({
42197
42297
  ...modulesOptions,
42198
42298
  getJSON(cssFileName, _modules, outputFileName) {
42199
42299
  modules = _modules;
@@ -42504,17 +42604,23 @@ async function minifyCSS(css, config) {
42504
42604
  }
42505
42605
  }
42506
42606
  function resolveEsbuildMinifyOptions(options) {
42607
+ const base = {
42608
+ logLevel: options.logLevel,
42609
+ logLimit: options.logLimit,
42610
+ logOverride: options.logOverride
42611
+ };
42507
42612
  if (options.minifyIdentifiers != null ||
42508
42613
  options.minifySyntax != null ||
42509
42614
  options.minifyWhitespace != null) {
42510
42615
  return {
42616
+ ...base,
42511
42617
  minifyIdentifiers: options.minifyIdentifiers ?? true,
42512
42618
  minifySyntax: options.minifySyntax ?? true,
42513
42619
  minifyWhitespace: options.minifyWhitespace ?? true
42514
42620
  };
42515
42621
  }
42516
42622
  else {
42517
- return { minify: true };
42623
+ return { ...base, minify: true };
42518
42624
  }
42519
42625
  }
42520
42626
  async function hoistAtRules(css) {
@@ -43123,7 +43229,7 @@ function assetImportMetaUrlPlugin(config) {
43123
43229
  // target so we use the global location here. It can be
43124
43230
  // window.location or self.location in case it is used in a Web Worker.
43125
43231
  // @see https://developer.mozilla.org/en-US/docs/Web/API/Window/self
43126
- s.overwrite(index, index + exp.length, `new URL((import.meta.glob(${pattern}, { eager: true, import: 'default' }))[${rawUrl}], self.location)`, { contentOnly: true });
43232
+ s.overwrite(index, index + exp.length, `new URL((import.meta.glob(${pattern}, { eager: true, import: 'default', as: 'url' }))[${rawUrl}], self.location)`, { contentOnly: true });
43127
43233
  continue;
43128
43234
  }
43129
43235
  }
@@ -43368,10 +43474,11 @@ async function doBuild(inlineConfig = {}) {
43368
43474
  `This is deprecated and will override all Vite.js default output options. ` +
43369
43475
  `Please use "rollupOptions.output" instead.`);
43370
43476
  }
43371
- const ssrWorkerBuild = ssr && config.ssr?.target !== 'webworker';
43372
- const cjsSsrBuild = ssr && config.ssr?.format === 'cjs';
43477
+ const ssrNodeBuild = ssr && config.ssr.target === 'node';
43478
+ const ssrWorkerBuild = ssr && config.ssr.target === 'webworker';
43479
+ const cjsSsrBuild = ssr && config.ssr.format === 'cjs';
43373
43480
  const format = output.format || (cjsSsrBuild ? 'cjs' : 'es');
43374
- const jsExt = ssrWorkerBuild || libOptions
43481
+ const jsExt = ssrNodeBuild || libOptions
43375
43482
  ? resolveOutputJsExtension(format, getPkgJson(config.root)?.type)
43376
43483
  : 'js';
43377
43484
  return {
@@ -43656,7 +43763,7 @@ function wrapSsrTransform(fn) {
43656
43763
  function injectSsrFlag(options) {
43657
43764
  return { ...(options ?? {}), ssr: true };
43658
43765
  }
43659
- function toOutputFilePathInString(filename, type, hostId, hostType, config, toRelative) {
43766
+ function toOutputFilePathInString(filename, type, hostId, hostType, config, toRelative = toImportMetaURLBasedRelativePath) {
43660
43767
  const { renderBuiltUrl } = config.experimental;
43661
43768
  let relative = config.base === '' || config.base === './';
43662
43769
  if (renderBuiltUrl) {
@@ -43683,6 +43790,11 @@ function toOutputFilePathInString(filename, type, hostId, hostType, config, toRe
43683
43790
  }
43684
43791
  return config.base + filename;
43685
43792
  }
43793
+ function toImportMetaURLBasedRelativePath(filename, importer) {
43794
+ return {
43795
+ runtime: `new URL(${JSON.stringify(path$n.posix.relative(path$n.dirname(importer), filename))},import.meta.url).href`
43796
+ };
43797
+ }
43686
43798
  function toOutputFilePathWithoutRuntime(filename, type, hostId, hostType, config, toRelative) {
43687
43799
  const { renderBuiltUrl } = config.experimental;
43688
43800
  let relative = config.base === '' || config.base === './';
@@ -49727,30 +49839,44 @@ var guess = function guessEditor (specifiedEditor) {
49727
49839
  try {
49728
49840
  if (process.platform === 'darwin') {
49729
49841
  const output = childProcess$2
49730
- .execSync('ps x', {
49842
+ .execSync('ps x -o comm=', {
49731
49843
  stdio: ['pipe', 'pipe', 'ignore']
49732
49844
  })
49733
49845
  .toString();
49734
49846
  const processNames = Object.keys(COMMON_EDITORS_OSX);
49847
+ const processList = output.split('\n');
49735
49848
  for (let i = 0; i < processNames.length; i++) {
49736
49849
  const processName = processNames[i];
49850
+ // Find editor by exact match.
49737
49851
  if (output.indexOf(processName) !== -1) {
49738
49852
  return [COMMON_EDITORS_OSX[processName]]
49739
49853
  }
49854
+ const processNameWithoutApplications = processName.replace('/Applications', '');
49855
+ // Find editor installation not in /Applications.
49856
+ if (output.indexOf(processNameWithoutApplications) !== -1) {
49857
+ // Use the CLI command if one is specified
49858
+ if (processName !== COMMON_EDITORS_OSX[processName]) {
49859
+ return [COMMON_EDITORS_OSX[processName]]
49860
+ }
49861
+ // Use a partial match to find the running process path. If one is found, use the
49862
+ // existing path since it can be running from anywhere.
49863
+ const runningProcess = processList.find((procName) => procName.endsWith(processNameWithoutApplications));
49864
+ if (runningProcess !== undefined) {
49865
+ return [runningProcess]
49866
+ }
49867
+ }
49740
49868
  }
49741
49869
  } else if (process.platform === 'win32') {
49742
49870
  const output = childProcess$2
49743
- .execSync('powershell -Command "Get-Process | Select-Object Path"', {
49744
- stdio: ['pipe', 'pipe', 'ignore']
49745
- })
49871
+ .execSync(
49872
+ 'powershell -NoProfile -Command "Get-CimInstance -Query \\"select executablepath from win32_process where executablepath is not null\\" | % { $_.ExecutablePath }"',
49873
+ {
49874
+ stdio: ['pipe', 'pipe', 'ignore']
49875
+ }
49876
+ )
49746
49877
  .toString();
49747
49878
  const runningProcesses = output.split('\r\n');
49748
49879
  for (let i = 0; i < runningProcesses.length; i++) {
49749
- // `Get-Process` sometimes returns empty lines
49750
- if (!runningProcesses[i]) {
49751
- continue
49752
- }
49753
-
49754
49880
  const fullProcessPath = runningProcesses[i].trim();
49755
49881
  const shortProcessName = path$8.basename(fullProcessPath);
49756
49882
 
@@ -49826,6 +49952,7 @@ var getArgs = function getArgumentsForPosition (
49826
49952
  case 'code':
49827
49953
  case 'code-insiders':
49828
49954
  case 'Code':
49955
+ case 'codium':
49829
49956
  return ['-r', '-g', `${fileName}:${lineNumber}:${columnNumber}`]
49830
49957
  case 'appcode':
49831
49958
  case 'clion':
@@ -49840,7 +49967,7 @@ var getArgs = function getArgumentsForPosition (
49840
49967
  case 'rubymine64':
49841
49968
  case 'webstorm':
49842
49969
  case 'webstorm64':
49843
- return ['--line', lineNumber, fileName]
49970
+ return ['--line', lineNumber, '--column', columnNumber, fileName]
49844
49971
  }
49845
49972
 
49846
49973
  // For all others, drop the lineNumber until we have
@@ -50019,16 +50146,16 @@ var launchEditorMiddleware = (specifiedEditor, srcRoot, onErrorCallback) => {
50019
50146
 
50020
50147
  async function resolveHttpServer({ proxy }, app, httpsOptions) {
50021
50148
  if (!httpsOptions) {
50022
- const { createServer } = await import('http');
50149
+ const { createServer } = await import('node:http');
50023
50150
  return createServer(app);
50024
50151
  }
50025
50152
  // #484 fallback to http1 when proxy is needed.
50026
50153
  if (proxy) {
50027
- const { createServer } = await import('https');
50154
+ const { createServer } = await import('node:https');
50028
50155
  return createServer(httpsOptions, app);
50029
50156
  }
50030
50157
  else {
50031
- const { createSecureServer } = await import('http2');
50158
+ const { createSecureServer } = await import('node:http2');
50032
50159
  return createSecureServer({
50033
50160
  // Manually increase the session memory to prevent 502 ENHANCE_YOUR_CALM
50034
50161
  // errors on large numbers of requests
@@ -50126,7 +50253,7 @@ function ssrRequireHookPlugin(config) {
50126
50253
  /** Respect the `resolve.dedupe` option in production SSR. */
50127
50254
  function dedupeRequire(dedupe) {
50128
50255
  // eslint-disable-next-line no-restricted-globals
50129
- const Module = require('module');
50256
+ const Module = require('node:module');
50130
50257
  const resolveFilename = Module._resolveFilename;
50131
50258
  Module._resolveFilename = function (request, parent, isMain, options) {
50132
50259
  if (request[0] !== '.' && request[0] !== '/') {
@@ -50326,7 +50453,7 @@ async function instantiateModule(url, server, context = { global }, urlStack = [
50326
50453
  try {
50327
50454
  // eslint-disable-next-line @typescript-eslint/no-empty-function
50328
50455
  const AsyncFunction = async function () { }.constructor;
50329
- const initModule = new AsyncFunction(`global`, ssrModuleExportsKey, ssrImportMetaKey, ssrImportKey, ssrDynamicImportKey, ssrExportAllKey, result.code + `\n//# sourceURL=${mod.url}`);
50456
+ const initModule = new AsyncFunction(`global`, ssrModuleExportsKey, ssrImportMetaKey, ssrImportKey, ssrDynamicImportKey, ssrExportAllKey, '"use strict";' + result.code + `\n//# sourceURL=${mod.url}`);
50330
50457
  await initModule(context.global, ssrModule, ssrImportMeta, ssrImport, ssrDynamicImport, ssrExportAll);
50331
50458
  }
50332
50459
  catch (e) {
@@ -50407,7 +50534,7 @@ async function nodeImport(id, importer, resolveOptions) {
50407
50534
  }
50408
50535
  // rollup-style default import interop for cjs
50409
50536
  function proxyESM(mod) {
50410
- // This is the only sensible option when the exports object is a primitve
50537
+ // This is the only sensible option when the exports object is a primitive
50411
50538
  if (isPrimitive(mod))
50412
50539
  return { default: mod };
50413
50540
  let defaultExport = 'default' in mod ? mod.default : mod;
@@ -57406,9 +57533,9 @@ function transformMiddleware(server) {
57406
57533
  }
57407
57534
  // We don't need to log an error in this case, the request
57408
57535
  // is outdated because new dependencies were discovered and
57409
- // the new pre-bundle dependendencies have changed.
57536
+ // the new pre-bundle dependencies have changed.
57410
57537
  // A full-page reload has been issued, and these old requests
57411
- // can't be properly fullfilled. This isn't an unexpected
57538
+ // can't be properly fulfilled. This isn't an unexpected
57412
57539
  // error but a normal part of the missing deps discovery flow
57413
57540
  return;
57414
57541
  }
@@ -59831,14 +59958,6 @@ function emitSourcemapForWorkerEntry(config, query, chunk) {
59831
59958
  }
59832
59959
  return chunk;
59833
59960
  }
59834
- // TODO:base review why we aren't using import.meta.url here
59835
- function toStaticRelativePath(filename, importer) {
59836
- let outputFilepath = path$n.posix.relative(path$n.dirname(importer), filename);
59837
- if (!outputFilepath.startsWith('.')) {
59838
- outputFilepath = './' + outputFilepath;
59839
- }
59840
- return outputFilepath;
59841
- }
59842
59961
  const workerAssetUrlRE = /__VITE_WORKER_ASSET__([a-z\d]{8})__/g;
59843
59962
  function encodeWorkerAssetFileName(fileName, workerCache) {
59844
59963
  const { fileNameHash } = workerCache;
@@ -59994,7 +60113,7 @@ function webWorkerPlugin(config) {
59994
60113
  while ((match = workerAssetUrlRE.exec(code))) {
59995
60114
  const [full, hash] = match;
59996
60115
  const filename = fileNameHash.get(hash);
59997
- const replacement = toOutputFilePathInString(filename, 'asset', chunk.fileName, 'js', config, toStaticRelativePath);
60116
+ const replacement = toOutputFilePathInString(filename, 'asset', chunk.fileName, 'js', config);
59998
60117
  const replacementString = typeof replacement === 'string'
59999
60118
  ? JSON.stringify(replacement).slice(1, -1)
60000
60119
  : `"+${replacement.runtime}+"`;
@@ -61794,11 +61913,28 @@ function expressionToGlob(node) {
61794
61913
  }
61795
61914
  }
61796
61915
 
61916
+ const defaultProtocol = 'file:';
61917
+ const ignoredProtocols = ['data:', 'http:', 'https:'];
61918
+
61919
+ function shouldIgnore(glob) {
61920
+ const containsAsterisk = glob.includes('*');
61921
+
61922
+ const globURL = new URL(glob, defaultProtocol);
61923
+
61924
+ const containsIgnoredProtocol = ignoredProtocols.some(
61925
+ (ignoredProtocol) => ignoredProtocol === globURL.protocol
61926
+ );
61927
+
61928
+ return !containsAsterisk || containsIgnoredProtocol;
61929
+ }
61930
+
61797
61931
  function dynamicImportToGlob(node, sourceString) {
61798
61932
  let glob = expressionToGlob(node);
61799
- if (!glob.includes('*') || glob.startsWith('data:')) {
61933
+
61934
+ if (shouldIgnore(glob)) {
61800
61935
  return null;
61801
61936
  }
61937
+
61802
61938
  glob = glob.replace(/\*\*/g, '*');
61803
61939
 
61804
61940
  if (glob.startsWith('*')) {
@@ -61942,7 +62078,13 @@ function dynamicImportVarsPlugin(config) {
61942
62078
  s || (s = new MagicString(source));
61943
62079
  let result;
61944
62080
  try {
61945
- result = await transformDynamicImport(source.slice(start, end), importer, resolve);
62081
+ // When import string is using backticks, es-module-lexer `end` captures
62082
+ // until the closing parenthesis, instead of the closing backtick.
62083
+ // There may be inline comments between the backtick and the closing
62084
+ // parenthesis, so we manually remove them for now.
62085
+ // See https://github.com/guybedford/es-module-lexer/issues/118
62086
+ const importSource = removeComments(source.slice(start, end)).trim();
62087
+ result = await transformDynamicImport(importSource, importer, resolve);
61946
62088
  }
61947
62089
  catch (error) {
61948
62090
  if (warnOnError) {
@@ -62356,6 +62498,23 @@ async function resolveConfig(inlineConfig, command, defaultMode = 'development')
62356
62498
  // user config may provide an alternative mode. But --mode has a higher priority
62357
62499
  mode = inlineConfig.mode || config.mode || mode;
62358
62500
  configEnv.mode = mode;
62501
+ // Some plugins that aren't intended to work in the bundling of workers (doing post-processing at build time for example).
62502
+ // And Plugins may also have cached that could be corrupted by being used in these extra rollup calls.
62503
+ // So we need to separate the worker plugin from the plugin that vite needs to run.
62504
+ const rawWorkerUserPlugins = (await asyncFlatten(config.worker?.plugins || [])).filter((p) => {
62505
+ if (!p) {
62506
+ return false;
62507
+ }
62508
+ else if (!p.apply) {
62509
+ return true;
62510
+ }
62511
+ else if (typeof p.apply === 'function') {
62512
+ return p.apply({ ...config, mode }, configEnv);
62513
+ }
62514
+ else {
62515
+ return p.apply === command;
62516
+ }
62517
+ });
62359
62518
  // resolve plugins
62360
62519
  const rawUserPlugins = (await asyncFlatten(config.plugins || [])).filter((p) => {
62361
62520
  if (!p) {
@@ -62372,12 +62531,6 @@ async function resolveConfig(inlineConfig, command, defaultMode = 'development')
62372
62531
  }
62373
62532
  });
62374
62533
  const [prePlugins, normalPlugins, postPlugins] = sortUserPlugins(rawUserPlugins);
62375
- // resolve worker
62376
- const resolvedWorkerOptions = {
62377
- format: config.worker?.format || 'iife',
62378
- plugins: [],
62379
- rollupOptions: config.worker?.rollupOptions || {}
62380
- };
62381
62534
  // run config hooks
62382
62535
  const userPlugins = [...prePlugins, ...normalPlugins, ...postPlugins];
62383
62536
  for (const p of userPlugins) {
@@ -62496,8 +62649,29 @@ async function resolveConfig(inlineConfig, command, defaultMode = 'development')
62496
62649
  const middlewareMode = config?.server?.middlewareMode;
62497
62650
  const optimizeDeps = config.optimizeDeps || {};
62498
62651
  const BASE_URL = resolvedBase;
62499
- const resolved = {
62500
- ...config,
62652
+ // resolve worker
62653
+ let workerConfig = mergeConfig({}, config);
62654
+ const [workerPrePlugins, workerNormalPlugins, workerPostPlugins] = sortUserPlugins(rawWorkerUserPlugins);
62655
+ // run config hooks
62656
+ const workerUserPlugins = [
62657
+ ...workerPrePlugins,
62658
+ ...workerNormalPlugins,
62659
+ ...workerPostPlugins
62660
+ ];
62661
+ for (const p of workerUserPlugins) {
62662
+ if (p.config) {
62663
+ const res = await p.config(workerConfig, configEnv);
62664
+ if (res) {
62665
+ workerConfig = mergeConfig(workerConfig, res);
62666
+ }
62667
+ }
62668
+ }
62669
+ const resolvedWorkerOptions = {
62670
+ format: workerConfig.worker?.format || 'iife',
62671
+ plugins: [],
62672
+ rollupOptions: workerConfig.worker?.rollupOptions || {}
62673
+ };
62674
+ const resolvedConfig = {
62501
62675
  configFile: configFile ? normalizePath$3(configFile) : undefined,
62502
62676
  configFileDependencies: configFileDependencies.map((name) => normalizePath$3(path$n.resolve(name))),
62503
62677
  inlineConfig,
@@ -62545,6 +62719,23 @@ async function resolveConfig(inlineConfig, command, defaultMode = 'development')
62545
62719
  ...config.experimental
62546
62720
  }
62547
62721
  };
62722
+ const resolved = {
62723
+ ...config,
62724
+ ...resolvedConfig
62725
+ };
62726
+ resolved.plugins = await resolvePlugins(resolved, prePlugins, normalPlugins, postPlugins);
62727
+ const workerResolved = {
62728
+ ...workerConfig,
62729
+ ...resolvedConfig,
62730
+ isWorker: true,
62731
+ mainConfig: resolved
62732
+ };
62733
+ resolvedConfig.worker.plugins = await resolvePlugins(workerResolved, workerPrePlugins, workerNormalPlugins, workerPostPlugins);
62734
+ // call configResolved hooks
62735
+ await Promise.all(userPlugins
62736
+ .map((p) => p.configResolved?.(resolved))
62737
+ .concat(resolvedConfig.worker.plugins.map((p) => p.configResolved?.(workerResolved))));
62738
+ // validate config
62548
62739
  if (middlewareMode === 'ssr') {
62549
62740
  logger.warn(picocolors.exports.yellow(`Setting server.middlewareMode to 'ssr' is deprecated, set server.middlewareMode to \`true\`${config.appType === 'custom' ? '' : ` and appType to 'custom'`} instead`));
62550
62741
  }
@@ -62557,25 +62748,14 @@ async function resolveConfig(inlineConfig, command, defaultMode = 'development')
62557
62748
  resolved.optimizeDeps.force = true;
62558
62749
  logger.warn(picocolors.exports.yellow(`server.force is deprecated, use optimizeDeps.force instead`));
62559
62750
  }
62560
- // Some plugins that aren't intended to work in the bundling of workers (doing post-processing at build time for example).
62561
- // And Plugins may also have cached that could be corrupted by being used in these extra rollup calls.
62562
- // So we need to separate the worker plugin from the plugin that vite needs to run.
62563
- const [workerPrePlugins, workerNormalPlugins, workerPostPlugins] = sortUserPlugins(config.worker?.plugins);
62564
- const workerResolved = {
62565
- ...resolved,
62566
- isWorker: true,
62567
- mainConfig: resolved
62568
- };
62569
- resolved.worker.plugins = await resolvePlugins(workerResolved, workerPrePlugins, workerNormalPlugins, workerPostPlugins);
62570
- // call configResolved worker plugins hooks
62571
- await Promise.all(resolved.worker.plugins.map((p) => p.configResolved?.(workerResolved)));
62572
- resolved.plugins = await resolvePlugins(resolved, prePlugins, normalPlugins, postPlugins);
62573
- // call configResolved hooks
62574
- await Promise.all(userPlugins.map((p) => p.configResolved?.(resolved)));
62575
62751
  if (process.env.DEBUG) {
62576
62752
  debug(`using resolved config: %O`, {
62577
62753
  ...resolved,
62578
- plugins: resolved.plugins.map((p) => p.name)
62754
+ plugins: resolved.plugins.map((p) => p.name),
62755
+ worker: {
62756
+ ...resolved.worker,
62757
+ plugins: resolved.worker.plugins.map((p) => p.name)
62758
+ }
62579
62759
  });
62580
62760
  }
62581
62761
  if (config.build?.terserOptions && config.build.minify !== 'terser') {
@@ -62717,6 +62897,7 @@ async function bundleConfigFile(fileName, isESM) {
62717
62897
  entryPoints: [fileName],
62718
62898
  outfile: 'out.js',
62719
62899
  write: false,
62900
+ target: ['node14.18', 'node16'],
62720
62901
  platform: 'node',
62721
62902
  bundle: true,
62722
62903
  format: isESM ? 'esm' : 'cjs',
@@ -62760,7 +62941,7 @@ async function bundleConfigFile(fileName, isESM) {
62760
62941
  if (path$n.relative(idPkgDir, fileName).startsWith('..')) {
62761
62942
  return {
62762
62943
  // normalize actual import after bundled as a single vite config
62763
- path: idFsPath,
62944
+ path: pathToFileURL(idFsPath).href,
62764
62945
  external: true
62765
62946
  };
62766
62947
  }
@@ -62797,13 +62978,20 @@ async function loadConfigFromBundledFile(fileName, bundledCode, isESM) {
62797
62978
  // with --experimental-loader themselves, we have to do a hack here:
62798
62979
  // write it to disk, load it with native Node ESM, then delete the file.
62799
62980
  if (isESM) {
62800
- const fileUrl = pathToFileURL(fileName);
62801
- fs$l.writeFileSync(fileName + '.mjs', bundledCode);
62981
+ const fileBase = `${fileName}.timestamp-${Date.now()}`;
62982
+ const fileNameTmp = `${fileBase}.mjs`;
62983
+ const fileUrl = `${pathToFileURL(fileBase)}.mjs`;
62984
+ fs$l.writeFileSync(fileNameTmp, bundledCode);
62802
62985
  try {
62803
- return (await dynamicImport(`${fileUrl}.mjs?t=${Date.now()}`)).default;
62986
+ return (await dynamicImport(fileUrl)).default;
62804
62987
  }
62805
62988
  finally {
62806
- fs$l.unlinkSync(fileName + '.mjs');
62989
+ try {
62990
+ fs$l.unlinkSync(fileNameTmp);
62991
+ }
62992
+ catch {
62993
+ // already removed if this function is called twice simultaneously
62994
+ }
62807
62995
  }
62808
62996
  }
62809
62997
  // for cjs, we can register a custom loader via `_require.extensions`