vite 4.3.3 → 4.3.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.

Potentially problematic release.


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

@@ -1,4 +1,4 @@
1
- import { E as getDefaultExportFromCjs } from './dep-a178814b.js';
1
+ import { E as getDefaultExportFromCjs } from './dep-934dbc7c.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';
@@ -1,4 +1,4 @@
1
- import { F as commonjsGlobal, E as getDefaultExportFromCjs } from './dep-a178814b.js';
1
+ import { F as commonjsGlobal, E as getDefaultExportFromCjs } from './dep-934dbc7c.js';
2
2
  import require$$0__default from 'fs';
3
3
  import require$$0 from 'postcss';
4
4
  import require$$0$1 from 'path';
@@ -11876,7 +11876,7 @@ function createDebugger(namespace, options = {}) {
11876
11876
  }
11877
11877
  if (enabled) {
11878
11878
  return (...args) => {
11879
- if (!filter || args.some((a) => a?.includes(filter))) {
11879
+ if (!filter || args.some((a) => a?.includes?.(filter))) {
11880
11880
  log(...args);
11881
11881
  }
11882
11882
  };
@@ -32855,7 +32855,7 @@ function resolveEnd(end, offset, reqSpace, onError) {
32855
32855
  }
32856
32856
 
32857
32857
  const blockMsg = 'Block collections are not allowed within flow collections';
32858
- const isBlock = (token) => token && (token.type === 'block-map' || token.type === 'block-seq');
32858
+ const isBlock$1 = (token) => token && (token.type === 'block-map' || token.type === 'block-seq');
32859
32859
  function resolveFlowCollection({ composeNode, composeEmptyNode }, ctx, fc, onError) {
32860
32860
  const isMap = fc.start.source === '{';
32861
32861
  const fcName = isMap ? 'flow map' : 'flow sequence';
@@ -32938,7 +32938,7 @@ function resolveFlowCollection({ composeNode, composeEmptyNode }, ctx, fc, onErr
32938
32938
  : composeEmptyNode(ctx, props.end, sep, null, props, onError);
32939
32939
  coll.items.push(valueNode);
32940
32940
  offset = valueNode.range[2];
32941
- if (isBlock(value))
32941
+ if (isBlock$1(value))
32942
32942
  onError(valueNode.range, 'BLOCK_IN_FLOW', blockMsg);
32943
32943
  }
32944
32944
  else {
@@ -32948,7 +32948,7 @@ function resolveFlowCollection({ composeNode, composeEmptyNode }, ctx, fc, onErr
32948
32948
  const keyNode = key
32949
32949
  ? composeNode(ctx, key, props, onError)
32950
32950
  : composeEmptyNode(ctx, keyStart, start, null, props, onError);
32951
- if (isBlock(key))
32951
+ if (isBlock$1(key))
32952
32952
  onError(keyNode.range, 'BLOCK_IN_FLOW', blockMsg);
32953
32953
  // value properties
32954
32954
  const valueProps = resolveProps(sep ?? [], {
@@ -32987,7 +32987,7 @@ function resolveFlowCollection({ composeNode, composeEmptyNode }, ctx, fc, onErr
32987
32987
  ? composeEmptyNode(ctx, valueProps.end, sep, null, valueProps, onError)
32988
32988
  : null;
32989
32989
  if (valueNode) {
32990
- if (isBlock(value))
32990
+ if (isBlock$1(value))
32991
32991
  onError(valueNode.range, 'BLOCK_IN_FLOW', blockMsg);
32992
32992
  }
32993
32993
  else if (valueProps.comment) {
@@ -38574,8 +38574,8 @@ function createCachedImport(imp) {
38574
38574
  return cached;
38575
38575
  };
38576
38576
  }
38577
- const importPostcssImport = createCachedImport(() => import('./dep-3ea2db5b.js').then(function (n) { return n.i; }));
38578
- const importPostcssModules = createCachedImport(() => import('./dep-5728e8e9.js').then(function (n) { return n.i; }));
38577
+ const importPostcssImport = createCachedImport(() => import('./dep-5673ffe5.js').then(function (n) { return n.i; }));
38578
+ const importPostcssModules = createCachedImport(() => import('./dep-8989cf2a.js').then(function (n) { return n.i; }));
38579
38579
  const importPostcss = createCachedImport(() => import('postcss'));
38580
38580
  /**
38581
38581
  * @experimental
@@ -38875,6 +38875,7 @@ function cleanScssBugUrl(url) {
38875
38875
  if (
38876
38876
  // check bug via `window` and `location` global
38877
38877
  typeof window !== 'undefined' &&
38878
+ typeof location !== 'undefined' &&
38878
38879
  typeof location?.href === 'string') {
38879
38880
  const prefix = location.href.replace(/\/$/, '');
38880
38881
  return url.replace(prefix, '');
@@ -41550,13 +41551,7 @@ function definePlugin(config) {
41550
41551
  if (isBuild) {
41551
41552
  const match = key.match(metaEnvRe);
41552
41553
  if (match) {
41553
- userDefineEnv[match[1]] =
41554
- // test if value is raw identifier to wrap with __vite__ so when
41555
- // stringified for `import.meta.env`, we can remove the quotes and
41556
- // retain being an identifier
41557
- typeof val === 'string' && /^[\p{L}_$]/u.test(val.trim())
41558
- ? `__vite__define__${val}`
41559
- : val;
41554
+ userDefineEnv[match[1]] = `__vite__define__${userDefine[key]}`;
41560
41555
  }
41561
41556
  }
41562
41557
  }
@@ -41575,7 +41570,7 @@ function definePlugin(config) {
41575
41570
  ...config.env,
41576
41571
  SSR: '__vite__ssr__',
41577
41572
  ...userDefineEnv,
41578
- }).replace(/"__vite__define__(.+?)"/g, (_, val) => val),
41573
+ }).replace(/"__vite__define__(.+?)"([,}])/g, (_, val, suffix) => `${val.replace(/(^\\")|(\\"$)/g, '"')}${suffix}`),
41579
41574
  });
41580
41575
  }
41581
41576
  function getImportMetaKeys(ssr) {
@@ -41817,7 +41812,12 @@ function assetImportMetaUrlPlugin(config) {
41817
41812
  s = new MagicString(code);
41818
41813
  // potential dynamic template string
41819
41814
  if (rawUrl[0] === '`' && rawUrl.includes('${')) {
41820
- const ast = this.parse(rawUrl);
41815
+ let [pureUrl, queryString = ''] = rawUrl.split('?');
41816
+ if (queryString) {
41817
+ pureUrl += '`';
41818
+ queryString = '?' + queryString.slice(0, -1);
41819
+ }
41820
+ const ast = this.parse(pureUrl);
41821
41821
  const templateLiteral = ast.body[0].expression;
41822
41822
  if (templateLiteral.expressions.length) {
41823
41823
  const pattern = buildGlobPattern(templateLiteral);
@@ -41826,11 +41826,17 @@ function assetImportMetaUrlPlugin(config) {
41826
41826
  // because users won't intend to do that in most cases
41827
41827
  continue;
41828
41828
  }
41829
+ const globOptions = {
41830
+ eager: true,
41831
+ import: 'default',
41832
+ // A hack to allow 'as' & 'query' exist at the same time
41833
+ query: injectQuery(queryString, 'url'),
41834
+ };
41829
41835
  // Note: native import.meta.url is not supported in the baseline
41830
41836
  // target so we use the global location here. It can be
41831
41837
  // window.location or self.location in case it is used in a Web Worker.
41832
41838
  // @see https://developer.mozilla.org/en-US/docs/Web/API/Window/self
41833
- s.update(index, index + exp.length, `new URL((import.meta.glob(${JSON.stringify(pattern)}, { eager: true, import: 'default', as: 'url' }))[${rawUrl}], self.location)`);
41839
+ s.update(index, index + exp.length, `new URL((import.meta.glob(${JSON.stringify(pattern)}, ${JSON.stringify(globOptions)}))[${pureUrl}], self.location)`);
41834
41840
  continue;
41835
41841
  }
41836
41842
  }
@@ -42544,7 +42550,7 @@ async function createPluginContainer(config, moduleGraph, watcher) {
42544
42550
  }
42545
42551
  async load(options) {
42546
42552
  // We may not have added this to our module graph yet, so ensure it exists
42547
- await moduleGraph?.ensureEntryFromUrl(options.id);
42553
+ await moduleGraph?.ensureEntryFromUrl(unwrapId(options.id), this.ssr);
42548
42554
  // Not all options passed to this function make sense in the context of loading individual files,
42549
42555
  // but we can at least update the module info properties we support
42550
42556
  updateModuleInfo(options.id, options);
@@ -43087,8 +43093,7 @@ function globEntries(pattern, config) {
43087
43093
  suppressErrors: true, // suppress EACCES errors
43088
43094
  });
43089
43095
  }
43090
- const scriptModuleRE = /(<script\b[^>]+type\s*=\s*(?:"module"|'module')[^>]*>)(.*?)<\/script>/gis;
43091
- const scriptRE = /(<script(?:\s[^>]*>|>))(.*?)<\/script>/gis;
43096
+ const scriptRE = /(<script(?:\s+[a-z_:][-\w:]*(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^"'<>=\s]+))?)*\s*>)(.*?)<\/script>/gis;
43092
43097
  const commentRE = /<!--.*?-->/gs;
43093
43098
  const srcRE = /\bsrc\s*=\s*(?:"([^"]+)"|'([^']+)'|([^\s'">]+))/i;
43094
43099
  const typeRE = /\btype\s*=\s*(?:"([^"]+)"|'([^']+)'|([^\s'">]+))/i;
@@ -43178,17 +43183,20 @@ function esbuildScanPlugin(config, container, depImports, missing, entries) {
43178
43183
  // Avoid matching the content of the comment
43179
43184
  raw = raw.replace(commentRE, '<!---->');
43180
43185
  const isHtml = path.endsWith('.html');
43181
- const regex = isHtml ? scriptModuleRE : scriptRE;
43182
- regex.lastIndex = 0;
43186
+ scriptRE.lastIndex = 0;
43183
43187
  let js = '';
43184
43188
  let scriptId = 0;
43185
43189
  let match;
43186
- while ((match = regex.exec(raw))) {
43190
+ while ((match = scriptRE.exec(raw))) {
43187
43191
  const [, openTag, content] = match;
43188
43192
  const typeMatch = openTag.match(typeRE);
43189
43193
  const type = typeMatch && (typeMatch[1] || typeMatch[2] || typeMatch[3]);
43190
43194
  const langMatch = openTag.match(langRE);
43191
43195
  const lang = langMatch && (langMatch[1] || langMatch[2] || langMatch[3]);
43196
+ // skip non type module script
43197
+ if (isHtml && type !== 'module') {
43198
+ continue;
43199
+ }
43192
43200
  // skip type="application/ld+json" and other non-JS types
43193
43201
  if (type &&
43194
43202
  !(type.includes('javascript') ||
@@ -44896,7 +44904,7 @@ const isModernFlag = `__VITE_IS_MODERN__`;
44896
44904
  const preloadMethod = `__vitePreload`;
44897
44905
  const preloadMarker = `__VITE_PRELOAD__`;
44898
44906
  const preloadHelperId = '\0vite/preload-helper';
44899
- const preloadMarkerWithQuote = `"${preloadMarker}"`;
44907
+ const preloadMarkerWithQuote = new RegExp(`['"]${preloadMarker}['"]`);
44900
44908
  const dynamicImportPrefixRE = /import\s*\(/;
44901
44909
  // TODO: abstract
44902
44910
  const optimizedDepChunkRE = /\/chunk-[A-Z\d]{8}\.js/;
@@ -44905,6 +44913,13 @@ function toRelativePath(filename, importer) {
44905
44913
  const relPath = path$o.relative(path$o.dirname(importer), filename);
44906
44914
  return relPath[0] === '.' ? relPath : `./${relPath}`;
44907
44915
  }
44916
+ function indexOfMatchInSlice(str, reg, pos = 0) {
44917
+ if (pos !== 0) {
44918
+ str = str.slice(pos);
44919
+ }
44920
+ const matcher = str.match(reg);
44921
+ return matcher?.index !== undefined ? matcher.index + pos : -1;
44922
+ }
44908
44923
  /**
44909
44924
  * Helper for preloading CSS and direct imports of async chunks in parallel to
44910
44925
  * the async chunk itself.
@@ -45252,10 +45267,10 @@ function buildImportAnalysisPlugin(config) {
45252
45267
  };
45253
45268
  addDeps(normalizedFile);
45254
45269
  }
45255
- let markerStartPos = code.indexOf(preloadMarkerWithQuote, end);
45270
+ let markerStartPos = indexOfMatchInSlice(code, preloadMarkerWithQuote, end);
45256
45271
  // fix issue #3051
45257
45272
  if (markerStartPos === -1 && imports.length === 1) {
45258
- markerStartPos = code.indexOf(preloadMarkerWithQuote);
45273
+ markerStartPos = indexOfMatchInSlice(code, preloadMarkerWithQuote);
45259
45274
  }
45260
45275
  if (markerStartPos > 0) {
45261
45276
  // the dep list includes the main chunk, so only need to reload when there are actual other deps.
@@ -45304,19 +45319,19 @@ function buildImportAnalysisPlugin(config) {
45304
45319
  ? toRelativePath(d, file)
45305
45320
  : d));
45306
45321
  }
45307
- s.update(markerStartPos, markerStartPos + preloadMarkerWithQuote.length, `[${renderedDeps.join(',')}]`);
45322
+ s.update(markerStartPos, markerStartPos + preloadMarker.length + 2, `[${renderedDeps.join(',')}]`);
45308
45323
  rewroteMarkerStartPos.add(markerStartPos);
45309
45324
  }
45310
45325
  }
45311
45326
  }
45312
45327
  // there may still be markers due to inlined dynamic imports, remove
45313
45328
  // all the markers regardless
45314
- let markerStartPos = code.indexOf(preloadMarkerWithQuote);
45329
+ let markerStartPos = indexOfMatchInSlice(code, preloadMarkerWithQuote);
45315
45330
  while (markerStartPos >= 0) {
45316
45331
  if (!rewroteMarkerStartPos.has(markerStartPos)) {
45317
- s.update(markerStartPos, markerStartPos + preloadMarkerWithQuote.length, 'void 0');
45332
+ s.update(markerStartPos, markerStartPos + preloadMarker.length + 2, 'void 0');
45318
45333
  }
45319
- markerStartPos = code.indexOf(preloadMarkerWithQuote, markerStartPos + preloadMarkerWithQuote.length);
45334
+ markerStartPos = indexOfMatchInSlice(code, preloadMarkerWithQuote, markerStartPos + preloadMarker.length + 2);
45320
45335
  }
45321
45336
  if (s.hasChanged()) {
45322
45337
  chunk.code = s.toString();
@@ -54116,11 +54131,12 @@ const functionNodeTypeRE = /Function(?:Expression|Declaration)$|Method$/;
54116
54131
  function isFunction(node) {
54117
54132
  return functionNodeTypeRE.test(node.type);
54118
54133
  }
54134
+ const blockNodeTypeRE = /^BlockStatement$|^For(?:In|Of)?Statement$/;
54135
+ function isBlock(node) {
54136
+ return blockNodeTypeRE.test(node.type);
54137
+ }
54119
54138
  function findParentScope(parentStack, isVar = false) {
54120
- const predicate = isVar
54121
- ? isFunction
54122
- : (node) => node.type === 'BlockStatement';
54123
- return parentStack.find(predicate);
54139
+ return parentStack.find(isVar ? isFunction : isBlock);
54124
54140
  }
54125
54141
  function isInDestructuringAssignment(parent, parentStack) {
54126
54142
  if (parent &&
@@ -54316,7 +54332,7 @@ async function instantiateModule(url, server, context = { global }, urlStack = [
54316
54332
  };
54317
54333
  function ssrExportAll(sourceModule) {
54318
54334
  for (const key in sourceModule) {
54319
- if (key !== 'default') {
54335
+ if (key !== 'default' && key !== '__esModule') {
54320
54336
  Object.defineProperty(ssrModule, key, {
54321
54337
  enumerable: true,
54322
54338
  configurable: true,
@@ -63452,6 +63468,8 @@ async function _createServer(inlineConfig = {}, options) {
63452
63468
  const listen = httpServer.listen.bind(httpServer);
63453
63469
  httpServer.listen = (async (port, ...args) => {
63454
63470
  try {
63471
+ // ensure ws server started
63472
+ ws.listen();
63455
63473
  await initServer();
63456
63474
  }
63457
63475
  catch (e) {
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-a178814b.js';
5
+ import { C as colors, D as bindShortcuts, x as createLogger, h as resolveConfig } from './chunks/dep-934dbc7c.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-a178814b.js').then(function (n) { return n.I; });
731
+ const { createServer } = await import('./chunks/dep-934dbc7c.js').then(function (n) { return n.I; });
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-a178814b.js').then(function (n) { return n.H; });
809
+ const { build } = await import('./chunks/dep-934dbc7c.js').then(function (n) { return n.H; });
810
810
  const buildOptions = cleanOptions(options);
811
811
  try {
812
812
  await build({
@@ -834,7 +834,7 @@ 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-a178814b.js').then(function (n) { return n.G; });
837
+ const { optimizeDeps } = await import('./chunks/dep-934dbc7c.js').then(function (n) { return n.G; });
838
838
  try {
839
839
  const config = await resolveConfig({
840
840
  root,
@@ -860,7 +860,7 @@ cli
860
860
  .option('--outDir <dir>', `[string] output directory (default: dist)`)
861
861
  .action(async (root, options) => {
862
862
  filterDuplicateOptions(options);
863
- const { preview } = await import('./chunks/dep-a178814b.js').then(function (n) { return n.J; });
863
+ const { preview } = await import('./chunks/dep-934dbc7c.js').then(function (n) { return n.J; });
864
864
  try {
865
865
  const server = await preview({
866
866
  root,
@@ -1,5 +1,5 @@
1
- import { i as isInNodeModules } from './chunks/dep-a178814b.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-a178814b.js';
1
+ import { i as isInNodeModules } from './chunks/dep-934dbc7c.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-934dbc7c.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';
@@ -3306,7 +3306,7 @@ function createDebugger(namespace, options = {}) {
3306
3306
  }
3307
3307
  if (enabled) {
3308
3308
  return (...args) => {
3309
- if (!filter || args.some((a) => a?.includes(filter))) {
3309
+ if (!filter || args.some((a) => a?.includes?.(filter))) {
3310
3310
  log(...args);
3311
3311
  }
3312
3312
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite",
3
- "version": "4.3.3",
3
+ "version": "4.3.5",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Evan You",