vite 3.0.0-alpha.6 → 3.0.0-alpha.9

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.
@@ -11567,7 +11567,7 @@ function writeFile(filename, content) {
11567
11567
  fs__default.writeFileSync(filename, content);
11568
11568
  }
11569
11569
  /**
11570
- * Use instead of fs.existsSync(filename)
11570
+ * Use fs.statSync(filename) instead of fs.existsSync(filename)
11571
11571
  * #2051 if we don't have read permission on a directory, existsSync() still
11572
11572
  * works and will result in massively slow subsequent checks (which are
11573
11573
  * unnecessary in the first place)
@@ -11939,6 +11939,14 @@ function normalizeSingleAlias({ find, replacement, customResolver }) {
11939
11939
  }
11940
11940
  return alias;
11941
11941
  }
11942
+ function transformResult(s, id, config) {
11943
+ const isBuild = config.command === 'build';
11944
+ const needSourceMap = !isBuild || config.build.sourcemap;
11945
+ return {
11946
+ code: s.toString(),
11947
+ map: needSourceMap ? s.generateMap({ hires: true, source: id }) : null
11948
+ };
11949
+ }
11942
11950
 
11943
11951
  /* eslint no-console: 0 */
11944
11952
  const LogLevels = {
@@ -14682,7 +14690,7 @@ const debug$c = createDebugger('vite:resolve-details', {
14682
14690
  onlyWhenFocused: true
14683
14691
  });
14684
14692
  function resolvePlugin(baseOptions) {
14685
- const { root, isProduction, asSrc, ssrConfig, preferRelative = false } = baseOptions;
14693
+ const { root, isBuild, isProduction, asSrc, ssrConfig, preferRelative = false } = baseOptions;
14686
14694
  const { target: ssrTarget, noExternal: ssrNoExternal } = ssrConfig ?? {};
14687
14695
  return {
14688
14696
  name: 'vite:resolve',
@@ -14809,18 +14817,20 @@ function resolvePlugin(baseOptions) {
14809
14817
  }
14810
14818
  // bare package imports, perform node resolve
14811
14819
  if (bareImportRE.test(id)) {
14812
- if (asSrc &&
14820
+ const external = options.shouldExternalize?.(id);
14821
+ if (!external &&
14822
+ asSrc &&
14813
14823
  depsOptimizer &&
14814
- !ssr &&
14824
+ (isBuild || !ssr) &&
14815
14825
  !options.scan &&
14816
14826
  (res = await tryOptimizedResolve(depsOptimizer, id, importer))) {
14817
14827
  return res;
14818
14828
  }
14819
14829
  if (targetWeb &&
14820
- (res = tryResolveBrowserMapping(id, importer, options, false))) {
14830
+ (res = tryResolveBrowserMapping(id, importer, options, false, external))) {
14821
14831
  return res;
14822
14832
  }
14823
- if ((res = tryNodeResolve(id, importer, options, targetWeb, depsOptimizer, ssr))) {
14833
+ if ((res = tryNodeResolve(id, importer, options, targetWeb, depsOptimizer, ssr, external))) {
14824
14834
  return res;
14825
14835
  }
14826
14836
  // node built-ins.
@@ -14951,7 +14961,7 @@ function tryResolveFile(file, postfix, options, tryIndex, targetWeb, tryPrefix,
14951
14961
  }
14952
14962
  }
14953
14963
  const idToPkgMap = new Map();
14954
- function tryNodeResolve(id, importer, options, targetWeb, depsOptimizer, ssr) {
14964
+ function tryNodeResolve(id, importer, options, targetWeb, depsOptimizer, ssr, externalize) {
14955
14965
  const { root, dedupe, isBuild, preserveSymlinks, packageCache } = options;
14956
14966
  // split id by last '>' for nested selected packages, for example:
14957
14967
  // 'foo > bar > baz' => 'foo > bar' & 'baz'
@@ -15005,7 +15015,8 @@ function tryNodeResolve(id, importer, options, targetWeb, depsOptimizer, ssr) {
15005
15015
  }
15006
15016
  let resolveId = resolvePackageEntry;
15007
15017
  let unresolvedId = pkgId;
15008
- if (unresolvedId !== nestedPath) {
15018
+ const isDeepImport = unresolvedId !== nestedPath;
15019
+ if (isDeepImport) {
15009
15020
  resolveId = resolveDeepImport;
15010
15021
  unresolvedId = '.' + nestedPath.slice(pkgId.length);
15011
15022
  }
@@ -15029,15 +15040,33 @@ function tryNodeResolve(id, importer, options, targetWeb, depsOptimizer, ssr) {
15029
15040
  if (!resolved) {
15030
15041
  return;
15031
15042
  }
15043
+ const processResult = (resolved) => {
15044
+ if (!externalize) {
15045
+ return resolved;
15046
+ }
15047
+ const resolvedExt = path$p.extname(resolved.id);
15048
+ let resolvedId = id;
15049
+ if (isDeepImport) {
15050
+ // check ext before externalizing - only externalize
15051
+ // extension-less imports and explicit .js imports
15052
+ if (resolvedExt && !resolved.id.match(/(.js|.mjs|.cjs)$/)) {
15053
+ return;
15054
+ }
15055
+ if (!pkg?.data.exports && path$p.extname(id) !== resolvedExt) {
15056
+ resolvedId += resolvedExt;
15057
+ }
15058
+ }
15059
+ return { ...resolved, id: resolvedId, external: true };
15060
+ };
15032
15061
  // link id to pkg for browser field mapping check
15033
15062
  idToPkgMap.set(resolved, pkg);
15034
- if (isBuild && !depsOptimizer) {
15063
+ if ((isBuild && !depsOptimizer) || externalize) {
15035
15064
  // Resolve package side effects for build so that rollup can better
15036
15065
  // perform tree-shaking
15037
- return {
15066
+ return processResult({
15038
15067
  id: resolved,
15039
15068
  moduleSideEffects: pkg.hasSideEffects(resolved)
15040
- };
15069
+ });
15041
15070
  }
15042
15071
  if (!resolved.includes('node_modules') || // linked
15043
15072
  !depsOptimizer || // resolving before listening to the server
@@ -15053,7 +15082,7 @@ function tryNodeResolve(id, importer, options, targetWeb, depsOptimizer, ssr) {
15053
15082
  exclude?.includes(pkgId) ||
15054
15083
  exclude?.includes(nestedPath) ||
15055
15084
  SPECIAL_QUERY_RE.test(resolved) ||
15056
- ssr) {
15085
+ (!isBuild && ssr)) {
15057
15086
  // excluded from optimization
15058
15087
  // Inject a version query to npm deps so that the browser
15059
15088
  // can cache it without re-validation, but only do so for known js types.
@@ -15067,7 +15096,6 @@ function tryNodeResolve(id, importer, options, targetWeb, depsOptimizer, ssr) {
15067
15096
  }
15068
15097
  }
15069
15098
  else {
15070
- // TODO: depsBuild
15071
15099
  // this is a missing import, queue optimize-deps re-run and
15072
15100
  // get a resolved its optimized info
15073
15101
  const optimizedInfo = depsOptimizer.registerMissingImport(id, resolved);
@@ -15282,7 +15310,7 @@ function resolveDeepImport(id, { webResolvedImports, setResolvedCache, getResolv
15282
15310
  }
15283
15311
  }
15284
15312
  }
15285
- function tryResolveBrowserMapping(id, importer, options, isFilePath) {
15313
+ function tryResolveBrowserMapping(id, importer, options, isFilePath, externalize) {
15286
15314
  let res;
15287
15315
  const pkg = importer && idToPkgMap.get(importer);
15288
15316
  if (pkg && isObject$2(pkg.data.browser)) {
@@ -15294,10 +15322,11 @@ function tryResolveBrowserMapping(id, importer, options, isFilePath) {
15294
15322
  isDebug$4 &&
15295
15323
  debug$c(`[browser mapped] ${colors$1.cyan(id)} -> ${colors$1.dim(res)}`);
15296
15324
  idToPkgMap.set(res, pkg);
15297
- return {
15325
+ const result = {
15298
15326
  id: res,
15299
15327
  moduleSideEffects: pkg.hasSideEffects(res)
15300
15328
  };
15329
+ return externalize ? { ...result, external: true } : result;
15301
15330
  }
15302
15331
  }
15303
15332
  else if (browserMappedPath === false) {
@@ -15464,9 +15493,8 @@ function esbuildDepPlugin(qualified, exportsData, config) {
15464
15493
  relativePath = `./${relativePath}`;
15465
15494
  }
15466
15495
  let contents = '';
15467
- const data = exportsData[id];
15468
- const [imports, exports] = data;
15469
- if (!imports.length && !exports.length) {
15496
+ const { hasImports, exports, hasReExports } = exportsData[id];
15497
+ if (!hasImports && !exports.length) {
15470
15498
  // cjs
15471
15499
  contents += `export default require("${relativePath}");`;
15472
15500
  }
@@ -15474,9 +15502,7 @@ function esbuildDepPlugin(qualified, exportsData, config) {
15474
15502
  if (exports.includes('default')) {
15475
15503
  contents += `import d from "${relativePath}";export default d;`;
15476
15504
  }
15477
- if (data.hasReExports ||
15478
- exports.length > 1 ||
15479
- exports[0] !== 'default') {
15505
+ if (hasReExports || exports.length > 1 || exports[0] !== 'default') {
15480
15506
  contents += `\nexport * from "${relativePath}"`;
15481
15507
  }
15482
15508
  }
@@ -25984,7 +26010,7 @@ async function createPluginContainer({ plugins, logger, root, build: { rollupOpt
25984
26010
  (await plugin.options.call(minimalContext, options)) || options;
25985
26011
  }
25986
26012
  if (options.acornInjectPlugins) {
25987
- parser = Parser.extend(options.acornInjectPlugins);
26013
+ parser = Parser.extend(...arraify(options.acornInjectPlugins));
25988
26014
  }
25989
26015
  return {
25990
26016
  acorn,
@@ -26231,10 +26257,7 @@ function importGlobPlugin(config) {
26231
26257
  server.watcher.add(dirname(file));
26232
26258
  });
26233
26259
  }
26234
- return {
26235
- code: result.s.toString(),
26236
- map: config.build.sourcemap ? result.s.generateMap() : null
26237
- };
26260
+ return transformResult(result.s, id, config);
26238
26261
  }
26239
26262
  }
26240
26263
  };
@@ -27520,7 +27543,7 @@ async function runOptimizeDeps(resolvedConfig, depsInfo) {
27520
27543
  splitting: true,
27521
27544
  sourcemap: true,
27522
27545
  outdir: processingCacheDir,
27523
- ignoreAnnotations: true,
27546
+ ignoreAnnotations: resolvedConfig.command !== 'build',
27524
27547
  metafile: true,
27525
27548
  define,
27526
27549
  plugins: [
@@ -27606,12 +27629,22 @@ function depsFromOptimizedDepInfo(depsInfo) {
27606
27629
  function getOptimizedDepPath(id, config) {
27607
27630
  return normalizePath$3(path$p.resolve(getDepsCacheDir(config), flattenId(id) + '.js'));
27608
27631
  }
27632
+ function getDepsCacheSuffix(config) {
27633
+ let suffix = '';
27634
+ if (config.command === 'build') {
27635
+ suffix += '_build';
27636
+ if (config.build.ssr) {
27637
+ suffix += '_ssr';
27638
+ }
27639
+ }
27640
+ return suffix;
27641
+ }
27609
27642
  function getDepsCacheDir(config) {
27610
- const dirName = config.command === 'build' ? 'depsBuild' : 'deps';
27643
+ const dirName = 'deps' + getDepsCacheSuffix(config);
27611
27644
  return normalizePath$3(path$p.resolve(config.cacheDir, dirName));
27612
27645
  }
27613
27646
  function getProcessingDepsCacheDir(config) {
27614
- const dirName = config.command === 'build' ? 'processingBuild' : 'processing';
27647
+ const dirName = 'deps' + getDepsCacheSuffix(config) + '_temp';
27615
27648
  return normalizePath$3(path$p.resolve(config.cacheDir, dirName));
27616
27649
  }
27617
27650
  function isOptimizedDepFile(id, config) {
@@ -27708,7 +27741,6 @@ function esbuildOutputFromId(outputs, id, cacheDirOutputPath) {
27708
27741
  }
27709
27742
  async function extractExportsData(filePath, config) {
27710
27743
  await init;
27711
- let exportsData;
27712
27744
  const esbuildOptions = config.optimizeDeps?.esbuildOptions ?? {};
27713
27745
  if (config.optimizeDeps.extensions?.some((ext) => filePath.endsWith(ext))) {
27714
27746
  // For custom supported extensions, build the entry file to transform it into JS,
@@ -27720,35 +27752,45 @@ async function extractExportsData(filePath, config) {
27720
27752
  write: false,
27721
27753
  format: 'esm'
27722
27754
  });
27723
- exportsData = parse$h(result.outputFiles[0].text);
27755
+ const [imports, exports, facade] = parse$h(result.outputFiles[0].text);
27756
+ return {
27757
+ hasImports: imports.length > 0,
27758
+ exports,
27759
+ facade
27760
+ };
27761
+ }
27762
+ let parseResult;
27763
+ let usedJsxLoader = false;
27764
+ const entryContent = fs__default.readFileSync(filePath, 'utf-8');
27765
+ try {
27766
+ parseResult = parse$h(entryContent);
27767
+ }
27768
+ catch {
27769
+ const loader = esbuildOptions.loader?.[path$p.extname(filePath)] || 'jsx';
27770
+ debug$a(`Unable to parse: ${filePath}.\n Trying again with a ${loader} transform.`);
27771
+ const transformed = await transformWithEsbuild(entryContent, filePath, {
27772
+ loader
27773
+ });
27774
+ // Ensure that optimization won't fail by defaulting '.js' to the JSX parser.
27775
+ // This is useful for packages such as Gatsby.
27776
+ esbuildOptions.loader = {
27777
+ '.js': 'jsx',
27778
+ ...esbuildOptions.loader
27779
+ };
27780
+ parseResult = parse$h(transformed.code);
27781
+ usedJsxLoader = true;
27724
27782
  }
27725
- else {
27726
- const entryContent = fs__default.readFileSync(filePath, 'utf-8');
27727
- try {
27728
- exportsData = parse$h(entryContent);
27729
- }
27730
- catch {
27731
- const loader = esbuildOptions.loader?.[path$p.extname(filePath)] || 'jsx';
27732
- debug$a(`Unable to parse: ${filePath}.\n Trying again with a ${loader} transform.`);
27733
- const transformed = await transformWithEsbuild(entryContent, filePath, {
27734
- loader
27735
- });
27736
- // Ensure that optimization won't fail by defaulting '.js' to the JSX parser.
27737
- // This is useful for packages such as Gatsby.
27738
- esbuildOptions.loader = {
27739
- '.js': 'jsx',
27740
- ...esbuildOptions.loader
27741
- };
27742
- exportsData = parse$h(transformed.code);
27743
- exportsData.jsxLoader = true;
27744
- }
27745
- for (const { ss, se } of exportsData[0]) {
27783
+ const [imports, exports, facade] = parseResult;
27784
+ const exportsData = {
27785
+ hasImports: imports.length > 0,
27786
+ exports,
27787
+ facade,
27788
+ hasReExports: imports.some(({ ss, se }) => {
27746
27789
  const exp = entryContent.slice(ss, se);
27747
- if (/export\s+\*\s+from/.test(exp)) {
27748
- exportsData.hasReExports = true;
27749
- }
27750
- }
27751
- }
27790
+ return /export\s+\*\s+from/.test(exp);
27791
+ }),
27792
+ jsxLoader: usedJsxLoader
27793
+ };
27752
27794
  return exportsData;
27753
27795
  }
27754
27796
  // https://github.com/vitejs/vite/issues/1724#issuecomment-767619642
@@ -27760,9 +27802,9 @@ function needsInterop(config, id, exportsData, output) {
27760
27802
  KNOWN_INTEROP_IDS.has(id)) {
27761
27803
  return true;
27762
27804
  }
27763
- const [imports, exports] = exportsData;
27805
+ const { hasImports, exports } = exportsData;
27764
27806
  // entry has no ESM syntax - likely CJS or UMD
27765
- if (!exports.length && !imports.length) {
27807
+ if (!exports.length && !hasImports) {
27766
27808
  return true;
27767
27809
  }
27768
27810
  if (output) {
@@ -35872,7 +35914,7 @@ const assetAttrsConfig = {
35872
35914
  const isAsyncScriptMap = new WeakMap();
35873
35915
  async function traverseHtml(html, filePath, visitor) {
35874
35916
  // lazy load compiler
35875
- const { parse, transform } = await import('./dep-b4474709.js').then(function (n) { return n.c; });
35917
+ const { parse, transform } = await import('./dep-523c8a1b.js').then(function (n) { return n.c; });
35876
35918
  // @vue/compiler-core doesn't like lowercase doctypes
35877
35919
  html = html.replace(/<!doctype\s/i, '<!DOCTYPE ');
35878
35920
  try {
@@ -36977,7 +37019,7 @@ async function compileCSS(id, code, config, urlReplacer, atImportResolvers, serv
36977
37019
  logger: config.logger
36978
37020
  }));
36979
37021
  if (isModule) {
36980
- postcssPlugins.unshift((await import('./dep-8bed6f50.js').then(function (n) { return n.i; })).default({
37022
+ postcssPlugins.unshift((await import('./dep-3165073f.js').then(function (n) { return n.i; })).default({
36981
37023
  ...modulesOptions,
36982
37024
  getJSON(cssFileName, _modules, outputFileName) {
36983
37025
  modules = _modules;
@@ -37949,7 +37991,7 @@ function lexAcceptedHmrDeps(code, start, urls) {
37949
37991
  return false;
37950
37992
  }
37951
37993
  function error$1(pos) {
37952
- const err = new Error(`import.meta.accept() can only accept string literals or an ` +
37994
+ const err = new Error(`import.meta.hot.accept() can only accept string literals or an ` +
37953
37995
  `Array of string literals.`);
37954
37996
  err.pos = pos;
37955
37997
  throw err;
@@ -37996,7 +38038,7 @@ function stripNesting(packages) {
37996
38038
  * Heuristics for determining whether a dependency should be externalized for
37997
38039
  * server-side rendering.
37998
38040
  */
37999
- function resolveSSRExternal(config, knownImports) {
38041
+ function cjsSsrResolveExternals(config, knownImports) {
38000
38042
  // strip nesting since knownImports may be passed in from optimizeDeps which
38001
38043
  // supports a "parent > child" syntax
38002
38044
  knownImports = stripNesting(knownImports);
@@ -38010,7 +38052,7 @@ function resolveSSRExternal(config, knownImports) {
38010
38052
  ssrExternals.add(id);
38011
38053
  seen.add(id);
38012
38054
  });
38013
- collectExternals(config.root, config.resolve.preserveSymlinks, ssrExternals, seen, config.logger);
38055
+ cjsSsrCollectExternals(config.root, config.resolve.preserveSymlinks, ssrExternals, seen, config.logger);
38014
38056
  const importedDeps = knownImports.map(getNpmPackageName).filter(isDefined);
38015
38057
  for (const dep of importedDeps) {
38016
38058
  // Assume external if not yet seen
@@ -38032,8 +38074,62 @@ function resolveSSRExternal(config, knownImports) {
38032
38074
  const CJS_CONTENT_RE = /\bmodule\.exports\b|\bexports[.\[]|\brequire\s*\(|\bObject\.(defineProperty|defineProperties|assign)\s*\(\s*exports\b/;
38033
38075
  // TODO: use import()
38034
38076
  const _require$2 = createRequire$1(import.meta.url);
38035
- // do we need to do this ahead of time or could we do it lazily?
38036
- function collectExternals(root, preserveSymlinks, ssrExternals, seen, logger) {
38077
+ const isSsrExternalCache = new WeakMap();
38078
+ function shouldExternalizeForSSR(id, config) {
38079
+ let isSsrExternal = isSsrExternalCache.get(config);
38080
+ if (!isSsrExternal) {
38081
+ isSsrExternal = createIsSsrExternal(config);
38082
+ isSsrExternalCache.set(config, isSsrExternal);
38083
+ }
38084
+ return isSsrExternal(id);
38085
+ }
38086
+ function createIsSsrExternal(config) {
38087
+ const processedIds = new Map();
38088
+ const { ssr, root } = config;
38089
+ const noExternal = ssr?.noExternal;
38090
+ const noExternalFilter = noExternal !== 'undefined' &&
38091
+ typeof noExternal !== 'boolean' &&
38092
+ createFilter$1(undefined, noExternal, { resolve: false });
38093
+ const isConfiguredAsExternal = (id) => {
38094
+ const { ssr } = config;
38095
+ if (!ssr || ssr.external?.includes(id)) {
38096
+ return true;
38097
+ }
38098
+ if (typeof noExternal === 'boolean') {
38099
+ return !noExternal;
38100
+ }
38101
+ if (noExternalFilter) {
38102
+ return noExternalFilter(id);
38103
+ }
38104
+ return true;
38105
+ };
38106
+ const resolveOptions = {
38107
+ root,
38108
+ preserveSymlinks: config.resolve.preserveSymlinks,
38109
+ isProduction: false,
38110
+ isBuild: true
38111
+ };
38112
+ const isValidPackageEntry = (id) => {
38113
+ if (!bareImportRE.test(id) || id.includes('\0')) {
38114
+ return false;
38115
+ }
38116
+ return !!tryNodeResolve(id, undefined, resolveOptions, ssr?.target === 'webworker', undefined, true, true // try to externalize, will return undefined if not possible
38117
+ );
38118
+ };
38119
+ return (id) => {
38120
+ if (processedIds.has(id)) {
38121
+ return processedIds.get(id);
38122
+ }
38123
+ const external = !id.startsWith('.') &&
38124
+ !path$p.isAbsolute(id) &&
38125
+ (isBuiltin(id) || (isConfiguredAsExternal(id) && isValidPackageEntry(id)));
38126
+ processedIds.set(id, external);
38127
+ return external;
38128
+ };
38129
+ }
38130
+ // When ssr.format is 'cjs', this function is used reverting to the Vite 2.9
38131
+ // SSR externalization heuristics
38132
+ function cjsSsrCollectExternals(root, preserveSymlinks, ssrExternals, seen, logger) {
38037
38133
  const rootPkgContent = lookupFile(root, ['package.json']);
38038
38134
  if (!rootPkgContent) {
38039
38135
  return;
@@ -38117,10 +38213,13 @@ function collectExternals(root, preserveSymlinks, ssrExternals, seen, logger) {
38117
38213
  }
38118
38214
  }
38119
38215
  for (const depRoot of depsToTrace) {
38120
- collectExternals(depRoot, preserveSymlinks, ssrExternals, seen, logger);
38216
+ cjsSsrCollectExternals(depRoot, preserveSymlinks, ssrExternals, seen, logger);
38121
38217
  }
38122
38218
  }
38123
- function shouldExternalizeForSSR(id, externals) {
38219
+ function cjsShouldExternalizeForSSR(id, externals) {
38220
+ if (!externals) {
38221
+ return false;
38222
+ }
38124
38223
  const should = externals.some((e) => {
38125
38224
  if (id === e) {
38126
38225
  return true;
@@ -40032,8 +40131,12 @@ function importAnalysisPlugin(config) {
40032
40131
  }
40033
40132
  // skip ssr external
40034
40133
  if (ssr) {
40035
- if (server._ssrExternals &&
40036
- shouldExternalizeForSSR(specifier, server._ssrExternals)) {
40134
+ if (config.ssr?.format === 'cjs') {
40135
+ if (cjsShouldExternalizeForSSR(specifier, server._ssrExternals)) {
40136
+ continue;
40137
+ }
40138
+ }
40139
+ else if (shouldExternalizeForSSR(specifier, config)) {
40037
40140
  continue;
40038
40141
  }
40039
40142
  if (isBuiltin(specifier)) {
@@ -40216,10 +40319,7 @@ function importAnalysisPlugin(config) {
40216
40319
  });
40217
40320
  }
40218
40321
  if (s) {
40219
- return {
40220
- code: s.toString(),
40221
- map: config.build.sourcemap ? s.generateMap({ hires: true }) : null
40222
- };
40322
+ return transformResult(s, importer, config);
40223
40323
  }
40224
40324
  else {
40225
40325
  return source;
@@ -40733,7 +40833,7 @@ function ssrManifestPlugin(config) {
40733
40833
  const chunk = bundle[filename];
40734
40834
  if (chunk) {
40735
40835
  chunk.viteMetadata.importedCss.forEach((file) => {
40736
- deps.push(`/${file}`);
40836
+ deps.push(join$1(config.base, file));
40737
40837
  });
40738
40838
  chunk.imports.forEach(addDeps);
40739
40839
  }
@@ -40812,10 +40912,7 @@ function assetImportMetaUrlPlugin(config) {
40812
40912
  s.overwrite(index, index + exp.length, `new URL(${JSON.stringify(builtUrl)}, self.location)`, { contentOnly: true });
40813
40913
  }
40814
40914
  if (s) {
40815
- return {
40816
- code: s.toString(),
40817
- map: config.build.sourcemap ? s.generateMap({ hires: true }) : null
40818
- };
40915
+ return transformResult(s, id, config);
40819
40916
  }
40820
40917
  }
40821
40918
  return null;
@@ -40942,7 +41039,7 @@ function resolveBuildPlugins(config) {
40942
41039
  pre: [
40943
41040
  ...(options.watch ? [ensureWatchPlugin()] : []),
40944
41041
  watchPackageDataPlugin(config),
40945
- ...(!isDepsOptimizerEnabled(config) || options.ssr
41042
+ ...(!isDepsOptimizerEnabled(config)
40946
41043
  ? [commonjs(options.commonjsOptions)]
40947
41044
  : []),
40948
41045
  dataURIPlugin(),
@@ -41006,25 +41103,15 @@ async function doBuild(inlineConfig = {}) {
41006
41103
  const outDir = resolve(options.outDir);
41007
41104
  // inject ssr arg to plugin load/transform hooks
41008
41105
  const plugins = (ssr ? config.plugins.map((p) => injectSsrFlagToHooks(p)) : config.plugins);
41009
- // inject ssrExternal if present
41010
41106
  const userExternal = options.rollupOptions?.external;
41011
41107
  let external = userExternal;
41012
- if (ssr) {
41013
- // see if we have cached deps data available
41014
- let knownImports;
41015
- const dataPath = path$p.join(getDepsCacheDir(config), '_metadata.json');
41016
- try {
41017
- const data = JSON.parse(fs__default.readFileSync(dataPath, 'utf-8'));
41018
- knownImports = Object.keys(data.optimized);
41019
- }
41020
- catch (e) { }
41021
- if (!knownImports) {
41022
- // no dev deps optimization data, do a fresh scan
41023
- knownImports = await findKnownImports(config);
41024
- }
41025
- external = resolveExternal(resolveSSRExternal(config, knownImports), userExternal);
41108
+ // In CJS, we can pass the externals to rollup as is. In ESM, we need to
41109
+ // do it in the resolve plugin so we can add the resolved extension for
41110
+ // deep node_modules imports
41111
+ if (ssr && config.ssr?.format === 'cjs') {
41112
+ external = await cjsSsrResolveExternal(config, userExternal);
41026
41113
  }
41027
- if (isDepsOptimizerEnabled(config) && !ssr) {
41114
+ if (isDepsOptimizerEnabled(config)) {
41028
41115
  await initDepsOptimizer(config);
41029
41116
  }
41030
41117
  const rollupOptions = {
@@ -41054,20 +41141,33 @@ async function doBuild(inlineConfig = {}) {
41054
41141
  };
41055
41142
  try {
41056
41143
  const buildOutputOptions = (output = {}) => {
41144
+ // See https://github.com/vitejs/vite/issues/5812#issuecomment-984345618
41145
+ // @ts-ignore
41146
+ if (output.output) {
41147
+ config.logger.warn(`You've set "rollupOptions.output.output" in your config. ` +
41148
+ `This is deprecated and will override all Vite.js default output options. ` +
41149
+ `Please use "rollupOptions.output" instead.`);
41150
+ }
41151
+ const cjsSsrBuild = ssr && config.ssr?.format === 'cjs';
41152
+ const format = output.format || (cjsSsrBuild ? 'cjs' : 'es');
41153
+ const jsExt = (ssr && config.ssr?.target !== 'webworker') || libOptions
41154
+ ? resolveOutputJsExtension(format, getPkgJson(config.root)?.type)
41155
+ : 'js';
41057
41156
  return {
41058
41157
  dir: outDir,
41059
- format: ssr ? 'cjs' : 'es',
41060
- exports: ssr ? 'named' : 'auto',
41158
+ // Default format is 'es' for regular and for SSR builds
41159
+ format,
41160
+ exports: cjsSsrBuild ? 'named' : 'auto',
41061
41161
  sourcemap: options.sourcemap,
41062
41162
  name: libOptions ? libOptions.name : undefined,
41063
41163
  generatedCode: 'es2015',
41064
41164
  entryFileNames: ssr
41065
- ? `[name].js`
41165
+ ? `[name].${jsExt}`
41066
41166
  : libOptions
41067
- ? resolveLibFilename(libOptions, output.format || 'es', config.root)
41167
+ ? resolveLibFilename(libOptions, format, config.root, jsExt)
41068
41168
  : path$p.posix.join(options.assetsDir, `[name].[hash].js`),
41069
41169
  chunkFileNames: libOptions
41070
- ? `[name].[hash].js`
41170
+ ? `[name].[hash].${jsExt}`
41071
41171
  : path$p.posix.join(options.assetsDir, `[name].[hash].js`),
41072
41172
  assetFileNames: libOptions
41073
41173
  ? `[name].[ext]`
@@ -41179,7 +41279,15 @@ function getPkgJson(root) {
41179
41279
  function getPkgName(name) {
41180
41280
  return name?.startsWith('@') ? name.split('/')[1] : name;
41181
41281
  }
41182
- function resolveLibFilename(libOptions, format, root) {
41282
+ function resolveOutputJsExtension(format, type = 'commonjs') {
41283
+ if (type === 'module') {
41284
+ return format === 'cjs' || format === 'umd' ? 'cjs' : 'js';
41285
+ }
41286
+ else {
41287
+ return format === 'es' ? 'mjs' : 'js';
41288
+ }
41289
+ }
41290
+ function resolveLibFilename(libOptions, format, root, extension) {
41183
41291
  if (typeof libOptions.fileName === 'function') {
41184
41292
  return libOptions.fileName(format);
41185
41293
  }
@@ -41187,13 +41295,7 @@ function resolveLibFilename(libOptions, format, root) {
41187
41295
  const name = libOptions.fileName || getPkgName(packageJson.name);
41188
41296
  if (!name)
41189
41297
  throw new Error('Name in package.json is required if option "build.lib.fileName" is not provided.');
41190
- let extension;
41191
- if (packageJson?.type === 'module') {
41192
- extension = format === 'cjs' || format === 'umd' ? 'cjs' : 'js';
41193
- }
41194
- else {
41195
- extension = format === 'es' ? 'mjs' : 'js';
41196
- }
41298
+ extension ?? (extension = resolveOutputJsExtension(format, packageJson.type));
41197
41299
  if (format === 'cjs' || format === 'es') {
41198
41300
  return `${name}.${extension}`;
41199
41301
  }
@@ -41255,24 +41357,41 @@ function onRollupWarning(warning, warn, config) {
41255
41357
  }
41256
41358
  }
41257
41359
  }
41258
- function resolveExternal(ssrExternals, user) {
41360
+ async function cjsSsrResolveExternal(config, user) {
41361
+ // see if we have cached deps data available
41362
+ let knownImports;
41363
+ const dataPath = path$p.join(getDepsCacheDir(config), '_metadata.json');
41364
+ try {
41365
+ const data = JSON.parse(fs__default.readFileSync(dataPath, 'utf-8'));
41366
+ knownImports = Object.keys(data.optimized);
41367
+ }
41368
+ catch (e) { }
41369
+ if (!knownImports) {
41370
+ // no dev deps optimization data, do a fresh scan
41371
+ knownImports = await findKnownImports(config);
41372
+ }
41373
+ const ssrExternals = cjsSsrResolveExternals(config, knownImports);
41259
41374
  return (id, parentId, isResolved) => {
41260
- if (shouldExternalizeForSSR(id, ssrExternals)) {
41375
+ const isExternal = cjsShouldExternalizeForSSR(id, ssrExternals);
41376
+ if (isExternal) {
41261
41377
  return true;
41262
41378
  }
41263
41379
  if (user) {
41264
- if (typeof user === 'function') {
41265
- return user(id, parentId, isResolved);
41266
- }
41267
- else if (Array.isArray(user)) {
41268
- return user.some((test) => isExternal(id, test));
41269
- }
41270
- else {
41271
- return isExternal(id, user);
41272
- }
41380
+ return resolveUserExternal(user, id, parentId, isResolved);
41273
41381
  }
41274
41382
  };
41275
41383
  }
41384
+ function resolveUserExternal(user, id, parentId, isResolved) {
41385
+ if (typeof user === 'function') {
41386
+ return user(id, parentId, isResolved);
41387
+ }
41388
+ else if (Array.isArray(user)) {
41389
+ return user.some((test) => isExternal(id, test));
41390
+ }
41391
+ else {
41392
+ return isExternal(id, user);
41393
+ }
41394
+ }
41276
41395
  function isExternal(id, test) {
41277
41396
  if (typeof test === 'string') {
41278
41397
  return id === test;
@@ -47281,12 +47400,21 @@ var guess = function guessEditor (specifiedEditor) {
47281
47400
  if (specifiedEditor) {
47282
47401
  return shellQuote.parse(specifiedEditor)
47283
47402
  }
47403
+
47404
+ if (process.versions.webcontainer) {
47405
+ return [process.env.EDITOR || 'code']
47406
+ }
47407
+
47284
47408
  // We can find out which editor is currently running by:
47285
47409
  // `ps x` on macOS and Linux
47286
47410
  // `Get-Process` on Windows
47287
47411
  try {
47288
47412
  if (process.platform === 'darwin') {
47289
- const output = childProcess$2.execSync('ps x').toString();
47413
+ const output = childProcess$2
47414
+ .execSync('ps x', {
47415
+ stdio: ['pipe', 'pipe', 'ignore']
47416
+ })
47417
+ .toString();
47290
47418
  const processNames = Object.keys(COMMON_EDITORS_OSX);
47291
47419
  for (let i = 0; i < processNames.length; i++) {
47292
47420
  const processName = processNames[i];
@@ -47319,7 +47447,9 @@ var guess = function guessEditor (specifiedEditor) {
47319
47447
  // x List all processes owned by you
47320
47448
  // -o comm Need only names column
47321
47449
  const output = childProcess$2
47322
- .execSync('ps x --no-heading -o comm --sort=comm')
47450
+ .execSync('ps x --no-heading -o comm --sort=comm', {
47451
+ stdio: ['pipe', 'pipe', 'ignore']
47452
+ })
47323
47453
  .toString();
47324
47454
  const processNames = Object.keys(COMMON_EDITORS_LINUX);
47325
47455
  for (let i = 0; i < processNames.length; i++) {
@@ -47634,7 +47764,7 @@ async function getCertificate(cacheDir) {
47634
47764
  return content;
47635
47765
  }
47636
47766
  catch {
47637
- const content = (await import('./dep-a4f17494.js')).createCertificate();
47767
+ const content = (await import('./dep-08f2a2be.js')).createCertificate();
47638
47768
  promises
47639
47769
  .mkdir(cacheDir, { recursive: true })
47640
47770
  .then(() => promises.writeFile(cachePath, content))
@@ -47676,8 +47806,10 @@ async function httpServerStart(httpServer, serverOptions) {
47676
47806
  */
47677
47807
  function ssrRequireHookPlugin(config) {
47678
47808
  if (config.command !== 'build' ||
47809
+ !config.build.ssr ||
47679
47810
  !config.resolve.dedupe?.length ||
47680
47811
  config.ssr?.noExternal === true ||
47812
+ config.ssr?.format !== 'cjs' ||
47681
47813
  isBuildOutputEsm(config)) {
47682
47814
  return null;
47683
47815
  }
@@ -51159,6 +51291,7 @@ function initAsClient(websocket, address, protocols, options) {
51159
51291
 
51160
51292
  if (opts.followRedirects) {
51161
51293
  if (websocket._redirects === 0) {
51294
+ websocket._originalSecure = isSecure;
51162
51295
  websocket._originalHost = parsedUrl.host;
51163
51296
 
51164
51297
  const headers = options && options.headers;
@@ -51174,18 +51307,21 @@ function initAsClient(websocket, address, protocols, options) {
51174
51307
  options.headers[key.toLowerCase()] = value;
51175
51308
  }
51176
51309
  }
51177
- } else if (
51178
- websocket.listenerCount('redirect') === 0 &&
51179
- parsedUrl.host !== websocket._originalHost
51180
- ) {
51181
- //
51182
- // Match curl 7.77.0 behavior and drop the following headers. These
51183
- // headers are also dropped when following a redirect to a subdomain.
51184
- //
51185
- delete opts.headers.authorization;
51186
- delete opts.headers.cookie;
51187
- delete opts.headers.host;
51188
- opts.auth = undefined;
51310
+ } else if (websocket.listenerCount('redirect') === 0) {
51311
+ const isSameHost = parsedUrl.host === websocket._originalHost;
51312
+
51313
+ if (!isSameHost || (websocket._originalSecure && !isSecure)) {
51314
+ //
51315
+ // Match curl 7.77.0 behavior and drop the following headers. These
51316
+ // headers are also dropped when following a redirect to a subdomain.
51317
+ //
51318
+ delete opts.headers.authorization;
51319
+ delete opts.headers.cookie;
51320
+
51321
+ if (!isSameHost) delete opts.headers.host;
51322
+
51323
+ opts.auth = undefined;
51324
+ }
51189
51325
  }
51190
51326
 
51191
51327
  //
@@ -51277,6 +51413,11 @@ function initAsClient(websocket, address, protocols, options) {
51277
51413
 
51278
51414
  req = websocket._req = null;
51279
51415
 
51416
+ if (res.headers.upgrade.toLowerCase() !== 'websocket') {
51417
+ abortHandshake$1(websocket, socket, 'Invalid Upgrade header');
51418
+ return;
51419
+ }
51420
+
51280
51421
  const digest = createHash$1('sha1')
51281
51422
  .update(key + GUID$1)
51282
51423
  .digest('base64');
@@ -51962,21 +52103,36 @@ class WebSocketServer extends EventEmitter {
51962
52103
  handleUpgrade(req, socket, head, cb) {
51963
52104
  socket.on('error', socketOnError);
51964
52105
 
51965
- const key =
51966
- req.headers['sec-websocket-key'] !== undefined
51967
- ? req.headers['sec-websocket-key']
51968
- : false;
52106
+ const key = req.headers['sec-websocket-key'];
51969
52107
  const version = +req.headers['sec-websocket-version'];
51970
52108
 
51971
- if (
51972
- req.method !== 'GET' ||
51973
- req.headers.upgrade.toLowerCase() !== 'websocket' ||
51974
- !key ||
51975
- !keyRegex.test(key) ||
51976
- (version !== 8 && version !== 13) ||
51977
- !this.shouldHandle(req)
51978
- ) {
51979
- return abortHandshake(socket, 400);
52109
+ if (req.method !== 'GET') {
52110
+ const message = 'Invalid HTTP method';
52111
+ abortHandshakeOrEmitwsClientError(this, req, socket, 405, message);
52112
+ return;
52113
+ }
52114
+
52115
+ if (req.headers.upgrade.toLowerCase() !== 'websocket') {
52116
+ const message = 'Invalid Upgrade header';
52117
+ abortHandshakeOrEmitwsClientError(this, req, socket, 400, message);
52118
+ return;
52119
+ }
52120
+
52121
+ if (!key || !keyRegex.test(key)) {
52122
+ const message = 'Missing or invalid Sec-WebSocket-Key header';
52123
+ abortHandshakeOrEmitwsClientError(this, req, socket, 400, message);
52124
+ return;
52125
+ }
52126
+
52127
+ if (version !== 8 && version !== 13) {
52128
+ const message = 'Missing or invalid Sec-WebSocket-Version header';
52129
+ abortHandshakeOrEmitwsClientError(this, req, socket, 400, message);
52130
+ return;
52131
+ }
52132
+
52133
+ if (!this.shouldHandle(req)) {
52134
+ abortHandshake(socket, 400);
52135
+ return;
51980
52136
  }
51981
52137
 
51982
52138
  const secWebSocketProtocol = req.headers['sec-websocket-protocol'];
@@ -51986,7 +52142,9 @@ class WebSocketServer extends EventEmitter {
51986
52142
  try {
51987
52143
  protocols = subprotocol.parse(secWebSocketProtocol);
51988
52144
  } catch (err) {
51989
- return abortHandshake(socket, 400);
52145
+ const message = 'Invalid Sec-WebSocket-Protocol header';
52146
+ abortHandshakeOrEmitwsClientError(this, req, socket, 400, message);
52147
+ return;
51990
52148
  }
51991
52149
  }
51992
52150
 
@@ -52011,7 +52169,10 @@ class WebSocketServer extends EventEmitter {
52011
52169
  extensions[PerMessageDeflate.extensionName] = perMessageDeflate;
52012
52170
  }
52013
52171
  } catch (err) {
52014
- return abortHandshake(socket, 400);
52172
+ const message =
52173
+ 'Invalid or unacceptable Sec-WebSocket-Extensions header';
52174
+ abortHandshakeOrEmitwsClientError(this, req, socket, 400, message);
52175
+ return;
52015
52176
  }
52016
52177
  }
52017
52178
 
@@ -52178,7 +52339,7 @@ function emitClose(server) {
52178
52339
  }
52179
52340
 
52180
52341
  /**
52181
- * Handle premature socket errors.
52342
+ * Handle socket errors.
52182
52343
  *
52183
52344
  * @private
52184
52345
  */
@@ -52196,27 +52357,54 @@ function socketOnError() {
52196
52357
  * @private
52197
52358
  */
52198
52359
  function abortHandshake(socket, code, message, headers) {
52199
- if (socket.writable) {
52200
- message = message || http$2.STATUS_CODES[code];
52201
- headers = {
52202
- Connection: 'close',
52203
- 'Content-Type': 'text/html',
52204
- 'Content-Length': Buffer.byteLength(message),
52205
- ...headers
52206
- };
52360
+ //
52361
+ // The socket is writable unless the user destroyed or ended it before calling
52362
+ // `server.handleUpgrade()` or in the `verifyClient` function, which is a user
52363
+ // error. Handling this does not make much sense as the worst that can happen
52364
+ // is that some of the data written by the user might be discarded due to the
52365
+ // call to `socket.end()` below, which triggers an `'error'` event that in
52366
+ // turn causes the socket to be destroyed.
52367
+ //
52368
+ message = message || http$2.STATUS_CODES[code];
52369
+ headers = {
52370
+ Connection: 'close',
52371
+ 'Content-Type': 'text/html',
52372
+ 'Content-Length': Buffer.byteLength(message),
52373
+ ...headers
52374
+ };
52207
52375
 
52208
- socket.write(
52209
- `HTTP/1.1 ${code} ${http$2.STATUS_CODES[code]}\r\n` +
52210
- Object.keys(headers)
52211
- .map((h) => `${h}: ${headers[h]}`)
52212
- .join('\r\n') +
52213
- '\r\n\r\n' +
52214
- message
52215
- );
52216
- }
52376
+ socket.once('finish', socket.destroy);
52217
52377
 
52218
- socket.removeListener('error', socketOnError);
52219
- socket.destroy();
52378
+ socket.end(
52379
+ `HTTP/1.1 ${code} ${http$2.STATUS_CODES[code]}\r\n` +
52380
+ Object.keys(headers)
52381
+ .map((h) => `${h}: ${headers[h]}`)
52382
+ .join('\r\n') +
52383
+ '\r\n\r\n' +
52384
+ message
52385
+ );
52386
+ }
52387
+
52388
+ /**
52389
+ * Emit a `'wsClientError'` event on a `WebSocketServer` if there is at least
52390
+ * one listener for it, otherwise call `abortHandshake()`.
52391
+ *
52392
+ * @param {WebSocketServer} server The WebSocket server
52393
+ * @param {http.IncomingMessage} req The request object
52394
+ * @param {(net.Socket|tls.Socket)} socket The socket of the upgrade request
52395
+ * @param {Number} code The HTTP response status code
52396
+ * @param {String} message The HTTP response body
52397
+ * @private
52398
+ */
52399
+ function abortHandshakeOrEmitwsClientError(server, req, socket, code, message) {
52400
+ if (server.listenerCount('wsClientError')) {
52401
+ const err = new Error(message);
52402
+ Error.captureStackTrace(err, abortHandshakeOrEmitwsClientError);
52403
+
52404
+ server.emit('wsClientError', err, socket, req);
52405
+ } else {
52406
+ abortHandshake(socket, code, message);
52407
+ }
52220
52408
  }
52221
52409
 
52222
52410
  const HMR_HEADER = 'vite-hmr';
@@ -54811,8 +54999,19 @@ function transformMiddleware(server) {
54811
54999
  const publicPath = `${publicDir.slice(rootDir.length)}/`;
54812
55000
  // warn explicit public paths
54813
55001
  if (url.startsWith(publicPath)) {
54814
- logger.warn(colors$1.yellow(`files in the public directory are served at the root path.\n` +
54815
- `Instead of ${colors$1.cyan(url)}, use ${colors$1.cyan(url.replace(publicPath, '/'))}.`));
55002
+ let warning;
55003
+ if (isImportRequest(url)) {
55004
+ const rawUrl = removeImportQuery(url);
55005
+ warning =
55006
+ 'Assets in public cannot be imported from JavaScript.\n' +
55007
+ `Instead of ${colors$1.cyan(rawUrl)}, put the file in the src directory, and use ${colors$1.cyan(rawUrl.replace(publicPath, '/src/'))} instead.`;
55008
+ }
55009
+ else {
55010
+ warning =
55011
+ `files in the public directory are served at the root path.\n` +
55012
+ `Instead of ${colors$1.cyan(url)}, use ${colors$1.cyan(url.replace(publicPath, '/'))}.`;
55013
+ }
55014
+ logger.warn(colors$1.yellow(warning));
54816
55015
  }
54817
55016
  }
54818
55017
  if (isJSRequest(url) ||
@@ -56453,18 +56652,7 @@ async function createServer(inlineConfig = {}) {
56453
56652
  },
56454
56653
  transformIndexHtml: null,
56455
56654
  async ssrLoadModule(url, opts) {
56456
- if (!server._ssrExternals) {
56457
- let knownImports = [];
56458
- const depsOptimizer = getDepsOptimizer(config);
56459
- if (depsOptimizer) {
56460
- await depsOptimizer.scanProcessing;
56461
- knownImports = [
56462
- ...Object.keys(depsOptimizer.metadata.optimized),
56463
- ...Object.keys(depsOptimizer.metadata.discovered)
56464
- ];
56465
- }
56466
- server._ssrExternals = resolveSSRExternal(config, knownImports);
56467
- }
56655
+ await updateCjsSsrExternals(server);
56468
56656
  return ssrLoadModule(url, server, undefined, undefined, opts?.fixStacktrace);
56469
56657
  },
56470
56658
  ssrFixStacktrace(e) {
@@ -56810,6 +56998,20 @@ async function restartServer(server) {
56810
56998
  // new server (the current server) can restart now
56811
56999
  newServer._restartPromise = null;
56812
57000
  }
57001
+ async function updateCjsSsrExternals(server) {
57002
+ if (!server._ssrExternals) {
57003
+ let knownImports = [];
57004
+ const depsOptimizer = getDepsOptimizer(server.config);
57005
+ if (depsOptimizer) {
57006
+ await depsOptimizer.scanProcessing;
57007
+ knownImports = [
57008
+ ...Object.keys(depsOptimizer.metadata.optimized),
57009
+ ...Object.keys(depsOptimizer.metadata.discovered)
57010
+ ];
57011
+ }
57012
+ server._ssrExternals = cjsSsrResolveExternals(server.config, knownImports);
57013
+ }
57014
+ }
56813
57015
 
56814
57016
  var index = {
56815
57017
  __proto__: null,
@@ -59032,10 +59234,7 @@ function workerImportMetaUrlPlugin(config) {
59032
59234
  });
59033
59235
  }
59034
59236
  if (s) {
59035
- return {
59036
- code: s.toString(),
59037
- map: config.build.sourcemap ? s.generateMap({ hires: true }) : null
59038
- };
59237
+ return transformResult(s, id, config);
59039
59238
  }
59040
59239
  return null;
59041
59240
  }
@@ -59289,10 +59488,7 @@ function dynamicImportVarsPlugin(config) {
59289
59488
  if (needDynamicImportHelper) {
59290
59489
  s.prepend(`import __variableDynamicImportRuntimeHelper from "${dynamicImportHelperId}";`);
59291
59490
  }
59292
- return {
59293
- code: s.toString(),
59294
- map: config.build.sourcemap ? s.generateMap({ hires: true }) : null
59295
- };
59491
+ return transformResult(s, importer, config);
59296
59492
  }
59297
59493
  }
59298
59494
  };
@@ -59328,7 +59524,10 @@ async function resolvePlugins(config, prePlugins, normalPlugins, postPlugins) {
59328
59524
  packageCache: config.packageCache,
59329
59525
  ssrConfig: config.ssr,
59330
59526
  asSrc: true,
59331
- getDepsOptimizer: () => getDepsOptimizer(config)
59527
+ getDepsOptimizer: () => getDepsOptimizer(config),
59528
+ shouldExternalize: isBuild && config.build.ssr && config.ssr?.format !== 'cjs'
59529
+ ? (id) => shouldExternalizeForSSR(id, config)
59530
+ : undefined
59332
59531
  }),
59333
59532
  htmlInlineProxyPlugin(config),
59334
59533
  cssPlugin(config),