vite 5.0.0-beta.10 → 5.0.0-beta.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { z as commonjsGlobal, y as getDefaultExportFromCjs } from './dep-RTfXXG9P.js';
1
+ import { z as commonjsGlobal, y as getDefaultExportFromCjs } from './dep-poYMMaJ-.js';
2
2
  import require$$0__default from 'fs';
3
3
  import require$$0 from 'postcss';
4
4
  import require$$0$1 from 'path';
@@ -1,4 +1,4 @@
1
- import { y as getDefaultExportFromCjs } from './dep-RTfXXG9P.js';
1
+ import { y as getDefaultExportFromCjs } from './dep-poYMMaJ-.js';
2
2
  import require$$0 from 'path';
3
3
  import require$$0__default from 'fs';
4
4
  import { l as lib } from './dep-8a-6Quh6.js';
@@ -12220,6 +12220,24 @@ function lookupFile(dir, fileNames) {
12220
12220
  dir = parentDir;
12221
12221
  }
12222
12222
  }
12223
+ function isFilePathESM(filePath, packageCache) {
12224
+ if (/\.m[jt]s$/.test(filePath)) {
12225
+ return true;
12226
+ }
12227
+ else if (/\.c[jt]s$/.test(filePath)) {
12228
+ return false;
12229
+ }
12230
+ else {
12231
+ // check package.json for type: "module"
12232
+ try {
12233
+ const pkg = findNearestPackageData(path$o.dirname(filePath), packageCache);
12234
+ return pkg?.data.type === 'module';
12235
+ }
12236
+ catch {
12237
+ return false;
12238
+ }
12239
+ }
12240
+ }
12223
12241
  const splitRE = /\r?\n/;
12224
12242
  const range = 2;
12225
12243
  function pad$1(source, n = 2) {
@@ -12694,6 +12712,15 @@ function emptyCssComments(raw) {
12694
12712
  function removeComments(raw) {
12695
12713
  return raw.replace(multilineCommentsRE$1, '').replace(singlelineCommentsRE$1, '');
12696
12714
  }
12715
+ function backwardCompatibleWorkerPlugins(plugins) {
12716
+ if (Array.isArray(plugins)) {
12717
+ return plugins;
12718
+ }
12719
+ if (typeof plugins === 'function') {
12720
+ return plugins();
12721
+ }
12722
+ return [];
12723
+ }
12697
12724
  function mergeConfigRecursively(defaults, overrides, rootPath) {
12698
12725
  const merged = { ...defaults };
12699
12726
  for (const key in overrides) {
@@ -12721,6 +12748,13 @@ function mergeConfigRecursively(defaults, overrides, rootPath) {
12721
12748
  merged[key] = true;
12722
12749
  continue;
12723
12750
  }
12751
+ else if (key === 'plugins' && rootPath === 'worker') {
12752
+ merged[key] = () => [
12753
+ ...backwardCompatibleWorkerPlugins(existing),
12754
+ ...backwardCompatibleWorkerPlugins(value),
12755
+ ];
12756
+ continue;
12757
+ }
12724
12758
  if (Array.isArray(existing) || Array.isArray(value)) {
12725
12759
  merged[key] = [...arraify(existing ?? []), ...arraify(value ?? [])];
12726
12760
  continue;
@@ -15470,12 +15504,16 @@ const viteBuildPublicIdPrefix = '\0vite:asset:public';
15470
15504
  */
15471
15505
  function assetPlugin(config) {
15472
15506
  registerCustomMime();
15507
+ let moduleGraph;
15473
15508
  return {
15474
15509
  name: 'vite:asset',
15475
15510
  buildStart() {
15476
15511
  assetCache.set(config, new Map());
15477
15512
  generatedAssets.set(config, new Map());
15478
15513
  },
15514
+ configureServer(server) {
15515
+ moduleGraph = server.moduleGraph;
15516
+ },
15479
15517
  resolveId(id) {
15480
15518
  if (!config.assetsInclude(cleanUrl(id)) && !urlRE.test(id)) {
15481
15519
  return;
@@ -15509,8 +15547,15 @@ function assetPlugin(config) {
15509
15547
  return;
15510
15548
  }
15511
15549
  id = id.replace(urlRE, '$1').replace(unnededFinalQueryCharRE, '');
15512
- const url = await fileToUrl$1(id, config, this);
15513
- return `export default ${JSON.stringify(config.command === 'serve' ? `${url}?t=${Date.now()}` : url)}`;
15550
+ let url = await fileToUrl$1(id, config, this);
15551
+ // Inherit HMR timestamp if this asset was invalidated
15552
+ if (moduleGraph) {
15553
+ const mod = moduleGraph.getModuleById(id);
15554
+ if (mod && mod.lastHMRTimestamp > 0) {
15555
+ url = injectQuery(url, `t=${mod.lastHMRTimestamp}`);
15556
+ }
15557
+ }
15558
+ return `export default ${JSON.stringify(url)}`;
15514
15559
  },
15515
15560
  renderChunk(code, chunk, opts) {
15516
15561
  const s = renderAssetUrlInJS(this, config, chunk, opts, code);
@@ -15631,16 +15676,22 @@ async function fileToBuiltUrl(id, config, pluginContext, skipPublicCheck = false
15631
15676
  const content = await fsp.readFile(file);
15632
15677
  let url;
15633
15678
  if (config.build.lib ||
15634
- (!file.endsWith('.svg') &&
15679
+ // Don't inline SVG with fragments, as they are meant to be reused
15680
+ (!(file.endsWith('.svg') && id.includes('#')) &&
15635
15681
  !file.endsWith('.html') &&
15636
15682
  content.length < Number(config.build.assetsInlineLimit) &&
15637
15683
  !isGitLfsPlaceholder(content))) {
15638
15684
  if (config.build.lib && isGitLfsPlaceholder(content)) {
15639
15685
  config.logger.warn(colors$1.yellow(`Inlined file ${id} was not downloaded via Git LFS`));
15640
15686
  }
15641
- const mimeType = lookup(file) ?? 'application/octet-stream';
15642
- // base64 inlined as a string
15643
- url = `data:${mimeType};base64,${content.toString('base64')}`;
15687
+ if (file.endsWith('.svg')) {
15688
+ url = svgToDataURL(content);
15689
+ }
15690
+ else {
15691
+ const mimeType = lookup(file) ?? 'application/octet-stream';
15692
+ // base64 inlined as a string
15693
+ url = `data:${mimeType};base64,${content.toString('base64')}`;
15694
+ }
15644
15695
  }
15645
15696
  else {
15646
15697
  // emit as asset
@@ -15670,6 +15721,29 @@ async function urlToBuiltUrl(url, importer, config, pluginContext) {
15670
15721
  // skip public check since we just did it above
15671
15722
  true);
15672
15723
  }
15724
+ // Inspired by https://github.com/iconify/iconify/blob/main/packages/utils/src/svg/url.ts
15725
+ function svgToDataURL(content) {
15726
+ const stringContent = content.toString();
15727
+ // If the SVG contains some text, any transformation is unsafe, and given that double quotes would then
15728
+ // need to be escaped, the gain to use a data URI would be ridiculous if not negative
15729
+ if (stringContent.includes('<text')) {
15730
+ return `data:image/svg+xml;base64,${content.toString('base64')}`;
15731
+ }
15732
+ else {
15733
+ return ('data:image/svg+xml,' +
15734
+ stringContent
15735
+ .trim()
15736
+ .replaceAll('"', "'")
15737
+ .replaceAll('%', '%25')
15738
+ .replaceAll('#', '%23')
15739
+ .replaceAll('<', '%3c')
15740
+ .replaceAll('>', '%3e')
15741
+ // Spaces are not valid in srcset it has some use cases
15742
+ // it can make the uncompressed URI slightly higher than base64, but will compress way better
15743
+ // https://github.com/vitejs/vite/pull/14643#issuecomment-1766288673
15744
+ .replaceAll(/\s+/g, '%20'));
15745
+ }
15746
+ }
15673
15747
 
15674
15748
  function manifestPlugin(config) {
15675
15749
  const manifest = {};
@@ -27352,6 +27426,7 @@ function hasESMSyntax(code) {
27352
27426
 
27353
27427
  const normalizedClientEntry$1 = normalizePath$3(CLIENT_ENTRY);
27354
27428
  const normalizedEnvEntry$1 = normalizePath$3(ENV_ENTRY);
27429
+ const ERR_RESOLVE_PACKAGE_ENTRY_FAIL = 'ERR_RESOLVE_PACKAGE_ENTRY_FAIL';
27355
27430
  // special id for paths marked with browser: false
27356
27431
  // https://github.com/defunctzombie/package-browser-field-spec#ignore-a-module
27357
27432
  const browserExternalId = '__vite-browser-external';
@@ -27704,7 +27779,8 @@ function tryCleanFsResolve(file, options, tryIndex = true, targetWeb = true, ski
27704
27779
  }
27705
27780
  }
27706
27781
  catch (e) {
27707
- if (e.code !== 'ENOENT')
27782
+ // This check is best effort, so if an entry is not found, skip error for now
27783
+ if (e.code !== ERR_RESOLVE_PACKAGE_ENTRY_FAIL && e.code !== 'ENOENT')
27708
27784
  throw e;
27709
27785
  }
27710
27786
  }
@@ -27829,7 +27905,6 @@ function tryNodeResolve(id, importer, options, targetWeb, depsOptimizer, ssr = f
27829
27905
  moduleSideEffects: pkg.hasSideEffects(resolved),
27830
27906
  });
27831
27907
  }
27832
- const ext = path$o.extname(resolved);
27833
27908
  if (!options.ssrOptimizeCheck &&
27834
27909
  (!isInNodeModules$1(resolved) || // linked
27835
27910
  !depsOptimizer || // resolving before listening to the server
@@ -27860,10 +27935,7 @@ function tryNodeResolve(id, importer, options, targetWeb, depsOptimizer, ssr = f
27860
27935
  (!options.ssrOptimizeCheck && !isBuild && ssr) ||
27861
27936
  // Only optimize non-external CJS deps during SSR by default
27862
27937
  (ssr &&
27863
- !(ext === '.cjs' ||
27864
- (ext === '.js' &&
27865
- findNearestPackageData(path$o.dirname(resolved), options.packageCache)
27866
- ?.data.type !== 'module')) &&
27938
+ isFilePathESM(resolved, options.packageCache) &&
27867
27939
  !(include?.includes(pkgId) || include?.includes(id)));
27868
27940
  if (options.ssrOptimizeCheck) {
27869
27941
  return {
@@ -27956,14 +28028,8 @@ function resolvePackageEntry(id, { dir, data, setResolvedCache, getResolvedCache
27956
28028
  if (data.exports) {
27957
28029
  entryPoint = resolveExportsOrImports(data, '.', options, targetWeb, 'exports');
27958
28030
  }
27959
- const resolvedFromExports = !!entryPoint;
27960
- // if exports resolved to .mjs, still resolve other fields.
27961
- // This is because .mjs files can technically import .cjs files which would
27962
- // make them invalid for pure ESM environments - so if other module/browser
27963
- // fields are present, prioritize those instead.
27964
- if (targetWeb &&
27965
- options.browserField &&
27966
- (!entryPoint || entryPoint.endsWith('.mjs'))) {
28031
+ // handle edge case with browser and module field semantics
28032
+ if (!entryPoint && targetWeb && options.browserField) {
27967
28033
  // check browser field
27968
28034
  // https://github.com/defunctzombie/package-browser-field-spec
27969
28035
  const browserEntry = typeof data.browser === 'string'
@@ -28000,8 +28066,7 @@ function resolvePackageEntry(id, { dir, data, setResolvedCache, getResolvedCache
28000
28066
  }
28001
28067
  }
28002
28068
  // fallback to mainFields if still not resolved
28003
- // TODO: review if `.mjs` check is still needed
28004
- if (!resolvedFromExports && (!entryPoint || entryPoint.endsWith('.mjs'))) {
28069
+ if (!entryPoint) {
28005
28070
  for (const field of options.mainFields) {
28006
28071
  if (field === 'browser')
28007
28072
  continue; // already checked above
@@ -28047,9 +28112,11 @@ function resolvePackageEntry(id, { dir, data, setResolvedCache, getResolvedCache
28047
28112
  packageEntryFailure(id);
28048
28113
  }
28049
28114
  function packageEntryFailure(id, details) {
28050
- throw new Error(`Failed to resolve entry for package "${id}". ` +
28115
+ const err = new Error(`Failed to resolve entry for package "${id}". ` +
28051
28116
  `The package may have incorrect main/module/exports specified in its package.json` +
28052
28117
  (details ? ': ' + details : '.'));
28118
+ err.code = ERR_RESOLVE_PACKAGE_ENTRY_FAIL;
28119
+ throw err;
28053
28120
  }
28054
28121
  function resolveExportsOrImports(pkg, key, options, targetWeb, type) {
28055
28122
  const additionalConditions = new Set(options.overrideConditions || [
@@ -35895,10 +35962,12 @@ const addTypeScriptLoader = (options = {}, loader) => {
35895
35962
  `.${moduleName}rc.yaml`,
35896
35963
  `.${moduleName}rc.yml`,
35897
35964
  `.${moduleName}rc.ts`,
35965
+ `.${moduleName}rc.cts`,
35898
35966
  `.${moduleName}rc.js`,
35899
35967
  `.${moduleName}rc.cjs`,
35900
35968
  `.${moduleName}rc.mjs`,
35901
35969
  `${moduleName}.config.ts`,
35970
+ `${moduleName}.config.cts`,
35902
35971
  `${moduleName}.config.js`,
35903
35972
  `${moduleName}.config.cjs`,
35904
35973
  `${moduleName}.config.mjs`
@@ -35910,7 +35979,8 @@ const addTypeScriptLoader = (options = {}, loader) => {
35910
35979
  '.js': importDefault,
35911
35980
  '.cjs': importDefault,
35912
35981
  '.mjs': importDefault,
35913
- '.ts': loader
35982
+ '.ts': loader,
35983
+ '.cts': loader
35914
35984
  }
35915
35985
  }
35916
35986
  };
@@ -35922,7 +35992,9 @@ const withTypeScriptLoader = (rcFunc) => {
35922
35992
 
35923
35993
  try {
35924
35994
  // Register TypeScript compiler instance
35925
- registerer = __require('ts-node').register();
35995
+ registerer = __require('ts-node').register({
35996
+ moduleTypes: { '**/*.cts': 'cjs' }
35997
+ });
35926
35998
 
35927
35999
  return __require(configFile)
35928
36000
  } catch (err) {
@@ -37164,6 +37236,7 @@ function buildHtmlPlugin(config) {
37164
37236
  tag: 'link',
37165
37237
  attrs: {
37166
37238
  rel: 'stylesheet',
37239
+ crossorigin: true,
37167
37240
  href: toOutputPath(file),
37168
37241
  },
37169
37242
  });
@@ -37234,6 +37307,7 @@ function buildHtmlPlugin(config) {
37234
37307
  tag: 'link',
37235
37308
  attrs: {
37236
37309
  rel: 'stylesheet',
37310
+ crossorigin: true,
37237
37311
  href: toOutputAssetFilePath(cssChunk.fileName),
37238
37312
  },
37239
37313
  },
@@ -37261,7 +37335,11 @@ function buildHtmlPlugin(config) {
37261
37335
  });
37262
37336
  // resolve asset url references
37263
37337
  result = result.replace(assetUrlRE, (_, fileHash, postfix = '') => {
37264
- return toOutputAssetFilePath(this.getFileName(fileHash)) + postfix;
37338
+ const file = this.getFileName(fileHash);
37339
+ if (chunk) {
37340
+ chunk.viteMetadata.importedAssets.add(cleanUrl(file));
37341
+ }
37342
+ return toOutputAssetFilePath(file) + postfix;
37265
37343
  });
37266
37344
  result = result.replace(publicAssetUrlRE, (_, fileHash) => {
37267
37345
  const publicAssetPath = toOutputPublicAssetFilePath(getPublicAssetFilename(fileHash, config));
@@ -37605,6 +37683,7 @@ const inlineRE = /[?&]inline\b/;
37605
37683
  const inlineCSSRE = /[?&]inline-css\b/;
37606
37684
  const styleAttrRE = /[?&]style-attr\b/;
37607
37685
  const varRE = /^var\(/i;
37686
+ const nonEscapedDoubleQuoteRe = /(?<!\\)(")/g;
37608
37687
  const cssBundleName = 'style.css';
37609
37688
  const isCSSRequest = (request) => CSS_LANGS_RE.test(request);
37610
37689
  const isModuleCSSRequest = (request) => cssModuleRE.test(request);
@@ -38386,8 +38465,8 @@ function createCachedImport(imp) {
38386
38465
  return cached;
38387
38466
  };
38388
38467
  }
38389
- const importPostcssImport = createCachedImport(() => import('./dep-s3v9f2KI.js').then(function (n) { return n.i; }));
38390
- const importPostcssModules = createCachedImport(() => import('./dep-pNoMh5ox.js').then(function (n) { return n.i; }));
38468
+ const importPostcssImport = createCachedImport(() => import('./dep-cjQQUT93.js').then(function (n) { return n.i; }));
38469
+ const importPostcssModules = createCachedImport(() => import('./dep-BF1HzV2j.js').then(function (n) { return n.i; }));
38391
38470
  const importPostcss = createCachedImport(() => import('postcss'));
38392
38471
  /**
38393
38472
  * @experimental
@@ -38572,10 +38651,19 @@ async function doUrlReplace(rawUrl, matched, replacer, funcName = 'url') {
38572
38651
  if (skipUrlReplacer(rawUrl)) {
38573
38652
  return matched;
38574
38653
  }
38575
- const newUrl = await replacer(rawUrl);
38654
+ let newUrl = await replacer(rawUrl);
38655
+ // The new url might need wrapping even if the original did not have it, e.g. if a space was added during replacement
38576
38656
  if (wrap === '' && newUrl !== encodeURI(newUrl)) {
38577
- // The new url might need wrapping even if the original did not have it, e.g. if a space was added during replacement
38578
- wrap = "'";
38657
+ wrap = '"';
38658
+ }
38659
+ // If wrapping in single quotes and newUrl also contains single quotes, switch to double quotes.
38660
+ // Give preference to double quotes since SVG inlining converts double quotes to single quotes.
38661
+ if (wrap === "'" && newUrl.includes("'")) {
38662
+ wrap = '"';
38663
+ }
38664
+ // Escape double quotes if they exist (they also tend to be rarer than single quotes)
38665
+ if (wrap === '"' && newUrl.includes('"')) {
38666
+ newUrl = newUrl.replace(nonEscapedDoubleQuoteRe, '\\"');
38579
38667
  }
38580
38668
  return `${funcName}(${wrap}${newUrl}${wrap})`;
38581
38669
  }
@@ -40571,8 +40659,15 @@ function updateModules(file, modules, timestamp, { config, ws, moduleGraph }, af
40571
40659
  updates,
40572
40660
  });
40573
40661
  }
40574
- async function handleFileAddUnlink(file, server) {
40662
+ async function handleFileAddUnlink(file, server, isUnlink) {
40575
40663
  const modules = [...(server.moduleGraph.getModulesByFile(file) || [])];
40664
+ if (isUnlink) {
40665
+ for (const deletedMod of modules) {
40666
+ deletedMod.importedModules.forEach((importedMod) => {
40667
+ importedMod.importers.delete(deletedMod);
40668
+ });
40669
+ }
40670
+ }
40576
40671
  modules.push(...getAffectedGlobModules(file, server));
40577
40672
  if (modules.length > 0) {
40578
40673
  updateModules(getShortName(file, server.config.root), unique(modules), Date.now(), server);
@@ -41676,29 +41771,14 @@ function saveEmitWorkerAsset(config, asset) {
41676
41771
  const workerMap = workerCache.get(config.mainConfig || config);
41677
41772
  workerMap.assets.set(fileName, asset);
41678
41773
  }
41679
- // Ensure that only one rollup build is called at the same time to avoid
41680
- // leaking state in plugins between worker builds.
41681
- // TODO: Review if we can parallelize the bundling of workers.
41682
- const workerConfigSemaphore = new WeakMap();
41683
41774
  async function bundleWorkerEntry(config, id, query) {
41684
- const processing = workerConfigSemaphore.get(config);
41685
- if (processing) {
41686
- await processing;
41687
- return bundleWorkerEntry(config, id, query);
41688
- }
41689
- const promise = serialBundleWorkerEntry(config, id, query);
41690
- workerConfigSemaphore.set(config, promise);
41691
- promise.then(() => workerConfigSemaphore.delete(config));
41692
- return promise;
41693
- }
41694
- async function serialBundleWorkerEntry(config, id, query) {
41695
41775
  // bundle the file as entry to support imports
41696
41776
  const { rollup } = await import('rollup');
41697
41777
  const { plugins, rollupOptions, format } = config.worker;
41698
41778
  const bundle = await rollup({
41699
41779
  ...rollupOptions,
41700
41780
  input: cleanUrl(id),
41701
- plugins,
41781
+ plugins: await plugins(),
41702
41782
  onwarn(warning, warn) {
41703
41783
  onRollupWarning(warning, warn, config);
41704
41784
  },
@@ -54161,8 +54241,6 @@ async function resolveHttpServer({ proxy }, app, httpsOptions) {
54161
54241
  async function resolveHttpsConfig(https) {
54162
54242
  if (!https)
54163
54243
  return undefined;
54164
- if (!isObject$1(https))
54165
- return {};
54166
54244
  const [ca, cert, key, pfx] = await Promise.all([
54167
54245
  readFileIfExists(https.ca),
54168
54246
  readFileIfExists(https.cert),
@@ -54790,12 +54868,19 @@ async function ssrTransformScript(code, inMap, url, originalCode) {
54790
54868
  const declaredConst = new Set();
54791
54869
  // hoist at the start of the file, after the hashbang
54792
54870
  const hoistIndex = code.match(hashbangRE)?.[0].length ?? 0;
54793
- function defineImport(source) {
54871
+ function defineImport(source, metadata) {
54794
54872
  deps.add(source);
54795
54873
  const importId = `__vite_ssr_import_${uid++}__`;
54874
+ // Reduce metadata to undefined if it's all default values
54875
+ if (metadata &&
54876
+ (metadata.namedImportSpecifiers == null ||
54877
+ metadata.namedImportSpecifiers.length === 0)) {
54878
+ metadata = undefined;
54879
+ }
54880
+ const metadataStr = metadata ? `, ${JSON.stringify(metadata)}` : '';
54796
54881
  // There will be an error if the module is called before it is imported,
54797
54882
  // so the module import statement is hoisted to the top
54798
- s.appendLeft(hoistIndex, `const ${importId} = await ${ssrImportKey}(${JSON.stringify(source)});\n`);
54883
+ s.appendLeft(hoistIndex, `const ${importId} = await ${ssrImportKey}(${JSON.stringify(source)}${metadataStr});\n`);
54799
54884
  return importId;
54800
54885
  }
54801
54886
  function defineExport(position, name, local = name) {
@@ -54808,7 +54893,11 @@ async function ssrTransformScript(code, inMap, url, originalCode) {
54808
54893
  // import { baz } from 'foo' --> baz -> __import_foo__.baz
54809
54894
  // import * as ok from 'foo' --> ok -> __import_foo__
54810
54895
  if (node.type === 'ImportDeclaration') {
54811
- const importId = defineImport(node.source.value);
54896
+ const importId = defineImport(node.source.value, {
54897
+ namedImportSpecifiers: node.specifiers
54898
+ .map((s) => s.type === 'ImportSpecifier' && s.imported.name)
54899
+ .filter(Boolean),
54900
+ });
54812
54901
  s.remove(node.start, node.end);
54813
54902
  for (const spec of node.specifiers) {
54814
54903
  if (spec.type === 'ImportSpecifier') {
@@ -54849,7 +54938,9 @@ async function ssrTransformScript(code, inMap, url, originalCode) {
54849
54938
  s.remove(node.start, node.end);
54850
54939
  if (node.source) {
54851
54940
  // export { foo, bar } from './foo'
54852
- const importId = defineImport(node.source.value);
54941
+ const importId = defineImport(node.source.value, {
54942
+ namedImportSpecifiers: node.specifiers.map((s) => s.local.name),
54943
+ });
54853
54944
  // hoist re-exports near the defined import so they are immediately exported
54854
54945
  for (const spec of node.specifiers) {
54855
54946
  defineExport(hoistIndex, spec.exported.name, `${importId}.${spec.local.name}`);
@@ -55348,14 +55439,16 @@ async function instantiateModule(url, server, context = { global }, urlStack = [
55348
55439
  isProduction,
55349
55440
  root,
55350
55441
  ssrConfig: ssr,
55442
+ legacyProxySsrExternalModules: server.config.legacy?.proxySsrExternalModules,
55443
+ packageCache: server.config.packageCache,
55351
55444
  };
55352
55445
  // Since dynamic imports can happen in parallel, we need to
55353
55446
  // account for multiple pending deps and duplicate imports.
55354
55447
  const pendingDeps = [];
55355
- const ssrImport = async (dep) => {
55448
+ const ssrImport = async (dep, metadata) => {
55356
55449
  try {
55357
55450
  if (dep[0] !== '.' && dep[0] !== '/') {
55358
- return await nodeImport(dep, mod.file, resolveOptions);
55451
+ return await nodeImport(dep, mod.file, resolveOptions, metadata);
55359
55452
  }
55360
55453
  // convert to rollup URL because `pendingImports`, `moduleGraph.urlToModuleMap` requires that
55361
55454
  dep = unwrapId(dep);
@@ -55388,7 +55481,7 @@ async function instantiateModule(url, server, context = { global }, urlStack = [
55388
55481
  if (dep[0] === '.') {
55389
55482
  dep = path$o.posix.resolve(path$o.dirname(url), dep);
55390
55483
  }
55391
- return ssrImport(dep);
55484
+ return ssrImport(dep, { isDynamicImport: true });
55392
55485
  };
55393
55486
  function ssrExportAll(sourceModule) {
55394
55487
  for (const key in sourceModule) {
@@ -55439,9 +55532,10 @@ async function instantiateModule(url, server, context = { global }, urlStack = [
55439
55532
  return Object.freeze(ssrModule);
55440
55533
  }
55441
55534
  // In node@12+ we can use dynamic import to load CJS and ESM
55442
- async function nodeImport(id, importer, resolveOptions) {
55535
+ async function nodeImport(id, importer, resolveOptions, metadata) {
55443
55536
  let url;
55444
- if (id.startsWith('data:') || isBuiltin(id)) {
55537
+ const isRuntimeHandled = id.startsWith('data:') || isBuiltin(id);
55538
+ if (isRuntimeHandled) {
55445
55539
  url = id;
55446
55540
  }
55447
55541
  else {
@@ -55454,7 +55548,16 @@ async function nodeImport(id, importer, resolveOptions) {
55454
55548
  url = pathToFileURL(resolved.id).toString();
55455
55549
  }
55456
55550
  const mod = await import(url);
55457
- return proxyESM(mod);
55551
+ if (resolveOptions.legacyProxySsrExternalModules) {
55552
+ return proxyESM(mod);
55553
+ }
55554
+ else if (isRuntimeHandled) {
55555
+ return mod;
55556
+ }
55557
+ else {
55558
+ analyzeImportedModDifference(mod, url, id, metadata, resolveOptions.packageCache);
55559
+ return proxyGuardOnlyEsm(mod, id);
55560
+ }
55458
55561
  }
55459
55562
  // rollup-style default import interop for cjs
55460
55563
  function proxyESM(mod) {
@@ -55479,6 +55582,49 @@ function proxyESM(mod) {
55479
55582
  function isPrimitive(value) {
55480
55583
  return !value || (typeof value !== 'object' && typeof value !== 'function');
55481
55584
  }
55585
+ /**
55586
+ * Vite converts `import { } from 'foo'` to `const _ = __vite_ssr_import__('foo')`.
55587
+ * Top-level imports and dynamic imports work slightly differently in Node.js.
55588
+ * This function normalizes the differences so it matches prod behaviour.
55589
+ */
55590
+ function analyzeImportedModDifference(mod, filePath, rawId, metadata, packageCache) {
55591
+ // No normalization needed if the user already dynamic imports this module
55592
+ if (metadata?.isDynamicImport)
55593
+ return;
55594
+ // If file path is ESM, everything should be fine
55595
+ if (isFilePathESM(filePath, packageCache))
55596
+ return;
55597
+ // For non-ESM, named imports is done via static analysis with cjs-module-lexer in Node.js.
55598
+ // If the user named imports a specifier that can't be analyzed, error.
55599
+ if (metadata?.namedImportSpecifiers?.length) {
55600
+ const missingBindings = metadata.namedImportSpecifiers.filter((s) => !(s in mod));
55601
+ if (missingBindings.length) {
55602
+ const lastBinding = missingBindings[missingBindings.length - 1];
55603
+ // Copied from Node.js
55604
+ throw new SyntaxError(`\
55605
+ Named export '${lastBinding}' not found. The requested module '${rawId}' is a CommonJS module, which may not support all module.exports as named exports.
55606
+ CommonJS modules can always be imported via the default export, for example using:
55607
+
55608
+ import pkg from '${rawId}';
55609
+ const {${missingBindings.join(', ')}} = pkg;
55610
+ `);
55611
+ }
55612
+ }
55613
+ }
55614
+ /**
55615
+ * Guard invalid named exports only, similar to how Node.js errors for top-level imports.
55616
+ * But since we transform as dynamic imports, we need to emulate the error manually.
55617
+ */
55618
+ function proxyGuardOnlyEsm(mod, rawId) {
55619
+ return new Proxy(mod, {
55620
+ get(mod, prop) {
55621
+ if (prop !== 'then' && !(prop in mod)) {
55622
+ throw new SyntaxError(`The requested module '${rawId}' does not provide an export named '${prop.toString()}'`);
55623
+ }
55624
+ return mod[prop];
55625
+ },
55626
+ });
55627
+ }
55482
55628
 
55483
55629
  var isWsl$2 = {exports: {}};
55484
55630
 
@@ -64770,9 +64916,9 @@ async function _createServer(inlineConfig = {}, options) {
64770
64916
  }
64771
64917
  }
64772
64918
  };
64773
- const onFileAddUnlink = async (file) => {
64919
+ const onFileAddUnlink = async (file, isUnlink) => {
64774
64920
  file = normalizePath$3(file);
64775
- await handleFileAddUnlink(file, server);
64921
+ await handleFileAddUnlink(file, server, isUnlink);
64776
64922
  await onHMRUpdate(file, true);
64777
64923
  };
64778
64924
  watcher.on('change', async (file) => {
@@ -64781,8 +64927,8 @@ async function _createServer(inlineConfig = {}, options) {
64781
64927
  moduleGraph.onFileChange(file);
64782
64928
  await onHMRUpdate(file, false);
64783
64929
  });
64784
- watcher.on('add', onFileAddUnlink);
64785
- watcher.on('unlink', onFileAddUnlink);
64930
+ watcher.on('add', (file) => onFileAddUnlink(file, false));
64931
+ watcher.on('unlink', (file) => onFileAddUnlink(file, true));
64786
64932
  ws.on('vite:invalidate', async ({ path, message }) => {
64787
64933
  const mod = moduleGraph.urlToModuleMap.get(path);
64788
64934
  if (mod && mod.isSelfAccepting && mod.lastHMRTimestamp > 0) {
@@ -65336,10 +65482,6 @@ async function resolveConfig(inlineConfig, command, defaultMode = 'development',
65336
65482
  return p.apply === command;
65337
65483
  }
65338
65484
  };
65339
- // Some plugins that aren't intended to work in the bundling of workers (doing post-processing at build time for example).
65340
- // And Plugins may also have cached that could be corrupted by being used in these extra rollup calls.
65341
- // So we need to separate the worker plugin from the plugin that vite needs to run.
65342
- const rawWorkerUserPlugins = (await asyncFlatten(config.worker?.plugins || [])).filter(filterPlugin);
65343
65485
  // resolve plugins
65344
65486
  const rawUserPlugins = (await asyncFlatten(config.plugins || [])).filter(filterPlugin);
65345
65487
  const [prePlugins, normalPlugins, postPlugins] = sortUserPlugins(rawUserPlugins);
@@ -65489,24 +65631,48 @@ async function resolveConfig(inlineConfig, command, defaultMode = 'development',
65489
65631
  const middlewareMode = config?.server?.middlewareMode;
65490
65632
  const optimizeDeps = config.optimizeDeps || {};
65491
65633
  const BASE_URL = resolvedBase;
65492
- // resolve worker
65493
- let workerConfig = mergeConfig({}, config);
65494
- const [workerPrePlugins, workerNormalPlugins, workerPostPlugins] = sortUserPlugins(rawWorkerUserPlugins);
65495
- // run config hooks
65496
- const workerUserPlugins = [
65497
- ...workerPrePlugins,
65498
- ...workerNormalPlugins,
65499
- ...workerPostPlugins,
65500
- ];
65501
- workerConfig = await runConfigHook(workerConfig, workerUserPlugins, configEnv);
65634
+ let resolved;
65635
+ let createUserWorkerPlugins = config.worker?.plugins;
65636
+ if (Array.isArray(createUserWorkerPlugins)) {
65637
+ // @ts-expect-error backward compatibility
65638
+ createUserWorkerPlugins = () => config.worker?.plugins;
65639
+ logger.warn(colors$1.yellow(`worker.plugins is now a function that returns an array of plugins. ` +
65640
+ `Please update your Vite config accordingly.\n`));
65641
+ }
65642
+ const createWorkerPlugins = async function () {
65643
+ // Some plugins that aren't intended to work in the bundling of workers (doing post-processing at build time for example).
65644
+ // And Plugins may also have cached that could be corrupted by being used in these extra rollup calls.
65645
+ // So we need to separate the worker plugin from the plugin that vite needs to run.
65646
+ const rawWorkerUserPlugins = (await asyncFlatten(createUserWorkerPlugins?.() || [])).filter(filterPlugin);
65647
+ // resolve worker
65648
+ let workerConfig = mergeConfig({}, config);
65649
+ const [workerPrePlugins, workerNormalPlugins, workerPostPlugins] = sortUserPlugins(rawWorkerUserPlugins);
65650
+ // run config hooks
65651
+ const workerUserPlugins = [
65652
+ ...workerPrePlugins,
65653
+ ...workerNormalPlugins,
65654
+ ...workerPostPlugins,
65655
+ ];
65656
+ workerConfig = await runConfigHook(workerConfig, workerUserPlugins, configEnv);
65657
+ const workerResolved = {
65658
+ ...workerConfig,
65659
+ ...resolved,
65660
+ isWorker: true,
65661
+ mainConfig: resolved,
65662
+ };
65663
+ const resolvedWorkerPlugins = await resolvePlugins(workerResolved, workerPrePlugins, workerNormalPlugins, workerPostPlugins);
65664
+ // run configResolved hooks
65665
+ createPluginHookUtils(resolvedWorkerPlugins)
65666
+ .getSortedPluginHooks('configResolved')
65667
+ .map((hook) => hook(workerResolved));
65668
+ return resolvedWorkerPlugins;
65669
+ };
65502
65670
  const resolvedWorkerOptions = {
65503
- format: workerConfig.worker?.format || 'iife',
65504
- plugins: [],
65505
- rollupOptions: workerConfig.worker?.rollupOptions || {},
65506
- getSortedPlugins: undefined,
65507
- getSortedPluginHooks: undefined,
65671
+ format: config.worker?.format || 'iife',
65672
+ plugins: createWorkerPlugins,
65673
+ rollupOptions: config.worker?.rollupOptions || {},
65508
65674
  };
65509
- const resolvedConfig = {
65675
+ resolved = {
65510
65676
  configFile: configFile ? normalizePath$3(configFile) : undefined,
65511
65677
  configFileDependencies: configFileDependencies.map((name) => normalizePath$3(path$o.resolve(name))),
65512
65678
  inlineConfig,
@@ -65565,29 +65731,16 @@ async function resolveConfig(inlineConfig, command, defaultMode = 'development',
65565
65731
  getSortedPlugins: undefined,
65566
65732
  getSortedPluginHooks: undefined,
65567
65733
  };
65568
- const resolved = {
65734
+ resolved = {
65569
65735
  ...config,
65570
- ...resolvedConfig,
65736
+ ...resolved,
65571
65737
  };
65572
65738
  resolved.plugins = await resolvePlugins(resolved, prePlugins, normalPlugins, postPlugins);
65573
65739
  Object.assign(resolved, createPluginHookUtils(resolved.plugins));
65574
- const workerResolved = {
65575
- ...workerConfig,
65576
- ...resolvedConfig,
65577
- isWorker: true,
65578
- mainConfig: resolved,
65579
- };
65580
- resolvedConfig.worker.plugins = await resolvePlugins(workerResolved, workerPrePlugins, workerNormalPlugins, workerPostPlugins);
65581
- Object.assign(resolvedConfig.worker, createPluginHookUtils(resolvedConfig.worker.plugins));
65582
65740
  // call configResolved hooks
65583
- await Promise.all([
65584
- ...resolved
65585
- .getSortedPluginHooks('configResolved')
65586
- .map((hook) => hook(resolved)),
65587
- ...resolvedConfig.worker
65588
- .getSortedPluginHooks('configResolved')
65589
- .map((hook) => hook(workerResolved)),
65590
- ]);
65741
+ await Promise.all(resolved
65742
+ .getSortedPluginHooks('configResolved')
65743
+ .map((hook) => hook(resolved)));
65591
65744
  // validate config
65592
65745
  if (middlewareMode === 'ssr') {
65593
65746
  logger.warn(colors$1.yellow(`Setting server.middlewareMode to 'ssr' is deprecated, set server.middlewareMode to \`true\`${config.appType === 'custom' ? '' : ` and appType to 'custom'`} instead`));
@@ -65600,7 +65753,7 @@ async function resolveConfig(inlineConfig, command, defaultMode = 'development',
65600
65753
  plugins: resolved.plugins.map((p) => p.name),
65601
65754
  worker: {
65602
65755
  ...resolved.worker,
65603
- plugins: resolved.worker.plugins.map((p) => p.name),
65756
+ plugins: `() => plugins`,
65604
65757
  },
65605
65758
  });
65606
65759
  if (config.build?.terserOptions && config.build.minify !== 'terser') {
@@ -65702,22 +65855,7 @@ async function loadConfigFromFile(configEnv, configFile, configRoot = process.cw
65702
65855
  debug?.('no config file found.');
65703
65856
  return null;
65704
65857
  }
65705
- let isESM = false;
65706
- if (/\.m[jt]s$/.test(resolvedPath)) {
65707
- isESM = true;
65708
- }
65709
- else if (/\.c[jt]s$/.test(resolvedPath)) {
65710
- isESM = false;
65711
- }
65712
- else {
65713
- // check package.json for type: "module" and set `isESM` to true
65714
- try {
65715
- const pkg = lookupFile(configRoot, ['package.json']);
65716
- isESM =
65717
- !!pkg && JSON.parse(fs$l.readFileSync(pkg, 'utf-8')).type === 'module';
65718
- }
65719
- catch (e) { }
65720
- }
65858
+ const isESM = isFilePathESM(resolvedPath);
65721
65859
  try {
65722
65860
  const bundled = await bundleConfigFile(resolvedPath, isESM);
65723
65861
  const userConfig = await loadConfigFromBundledFile(resolvedPath, bundled.code, isESM);
@@ -65782,14 +65920,6 @@ async function bundleConfigFile(fileName, isESM) {
65782
65920
  isRequire,
65783
65921
  }, false)?.id;
65784
65922
  };
65785
- const isESMFile = (id) => {
65786
- if (id.endsWith('.mjs'))
65787
- return true;
65788
- if (id.endsWith('.cjs'))
65789
- return false;
65790
- const nearestPackageJson = findNearestPackageData(path$o.dirname(id), packageCache);
65791
- return (!!nearestPackageJson && nearestPackageJson.data.type === 'module');
65792
- };
65793
65923
  // externalize bare imports
65794
65924
  build.onResolve({ filter: /^[^.].*/ }, async ({ path: id, importer, kind }) => {
65795
65925
  if (kind === 'entry-point' ||
@@ -65824,7 +65954,9 @@ async function bundleConfigFile(fileName, isESM) {
65824
65954
  if (idFsPath && isImport) {
65825
65955
  idFsPath = pathToFileURL(idFsPath).href;
65826
65956
  }
65827
- if (idFsPath && !isImport && isESMFile(idFsPath)) {
65957
+ if (idFsPath &&
65958
+ !isImport &&
65959
+ isFilePathESM(idFsPath, packageCache)) {
65828
65960
  throw new Error(`${JSON.stringify(id)} resolved to an ESM file. ESM file cannot be loaded by \`require\`. See http://vitejs.dev/guide/troubleshooting.html#this-package-is-esm-only for more details.`);
65829
65961
  }
65830
65962
  return {
package/dist/node/cli.js CHANGED
@@ -2,7 +2,7 @@ import path from 'node:path';
2
2
  import fs from 'node:fs';
3
3
  import { performance } from 'node:perf_hooks';
4
4
  import { EventEmitter } from 'events';
5
- import { x as colors, k as createLogger, r as resolveConfig } from './chunks/dep-RTfXXG9P.js';
5
+ import { x as colors, k as createLogger, r as resolveConfig } from './chunks/dep-poYMMaJ-.js';
6
6
  import { VERSION } from './constants.js';
7
7
  import 'node:fs/promises';
8
8
  import 'node:url';
@@ -751,7 +751,6 @@ cli
751
751
  .alias('dev') // alias to align with the script name
752
752
  .option('--host [host]', `[string] specify hostname`, { type: [convertHost] })
753
753
  .option('--port <port>', `[number] specify port`)
754
- .option('--https', `[boolean] use TLS + HTTP/2`)
755
754
  .option('--open [path]', `[boolean | string] open browser on startup`)
756
755
  .option('--cors', `[boolean] enable CORS`)
757
756
  .option('--strictPort', `[boolean] exit if specified port is already in use`)
@@ -760,7 +759,7 @@ cli
760
759
  filterDuplicateOptions(options);
761
760
  // output structure is preserved even after bundling so require()
762
761
  // is ok here
763
- const { createServer } = await import('./chunks/dep-RTfXXG9P.js').then(function (n) { return n.C; });
762
+ const { createServer } = await import('./chunks/dep-poYMMaJ-.js').then(function (n) { return n.C; });
764
763
  try {
765
764
  const server = await createServer({
766
765
  root,
@@ -841,7 +840,7 @@ cli
841
840
  .option('-w, --watch', `[boolean] rebuilds when modules have changed on disk`)
842
841
  .action(async (root, options) => {
843
842
  filterDuplicateOptions(options);
844
- const { build } = await import('./chunks/dep-RTfXXG9P.js').then(function (n) { return n.B; });
843
+ const { build } = await import('./chunks/dep-poYMMaJ-.js').then(function (n) { return n.B; });
845
844
  const buildOptions = cleanOptions(options);
846
845
  try {
847
846
  await build({
@@ -869,7 +868,7 @@ cli
869
868
  .option('--force', `[boolean] force the optimizer to ignore the cache and re-bundle`)
870
869
  .action(async (root, options) => {
871
870
  filterDuplicateOptions(options);
872
- const { optimizeDeps } = await import('./chunks/dep-RTfXXG9P.js').then(function (n) { return n.A; });
871
+ const { optimizeDeps } = await import('./chunks/dep-poYMMaJ-.js').then(function (n) { return n.A; });
873
872
  try {
874
873
  const config = await resolveConfig({
875
874
  root,
@@ -891,12 +890,11 @@ cli
891
890
  .option('--host [host]', `[string] specify hostname`, { type: [convertHost] })
892
891
  .option('--port <port>', `[number] specify port`)
893
892
  .option('--strictPort', `[boolean] exit if specified port is already in use`)
894
- .option('--https', `[boolean] use TLS + HTTP/2`)
895
893
  .option('--open [path]', `[boolean | string] open browser on startup`)
896
894
  .option('--outDir <dir>', `[string] output directory (default: dist)`)
897
895
  .action(async (root, options) => {
898
896
  filterDuplicateOptions(options);
899
- const { preview } = await import('./chunks/dep-RTfXXG9P.js').then(function (n) { return n.D; });
897
+ const { preview } = await import('./chunks/dep-poYMMaJ-.js').then(function (n) { return n.D; });
900
898
  try {
901
899
  const server = await preview({
902
900
  root,
@@ -911,7 +909,6 @@ cli
911
909
  port: options.port,
912
910
  strictPort: options.strictPort,
913
911
  host: options.host,
914
- https: options.https,
915
912
  open: options.open,
916
913
  },
917
914
  });
@@ -639,7 +639,7 @@ interface CommonServerOptions {
639
639
  * Enable TLS + HTTP/2.
640
640
  * Note: this downgrades to TLS only when the proxy option is also used.
641
641
  */
642
- https?: boolean | HttpsServerOptions;
642
+ https?: HttpsServerOptions;
643
643
  /**
644
644
  * Open browser window on startup
645
645
  */
@@ -3095,9 +3095,11 @@ interface UserConfig {
3095
3095
  */
3096
3096
  format?: 'es' | 'iife';
3097
3097
  /**
3098
- * Vite plugins that apply to worker bundle
3098
+ * Vite plugins that apply to worker bundle. The plugins retured by this function
3099
+ * should be new instances every time it is called, because they are used for each
3100
+ * rollup worker bundling process.
3099
3101
  */
3100
- plugins?: PluginOption[];
3102
+ plugins?: () => PluginOption[];
3101
3103
  /**
3102
3104
  * Rollup options to build worker bundle
3103
3105
  */
@@ -3142,10 +3144,21 @@ interface ExperimentalOptions {
3142
3144
  skipSsrTransform?: boolean;
3143
3145
  }
3144
3146
  interface LegacyOptions {
3147
+ /**
3148
+ * In Vite 4, SSR-externalized modules (modules not bundled and loaded by Node.js at runtime)
3149
+ * are implicitly proxied in dev to automatically handle `default` and `__esModule` access.
3150
+ * However, this does not correctly reflect how it works in the Node.js runtime, causing
3151
+ * inconsistencies between dev and prod.
3152
+ *
3153
+ * In Vite 5, the proxy is removed so dev and prod are consistent, but if you still require
3154
+ * the old behaviour, you can enable this option. If so, please leave your feedback at
3155
+ * https:
3156
+ */
3157
+ proxySsrExternalModules?: boolean;
3145
3158
  }
3146
- interface ResolvedWorkerOptions extends PluginHookUtils {
3159
+ interface ResolvedWorkerOptions {
3147
3160
  format: 'es' | 'iife';
3148
- plugins: Plugin[];
3161
+ plugins: () => Promise<Plugin[]>;
3149
3162
  rollupOptions: RollupOptions;
3150
3163
  }
3151
3164
  interface InlineConfig extends UserConfig {
@@ -1,5 +1,5 @@
1
- import { i as isInNodeModules } from './chunks/dep-RTfXXG9P.js';
2
- export { b as build, e as buildErrorMessage, h as createFilter, k as createLogger, c as createServer, d as defineConfig, f as formatPostcssSourceMap, u as isFileServingAllowed, l as loadConfigFromFile, v as loadEnv, g as mergeAlias, m as mergeConfig, n as normalizePath, o as optimizeDeps, a as preprocessCSS, p as preview, r as resolveConfig, w as resolveEnvPrefix, q as searchForWorkspaceRoot, j as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-RTfXXG9P.js';
1
+ import { i as isInNodeModules } from './chunks/dep-poYMMaJ-.js';
2
+ export { b as build, e as buildErrorMessage, h as createFilter, k as createLogger, c as createServer, d as defineConfig, f as formatPostcssSourceMap, u as isFileServingAllowed, l as loadConfigFromFile, v as loadEnv, g as mergeAlias, m as mergeConfig, n as normalizePath, o as optimizeDeps, a as preprocessCSS, p as preview, r as resolveConfig, w as resolveEnvPrefix, q as searchForWorkspaceRoot, j as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-poYMMaJ-.js';
3
3
  export { VERSION as version } from './constants.js';
4
4
  export { version as esbuildVersion } from 'esbuild';
5
5
  export { VERSION as rollupVersion } from 'rollup';
@@ -3488,6 +3488,15 @@ function arraify(target) {
3488
3488
  return Array.isArray(target) ? target : [target];
3489
3489
  }
3490
3490
  path$3.dirname(node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('node-cjs/publicUtils.cjs', document.baseURI).href))));
3491
+ function backwardCompatibleWorkerPlugins(plugins) {
3492
+ if (Array.isArray(plugins)) {
3493
+ return plugins;
3494
+ }
3495
+ if (typeof plugins === 'function') {
3496
+ return plugins();
3497
+ }
3498
+ return [];
3499
+ }
3491
3500
  function mergeConfigRecursively(defaults, overrides, rootPath) {
3492
3501
  const merged = { ...defaults };
3493
3502
  for (const key in overrides) {
@@ -3515,6 +3524,13 @@ function mergeConfigRecursively(defaults, overrides, rootPath) {
3515
3524
  merged[key] = true;
3516
3525
  continue;
3517
3526
  }
3527
+ else if (key === 'plugins' && rootPath === 'worker') {
3528
+ merged[key] = () => [
3529
+ ...backwardCompatibleWorkerPlugins(existing),
3530
+ ...backwardCompatibleWorkerPlugins(value),
3531
+ ];
3532
+ continue;
3533
+ }
3518
3534
  if (Array.isArray(existing) || Array.isArray(value)) {
3519
3535
  merged[key] = [...arraify(existing ?? []), ...arraify(value ?? [])];
3520
3536
  continue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite",
3
- "version": "5.0.0-beta.10",
3
+ "version": "5.0.0-beta.12",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Evan You",