vite 5.1.0 → 5.1.1

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.
package/LICENSE.md CHANGED
@@ -1912,7 +1912,7 @@ Repository: lydell/js-tokens
1912
1912
 
1913
1913
  > The MIT License (MIT)
1914
1914
  >
1915
- > Copyright (c) 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023 Simon Lydell
1915
+ > Copyright (c) 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024 Simon Lydell
1916
1916
  >
1917
1917
  > Permission is hereby granted, free of charge, to any person obtaining a copy
1918
1918
  > of this software and associated documentation files (the "Software"), to deal
@@ -15995,6 +15995,7 @@ function svgToDataURL(content) {
15995
15995
  }
15996
15996
  }
15997
15997
 
15998
+ const endsWithJSRE = /\.[cm]?js$/;
15998
15999
  function manifestPlugin(config) {
15999
16000
  const manifest = {};
16000
16001
  let outputCount;
@@ -16085,7 +16086,8 @@ function manifestPlugin(config) {
16085
16086
  const asset = createAsset(chunk, src, assetMeta?.isEntry);
16086
16087
  // If JS chunk and asset chunk are both generated from the same source file,
16087
16088
  // prioritize JS chunk as it contains more information
16088
- if (manifest[src]?.file.endsWith('.js'))
16089
+ const file = manifest[src]?.file;
16090
+ if (file && endsWithJSRE.test(file))
16089
16091
  continue;
16090
16092
  manifest[src] = asset;
16091
16093
  fileNameToAsset.set(chunk.fileName, asset);
@@ -29137,19 +29139,19 @@ var postcssrc = /*@__PURE__*/getDefaultExportFromCjs(src$1);
29137
29139
  // Copyright 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023 Simon Lydell
29138
29140
  // License: MIT.
29139
29141
  var Identifier, JSXIdentifier, JSXPunctuator, JSXString, JSXText, KeywordsWithExpressionAfter, KeywordsWithNoLineTerminatorAfter, LineTerminatorSequence, MultiLineComment, Newline, NumericLiteral, Punctuator, RegularExpressionLiteral, SingleLineComment, StringLiteral, Template, TokensNotPrecedingObjectLiteral, TokensPrecedingExpression, WhiteSpace;
29140
- RegularExpressionLiteral = /\/(?![*\/])(?:\[(?:(?![\]\\]).|\\.)*\]|(?![\/\\]).|\\.)*(\/[$_\u200C\u200D\p{ID_Continue}]*|\\)?/yu;
29142
+ RegularExpressionLiteral = /\/(?![*\/])(?:\[(?:[^\]\\\n\r\u2028\u2029]+|\\.)*\]|[^\/\\\n\r\u2028\u2029]+|\\.)*(\/[$_\u200C\u200D\p{ID_Continue}]*|\\)?/yu;
29141
29143
  Punctuator = /--|\+\+|=>|\.{3}|\??\.(?!\d)|(?:&&|\|\||\?\?|[+\-%&|^]|\*{1,2}|<{1,2}|>{1,3}|!=?|={1,2}|\/(?![\/*]))=?|[?~,:;[\](){}]/y;
29142
- Identifier = /(\x23?)(?=[$_\p{ID_Start}\\])(?:[$_\u200C\u200D\p{ID_Continue}]|\\u[\da-fA-F]{4}|\\u\{[\da-fA-F]+\})+/yu;
29143
- StringLiteral = /(['"])(?:(?!\1)[^\\\n\r]|\\(?:\r\n|[^]))*(\1)?/y;
29144
+ Identifier = /(\x23?)(?=[$_\p{ID_Start}\\])(?:[$_\u200C\u200D\p{ID_Continue}]+|\\u[\da-fA-F]{4}|\\u\{[\da-fA-F]+\})+/yu;
29145
+ StringLiteral = /(['"])(?:[^'"\\\n\r]+|(?!\1)['"]|\\(?:\r\n|[^]))*(\1)?/y;
29144
29146
  NumericLiteral = /(?:0[xX][\da-fA-F](?:_?[\da-fA-F])*|0[oO][0-7](?:_?[0-7])*|0[bB][01](?:_?[01])*)n?|0n|[1-9](?:_?\d)*n|(?:(?:0(?!\d)|0\d*[89]\d*|[1-9](?:_?\d)*)(?:\.(?:\d(?:_?\d)*)?)?|\.\d(?:_?\d)*)(?:[eE][+-]?\d(?:_?\d)*)?|0[0-7]+/y;
29145
- Template = /[`}](?:[^`\\$]|\\[^]|\$(?!\{))*(`|\$\{)?/y;
29147
+ Template = /[`}](?:[^`\\$]+|\\[^]|\$(?!\{))*(`|\$\{)?/y;
29146
29148
  WhiteSpace = /[\t\v\f\ufeff\p{Zs}]+/yu;
29147
29149
  LineTerminatorSequence = /\r?\n|[\r\u2028\u2029]/y;
29148
- MultiLineComment = /\/\*(?:[^*]|\*(?!\/))*(\*\/)?/y;
29150
+ MultiLineComment = /\/\*(?:[^*]+|\*(?!\/))*(\*\/)?/y;
29149
29151
  SingleLineComment = /\/\/.*/y;
29150
29152
  JSXPunctuator = /[<>.:={}]|\/(?![\/*])/y;
29151
29153
  JSXIdentifier = /[$_\p{ID_Start}][$_\u200C\u200D\p{ID_Continue}-]*/yu;
29152
- JSXString = /(['"])(?:(?!\1)[^])*(\1)?/y;
29154
+ JSXString = /(['"])(?:[^'"]+|(?!\1)['"])*(\1)?/y;
29153
29155
  JSXText = /[^<>{}]+/y;
29154
29156
  TokensPrecedingExpression = /^(?:[\/+-]|\.{3}|\?(?:InterpolationIn(?:JSX|Template)|NoLineTerminatorHere|NonExpressionParenEnd|UnaryIncDec))?$|[{}([,;<>=*%&|^!~?:]$/;
29155
29157
  TokensNotPrecedingObjectLiteral = /^(?:=>|[;\]){}]|else|\?(?:NoLineTerminatorHere|NonExpressionParenEnd))?$/;
@@ -31551,75 +31553,74 @@ function cssPostPlugin(config) {
31551
31553
  s.update(start, end, replacementString);
31552
31554
  }
31553
31555
  }
31554
- if (!chunkCSS && !s) {
31555
- return null;
31556
- }
31557
- if (config.build.cssCodeSplit) {
31558
- if (opts.format === 'es' || opts.format === 'cjs') {
31559
- if (isPureCssChunk) {
31560
- // this is a shared CSS-only chunk that is empty.
31561
- pureCssChunks.add(chunk);
31562
- }
31563
- const isEntry = chunk.isEntry && isPureCssChunk;
31564
- const cssFullAssetName = ensureFileExt(chunk.name, '.css');
31565
- // if facadeModuleId doesn't exist or doesn't have a CSS extension,
31566
- // that means a JS entry file imports a CSS file.
31567
- // in this case, only use the filename for the CSS chunk name like JS chunks.
31568
- const cssAssetName = chunk.isEntry &&
31569
- (!chunk.facadeModuleId || !isCSSRequest(chunk.facadeModuleId))
31570
- ? path$o.basename(cssFullAssetName)
31571
- : cssFullAssetName;
31572
- const originalFilename = getChunkOriginalFileName(chunk, config.root, opts.format);
31573
- chunkCSS = resolveAssetUrlsInCss(chunkCSS, cssAssetName);
31574
- // wait for previous tasks as well
31575
- chunkCSS = await codeSplitEmitQueue.run(async () => {
31576
- return finalizeCss(chunkCSS, true, config);
31577
- });
31578
- // emit corresponding css file
31579
- const referenceId = this.emitFile({
31580
- name: cssAssetName,
31581
- type: 'asset',
31582
- source: chunkCSS,
31583
- });
31584
- generatedAssets
31585
- .get(config)
31586
- .set(referenceId, { originalName: originalFilename, isEntry });
31587
- chunk.viteMetadata.importedCss.add(this.getFileName(referenceId));
31588
- }
31589
- else if (!config.build.ssr) {
31590
- // legacy build and inline css
31591
- // Entry chunk CSS will be collected into `chunk.viteMetadata.importedCss`
31592
- // and injected later by the `'vite:build-html'` plugin into the `index.html`
31593
- // so it will be duplicated. (https://github.com/vitejs/vite/issues/2062#issuecomment-782388010)
31594
- // But because entry chunk can be imported by dynamic import,
31595
- // we shouldn't remove the inlined CSS. (#10285)
31596
- chunkCSS = await finalizeCss(chunkCSS, true, config);
31597
- let cssString = JSON.stringify(chunkCSS);
31598
- cssString =
31599
- renderAssetUrlInJS(this, config, chunk, opts, cssString)?.toString() || cssString;
31600
- const style = `__vite_style__`;
31601
- const injectCode = `var ${style} = document.createElement('style');` +
31602
- `${style}.textContent = ${cssString};` +
31603
- `document.head.appendChild(${style});`;
31604
- let injectionPoint;
31605
- const wrapIdx = code.indexOf('System.register');
31606
- if (wrapIdx >= 0) {
31607
- const executeFnStart = code.indexOf('execute:', wrapIdx);
31608
- injectionPoint = code.indexOf('{', executeFnStart) + 1;
31556
+ if (chunkCSS) {
31557
+ if (config.build.cssCodeSplit) {
31558
+ if (opts.format === 'es' || opts.format === 'cjs') {
31559
+ if (isPureCssChunk) {
31560
+ // this is a shared CSS-only chunk that is empty.
31561
+ pureCssChunks.add(chunk);
31562
+ }
31563
+ const isEntry = chunk.isEntry && isPureCssChunk;
31564
+ const cssFullAssetName = ensureFileExt(chunk.name, '.css');
31565
+ // if facadeModuleId doesn't exist or doesn't have a CSS extension,
31566
+ // that means a JS entry file imports a CSS file.
31567
+ // in this case, only use the filename for the CSS chunk name like JS chunks.
31568
+ const cssAssetName = chunk.isEntry &&
31569
+ (!chunk.facadeModuleId || !isCSSRequest(chunk.facadeModuleId))
31570
+ ? path$o.basename(cssFullAssetName)
31571
+ : cssFullAssetName;
31572
+ const originalFilename = getChunkOriginalFileName(chunk, config.root, opts.format);
31573
+ chunkCSS = resolveAssetUrlsInCss(chunkCSS, cssAssetName);
31574
+ // wait for previous tasks as well
31575
+ chunkCSS = await codeSplitEmitQueue.run(async () => {
31576
+ return finalizeCss(chunkCSS, true, config);
31577
+ });
31578
+ // emit corresponding css file
31579
+ const referenceId = this.emitFile({
31580
+ name: cssAssetName,
31581
+ type: 'asset',
31582
+ source: chunkCSS,
31583
+ });
31584
+ generatedAssets
31585
+ .get(config)
31586
+ .set(referenceId, { originalName: originalFilename, isEntry });
31587
+ chunk.viteMetadata.importedCss.add(this.getFileName(referenceId));
31609
31588
  }
31610
- else {
31611
- const insertMark = "'use strict';";
31612
- injectionPoint = code.indexOf(insertMark) + insertMark.length;
31589
+ else if (!config.build.ssr) {
31590
+ // legacy build and inline css
31591
+ // Entry chunk CSS will be collected into `chunk.viteMetadata.importedCss`
31592
+ // and injected later by the `'vite:build-html'` plugin into the `index.html`
31593
+ // so it will be duplicated. (https://github.com/vitejs/vite/issues/2062#issuecomment-782388010)
31594
+ // But because entry chunk can be imported by dynamic import,
31595
+ // we shouldn't remove the inlined CSS. (#10285)
31596
+ chunkCSS = await finalizeCss(chunkCSS, true, config);
31597
+ let cssString = JSON.stringify(chunkCSS);
31598
+ cssString =
31599
+ renderAssetUrlInJS(this, config, chunk, opts, cssString)?.toString() || cssString;
31600
+ const style = `__vite_style__`;
31601
+ const injectCode = `var ${style} = document.createElement('style');` +
31602
+ `${style}.textContent = ${cssString};` +
31603
+ `document.head.appendChild(${style});`;
31604
+ let injectionPoint;
31605
+ const wrapIdx = code.indexOf('System.register');
31606
+ if (wrapIdx >= 0) {
31607
+ const executeFnStart = code.indexOf('execute:', wrapIdx);
31608
+ injectionPoint = code.indexOf('{', executeFnStart) + 1;
31609
+ }
31610
+ else {
31611
+ const insertMark = "'use strict';";
31612
+ injectionPoint = code.indexOf(insertMark) + insertMark.length;
31613
+ }
31614
+ s ||= new MagicString(code);
31615
+ s.appendRight(injectionPoint, injectCode);
31613
31616
  }
31614
- s ||= new MagicString(code);
31615
- s.appendRight(injectionPoint, injectCode);
31616
31617
  }
31617
- }
31618
- else {
31619
- // resolve public URL from CSS paths, we need to use absolute paths
31620
- chunkCSS = resolveAssetUrlsInCss(chunkCSS, cssBundleName);
31621
- // finalizeCss is called for the aggregated chunk in generateBundle
31622
- chunkCSSMap.set(chunk.fileName, chunkCSS);
31618
+ else {
31619
+ // resolve public URL from CSS paths, we need to use absolute paths
31620
+ chunkCSS = resolveAssetUrlsInCss(chunkCSS, cssBundleName);
31621
+ // finalizeCss is called for the aggregated chunk in generateBundle
31622
+ chunkCSSMap.set(chunk.fileName, chunkCSS);
31623
+ }
31623
31624
  }
31624
31625
  if (s) {
31625
31626
  if (config.build.sourcemap) {
@@ -32081,8 +32082,8 @@ function createCachedImport(imp) {
32081
32082
  return cached;
32082
32083
  };
32083
32084
  }
32084
- const importPostcssImport = createCachedImport(() => import('./dep-QywIN17l.js').then(function (n) { return n.i; }));
32085
- const importPostcssModules = createCachedImport(() => import('./dep-BWGc69YA.js').then(function (n) { return n.i; }));
32085
+ const importPostcssImport = createCachedImport(() => import('./dep-xESY8DUV.js').then(function (n) { return n.i; }));
32086
+ const importPostcssModules = createCachedImport(() => import('./dep-XbJJvsnO.js').then(function (n) { return n.i; }));
32086
32087
  const importPostcss = createCachedImport(() => import('postcss'));
32087
32088
  const preprocessorWorkerControllerCache = new WeakMap();
32088
32089
  let alwaysFakeWorkerWorkerControllerCache;
@@ -1,4 +1,4 @@
1
- import { C as commonjsGlobal, B as getDefaultExportFromCjs } from './dep-nGG-_oRu.js';
1
+ import { C as commonjsGlobal, B as getDefaultExportFromCjs } from './dep-94_H5fT6.js';
2
2
  import require$$0__default from 'fs';
3
3
  import require$$0 from 'postcss';
4
4
  import require$$0$1 from 'path';
@@ -1,4 +1,4 @@
1
- import { B as getDefaultExportFromCjs } from './dep-nGG-_oRu.js';
1
+ import { B as getDefaultExportFromCjs } from './dep-94_H5fT6.js';
2
2
  import require$$0 from 'path';
3
3
  import require$$0__default from 'fs';
4
4
  import { l as lib } from './dep-8a-6Quh6.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, a as createLogger, r as resolveConfig } from './chunks/dep-nGG-_oRu.js';
5
+ import { c as colors, a as createLogger, r as resolveConfig } from './chunks/dep-94_H5fT6.js';
6
6
  import { VERSION } from './constants.js';
7
7
  import 'node:fs/promises';
8
8
  import 'node:url';
@@ -757,7 +757,7 @@ cli
757
757
  filterDuplicateOptions(options);
758
758
  // output structure is preserved even after bundling so require()
759
759
  // is ok here
760
- const { createServer } = await import('./chunks/dep-nGG-_oRu.js').then(function (n) { return n.E; });
760
+ const { createServer } = await import('./chunks/dep-94_H5fT6.js').then(function (n) { return n.E; });
761
761
  try {
762
762
  const server = await createServer({
763
763
  root,
@@ -836,7 +836,7 @@ cli
836
836
  .option('-w, --watch', `[boolean] rebuilds when modules have changed on disk`)
837
837
  .action(async (root, options) => {
838
838
  filterDuplicateOptions(options);
839
- const { build } = await import('./chunks/dep-nGG-_oRu.js').then(function (n) { return n.F; });
839
+ const { build } = await import('./chunks/dep-94_H5fT6.js').then(function (n) { return n.F; });
840
840
  const buildOptions = cleanOptions(options);
841
841
  try {
842
842
  await build({
@@ -863,7 +863,7 @@ cli
863
863
  .option('--force', `[boolean] force the optimizer to ignore the cache and re-bundle`)
864
864
  .action(async (root, options) => {
865
865
  filterDuplicateOptions(options);
866
- const { optimizeDeps } = await import('./chunks/dep-nGG-_oRu.js').then(function (n) { return n.D; });
866
+ const { optimizeDeps } = await import('./chunks/dep-94_H5fT6.js').then(function (n) { return n.D; });
867
867
  try {
868
868
  const config = await resolveConfig({
869
869
  root,
@@ -889,7 +889,7 @@ cli
889
889
  .option('--outDir <dir>', `[string] output directory (default: dist)`)
890
890
  .action(async (root, options) => {
891
891
  filterDuplicateOptions(options);
892
- const { preview } = await import('./chunks/dep-nGG-_oRu.js').then(function (n) { return n.G; });
892
+ const { preview } = await import('./chunks/dep-94_H5fT6.js').then(function (n) { return n.G; });
893
893
  try {
894
894
  const server = await preview({
895
895
  root,
@@ -1,6 +1,6 @@
1
1
  export { parseAst, parseAstAsync } from 'rollup/parseAst';
2
- import { i as isInNodeModules, b as arraify } from './chunks/dep-nGG-_oRu.js';
3
- export { f as build, j as buildErrorMessage, u as createFilter, a as createLogger, e as createServer, d as defineConfig, k as fetchModule, g as formatPostcssSourceMap, y as isFileServingAllowed, l as loadConfigFromFile, z as loadEnv, q as mergeAlias, m as mergeConfig, n as normalizePath, o as optimizeDeps, h as preprocessCSS, p as preview, r as resolveConfig, A as resolveEnvPrefix, v as rollupVersion, x as searchForWorkspaceRoot, w as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-nGG-_oRu.js';
2
+ import { i as isInNodeModules, b as arraify } from './chunks/dep-94_H5fT6.js';
3
+ export { f as build, j as buildErrorMessage, u as createFilter, a as createLogger, e as createServer, d as defineConfig, k as fetchModule, g as formatPostcssSourceMap, y as isFileServingAllowed, l as loadConfigFromFile, z as loadEnv, q as mergeAlias, m as mergeConfig, n as normalizePath, o as optimizeDeps, h as preprocessCSS, p as preview, r as resolveConfig, A as resolveEnvPrefix, v as rollupVersion, x as searchForWorkspaceRoot, w as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-94_H5fT6.js';
4
4
  export { VERSION as version } from './constants.js';
5
5
  export { version as esbuildVersion } from 'esbuild';
6
6
  import { existsSync, readFileSync } from 'node:fs';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite",
3
- "version": "5.1.0",
3
+ "version": "5.1.1",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Evan You",