vite 4.4.8 → 4.4.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.

Potentially problematic release.


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

@@ -1,4 +1,4 @@
1
- import { F as commonjsGlobal, E as getDefaultExportFromCjs } from './dep-75f53616.js';
1
+ import { F as commonjsGlobal, E as getDefaultExportFromCjs } from './dep-df561101.js';
2
2
  import require$$0__default from 'fs';
3
3
  import require$$0 from 'postcss';
4
4
  import require$$0$1 from 'path';
@@ -12984,21 +12984,23 @@ function buildReporterPlugin(config) {
12984
12984
  chunkCount = 0;
12985
12985
  compressedCount = 0;
12986
12986
  },
12987
- renderChunk(code, chunk) {
12988
- for (const id of chunk.moduleIds) {
12989
- const module = this.getModuleInfo(id);
12990
- if (!module)
12991
- continue;
12992
- // When a dynamic importer shares a chunk with the imported module,
12993
- // warn that the dynamic imported module will not be moved to another chunk (#12850).
12994
- if (module.importers.length && module.dynamicImporters.length) {
12995
- // Filter out the intersection of dynamic importers and sibling modules in
12996
- // the same chunk. The intersecting dynamic importers' dynamic import is not
12997
- // expected to work. Note we're only detecting the direct ineffective
12998
- // dynamic import here.
12999
- const detectedIneffectiveDynamicImport = module.dynamicImporters.some((id) => !isInNodeModules(id) && chunk.moduleIds.includes(id));
13000
- if (detectedIneffectiveDynamicImport) {
13001
- this.warn(`\n(!) ${module.id} is dynamically imported by ${module.dynamicImporters.join(', ')} but also statically imported by ${module.importers.join(', ')}, dynamic import will not move module into another chunk.\n`);
12987
+ renderChunk(code, chunk, options) {
12988
+ if (!options.inlineDynamicImports) {
12989
+ for (const id of chunk.moduleIds) {
12990
+ const module = this.getModuleInfo(id);
12991
+ if (!module)
12992
+ continue;
12993
+ // When a dynamic importer shares a chunk with the imported module,
12994
+ // warn that the dynamic imported module will not be moved to another chunk (#12850).
12995
+ if (module.importers.length && module.dynamicImporters.length) {
12996
+ // Filter out the intersection of dynamic importers and sibling modules in
12997
+ // the same chunk. The intersecting dynamic importers' dynamic import is not
12998
+ // expected to work. Note we're only detecting the direct ineffective
12999
+ // dynamic import here.
13000
+ const detectedIneffectiveDynamicImport = module.dynamicImporters.some((id) => !isInNodeModules(id) && chunk.moduleIds.includes(id));
13001
+ if (detectedIneffectiveDynamicImport) {
13002
+ this.warn(`\n(!) ${module.id} is dynamically imported by ${module.dynamicImporters.join(', ')} but also statically imported by ${module.importers.join(', ')}, dynamic import will not move module into another chunk.\n`);
13003
+ }
13002
13004
  }
13003
13005
  }
13004
13006
  }
@@ -21300,6 +21302,8 @@ var settings = {};
21300
21302
  if (this.stats) {
21301
21303
  this.objectMode = true;
21302
21304
  }
21305
+ // Remove the cast to the array in the next major (#404).
21306
+ this.ignore = [].concat(this.ignore);
21303
21307
  }
21304
21308
  _getValue(option, value) {
21305
21309
  return option === undefined ? value : option;
@@ -27431,7 +27435,7 @@ function encodeQueryItem(key, value) {
27431
27435
  return `${encodeQueryKey(key)}=${encodeQueryValue(value)}`;
27432
27436
  }
27433
27437
  function stringifyQuery(query) {
27434
- return Object.keys(query).filter((k) => query[k] !== void 0).map((k) => encodeQueryItem(k, query[k])).join("&");
27438
+ return Object.keys(query).filter((k) => query[k] !== void 0).map((k) => encodeQueryItem(k, query[k])).filter(Boolean).join("&");
27435
27439
  }
27436
27440
 
27437
27441
  new Set(builtinModules);
@@ -36627,47 +36631,77 @@ var src$1 = rc;
36627
36631
 
36628
36632
  var postcssrc = /*@__PURE__*/getDefaultExportFromCjs(src$1);
36629
36633
 
36630
- function stripLiteralAcorn(code) {
36631
- const FILL = " ";
36634
+ function _stripLiteralAcorn(code, options) {
36635
+ const FILL = options?.fillChar ?? " ";
36636
+ const FILL_COMMENT = " ";
36632
36637
  let result = "";
36633
- function fulfill(index) {
36638
+ const filter = options?.filter ?? (() => true);
36639
+ function fillupTo(index) {
36634
36640
  if (index > result.length)
36635
- result += code.slice(result.length, index).replace(/[^\n]/g, FILL);
36641
+ result += code.slice(result.length, index).replace(/[^\n]/g, FILL_COMMENT);
36636
36642
  }
36637
- const tokens = tokenizer(code, {
36643
+ const tokens = [];
36644
+ const pasers = tokenizer(code, {
36638
36645
  ecmaVersion: "latest",
36639
36646
  sourceType: "module",
36640
36647
  allowHashBang: true,
36641
36648
  allowAwaitOutsideFunction: true,
36642
36649
  allowImportExportEverywhere: true
36643
36650
  });
36644
- const inter = tokens[Symbol.iterator]();
36645
- while (true) {
36646
- const { done, value: token } = inter.next();
36647
- if (done)
36648
- break;
36649
- fulfill(token.start);
36650
- if (token.type.label === "string")
36651
- result += code[token.start] + FILL.repeat(token.end - token.start - 2) + code[token.end - 1];
36652
- else if (token.type.label === "template")
36653
- result += FILL.repeat(token.end - token.start);
36654
- else
36651
+ const iter = pasers[Symbol.iterator]();
36652
+ let error;
36653
+ try {
36654
+ while (true) {
36655
+ const { done, value: token } = iter.next();
36656
+ if (done)
36657
+ break;
36658
+ tokens.push(token);
36659
+ fillupTo(token.start);
36660
+ if (token.type.label === "string") {
36661
+ const body = code.slice(token.start + 1, token.end - 1);
36662
+ if (filter(body)) {
36663
+ result += code[token.start] + FILL.repeat(token.end - token.start - 2) + code[token.end - 1];
36664
+ continue;
36665
+ }
36666
+ } else if (token.type.label === "template") {
36667
+ const body = code.slice(token.start, token.end);
36668
+ if (filter(body)) {
36669
+ result += FILL.repeat(token.end - token.start);
36670
+ continue;
36671
+ }
36672
+ } else if (token.type.label === "regexp") {
36673
+ const body = code.slice(token.start, token.end);
36674
+ if (filter(body)) {
36675
+ result += body.replace(/\/(.*)\/(\w?)$/g, (_, $1, $2) => `/${FILL.repeat($1.length)}/${$2}`);
36676
+ continue;
36677
+ }
36678
+ }
36655
36679
  result += code.slice(token.start, token.end);
36680
+ }
36681
+ fillupTo(code.length);
36682
+ } catch (e) {
36683
+ error = e;
36656
36684
  }
36657
- fulfill(code.length);
36658
- return result;
36685
+ return {
36686
+ error,
36687
+ result,
36688
+ tokens
36689
+ };
36659
36690
  }
36660
36691
 
36661
36692
  const multilineCommentsRE = /\/\*([^*\/])*?\*\//gms;
36662
36693
  const singlelineCommentsRE = /(?:^|\n|\r)\s*\/\/.*(?:\r|\n|$)/gm;
36663
- const templateLiteralRE = /\$\{(\s*(?:(?!\$\{).|\n|\r)*?\s*)\}/g;
36694
+ const templateLiteralRE = /\$\{(\s*(?:|{.*}|(?!\$\{).|\n|\r)*?\s*)\}/g;
36664
36695
  const quotesRE = [
36665
36696
  /(["'`])((?:\\\1|(?!\1)|.|\r)*?)\1/gm,
36666
36697
  /([`])((?:\\\1|(?!\1)|.|\n|\r)*?)\1/gm
36667
36698
  // multi-line strings (i.e. template literals only)
36668
36699
  ];
36669
- function stripLiteralRegex(code) {
36670
- code = code.replace(multilineCommentsRE, (s) => " ".repeat(s.length)).replace(singlelineCommentsRE, (s) => " ".repeat(s.length));
36700
+ function stripLiteralRegex(code, options) {
36701
+ const FILL_COMMENT = " ";
36702
+ const FILL = options?.fillChar ?? " ";
36703
+ const filter = options?.filter ?? (() => true);
36704
+ code = code.replace(multilineCommentsRE, (s) => filter(s) ? FILL_COMMENT.repeat(s.length) : s).replace(singlelineCommentsRE, (s) => filter(s) ? FILL_COMMENT.repeat(s.length) : s);
36671
36705
  let expanded = code;
36672
36706
  for (let i = 0; i < 16; i++) {
36673
36707
  const before = expanded;
@@ -36677,19 +36711,32 @@ function stripLiteralRegex(code) {
36677
36711
  }
36678
36712
  quotesRE.forEach((re) => {
36679
36713
  expanded = expanded.replace(re, (s, quote, body, index) => {
36680
- code = code.slice(0, index + 1) + " ".repeat(s.length - 2) + code.slice(index + s.length - 1);
36681
- return quote + " ".repeat(s.length - 2) + quote;
36714
+ if (!filter(s.slice(1, -1)))
36715
+ return s;
36716
+ code = code.slice(0, index + 1) + FILL.repeat(s.length - 2) + code.slice(index + s.length - 1);
36717
+ return quote + FILL.repeat(s.length - 2) + quote;
36682
36718
  });
36683
36719
  });
36684
36720
  return code;
36685
36721
  }
36686
36722
 
36687
- function stripLiteral(code) {
36688
- try {
36689
- return stripLiteralAcorn(code);
36690
- } catch (e) {
36691
- return stripLiteralRegex(code);
36723
+ function stripLiteral(code, options) {
36724
+ return stripLiteralDetailed(code, options).result;
36725
+ }
36726
+ function stripLiteralDetailed(code, options) {
36727
+ const acorn = _stripLiteralAcorn(code, options);
36728
+ if (!acorn.error) {
36729
+ return {
36730
+ mode: "acorn",
36731
+ result: acorn.result,
36732
+ acorn
36733
+ };
36692
36734
  }
36735
+ return {
36736
+ mode: "regex",
36737
+ result: stripLiteralRegex(acorn.result + code.slice(acorn.result.length), options),
36738
+ acorn
36739
+ };
36693
36740
  }
36694
36741
 
36695
36742
  var main$1 = {exports: {}};
@@ -38912,8 +38959,8 @@ function createCachedImport(imp) {
38912
38959
  return cached;
38913
38960
  };
38914
38961
  }
38915
- const importPostcssImport = createCachedImport(() => import('./dep-d502c17d.js').then(function (n) { return n.i; }));
38916
- const importPostcssModules = createCachedImport(() => import('./dep-def3b363.js').then(function (n) { return n.i; }));
38962
+ const importPostcssImport = createCachedImport(() => import('./dep-e0331088.js').then(function (n) { return n.i; }));
38963
+ const importPostcssModules = createCachedImport(() => import('./dep-73522cdf.js').then(function (n) { return n.i; }));
38917
38964
  const importPostcss = createCachedImport(() => import('postcss'));
38918
38965
  /**
38919
38966
  * @experimental
@@ -42912,7 +42959,6 @@ function definePlugin(config) {
42912
42959
  };
42913
42960
  }
42914
42961
 
42915
- const ignoreFlagRE = /\/\*\s*@vite-ignore\s*\*\//;
42916
42962
  function err(e, pos) {
42917
42963
  const error = new Error(e);
42918
42964
  error.pos = pos;
@@ -42949,7 +42995,7 @@ function getWorkerType(raw, clean, i) {
42949
42995
  const workerOptString = raw
42950
42996
  .substring(commaIndex + 1, endIndex)
42951
42997
  .replace(/\}[\s\S]*,/g, '}'); // strip trailing comma for parsing
42952
- const hasViteIgnore = ignoreFlagRE.test(workerOptString);
42998
+ const hasViteIgnore = hasViteIgnoreRE.test(workerOptString);
42953
42999
  if (hasViteIgnore) {
42954
43000
  return 'ignore';
42955
43001
  }
@@ -43468,6 +43514,9 @@ function dynamicImportVarsPlugin(config) {
43468
43514
  if (dynamicIndex === -1 || source[start] !== '`') {
43469
43515
  continue;
43470
43516
  }
43517
+ if (hasViteIgnoreRE.test(source.slice(expStart, expEnd))) {
43518
+ continue;
43519
+ }
43471
43520
  s || (s = new MagicString(source));
43472
43521
  let result;
43473
43522
  try {
@@ -46498,7 +46547,7 @@ function buildImportAnalysisPlugin(config) {
46498
46547
  ? // If `experimental.renderBuiltUrl` or `build.modulePreload.resolveDependencies` are used
46499
46548
  // the dependencies are already resolved. To avoid the need for `new URL(dep, import.meta.url)`
46500
46549
  // a helper `__vitePreloadRelativeDep` is used to resolve from relative paths which can be minimized.
46501
- `function(dep, importerUrl) { return dep.startsWith('.') ? new URL(dep, importerUrl).href : dep }`
46550
+ `function(dep, importerUrl) { return dep[0] === '.' ? new URL(dep, importerUrl).href : dep }`
46502
46551
  : optimizeModulePreloadRelativePaths
46503
46552
  ? // If there isn't custom resolvers affecting the deps list, deps in the list are relative
46504
46553
  // to the current chunk and are resolved to absolute URL by the __vitePreload helper itself.
@@ -1,4 +1,4 @@
1
- import { E as getDefaultExportFromCjs } from './dep-75f53616.js';
1
+ import { E as getDefaultExportFromCjs } from './dep-df561101.js';
2
2
  import require$$0 from 'path';
3
3
  import require$$0__default from 'fs';
4
4
  import { l as lib } from './dep-c423598f.js';
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 { C as colors, D as bindShortcuts, x as createLogger, h as resolveConfig } from './chunks/dep-75f53616.js';
5
+ import { C as colors, D as bindShortcuts, x as createLogger, h as resolveConfig } from './chunks/dep-df561101.js';
6
6
  import { VERSION } from './constants.js';
7
7
  import 'node:fs/promises';
8
8
  import 'node:url';
@@ -738,7 +738,7 @@ cli
738
738
  filterDuplicateOptions(options);
739
739
  // output structure is preserved even after bundling so require()
740
740
  // is ok here
741
- const { createServer } = await import('./chunks/dep-75f53616.js').then(function (n) { return n.I; });
741
+ const { createServer } = await import('./chunks/dep-df561101.js').then(function (n) { return n.I; });
742
742
  try {
743
743
  const server = await createServer({
744
744
  root,
@@ -816,7 +816,7 @@ cli
816
816
  .option('-w, --watch', `[boolean] rebuilds when modules have changed on disk`)
817
817
  .action(async (root, options) => {
818
818
  filterDuplicateOptions(options);
819
- const { build } = await import('./chunks/dep-75f53616.js').then(function (n) { return n.H; });
819
+ const { build } = await import('./chunks/dep-df561101.js').then(function (n) { return n.H; });
820
820
  const buildOptions = cleanOptions(options);
821
821
  try {
822
822
  await build({
@@ -844,7 +844,7 @@ cli
844
844
  .option('--force', `[boolean] force the optimizer to ignore the cache and re-bundle`)
845
845
  .action(async (root, options) => {
846
846
  filterDuplicateOptions(options);
847
- const { optimizeDeps } = await import('./chunks/dep-75f53616.js').then(function (n) { return n.G; });
847
+ const { optimizeDeps } = await import('./chunks/dep-df561101.js').then(function (n) { return n.G; });
848
848
  try {
849
849
  const config = await resolveConfig({
850
850
  root,
@@ -871,7 +871,7 @@ cli
871
871
  .option('--outDir <dir>', `[string] output directory (default: dist)`)
872
872
  .action(async (root, options) => {
873
873
  filterDuplicateOptions(options);
874
- const { preview } = await import('./chunks/dep-75f53616.js').then(function (n) { return n.J; });
874
+ const { preview } = await import('./chunks/dep-df561101.js').then(function (n) { return n.J; });
875
875
  try {
876
876
  const server = await preview({
877
877
  root,
@@ -1,5 +1,5 @@
1
- import { i as isInNodeModules } from './chunks/dep-75f53616.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, z as isFileServingAllowed, l as loadConfigFromFile, A 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, B as resolveEnvPrefix, d as resolvePackageData, r as resolvePackageEntry, y as searchForWorkspaceRoot, w as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-75f53616.js';
1
+ import { i as isInNodeModules } from './chunks/dep-df561101.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, z as isFileServingAllowed, l as loadConfigFromFile, A 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, B as resolveEnvPrefix, d as resolvePackageData, r as resolvePackageEntry, y as searchForWorkspaceRoot, w as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-df561101.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.4.8",
3
+ "version": "4.4.9",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Evan You",
@@ -68,8 +68,8 @@
68
68
  "//": "READ CONTRIBUTING.md to understand what to put under deps vs. devDeps!",
69
69
  "dependencies": {
70
70
  "esbuild": "^0.18.10",
71
- "postcss": "^8.4.26",
72
- "rollup": "^3.25.2"
71
+ "postcss": "^8.4.27",
72
+ "rollup": "^3.27.1"
73
73
  },
74
74
  "optionalDependencies": {
75
75
  "fsevents": "~2.3.2"
@@ -105,7 +105,7 @@
105
105
  "escape-html": "^1.0.3",
106
106
  "estree-walker": "^3.0.3",
107
107
  "etag": "^1.8.1",
108
- "fast-glob": "^3.3.0",
108
+ "fast-glob": "^3.3.1",
109
109
  "http-proxy": "^1.18.1",
110
110
  "json-stable-stringify": "^1.0.2",
111
111
  "launch-editor-middleware": "^2.6.0",
@@ -128,11 +128,11 @@
128
128
  "sirv": "^2.0.3",
129
129
  "source-map-support": "^0.5.21",
130
130
  "strip-ansi": "^7.1.0",
131
- "strip-literal": "^1.0.1",
131
+ "strip-literal": "^1.3.0",
132
132
  "tsconfck": "^2.1.2",
133
- "tslib": "^2.6.0",
133
+ "tslib": "^2.6.1",
134
134
  "types": "link:./types",
135
- "ufo": "^1.1.2",
135
+ "ufo": "^1.2.0",
136
136
  "ws": "^8.13.0"
137
137
  },
138
138
  "peerDependencies": {
@@ -2,8 +2,6 @@
2
2
  // Thus cannot contain any top-level imports
3
3
  // <https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation>
4
4
 
5
- /* eslint-disable @typescript-eslint/consistent-type-imports */
6
-
7
5
  interface ImportMetaEnv {
8
6
  [key: string]: any
9
7
  BASE_URL: string