vite 3.0.0-beta.4 → 3.0.0-beta.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.
@@ -22,10 +22,9 @@ import { createHash as createHash$2 } from 'node:crypto';
22
22
  import { promisify as promisify$4 } from 'node:util';
23
23
  import { promises } from 'node:dns';
24
24
  import resolve$5 from 'resolve';
25
- import { CLIENT_ENTRY, DEFAULT_EXTENSIONS as DEFAULT_EXTENSIONS$1, VALID_ID_PREFIX, FS_PREFIX, wildcardHosts, CLIENT_PUBLIC_PATH, ENV_PUBLIC_PATH, loopbackHosts, DEFAULT_MAIN_FIELDS, DEP_VERSION_RE, OPTIMIZABLE_ENTRY_RE, SPECIAL_QUERY_RE, KNOWN_ASSET_TYPES, JS_TYPES_RE, CLIENT_DIR, NULL_BYTE_PLACEHOLDER, VERSION, VITE_PACKAGE_DIR, ENV_ENTRY, DEFAULT_ASSETS_RE, DEFAULT_CONFIG_FILES } from '../constants.js';
25
+ import { CLIENT_ENTRY, DEFAULT_EXTENSIONS as DEFAULT_EXTENSIONS$1, VALID_ID_PREFIX, FS_PREFIX, wildcardHosts, CLIENT_PUBLIC_PATH, ENV_PUBLIC_PATH, loopbackHosts, DEFAULT_MAIN_FIELDS, DEP_VERSION_RE, OPTIMIZABLE_ENTRY_RE, SPECIAL_QUERY_RE, KNOWN_ASSET_TYPES, JS_TYPES_RE, ESBUILD_MODULES_TARGET, CLIENT_DIR, NULL_BYTE_PLACEHOLDER, VERSION, VITE_PACKAGE_DIR, ENV_ENTRY, DEFAULT_ASSETS_RE, DEFAULT_CONFIG_FILES } from '../constants.js';
26
26
  import require$$5 from 'crypto';
27
27
  import require$$0$9 from 'buffer';
28
- import * as qs from 'querystring';
29
28
  import require$$0$7, { createRequire as createRequire$2 } from 'module';
30
29
  import require$$0$a from 'zlib';
31
30
  import require$$1$3 from 'https';
@@ -33,6 +32,7 @@ import require$$4 from 'tls';
33
32
  import { STATUS_CODES } from 'node:http';
34
33
  import { createServer as createServer$2 } from 'node:https';
35
34
  import require$$1$1 from 'worker_threads';
35
+ import * as qs from 'querystring';
36
36
  import readline from 'readline';
37
37
  import { execSync } from 'node:child_process';
38
38
  import zlib$1, { gzip } from 'node:zlib';
@@ -12377,6 +12377,16 @@ function stripBomTag(content) {
12377
12377
  return content;
12378
12378
  }
12379
12379
  const isTS = (filename) => /\.[cm]?ts$/.test(filename);
12380
+ const windowsDrivePathPrefixRE = /^[A-Za-z]:[/\\]/;
12381
+ /**
12382
+ * path.isAbsolute also returns true for drive relative paths on windows (e.g. /something)
12383
+ * this function returns false for them but true for absolute paths (e.g. C:/something)
12384
+ */
12385
+ const isNonDriveRelativeAbsolutePath = (p) => {
12386
+ if (!isWindows$4)
12387
+ return p.startsWith('/');
12388
+ return windowsDrivePathPrefixRE.test(p);
12389
+ };
12380
12390
 
12381
12391
  /* eslint no-console: 0 */
12382
12392
  const LogLevels = {
@@ -13440,14 +13450,16 @@ function resolveEsbuildTranspileOptions(config, format) {
13440
13450
  };
13441
13451
  }
13442
13452
  // If user enable fine-grain minify options, minify with their options instead
13443
- if (options.minifyIdentifiers ||
13444
- options.minifySyntax ||
13445
- options.minifyWhitespace) {
13453
+ if (options.minifyIdentifiers != null ||
13454
+ options.minifySyntax != null ||
13455
+ options.minifyWhitespace != null) {
13446
13456
  if (isEsLibBuild) {
13447
13457
  // Disable minify whitespace as it breaks tree-shaking
13448
13458
  return {
13449
13459
  ...options,
13450
13460
  minify: false,
13461
+ minifyIdentifiers: options.minifyIdentifiers ?? true,
13462
+ minifySyntax: options.minifySyntax ?? true,
13451
13463
  minifyWhitespace: false,
13452
13464
  treeShaking: true
13453
13465
  };
@@ -13456,6 +13468,9 @@ function resolveEsbuildTranspileOptions(config, format) {
13456
13468
  return {
13457
13469
  ...options,
13458
13470
  minify: false,
13471
+ minifyIdentifiers: options.minifyIdentifiers ?? true,
13472
+ minifySyntax: options.minifySyntax ?? true,
13473
+ minifyWhitespace: options.minifyWhitespace ?? true,
13459
13474
  treeShaking: true
13460
13475
  };
13461
13476
  }
@@ -33269,13 +33284,10 @@ function assetPlugin(config) {
33269
33284
  renderChunk(code, chunk) {
33270
33285
  let match;
33271
33286
  let s;
33272
- const absoluteUrlPathInterpolation = (filename) => `"+new URL(${JSON.stringify(path$o.posix.relative(path$o.dirname(chunk.fileName), filename))},import.meta.url).href+"`;
33273
- const toOutputFilePathInString = (filename, base) => {
33274
- return base.runtime
33275
- ? `"+${base.runtime(JSON.stringify(filename))}+"`
33276
- : base.relative && !config.build.ssr
33277
- ? absoluteUrlPathInterpolation(filename)
33278
- : JSON.stringify((base.url ?? config.base) + filename).slice(1, -1);
33287
+ const toRelative = (filename, importer) => {
33288
+ return {
33289
+ runtime: `new URL(${JSON.stringify(path$o.posix.relative(path$o.dirname(importer), filename))},import.meta.url).href`
33290
+ };
33279
33291
  };
33280
33292
  // Urls added with JS using e.g.
33281
33293
  // imgElement.src = "__VITE_ASSET__5aa0ddc0__" are using quotes
@@ -33290,8 +33302,11 @@ function assetPlugin(config) {
33290
33302
  const file = getAssetFilename(hash, config) || this.getFileName(hash);
33291
33303
  chunk.viteMetadata.importedAssets.add(cleanUrl(file));
33292
33304
  const filename = file + postfix;
33293
- const replacement = toOutputFilePathInString(filename, config.experimental.buildAdvancedBaseOptions.assets);
33294
- s.overwrite(match.index, match.index + full.length, replacement, {
33305
+ const replacement = toOutputFilePathInString(filename, 'asset', chunk.fileName, 'js', config, toRelative);
33306
+ const replacementString = typeof replacement === 'string'
33307
+ ? JSON.stringify(replacement).slice(1, -1)
33308
+ : `"+${replacement.runtime}+"`;
33309
+ s.overwrite(match.index, match.index + full.length, replacementString, {
33295
33310
  contentOnly: true
33296
33311
  });
33297
33312
  }
@@ -33301,8 +33316,11 @@ function assetPlugin(config) {
33301
33316
  s = s || (s = new MagicString(code));
33302
33317
  const [full, hash] = match;
33303
33318
  const publicUrl = publicAssetUrlMap.get(hash).slice(1);
33304
- const replacement = toOutputFilePathInString(publicUrl, config.experimental.buildAdvancedBaseOptions.public);
33305
- s.overwrite(match.index, match.index + full.length, replacement, {
33319
+ const replacement = toOutputFilePathInString(publicUrl, 'public', chunk.fileName, 'js', config, toRelative);
33320
+ const replacementString = typeof replacement === 'string'
33321
+ ? JSON.stringify(replacement).slice(1, -1)
33322
+ : `"+${replacement.runtime}+"`;
33323
+ s.overwrite(match.index, match.index + full.length, replacementString, {
33306
33324
  contentOnly: true
33307
33325
  });
33308
33326
  }
@@ -33450,7 +33468,7 @@ const publicAssetUrlCache = new WeakMap();
33450
33468
  const publicAssetUrlRE = /__VITE_PUBLIC_ASSET__([a-z\d]{8})__/g;
33451
33469
  function publicFileToBuiltUrl(url, config) {
33452
33470
  if (config.command !== 'build') {
33453
- // We don't need relative base or buildAdvancedBaseOptions support during dev
33471
+ // We don't need relative base or renderBuiltUrl support during dev
33454
33472
  return config.base + url.slice(1);
33455
33473
  }
33456
33474
  const hash = getHash(url);
@@ -33515,7 +33533,7 @@ async function fileToBuiltUrl(id, config, pluginContext, skipPublicCheck = false
33515
33533
  });
33516
33534
  emittedSet.add(contentHash);
33517
33535
  }
33518
- url = `__VITE_ASSET__${contentHash}__${postfix ? `$_${postfix}__` : ``}`;
33536
+ url = `__VITE_ASSET__${contentHash}__${postfix ? `$_${postfix}__` : ``}`; // TODO_BASE
33519
33537
  }
33520
33538
  cache.set(id, url);
33521
33539
  return url;
@@ -33838,8 +33856,7 @@ function resolvePlugin(resolveOptions) {
33838
33856
  }
33839
33857
  // relative
33840
33858
  if (id.startsWith('.') ||
33841
- (preferRelative && /^\w/.test(id)) ||
33842
- importer?.endsWith('.html')) {
33859
+ ((preferRelative || importer?.endsWith('.html')) && /^\w/.test(id))) {
33843
33860
  const basedir = importer ? path$o.dirname(importer) : process.cwd();
33844
33861
  const fsPath = path$o.resolve(basedir, id);
33845
33862
  // handle browser field mapping for relative imports
@@ -33884,7 +33901,8 @@ function resolvePlugin(resolveOptions) {
33884
33901
  }
33885
33902
  }
33886
33903
  // absolute fs paths
33887
- if (path$o.isAbsolute(id) && (res = tryFsResolve(id, options))) {
33904
+ if (isNonDriveRelativeAbsolutePath(id) &&
33905
+ (res = tryFsResolve(id, options))) {
33888
33906
  isDebug$4 && debug$c(`[fs] ${picocolors.exports.cyan(id)} -> ${picocolors.exports.dim(res)}`);
33889
33907
  return res;
33890
33908
  }
@@ -37535,9 +37553,8 @@ function transformRequest(url, server, options = {}) {
37535
37553
  }
37536
37554
  async function doTransform(url, server, options, timestamp) {
37537
37555
  url = removeTimestampQuery(url);
37538
- const { config, pluginContainer, moduleGraph, watcher } = server;
37539
- const { root, logger } = config;
37540
- const prettyUrl = isDebug$3 ? prettifyUrl(url, root) : '';
37556
+ const { config, pluginContainer } = server;
37557
+ const prettyUrl = isDebug$3 ? prettifyUrl(url, config.root) : '';
37541
37558
  const ssr = !!options.ssr;
37542
37559
  const module = await server.moduleGraph.getModuleByUrl(url, ssr);
37543
37560
  // check if we have a fresh cache
@@ -37553,6 +37570,18 @@ async function doTransform(url, server, options, timestamp) {
37553
37570
  }
37554
37571
  // resolve
37555
37572
  const id = (await pluginContainer.resolveId(url, undefined, { ssr }))?.id || url;
37573
+ const result = loadAndTransform(id, url, server, options, timestamp);
37574
+ const depsOptimizer = getDepsOptimizer(config);
37575
+ if (depsOptimizer && !config.legacy?.devDepsScanner) {
37576
+ depsOptimizer.delayDepsOptimizerUntil(id, () => result);
37577
+ }
37578
+ return result;
37579
+ }
37580
+ async function loadAndTransform(id, url, server, options, timestamp) {
37581
+ const { config, pluginContainer, moduleGraph, watcher } = server;
37582
+ const { root, logger } = config;
37583
+ const prettyUrl = isDebug$3 ? prettifyUrl(url, config.root) : '';
37584
+ const ssr = !!options.ssr;
37556
37585
  const file = cleanUrl(id);
37557
37586
  let code = null;
37558
37587
  let map = null;
@@ -38360,7 +38389,7 @@ async function runOptimizeDeps(resolvedConfig, depsInfo, ssr = !!resolvedConfig.
38360
38389
  : 'browser',
38361
38390
  define,
38362
38391
  format: 'esm',
38363
- target: config.build.target || undefined,
38392
+ target: isBuild ? config.build.target || undefined : ESBUILD_MODULES_TARGET,
38364
38393
  external: config.optimizeDeps?.exclude,
38365
38394
  logLevel: 'error',
38366
38395
  splitting: true,
@@ -38372,7 +38401,12 @@ async function runOptimizeDeps(resolvedConfig, depsInfo, ssr = !!resolvedConfig.
38372
38401
  ...plugins,
38373
38402
  esbuildDepPlugin(flatIdDeps, flatIdToExports, config)
38374
38403
  ],
38375
- ...esbuildOptions
38404
+ ...esbuildOptions,
38405
+ supported: {
38406
+ 'dynamic-import': true,
38407
+ 'import-meta': true,
38408
+ ...esbuildOptions.supported
38409
+ }
38376
38410
  });
38377
38411
  const meta = result.metafile;
38378
38412
  // the paths in `meta.outputs` are relative to `process.cwd()`
@@ -40143,7 +40177,7 @@ function importAnalysisPlugin(config) {
40143
40177
  if (config.server.preTransformRequests && staticImportedUrls.size) {
40144
40178
  staticImportedUrls.forEach(({ url, id }) => {
40145
40179
  url = unwrapId(removeImportQuery(url)).replace(NULL_BYTE_PLACEHOLDER, '\0');
40146
- const request = transformRequest(url, server, { ssr }).catch((e) => {
40180
+ transformRequest(url, server, { ssr }).catch((e) => {
40147
40181
  if (e?.code === ERR_OUTDATED_OPTIMIZED_DEP) {
40148
40182
  // This are expected errors
40149
40183
  return;
@@ -40151,9 +40185,6 @@ function importAnalysisPlugin(config) {
40151
40185
  // Unexpected error, log the issue but avoid an unhandled exception
40152
40186
  config.logger.error(e.message);
40153
40187
  });
40154
- if (depsOptimizer && !config.legacy?.devDepsScanner) {
40155
- depsOptimizer.delayDepsOptimizerUntil(id, () => request);
40156
- }
40157
40188
  });
40158
40189
  }
40159
40190
  if (s) {
@@ -40339,16 +40370,13 @@ function buildImportAnalysisPlugin(config) {
40339
40370
  const ssr = !!config.build.ssr;
40340
40371
  const isWorker = config.isWorker;
40341
40372
  const insertPreload = !(ssr || !!config.build.lib || isWorker);
40342
- const assetsBase = config.experimental.buildAdvancedBaseOptions.assets;
40343
- const relativePreloadUrls = !(assetsBase.url || assetsBase.runtime);
40373
+ const relativePreloadUrls = config.base === './' || config.base === '';
40344
40374
  const scriptRel = config.build.polyfillModulePreload
40345
40375
  ? `'modulepreload'`
40346
40376
  : `(${detectScriptRel.toString()})()`;
40347
40377
  const assetsURL = relativePreloadUrls
40348
40378
  ? `function(dep,importerUrl) { return new URL(dep, importerUrl).href }`
40349
- : `function(dep) { return ${assetsBase.runtime
40350
- ? assetsBase.runtime('dep')
40351
- : `${JSON.stringify(assetsBase.url ?? config.base)}+dep`}}`;
40379
+ : `function(dep) { return ${JSON.stringify(config.base)}+dep }`;
40352
40380
  const preloadCode = `const scriptRel = ${scriptRel};const assetsURL = ${assetsURL};const seen = {};export const ${preloadMethod} = ${preload.toString()}`;
40353
40381
  return {
40354
40382
  name: 'vite:build-import-analysis',
@@ -40761,7 +40789,7 @@ const assetAttrsConfig = {
40761
40789
  const isAsyncScriptMap = new WeakMap();
40762
40790
  async function traverseHtml(html, filePath, visitor) {
40763
40791
  // lazy load compiler
40764
- const { parse, transform } = await import('./dep-02aa3d4a.js').then(function (n) { return n.c; });
40792
+ const { parse, transform } = await import('./dep-f32eac6f.js').then(function (n) { return n.c; });
40765
40793
  // @vue/compiler-core doesn't like lowercase doctypes
40766
40794
  html = html.replace(/<!doctype\s/i, '<!DOCTYPE ');
40767
40795
  try {
@@ -40835,7 +40863,9 @@ function buildHtmlPlugin(config) {
40835
40863
  if (id.endsWith('.html')) {
40836
40864
  const relativeUrlPath = slash$1(path$o.relative(config.root, id));
40837
40865
  const publicPath = `/${relativeUrlPath}`;
40838
- const publicBase = getPublicBase(relativeUrlPath, config);
40866
+ const publicBase = getBaseInHTML(relativeUrlPath, config);
40867
+ const publicToRelative = (filename, importer) => publicBase + filename;
40868
+ const toOutputPublicFilePath = (url) => toOutputFilePathInHtml(url.slice(1), 'public', relativeUrlPath, 'html', config, publicToRelative);
40839
40869
  // pre-transform
40840
40870
  html = await applyHtmlTransforms(html, preHooks, {
40841
40871
  path: publicPath,
@@ -40862,7 +40892,7 @@ function buildHtmlPlugin(config) {
40862
40892
  const isPublicFile = !!(url && checkPublicFile(url, config));
40863
40893
  if (isPublicFile) {
40864
40894
  // referencing public dir url, prefix with base
40865
- s.overwrite(src.value.loc.start.offset, src.value.loc.end.offset, `"${normalizePublicPath(url, publicBase)}"`, { contentOnly: true });
40895
+ s.overwrite(src.value.loc.start.offset, src.value.loc.end.offset, `"${toOutputPublicFilePath(url)}"`, { contentOnly: true });
40866
40896
  }
40867
40897
  if (isModule) {
40868
40898
  inlineModuleIndex++;
@@ -40936,7 +40966,7 @@ function buildHtmlPlugin(config) {
40936
40966
  }
40937
40967
  }
40938
40968
  else if (checkPublicFile(url, config)) {
40939
- s.overwrite(p.value.loc.start.offset, p.value.loc.end.offset, `"${normalizePublicPath(url, publicBase)}"`, { contentOnly: true });
40969
+ s.overwrite(p.value.loc.start.offset, p.value.loc.end.offset, `"${toOutputPublicFilePath(url)}"`, { contentOnly: true });
40940
40970
  }
40941
40971
  }
40942
40972
  }
@@ -41016,7 +41046,7 @@ function buildHtmlPlugin(config) {
41016
41046
  s.overwrite(start, end, await urlToBuiltUrl(url, id, config, this), { contentOnly: true });
41017
41047
  }
41018
41048
  else if (checkPublicFile(url, config)) {
41019
- s.overwrite(start, end, normalizePublicPath(url, publicBase), {
41049
+ s.overwrite(start, end, toOutputPublicFilePath(url), {
41020
41050
  contentOnly: true
41021
41051
  });
41022
41052
  }
@@ -41060,31 +41090,31 @@ function buildHtmlPlugin(config) {
41060
41090
  });
41061
41091
  return chunks;
41062
41092
  };
41063
- const toScriptTag = (chunk, assetsBase, isAsync) => ({
41093
+ const toScriptTag = (chunk, toOutputPath, isAsync) => ({
41064
41094
  tag: 'script',
41065
41095
  attrs: {
41066
41096
  ...(isAsync ? { async: true } : {}),
41067
41097
  type: 'module',
41068
41098
  crossorigin: true,
41069
- src: toPublicPath(chunk.fileName, assetsBase)
41099
+ src: toOutputPath(chunk.fileName)
41070
41100
  }
41071
41101
  });
41072
- const toPreloadTag = (chunk, assetsBase) => ({
41102
+ const toPreloadTag = (chunk, toOutputPath) => ({
41073
41103
  tag: 'link',
41074
41104
  attrs: {
41075
41105
  rel: 'modulepreload',
41076
41106
  crossorigin: true,
41077
- href: toPublicPath(chunk.fileName, assetsBase)
41107
+ href: toOutputPath(chunk.fileName)
41078
41108
  }
41079
41109
  });
41080
- const getCssTagsForChunk = (chunk, assetsBase, seen = new Set()) => {
41110
+ const getCssTagsForChunk = (chunk, toOutputPath, seen = new Set()) => {
41081
41111
  const tags = [];
41082
41112
  if (!analyzedChunk.has(chunk)) {
41083
41113
  analyzedChunk.set(chunk, 1);
41084
41114
  chunk.imports.forEach((file) => {
41085
41115
  const importee = bundle[file];
41086
41116
  if (importee?.type === 'chunk') {
41087
- tags.push(...getCssTagsForChunk(importee, assetsBase, seen));
41117
+ tags.push(...getCssTagsForChunk(importee, toOutputPath, seen));
41088
41118
  }
41089
41119
  });
41090
41120
  }
@@ -41095,7 +41125,7 @@ function buildHtmlPlugin(config) {
41095
41125
  tag: 'link',
41096
41126
  attrs: {
41097
41127
  rel: 'stylesheet',
41098
- href: toPublicPath(file, assetsBase)
41128
+ href: toOutputPath(file)
41099
41129
  }
41100
41130
  });
41101
41131
  }
@@ -41104,7 +41134,15 @@ function buildHtmlPlugin(config) {
41104
41134
  };
41105
41135
  for (const [id, html] of processedHtml) {
41106
41136
  const relativeUrlPath = path$o.posix.relative(config.root, id);
41107
- const assetsBase = getAssetsBase(relativeUrlPath, config);
41137
+ const assetsBase = getBaseInHTML(relativeUrlPath, config);
41138
+ const toOutputAssetFilePath = (filename) => {
41139
+ if (isExternalUrl(filename)) {
41140
+ return filename;
41141
+ }
41142
+ else {
41143
+ return toOutputFilePathInHtml(filename, 'asset', relativeUrlPath, 'html', config, (filename, importer) => assetsBase + filename);
41144
+ }
41145
+ };
41108
41146
  const isAsync = isAsyncScriptMap.get(config).get(id);
41109
41147
  let result = html;
41110
41148
  // find corresponding entry chunk
@@ -41124,12 +41162,12 @@ function buildHtmlPlugin(config) {
41124
41162
  // when inlined, discard entry chunk and inject <script> for everything in post-order
41125
41163
  const imports = getImportedChunks(chunk);
41126
41164
  const assetTags = canInlineEntry
41127
- ? imports.map((chunk) => toScriptTag(chunk, assetsBase, isAsync))
41165
+ ? imports.map((chunk) => toScriptTag(chunk, toOutputAssetFilePath, isAsync))
41128
41166
  : [
41129
- toScriptTag(chunk, assetsBase, isAsync),
41130
- ...imports.map((i) => toPreloadTag(i, assetsBase))
41167
+ toScriptTag(chunk, toOutputAssetFilePath, isAsync),
41168
+ ...imports.map((i) => toPreloadTag(i, toOutputAssetFilePath))
41131
41169
  ];
41132
- assetTags.push(...getCssTagsForChunk(chunk, assetsBase));
41170
+ assetTags.push(...getCssTagsForChunk(chunk, toOutputAssetFilePath));
41133
41171
  result = injectToHead(result, assetTags);
41134
41172
  }
41135
41173
  // inject css link when cssCodeSplit is false
@@ -41141,7 +41179,7 @@ function buildHtmlPlugin(config) {
41141
41179
  tag: 'link',
41142
41180
  attrs: {
41143
41181
  rel: 'stylesheet',
41144
- href: toPublicPath(cssChunk.fileName, assetsBase)
41182
+ href: toOutputAssetFilePath(cssChunk.fileName)
41145
41183
  }
41146
41184
  }
41147
41185
  ]);
@@ -41167,7 +41205,7 @@ function buildHtmlPlugin(config) {
41167
41205
  });
41168
41206
  // resolve asset url references
41169
41207
  result = result.replace(assetUrlRE, (_, fileHash, postfix = '') => {
41170
- return assetsBase + getAssetFilename(fileHash, config) + postfix;
41208
+ return (toOutputAssetFilePath(getAssetFilename(fileHash, config)) + postfix);
41171
41209
  });
41172
41210
  if (chunk && canInlineEntry) {
41173
41211
  // all imports from entry have been inlined to html, prevent rollup from outputting it
@@ -41253,25 +41291,12 @@ function isEntirelyImport(code) {
41253
41291
  // the regexes will remove too little in some exotic cases, but false-negatives are alright
41254
41292
  return !code.replace(importRE, '').replace(commentRE, '').trim().length;
41255
41293
  }
41256
- function getBaseInHTML(urlRelativePath, baseOptions, config) {
41294
+ function getBaseInHTML(urlRelativePath, config) {
41257
41295
  // Prefer explicit URL if defined for linking to assets and public files from HTML,
41258
41296
  // even when base relative is specified
41259
- return (baseOptions.url ??
41260
- (baseOptions.relative
41261
- ? path$o.posix.join(path$o.posix.relative(urlRelativePath, '').slice(0, -2), './')
41262
- : config.base));
41263
- }
41264
- function getPublicBase(urlRelativePath, config) {
41265
- return getBaseInHTML(urlRelativePath, config.experimental.buildAdvancedBaseOptions.public, config);
41266
- }
41267
- function getAssetsBase(urlRelativePath, config) {
41268
- return getBaseInHTML(urlRelativePath, config.experimental.buildAdvancedBaseOptions.assets, config);
41269
- }
41270
- function toPublicPath(filename, publicBase) {
41271
- return isExternalUrl(filename) ? filename : publicBase + filename;
41272
- }
41273
- function normalizePublicPath(publicPath, publicBase) {
41274
- return publicBase + publicPath.slice(1);
41297
+ return config.base === './' || config.base === ''
41298
+ ? path$o.posix.join(path$o.posix.relative(urlRelativePath, '').slice(0, -2), './')
41299
+ : config.base;
41275
41300
  }
41276
41301
  const headInjectRE = /([ \t]*)<\/head>/i;
41277
41302
  const headPrependInjectRE = /([ \t]*)<head[^>]*>/i;
@@ -41629,38 +41654,29 @@ function cssPostPlugin(config) {
41629
41654
  // resolve asset URL placeholders to their built file URLs
41630
41655
  function resolveAssetUrlsInCss(chunkCSS, cssAssetName) {
41631
41656
  const encodedPublicUrls = encodePublicUrlsInCSS(config);
41632
- const { assets: assetsBase, public: publicBase } = config.experimental.buildAdvancedBaseOptions;
41633
- const cssAssetDirname = encodedPublicUrls || assetsBase.relative
41657
+ const relative = config.base === './' || config.base === '';
41658
+ const cssAssetDirname = encodedPublicUrls || relative
41634
41659
  ? getCssAssetDirname(cssAssetName)
41635
41660
  : undefined;
41661
+ const toRelative = (filename, importer) => {
41662
+ // relative base + extracted CSS
41663
+ const relativePath = path$o.posix.relative(cssAssetDirname, filename);
41664
+ return relativePath.startsWith('.')
41665
+ ? relativePath
41666
+ : './' + relativePath;
41667
+ };
41636
41668
  // replace asset url references with resolved url.
41637
41669
  chunkCSS = chunkCSS.replace(assetUrlRE, (_, fileHash, postfix = '') => {
41638
41670
  const filename = getAssetFilename(fileHash, config) + postfix;
41639
41671
  chunk.viteMetadata.importedAssets.add(cleanUrl(filename));
41640
- if (assetsBase.relative && !config.build.ssr) {
41641
- // relative base + extracted CSS
41642
- const relativePath = path$o.posix.relative(cssAssetDirname, filename);
41643
- return relativePath.startsWith('.')
41644
- ? relativePath
41645
- : './' + relativePath;
41646
- }
41647
- else {
41648
- // assetsBase.runtime has no effect for assets in CSS
41649
- return (assetsBase.url ?? config.base) + filename;
41650
- }
41672
+ return toOutputFilePathInCss(filename, 'asset', cssAssetName, 'css', config, toRelative);
41651
41673
  });
41652
41674
  // resolve public URL from CSS paths
41653
41675
  if (encodedPublicUrls) {
41654
41676
  const relativePathToPublicFromCSS = path$o.posix.relative(cssAssetDirname, '');
41655
41677
  chunkCSS = chunkCSS.replace(publicAssetUrlRE, (_, hash) => {
41656
- const publicUrl = publicAssetUrlMap.get(hash);
41657
- if (publicBase.relative && !config.build.ssr) {
41658
- return relativePathToPublicFromCSS + publicUrl;
41659
- }
41660
- else {
41661
- // publicBase.runtime has no effect for assets in CSS
41662
- return (publicBase.url ?? config.base) + publicUrl.slice(1);
41663
- }
41678
+ const publicUrl = publicAssetUrlMap.get(hash).slice(1);
41679
+ return toOutputFilePathInCss(publicUrl, 'public', cssAssetName, 'css', config, () => `${relativePathToPublicFromCSS}/${publicUrl}`);
41664
41680
  });
41665
41681
  }
41666
41682
  return chunkCSS;
@@ -41896,7 +41912,7 @@ async function compileCSS(id, code, config, urlReplacer, atImportResolvers, serv
41896
41912
  logger: config.logger
41897
41913
  }));
41898
41914
  if (isModule) {
41899
- postcssPlugins.unshift((await import('./dep-30bcfc51.js').then(function (n) { return n.i; })).default({
41915
+ postcssPlugins.unshift((await import('./dep-a4ad4a6b.js').then(function (n) { return n.i; })).default({
41900
41916
  ...modulesOptions,
41901
41917
  getJSON(cssFileName, _modules, outputFileName) {
41902
41918
  modules = _modules;
@@ -42188,8 +42204,8 @@ async function minifyCSS(css, config) {
42188
42204
  try {
42189
42205
  const { code, warnings } = await transform$2(css, {
42190
42206
  loader: 'css',
42191
- minify: true,
42192
- target: config.build.cssTarget || undefined
42207
+ target: config.build.cssTarget || undefined,
42208
+ ...resolveEsbuildMinifyOptions(config.esbuild || {})
42193
42209
  });
42194
42210
  if (warnings.length) {
42195
42211
  const msgs = await formatMessages(warnings, { kind: 'warning' });
@@ -42206,6 +42222,20 @@ async function minifyCSS(css, config) {
42206
42222
  throw e;
42207
42223
  }
42208
42224
  }
42225
+ function resolveEsbuildMinifyOptions(options) {
42226
+ if (options.minifyIdentifiers != null ||
42227
+ options.minifySyntax != null ||
42228
+ options.minifyWhitespace != null) {
42229
+ return {
42230
+ minifyIdentifiers: options.minifyIdentifiers ?? true,
42231
+ minifySyntax: options.minifySyntax ?? true,
42232
+ minifyWhitespace: options.minifyWhitespace ?? true
42233
+ };
42234
+ }
42235
+ else {
42236
+ return { minify: true };
42237
+ }
42238
+ }
42209
42239
  async function hoistAtRules(css) {
42210
42240
  const s = new MagicString(css);
42211
42241
  const cleanCss = emptyCssComments(css);
@@ -42923,15 +42953,7 @@ function resolveBuildOptions(raw, isBuild, logger) {
42923
42953
  };
42924
42954
  // handle special build targets
42925
42955
  if (resolved.target === 'modules') {
42926
- // Support browserslist
42927
- // "defaults and supports es6-module and supports es6-module-dynamic-import",
42928
- resolved.target = [
42929
- 'es2020',
42930
- 'edge88',
42931
- 'firefox78',
42932
- 'chrome87',
42933
- 'safari13' // transpile nullish coalescing
42934
- ];
42956
+ resolved.target = ESBUILD_MODULES_TARGET;
42935
42957
  }
42936
42958
  else if (resolved.target === 'esnext' && resolved.minify === 'terser') {
42937
42959
  // esnext + terser: limit to es2021 so it can be minified by terser
@@ -43352,39 +43374,64 @@ function wrapSsrTransform(fn) {
43352
43374
  function injectSsrFlag(options) {
43353
43375
  return { ...(options ?? {}), ssr: true };
43354
43376
  }
43355
- /**
43356
- * Resolve base. Note that some users use Vite to build for non-web targets like
43357
- * electron or expects to deploy
43358
- */
43359
- function resolveBuildAdvancedBaseConfig(baseConfig, resolvedBase, isBuild, logger) {
43360
- baseConfig ?? (baseConfig = {});
43361
- const relativeBaseShortcut = resolvedBase === '' || resolvedBase === './';
43362
- const resolved = {
43363
- relative: baseConfig?.relative ?? relativeBaseShortcut,
43364
- url: baseConfig?.url
43365
- ? resolveBaseUrl(baseConfig?.url, isBuild, logger, 'experimental.buildAdvancedBaseOptions.url')
43366
- : undefined,
43367
- runtime: baseConfig?.runtime
43368
- };
43369
- return {
43370
- ...resolved,
43371
- assets: resolveBuildBaseSpecificOptions(baseConfig?.assets, resolved, isBuild, logger, 'assets'),
43372
- public: resolveBuildBaseSpecificOptions(baseConfig?.public, resolved, isBuild, logger, 'public')
43373
- };
43377
+ function toOutputFilePathInString(filename, type, hostId, hostType, config, toRelative) {
43378
+ const { renderBuiltUrl } = config.experimental;
43379
+ let relative = config.base === '' || config.base === './';
43380
+ if (renderBuiltUrl) {
43381
+ const result = renderBuiltUrl(filename, {
43382
+ hostId,
43383
+ hostType,
43384
+ type,
43385
+ ssr: !!config.build.ssr
43386
+ });
43387
+ if (typeof result === 'object') {
43388
+ if (result.runtime) {
43389
+ return { runtime: result.runtime };
43390
+ }
43391
+ if (typeof result.relative === 'boolean') {
43392
+ relative = result.relative;
43393
+ }
43394
+ }
43395
+ else if (result) {
43396
+ return result;
43397
+ }
43398
+ }
43399
+ if (relative && !config.build.ssr) {
43400
+ return toRelative(filename, hostId);
43401
+ }
43402
+ return config.base + filename;
43374
43403
  }
43375
- function resolveBuildBaseSpecificOptions(options, parent, isBuild, logger, optionName) {
43376
- const urlConfigPath = `experimental.buildAdvancedBaseOptions.${optionName}.url`;
43377
- if (typeof options === 'string') {
43378
- options = { url: options };
43404
+ function toOutputFilePathWithoutRuntime(filename, type, hostId, hostType, config, toRelative) {
43405
+ const { renderBuiltUrl } = config.experimental;
43406
+ let relative = config.base === '' || config.base === './';
43407
+ if (renderBuiltUrl) {
43408
+ const result = renderBuiltUrl(filename, {
43409
+ hostId,
43410
+ hostType,
43411
+ type,
43412
+ ssr: !!config.build.ssr
43413
+ });
43414
+ if (typeof result === 'object') {
43415
+ if (result.runtime) {
43416
+ throw new Error(`{ runtime: "${result.runtime} }" is not supported for assets in ${hostType} files: ${filename}`);
43417
+ }
43418
+ if (typeof result.relative === 'boolean') {
43419
+ relative = result.relative;
43420
+ }
43421
+ }
43422
+ else if (result) {
43423
+ return result;
43424
+ }
43425
+ }
43426
+ if (relative && !config.build.ssr) {
43427
+ return toRelative(filename, hostId);
43428
+ }
43429
+ else {
43430
+ return config.base + filename;
43379
43431
  }
43380
- return {
43381
- relative: options?.relative ?? parent.relative,
43382
- url: options?.url
43383
- ? resolveBaseUrl(options?.url, isBuild, logger, urlConfigPath)
43384
- : parent.url,
43385
- runtime: options?.runtime ?? parent.runtime
43386
- };
43387
43432
  }
43433
+ const toOutputFilePathInCss = toOutputFilePathWithoutRuntime;
43434
+ const toOutputFilePathInHtml = toOutputFilePathWithoutRuntime;
43388
43435
 
43389
43436
  var build$1 = {
43390
43437
  __proto__: null,
@@ -43393,7 +43440,10 @@ var build$1 = {
43393
43440
  build: build,
43394
43441
  resolveLibFilename: resolveLibFilename,
43395
43442
  onRollupWarning: onRollupWarning,
43396
- resolveBuildAdvancedBaseConfig: resolveBuildAdvancedBaseConfig
43443
+ toOutputFilePathInString: toOutputFilePathInString,
43444
+ toOutputFilePathWithoutRuntime: toOutputFilePathWithoutRuntime,
43445
+ toOutputFilePathInCss: toOutputFilePathInCss,
43446
+ toOutputFilePathInHtml: toOutputFilePathInHtml
43397
43447
  };
43398
43448
 
43399
43449
  var src = {exports: {}};
@@ -49748,7 +49798,7 @@ async function getCertificate(cacheDir) {
49748
49798
  return content;
49749
49799
  }
49750
49800
  catch {
49751
- const content = (await import('./dep-d55123c0.js')).createCertificate();
49801
+ const content = (await import('./dep-39250386.js')).createCertificate();
49752
49802
  promises$2
49753
49803
  .mkdir(cacheDir, { recursive: true })
49754
49804
  .then(() => promises$2.writeFile(cachePath, content))
@@ -59463,6 +59513,14 @@ function emitSourcemapForWorkerEntry(config, query, chunk) {
59463
59513
  }
59464
59514
  return chunk;
59465
59515
  }
59516
+ // TODO:base review why we aren't using import.meta.url here
59517
+ function toStaticRelativePath(filename, importer) {
59518
+ let outputFilepath = path$o.posix.relative(path$o.dirname(importer), filename);
59519
+ if (!outputFilepath.startsWith('.')) {
59520
+ outputFilepath = './' + outputFilepath;
59521
+ }
59522
+ return outputFilepath;
59523
+ }
59466
59524
  const workerAssetUrlRE = /__VITE_WORKER_ASSET__([a-z\d]{8})__/g;
59467
59525
  function encodeWorkerAssetFileName(fileName, workerCache) {
59468
59526
  const { fileNameHash } = workerCache;
@@ -59485,10 +59543,7 @@ async function workerFileToUrl(config, id, query) {
59485
59543
  });
59486
59544
  workerMap.bundle.set(id, fileName);
59487
59545
  }
59488
- const assetsBase = config.experimental.buildAdvancedBaseOptions.assets;
59489
- return assetsBase.relative || assetsBase.runtime
59490
- ? encodeWorkerAssetFileName(fileName, workerMap)
59491
- : (assetsBase.url ?? config.base) + fileName;
59546
+ return encodeWorkerAssetFileName(fileName, workerMap);
59492
59547
  }
59493
59548
  function webWorkerPlugin(config) {
59494
59549
  const isBuild = config.command === 'build';
@@ -59617,29 +59672,14 @@ function webWorkerPlugin(config) {
59617
59672
  // Replace "__VITE_WORKER_ASSET__5aa0ddc0__" using relative paths
59618
59673
  const workerMap = workerCache.get(config.mainConfig || config);
59619
59674
  const { fileNameHash } = workerMap;
59620
- const assetsBase = config.experimental.buildAdvancedBaseOptions.assets;
59621
59675
  while ((match = workerAssetUrlRE.exec(code))) {
59622
59676
  const [full, hash] = match;
59623
59677
  const filename = fileNameHash.get(hash);
59624
- let replacement;
59625
- if (assetsBase.runtime) {
59626
- replacement = `"+${assetsBase.runtime(JSON.stringify(filename))}+"`;
59627
- }
59628
- else {
59629
- // Relative base
59630
- let outputFilepath;
59631
- if (assetsBase.relative && !config.build.ssr) {
59632
- outputFilepath = path$o.posix.relative(path$o.dirname(chunk.fileName), filename);
59633
- if (!outputFilepath.startsWith('.')) {
59634
- outputFilepath = './' + outputFilepath;
59635
- }
59636
- }
59637
- else {
59638
- outputFilepath = (assetsBase.url ?? config.base) + filename;
59639
- }
59640
- replacement = JSON.stringify(outputFilepath).slice(1, -1);
59641
- }
59642
- s.overwrite(match.index, match.index + full.length, replacement, {
59678
+ const replacement = toOutputFilePathInString(filename, 'asset', chunk.fileName, 'js', config, toStaticRelativePath);
59679
+ const replacementString = typeof replacement === 'string'
59680
+ ? JSON.stringify(replacement).slice(1, -1)
59681
+ : `"+${replacement.runtime}+"`;
59682
+ s.overwrite(match.index, match.index + full.length, replacementString, {
59643
59683
  contentOnly: true
59644
59684
  });
59645
59685
  }
@@ -61969,19 +62009,12 @@ async function resolveConfig(inlineConfig, command, defaultMode = 'development')
61969
62009
  const relativeBaseShortcut = config.base === '' || config.base === './';
61970
62010
  // During dev, we ignore relative base and fallback to '/'
61971
62011
  // For the SSR build, relative base isn't possible by means
61972
- // of import.meta.url. The user will be able to work out a setup
61973
- // using experimental.buildAdvancedBaseOptions
61974
- const base = relativeBaseShortcut && (!isBuild || config.build?.ssr)
61975
- ? '/'
61976
- : config.base ?? '/';
61977
- let resolvedBase = relativeBaseShortcut
61978
- ? base
61979
- : resolveBaseUrl(base, isBuild, logger, 'base');
61980
- if (config.experimental?.buildAdvancedBaseOptions?.relative &&
61981
- config.base === undefined) {
61982
- resolvedBase = './';
61983
- }
61984
- const resolvedBuildAdvancedBaseOptions = resolveBuildAdvancedBaseConfig(config.experimental?.buildAdvancedBaseOptions, resolvedBase, isBuild, logger);
62012
+ // of import.meta.url.
62013
+ const resolvedBase = relativeBaseShortcut
62014
+ ? !isBuild || config.build?.ssr
62015
+ ? '/'
62016
+ : './'
62017
+ : resolveBaseUrl(config.base, isBuild, logger) ?? '/';
61985
62018
  const resolvedBuildOptions = resolveBuildOptions(config.build);
61986
62019
  // resolve cache directory
61987
62020
  const pkgPath = lookupFile(resolvedRoot, [`package.json`], { pathOnly: true });
@@ -62099,8 +62132,7 @@ async function resolveConfig(inlineConfig, command, defaultMode = 'development')
62099
62132
  experimental: {
62100
62133
  importGlobRestoreExtension: false,
62101
62134
  hmrPartialAccept: false,
62102
- ...config.experimental,
62103
- buildAdvancedBaseOptions: resolvedBuildAdvancedBaseOptions
62135
+ ...config.experimental
62104
62136
  }
62105
62137
  };
62106
62138
  if (middlewareMode === 'ssr') {
@@ -62166,9 +62198,9 @@ assetFileNames isn't equal for every build.rollupOptions.output. A single patter
62166
62198
  * Resolve base url. Note that some users use Vite to build for non-web targets like
62167
62199
  * electron or expects to deploy
62168
62200
  */
62169
- function resolveBaseUrl(base = '/', isBuild, logger, optionName) {
62201
+ function resolveBaseUrl(base = '/', isBuild, logger) {
62170
62202
  if (base.startsWith('.')) {
62171
- logger.warn(picocolors.exports.yellow(picocolors.exports.bold(`(!) invalid "${optionName}" option: ${base}. The value can only be an absolute ` +
62203
+ logger.warn(picocolors.exports.yellow(picocolors.exports.bold(`(!) invalid "base" option: ${base}. The value can only be an absolute ` +
62172
62204
  `URL, ./, or an empty string.`)));
62173
62205
  base = '/';
62174
62206
  }
@@ -62183,13 +62215,13 @@ function resolveBaseUrl(base = '/', isBuild, logger, optionName) {
62183
62215
  else {
62184
62216
  // ensure leading slash
62185
62217
  if (!base.startsWith('/')) {
62186
- logger.warn(picocolors.exports.yellow(picocolors.exports.bold(`(!) "${optionName}" option should start with a slash.`)));
62218
+ logger.warn(picocolors.exports.yellow(picocolors.exports.bold(`(!) "base" option should start with a slash.`)));
62187
62219
  base = '/' + base;
62188
62220
  }
62189
62221
  }
62190
62222
  // ensure ending slash
62191
62223
  if (!base.endsWith('/')) {
62192
- logger.warn(picocolors.exports.yellow(picocolors.exports.bold(`(!) "${optionName}" option should end with a slash.`)));
62224
+ logger.warn(picocolors.exports.yellow(picocolors.exports.bold(`(!) "base" option should end with a slash.`)));
62193
62225
  base += '/';
62194
62226
  }
62195
62227
  return base;
@@ -1,4 +1,4 @@
1
- import { y as commonjsGlobal } from './dep-07df4e90.js';
1
+ import { y as commonjsGlobal } from './dep-332aa27f.js';
2
2
  import require$$5 from 'crypto';
3
3
  import 'node:fs';
4
4
  import 'node:path';
@@ -25,7 +25,6 @@ import 'node:dns';
25
25
  import 'resolve';
26
26
  import '../constants.js';
27
27
  import 'buffer';
28
- import 'querystring';
29
28
  import 'module';
30
29
  import 'zlib';
31
30
  import 'https';
@@ -33,6 +32,7 @@ import 'tls';
33
32
  import 'node:http';
34
33
  import 'node:https';
35
34
  import 'worker_threads';
35
+ import 'querystring';
36
36
  import 'readline';
37
37
  import 'node:child_process';
38
38
  import 'node:zlib';
@@ -1,5 +1,5 @@
1
1
  import require$$0 from 'postcss';
2
- import { y as commonjsGlobal } from './dep-07df4e90.js';
2
+ import { y as commonjsGlobal } from './dep-332aa27f.js';
3
3
  import path$2 from 'path';
4
4
  import require$$5 from 'crypto';
5
5
  import require$$0__default from 'fs';
@@ -1,4 +1,4 @@
1
- import { z as getAugmentedNamespace, A as getDefaultExportFromCjs } from './dep-07df4e90.js';
1
+ import { z as getAugmentedNamespace, A as getDefaultExportFromCjs } from './dep-332aa27f.js';
2
2
 
3
3
  import { fileURLToPath as __cjs_fileURLToPath } from 'node:url';
4
4
  import { dirname as __cjs_dirname } from 'node:path';
package/dist/node/cli.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { performance } from 'node:perf_hooks';
2
2
  import { EventEmitter } from 'events';
3
- import { x as picocolors, q as createLogger, e as resolveConfig } from './chunks/dep-07df4e90.js';
3
+ import { x as picocolors, q as createLogger, e as resolveConfig } from './chunks/dep-332aa27f.js';
4
4
  import { VERSION } from './constants.js';
5
5
  import 'node:fs';
6
6
  import 'node:path';
@@ -25,7 +25,6 @@ import 'node:dns';
25
25
  import 'resolve';
26
26
  import 'crypto';
27
27
  import 'buffer';
28
- import 'querystring';
29
28
  import 'module';
30
29
  import 'zlib';
31
30
  import 'https';
@@ -33,6 +32,7 @@ import 'tls';
33
32
  import 'node:http';
34
33
  import 'node:https';
35
34
  import 'worker_threads';
35
+ import 'querystring';
36
36
  import 'readline';
37
37
  import 'node:child_process';
38
38
  import 'node:zlib';
@@ -694,7 +694,7 @@ cli
694
694
  .action(async (root, options) => {
695
695
  // output structure is preserved even after bundling so require()
696
696
  // is ok here
697
- const { createServer } = await import('./chunks/dep-07df4e90.js').then(function (n) { return n.D; });
697
+ const { createServer } = await import('./chunks/dep-332aa27f.js').then(function (n) { return n.D; });
698
698
  try {
699
699
  const server = await createServer({
700
700
  root,
@@ -741,7 +741,7 @@ cli
741
741
  .option('--emptyOutDir', `[boolean] force empty outDir when it's outside of root`)
742
742
  .option('-w, --watch', `[boolean] rebuilds when modules have changed on disk`)
743
743
  .action(async (root, options) => {
744
- const { build } = await import('./chunks/dep-07df4e90.js').then(function (n) { return n.C; });
744
+ const { build } = await import('./chunks/dep-332aa27f.js').then(function (n) { return n.C; });
745
745
  const buildOptions = cleanOptions(options);
746
746
  try {
747
747
  await build({
@@ -765,7 +765,7 @@ cli
765
765
  .command('optimize [root]', 'pre-bundle dependencies')
766
766
  .option('--force', `[boolean] force the optimizer to ignore the cache and re-bundle`)
767
767
  .action(async (root, options) => {
768
- const { optimizeDeps } = await import('./chunks/dep-07df4e90.js').then(function (n) { return n.B; });
768
+ const { optimizeDeps } = await import('./chunks/dep-332aa27f.js').then(function (n) { return n.B; });
769
769
  try {
770
770
  const config = await resolveConfig({
771
771
  root,
@@ -788,7 +788,7 @@ cli
788
788
  .option('--https', `[boolean] use TLS + HTTP/2`)
789
789
  .option('--open [path]', `[boolean | string] open browser on startup`)
790
790
  .action(async (root, options) => {
791
- const { preview } = await import('./chunks/dep-07df4e90.js').then(function (n) { return n.E; });
791
+ const { preview } = await import('./chunks/dep-332aa27f.js').then(function (n) { return n.E; });
792
792
  try {
793
793
  const server = await preview({
794
794
  root,
@@ -1,7 +1,7 @@
1
1
  import path, { resolve } from 'node:path';
2
2
  import { fileURLToPath } from 'node:url';
3
3
 
4
- var version = "3.0.0-beta.4";
4
+ var version = "3.0.0-beta.5";
5
5
 
6
6
  const VERSION = version;
7
7
  const DEFAULT_MAIN_FIELDS = [
@@ -9,6 +9,15 @@ const DEFAULT_MAIN_FIELDS = [
9
9
  'jsnext:main',
10
10
  'jsnext'
11
11
  ];
12
+ // Support browserslist
13
+ // "defaults and supports es6-module and supports es6-module-dynamic-import",
14
+ const ESBUILD_MODULES_TARGET = [
15
+ 'es2020',
16
+ 'edge88',
17
+ 'firefox78',
18
+ 'chrome87',
19
+ 'safari13' // transpile nullish coalescing
20
+ ];
12
21
  const DEFAULT_EXTENSIONS = [
13
22
  '.mjs',
14
23
  '.js',
@@ -106,4 +115,4 @@ const wildcardHosts = new Set([
106
115
  '0000:0000:0000:0000:0000:0000:0000:0000'
107
116
  ]);
108
117
 
109
- export { CLIENT_DIR, CLIENT_ENTRY, CLIENT_PUBLIC_PATH, DEFAULT_ASSETS_RE, DEFAULT_CONFIG_FILES, DEFAULT_EXTENSIONS, DEFAULT_MAIN_FIELDS, DEP_VERSION_RE, ENV_ENTRY, ENV_PUBLIC_PATH, FS_PREFIX, JS_TYPES_RE, KNOWN_ASSET_TYPES, NULL_BYTE_PLACEHOLDER, OPTIMIZABLE_ENTRY_RE, SPECIAL_QUERY_RE, VALID_ID_PREFIX, VERSION, VITE_PACKAGE_DIR, loopbackHosts, wildcardHosts };
118
+ export { CLIENT_DIR, CLIENT_ENTRY, CLIENT_PUBLIC_PATH, DEFAULT_ASSETS_RE, DEFAULT_CONFIG_FILES, DEFAULT_EXTENSIONS, DEFAULT_MAIN_FIELDS, DEP_VERSION_RE, ENV_ENTRY, ENV_PUBLIC_PATH, ESBUILD_MODULES_TARGET, FS_PREFIX, JS_TYPES_RE, KNOWN_ASSET_TYPES, NULL_BYTE_PLACEHOLDER, OPTIMIZABLE_ENTRY_RE, SPECIAL_QUERY_RE, VALID_ID_PREFIX, VERSION, VITE_PACKAGE_DIR, loopbackHosts, wildcardHosts };
@@ -104,26 +104,6 @@ export declare interface AwaitWriteFinishOptions {
104
104
  */
105
105
  export declare function build(inlineConfig?: InlineConfig): Promise<RollupOutput | RollupOutput[] | RollupWatcher>;
106
106
 
107
- export declare type BuildAdvancedBaseConfig = BuildAdvancedBaseOptions & {
108
- /**
109
- * Base for assets and public files in case they should be different
110
- */
111
- assets?: string | BuildAdvancedBaseOptions;
112
- public?: string | BuildAdvancedBaseOptions;
113
- };
114
-
115
- export declare interface BuildAdvancedBaseOptions {
116
- /**
117
- * Relative base. If true, every generated URL is relative and the dist folder
118
- * can be deployed to any base or subdomain. Use this option when the base
119
- * is unkown at build time
120
- * @default false
121
- */
122
- relative?: boolean;
123
- url?: string;
124
- runtime?: (filename: string) => string;
125
- }
126
-
127
107
  export declare interface BuildOptions {
128
108
  /**
129
109
  * Compatibility transform target. The transform is performed with esbuild
@@ -699,11 +679,11 @@ export declare interface ExperimentalOptions {
699
679
  */
700
680
  importGlobRestoreExtension?: boolean;
701
681
  /**
702
- * Build advanced base options. Allow finegrain contol over assets and public files base
682
+ * Allow finegrain contol over assets and public files paths
703
683
  *
704
684
  * @experimental
705
685
  */
706
- buildAdvancedBaseOptions?: BuildAdvancedBaseConfig;
686
+ renderBuiltUrl?: RenderBuiltAssetUrl;
707
687
  /**
708
688
  * Enables support of HMR partial accept via `import.meta.hot.acceptExports`.
709
689
  *
@@ -1653,19 +1633,24 @@ export declare interface PrunePayload {
1653
1633
  paths: string[]
1654
1634
  }
1655
1635
 
1636
+ export declare type RenderBuiltAssetUrl = (filename: string, type: {
1637
+ type: 'asset' | 'public';
1638
+ hostId: string;
1639
+ hostType: 'js' | 'css' | 'html';
1640
+ ssr: boolean;
1641
+ }) => string | {
1642
+ relative?: boolean;
1643
+ runtime?: string;
1644
+ } | undefined;
1645
+
1656
1646
  /**
1657
1647
  * Resolve base url. Note that some users use Vite to build for non-web targets like
1658
1648
  * electron or expects to deploy
1659
1649
  */
1660
- export declare function resolveBaseUrl(base: string | undefined, isBuild: boolean, logger: Logger, optionName: string): string;
1650
+ export declare function resolveBaseUrl(base: string | undefined, isBuild: boolean, logger: Logger): string;
1661
1651
 
1662
1652
  export declare function resolveConfig(inlineConfig: InlineConfig, command: 'build' | 'serve', defaultMode?: string): Promise<ResolvedConfig>;
1663
1653
 
1664
- export declare type ResolvedBuildAdvancedBaseConfig = BuildAdvancedBaseOptions & {
1665
- assets: BuildAdvancedBaseOptions;
1666
- public: BuildAdvancedBaseOptions;
1667
- };
1668
-
1669
1654
  export declare type ResolvedBuildOptions = Required<BuildOptions>;
1670
1655
 
1671
1656
  export declare type ResolvedConfig = Readonly<Omit<UserConfig, 'plugins' | 'assetsInclude' | 'optimizeDeps' | 'worker'> & {
@@ -1697,13 +1682,9 @@ export declare type ResolvedConfig = Readonly<Omit<UserConfig, 'plugins' | 'asse
1697
1682
  /* Excluded from this release type: packageCache */
1698
1683
  worker: ResolveWorkerOptions;
1699
1684
  appType: AppType;
1700
- experimental: ResolvedExperimentalOptions;
1685
+ experimental: ExperimentalOptions;
1701
1686
  }>;
1702
1687
 
1703
- export declare type ResolvedExperimentalOptions = Required<ExperimentalOptions> & {
1704
- buildAdvancedBaseOptions: ResolvedBuildAdvancedBaseConfig;
1705
- };
1706
-
1707
1688
  export declare interface ResolvedPreviewOptions extends PreviewOptions {
1708
1689
  }
1709
1690
 
@@ -1,4 +1,4 @@
1
- export { b as build, j as createFilter, q as createLogger, c as createServer, d as defineConfig, f as formatPostcssSourceMap, i as isDepsOptimizerEnabled, l as loadConfigFromFile, v as loadEnv, h as mergeAlias, m as mergeConfig, n as normalizePath, o as optimizeDeps, p as preview, g as resolveBaseUrl, e as resolveConfig, w as resolveEnvPrefix, a as resolvePackageData, r as resolvePackageEntry, u as searchForWorkspaceRoot, k as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-07df4e90.js';
1
+ export { b as build, j as createFilter, q as createLogger, c as createServer, d as defineConfig, f as formatPostcssSourceMap, i as isDepsOptimizerEnabled, l as loadConfigFromFile, v as loadEnv, h as mergeAlias, m as mergeConfig, n as normalizePath, o as optimizeDeps, p as preview, g as resolveBaseUrl, e as resolveConfig, w as resolveEnvPrefix, a as resolvePackageData, r as resolvePackageEntry, u as searchForWorkspaceRoot, k as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-332aa27f.js';
2
2
  export { VERSION as version } from './constants.js';
3
3
  export { version as esbuildVersion } from 'esbuild';
4
4
  export { VERSION as rollupVersion } from 'rollup';
@@ -26,7 +26,6 @@ import 'node:dns';
26
26
  import 'resolve';
27
27
  import 'crypto';
28
28
  import 'buffer';
29
- import 'querystring';
30
29
  import 'module';
31
30
  import 'zlib';
32
31
  import 'https';
@@ -34,6 +33,7 @@ import 'tls';
34
33
  import 'node:http';
35
34
  import 'node:https';
36
35
  import 'worker_threads';
36
+ import 'querystring';
37
37
  import 'readline';
38
38
  import 'node:child_process';
39
39
  import 'node:zlib';
@@ -31,7 +31,7 @@ var require$$1__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$1$1);
31
31
  var readline__default = /*#__PURE__*/_interopDefaultLegacy(readline);
32
32
  var require$$2__default = /*#__PURE__*/_interopDefaultLegacy(require$$2);
33
33
 
34
- var version = "3.0.0-beta.4";
34
+ var version = "3.0.0-beta.5";
35
35
 
36
36
  const VERSION = version;
37
37
  const VITE_PACKAGE_DIR = path$3.resolve(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite",
3
- "version": "3.0.0-beta.4",
3
+ "version": "3.0.0-beta.5",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Evan You",
@@ -57,7 +57,7 @@
57
57
  },
58
58
  "//": "READ CONTRIBUTING.md to understand what to put under deps vs. devDeps!",
59
59
  "dependencies": {
60
- "esbuild": "^0.14.43",
60
+ "esbuild": "^0.14.47",
61
61
  "postcss": "^8.4.14",
62
62
  "resolve": "^1.22.1",
63
63
  "rollup": "^2.75.6"