vite 4.3.0-beta.3 → 4.3.0-beta.4

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.

Potentially problematic release.


This version of vite might be problematic. Click here for more details.

@@ -12877,6 +12877,9 @@ function buildReporterPlugin(config) {
12877
12877
  options() {
12878
12878
  startTime = Date.now();
12879
12879
  },
12880
+ buildStart() {
12881
+ transformedCount = 0;
12882
+ },
12880
12883
  buildEnd() {
12881
12884
  if (shouldLogInfo) {
12882
12885
  if (tty) {
@@ -15852,7 +15855,7 @@ function registerCustomMime() {
15852
15855
  mimes$1['eot'] = 'application/vnd.ms-fontobject';
15853
15856
  }
15854
15857
  function renderAssetUrlInJS(ctx, config, chunk, opts, code) {
15855
- const toRelativeRuntime = createToImportMetaURLBasedRelativeRuntime(opts.format);
15858
+ const toRelativeRuntime = createToImportMetaURLBasedRelativeRuntime(opts.format, config.isWorker);
15856
15859
  let match;
15857
15860
  let s;
15858
15861
  // Urls added with JS using e.g.
@@ -22742,15 +22745,23 @@ function resolvePlugin(resolveOptions) {
22742
22745
  return res;
22743
22746
  }
22744
22747
  if ((res = tryFsResolve(fsPath, options))) {
22745
- const resPkg = findNearestPackageData(path$o.dirname(res), options.packageCache);
22746
22748
  res = ensureVersionQuery(res, id, options, depsOptimizer);
22747
22749
  debug$d?.(`[relative] ${picocolorsExports.cyan(id)} -> ${picocolorsExports.dim(res)}`);
22748
- return resPkg
22749
- ? {
22750
- id: res,
22751
- moduleSideEffects: resPkg.hasSideEffects(res),
22750
+ // If this isn't a script imported from a .html file, include side effects
22751
+ // hints so the non-used code is properly tree-shaken during build time.
22752
+ if (!options.idOnly &&
22753
+ !options.scan &&
22754
+ options.isBuild &&
22755
+ !importer?.endsWith('.html')) {
22756
+ const resPkg = findNearestPackageData(path$o.dirname(res), options.packageCache);
22757
+ if (resPkg) {
22758
+ return {
22759
+ id: res,
22760
+ moduleSideEffects: resPkg.hasSideEffects(res),
22761
+ };
22752
22762
  }
22753
- : res;
22763
+ }
22764
+ return res;
22754
22765
  }
22755
22766
  }
22756
22767
  // drive relative fs paths (only windows)
@@ -22770,10 +22781,7 @@ function resolvePlugin(resolveOptions) {
22770
22781
  }
22771
22782
  // external
22772
22783
  if (isExternalUrl(id)) {
22773
- return {
22774
- id,
22775
- external: true,
22776
- };
22784
+ return options.idOnly ? id : { id, external: true };
22777
22785
  }
22778
22786
  // data uri: pass through (this only happens during build and will be
22779
22787
  // handled by dedicated plugin)
@@ -22810,16 +22818,17 @@ function resolvePlugin(resolveOptions) {
22810
22818
  message += `. Consider disabling ssr.noExternal or remove the built-in dependency.`;
22811
22819
  this.error(message);
22812
22820
  }
22813
- return {
22814
- id,
22815
- external: true,
22816
- };
22821
+ return options.idOnly ? id : { id, external: true };
22817
22822
  }
22818
22823
  else {
22819
22824
  if (!asSrc) {
22820
22825
  debug$d?.(`externalized node built-in "${id}" to empty module. ` +
22821
22826
  `(imported by: ${picocolorsExports.white(picocolorsExports.dim(importer))})`);
22822
22827
  }
22828
+ else if (isProduction) {
22829
+ this.warn(`Module "${id}" has been externalized for browser compatibility, imported by "${importer}". ` +
22830
+ `See http://vitejs.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.`);
22831
+ }
22823
22832
  return isProduction
22824
22833
  ? browserExternalId
22825
22834
  : `${browserExternalId}:${id}`;
@@ -23000,10 +23009,11 @@ function tryNodeResolve(id, importer, options, targetWeb, depsOptimizer, ssr = f
23000
23009
  if (dedupe?.includes(pkgId)) {
23001
23010
  basedir = root;
23002
23011
  }
23003
- else if (importer &&
23004
- path$o.isAbsolute(importer) &&
23005
- fs$l.existsSync(cleanUrl(importer))) {
23012
+ else if (importer && path$o.isAbsolute(importer)) {
23006
23013
  basedir = path$o.dirname(importer);
23014
+ if (!fs$l.existsSync(basedir)) {
23015
+ basedir = root;
23016
+ }
23007
23017
  }
23008
23018
  else {
23009
23019
  basedir = root;
@@ -23073,7 +23083,8 @@ function tryNodeResolve(id, importer, options, targetWeb, depsOptimizer, ssr = f
23073
23083
  }
23074
23084
  return { ...resolved, id: resolvedId, external: true };
23075
23085
  };
23076
- if ((isBuild && !depsOptimizer) || externalize) {
23086
+ if (!options.idOnly &&
23087
+ ((!options.scan && isBuild && !depsOptimizer) || externalize)) {
23077
23088
  // Resolve package side effects for build so that rollup can better
23078
23089
  // perform tree-shaking
23079
23090
  return processResult({
@@ -23142,7 +23153,7 @@ function tryNodeResolve(id, importer, options, targetWeb, depsOptimizer, ssr = f
23142
23153
  const optimizedInfo = depsOptimizer.registerMissingImport(id, resolved);
23143
23154
  resolved = depsOptimizer.getOptimizedDepId(optimizedInfo);
23144
23155
  }
23145
- if (isBuild) {
23156
+ if (!options.idOnly && !options.scan && isBuild) {
23146
23157
  // Resolve package side effects for build so that rollup can better
23147
23158
  // perform tree-shaking
23148
23159
  return {
@@ -23392,13 +23403,19 @@ function tryResolveBrowserMapping(id, importer, options, isFilePath, externalize
23392
23403
  ? tryNodeResolve(browserMappedPath, importer, options, true)?.id
23393
23404
  : tryFsResolve(path$o.join(pkg.dir, browserMappedPath), options))) {
23394
23405
  debug$d?.(`[browser mapped] ${picocolorsExports.cyan(id)} -> ${picocolorsExports.dim(res)}`);
23395
- const resPkg = findNearestPackageData(path$o.dirname(res), options.packageCache);
23396
- const result = resPkg
23397
- ? {
23398
- id: res,
23399
- moduleSideEffects: resPkg.hasSideEffects(res),
23406
+ let result = { id: res };
23407
+ if (options.idOnly) {
23408
+ return result;
23409
+ }
23410
+ if (!options.scan && options.isBuild) {
23411
+ const resPkg = findNearestPackageData(path$o.dirname(res), options.packageCache);
23412
+ if (resPkg) {
23413
+ result = {
23414
+ id: res,
23415
+ moduleSideEffects: resPkg.hasSideEffects(res),
23416
+ };
23400
23417
  }
23401
- : { id: res };
23418
+ }
23402
23419
  return externalize ? { ...result, external: true } : result;
23403
23420
  }
23404
23421
  }
@@ -38322,6 +38339,12 @@ async function compileCSS(id, code, config, urlReplacer) {
38322
38339
  if (resolved) {
38323
38340
  return path$o.resolve(resolved);
38324
38341
  }
38342
+ // postcss-import falls back to `resolve` dep if this is unresolved,
38343
+ // but we've shimmed to remove the `resolve` dep to cut on bundle size.
38344
+ // warn here to provide a better error message.
38345
+ if (!path$o.isAbsolute(id)) {
38346
+ config.logger.error(picocolorsExports.red(`Unable to resolve \`@import "${id}"\` from ${basedir}`));
38347
+ }
38325
38348
  return id;
38326
38349
  },
38327
38350
  nameLayer(index) {
@@ -38461,8 +38484,8 @@ function createCachedImport(imp) {
38461
38484
  return cached;
38462
38485
  };
38463
38486
  }
38464
- const importPostcssImport = createCachedImport(() => import('./dep-0eeee069.js').then(function (n) { return n.i; }));
38465
- const importPostcssModules = createCachedImport(() => import('./dep-afdc0526.js').then(function (n) { return n.i; }));
38487
+ const importPostcssImport = createCachedImport(() => import('./dep-e3f470e2.js').then(function (n) { return n.i; }));
38488
+ const importPostcssModules = createCachedImport(() => import('./dep-a4107a1b.js').then(function (n) { return n.i; }));
38466
38489
  const importPostcss = createCachedImport(() => import('postcss'));
38467
38490
  /**
38468
38491
  * @experimental
@@ -41163,11 +41186,12 @@ function webWorkerPlugin(config) {
41163
41186
  return '';
41164
41187
  }
41165
41188
  },
41189
+ // @ts-expect-error return void to fallback to other plugins, even though
41190
+ // the types doesn't allow it. https://github.com/rollup/rollup/pull/4932
41166
41191
  shouldTransformCachedModule({ id }) {
41167
41192
  if (isBuild && isWorkerQueryId(id) && config.build.watch) {
41168
41193
  return true;
41169
41194
  }
41170
- return false;
41171
41195
  },
41172
41196
  async transform(raw, id, options) {
41173
41197
  const ssr = options?.ssr === true;
@@ -41277,7 +41301,7 @@ function webWorkerPlugin(config) {
41277
41301
  });
41278
41302
  };
41279
41303
  if (code.match(workerAssetUrlRE)) {
41280
- const toRelativeRuntime = createToImportMetaURLBasedRelativeRuntime(outputOptions.format);
41304
+ const toRelativeRuntime = createToImportMetaURLBasedRelativeRuntime(outputOptions.format, config.isWorker);
41281
41305
  let match;
41282
41306
  s = new MagicString(code);
41283
41307
  workerAssetUrlRE.lastIndex = 0;
@@ -46124,6 +46148,11 @@ const relativeUrlMechanisms = {
46124
46148
  system: (relativePath) => getResolveUrl(`'${relativePath}', module.meta.url`),
46125
46149
  umd: (relativePath) => `(typeof document === 'undefined' && typeof location === 'undefined' ? ${getFileUrlFromRelativePath(relativePath)} : ${getRelativeUrlFromDocument(relativePath, true)})`,
46126
46150
  };
46151
+ /* end of copy */
46152
+ const customRelativeUrlMechanisms = {
46153
+ ...relativeUrlMechanisms,
46154
+ 'worker-iife': (relativePath) => getResolveUrl(`'${relativePath}', self.location.href`),
46155
+ };
46127
46156
  function toOutputFilePathInJS(filename, type, hostId, hostType, config, toRelative) {
46128
46157
  const { renderBuiltUrl } = config.experimental;
46129
46158
  let relative = config.base === '' || config.base === './';
@@ -46151,8 +46180,9 @@ function toOutputFilePathInJS(filename, type, hostId, hostType, config, toRelati
46151
46180
  }
46152
46181
  return joinUrlSegments(config.base, filename);
46153
46182
  }
46154
- function createToImportMetaURLBasedRelativeRuntime(format) {
46155
- const toRelativePath = relativeUrlMechanisms[format];
46183
+ function createToImportMetaURLBasedRelativeRuntime(format, isWorker) {
46184
+ const formatLong = isWorker && format === 'iife' ? 'worker-iife' : format;
46185
+ const toRelativePath = customRelativeUrlMechanisms[formatLong];
46156
46186
  return (filename, importer) => ({
46157
46187
  runtime: toRelativePath(path$o.posix.relative(path$o.dirname(importer), filename)),
46158
46188
  });
@@ -63995,6 +64025,7 @@ async function resolveConfig(inlineConfig, command, defaultMode = 'development',
63995
64025
  preferRelative: false,
63996
64026
  tryIndex: true,
63997
64027
  ...options,
64028
+ idOnly: true,
63998
64029
  }),
63999
64030
  ],
64000
64031
  }));
@@ -1,6 +1,6 @@
1
1
  import require$$0__default from 'fs';
2
2
  import require$$0 from 'postcss';
3
- import { D as commonjsGlobal } from './dep-366ea021.js';
3
+ import { D as commonjsGlobal } from './dep-a36bfc56.js';
4
4
  import require$$0$1 from 'path';
5
5
  import require$$5 from 'crypto';
6
6
  import require$$0$2 from 'util';
@@ -493,7 +493,7 @@ const path = require$$0;
493
493
  // internal tooling
494
494
  const joinMedia = joinMedia$1;
495
495
  const joinLayer = joinLayer$1;
496
- const resolveId = undefined;
496
+ const resolveId = (id) => id;
497
497
  const loadContent = loadContent$1;
498
498
  const processContent = processContent$1;
499
499
  const parseStatements = parseStatements$1;
@@ -803,7 +803,7 @@ function AtImport(options) {
803
803
  return Promise.all(
804
804
  paths.map(file => {
805
805
  return !path.isAbsolute(file)
806
- ? resolveId(file, base, options)
806
+ ? resolveId(file)
807
807
  : file
808
808
  })
809
809
  )
package/dist/node/cli.js CHANGED
@@ -2,7 +2,7 @@ import path from 'node:path';
2
2
  import fs from 'node:fs';
3
3
  import { performance } from 'node:perf_hooks';
4
4
  import { EventEmitter } from 'events';
5
- import { B as picocolorsExports, C as bindShortcuts, x as createLogger, h as resolveConfig } from './chunks/dep-366ea021.js';
5
+ import { B as picocolorsExports, C as bindShortcuts, x as createLogger, h as resolveConfig } from './chunks/dep-a36bfc56.js';
6
6
  import { VERSION } from './constants.js';
7
7
  import 'node:fs/promises';
8
8
  import 'node:url';
@@ -728,7 +728,7 @@ cli
728
728
  filterDuplicateOptions(options);
729
729
  // output structure is preserved even after bundling so require()
730
730
  // is ok here
731
- const { createServer } = await import('./chunks/dep-366ea021.js').then(function (n) { return n.G; });
731
+ const { createServer } = await import('./chunks/dep-a36bfc56.js').then(function (n) { return n.G; });
732
732
  try {
733
733
  const server = await createServer({
734
734
  root,
@@ -806,7 +806,7 @@ cli
806
806
  .option('-w, --watch', `[boolean] rebuilds when modules have changed on disk`)
807
807
  .action(async (root, options) => {
808
808
  filterDuplicateOptions(options);
809
- const { build } = await import('./chunks/dep-366ea021.js').then(function (n) { return n.F; });
809
+ const { build } = await import('./chunks/dep-a36bfc56.js').then(function (n) { return n.F; });
810
810
  const buildOptions = cleanOptions(options);
811
811
  try {
812
812
  await build({
@@ -834,13 +834,14 @@ cli
834
834
  .option('--force', `[boolean] force the optimizer to ignore the cache and re-bundle`)
835
835
  .action(async (root, options) => {
836
836
  filterDuplicateOptions(options);
837
- const { optimizeDeps } = await import('./chunks/dep-366ea021.js').then(function (n) { return n.E; });
837
+ const { optimizeDeps } = await import('./chunks/dep-a36bfc56.js').then(function (n) { return n.E; });
838
838
  try {
839
839
  const config = await resolveConfig({
840
840
  root,
841
841
  base: options.base,
842
842
  configFile: options.config,
843
843
  logLevel: options.logLevel,
844
+ mode: options.mode,
844
845
  }, 'serve');
845
846
  await optimizeDeps(config, options.force, true);
846
847
  }
@@ -859,7 +860,7 @@ cli
859
860
  .option('--outDir <dir>', `[string] output directory (default: dist)`)
860
861
  .action(async (root, options) => {
861
862
  filterDuplicateOptions(options);
862
- const { preview } = await import('./chunks/dep-366ea021.js').then(function (n) { return n.H; });
863
+ const { preview } = await import('./chunks/dep-a36bfc56.js').then(function (n) { return n.H; });
863
864
  try {
864
865
  const server = await preview({
865
866
  root,
@@ -1191,6 +1191,7 @@ export declare interface InternalResolveOptions extends Required<ResolveOptions>
1191
1191
  ssrOptimizeCheck?: boolean;
1192
1192
  getDepsOptimizer?: (ssr: boolean) => DepsOptimizer | undefined;
1193
1193
  shouldExternalize?: (id: string) => boolean | undefined;
1194
+ /* Excluded from this release type: idOnly */
1194
1195
  }
1195
1196
 
1196
1197
  export { InvalidatePayload }
@@ -1,5 +1,5 @@
1
- import { i as isInNodeModules } from './chunks/dep-366ea021.js';
2
- export { b as build, e as buildErrorMessage, v as createFilter, x as createLogger, c as createServer, g as defineConfig, f as formatPostcssSourceMap, k as getDepOptimizationConfig, m as isDepsOptimizerEnabled, l as loadConfigFromFile, z as loadEnv, u as mergeAlias, q as mergeConfig, n as normalizePath, o as optimizeDeps, a as preprocessCSS, p as preview, j as resolveBaseUrl, h as resolveConfig, A as resolveEnvPrefix, d as resolvePackageData, r as resolvePackageEntry, y as searchForWorkspaceRoot, w as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-366ea021.js';
1
+ import { i as isInNodeModules } from './chunks/dep-a36bfc56.js';
2
+ export { b as build, e as buildErrorMessage, v as createFilter, x as createLogger, c as createServer, g as defineConfig, f as formatPostcssSourceMap, k as getDepOptimizationConfig, m as isDepsOptimizerEnabled, l as loadConfigFromFile, z as loadEnv, u as mergeAlias, q as mergeConfig, n as normalizePath, o as optimizeDeps, a as preprocessCSS, p as preview, j as resolveBaseUrl, h as resolveConfig, A as resolveEnvPrefix, d as resolvePackageData, r as resolvePackageEntry, y as searchForWorkspaceRoot, w as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-a36bfc56.js';
3
3
  export { VERSION as version } from './constants.js';
4
4
  export { version as esbuildVersion } from 'esbuild';
5
5
  export { VERSION as rollupVersion } from 'rollup';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite",
3
- "version": "4.3.0-beta.3",
3
+ "version": "4.3.0-beta.4",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Evan You",