vite 5.0.0 → 5.0.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.
@@ -1,4 +1,4 @@
1
- import { z as commonjsGlobal, y as getDefaultExportFromCjs } from './dep-T98iZFpD.js';
1
+ import { z as commonjsGlobal, y as getDefaultExportFromCjs } from './dep-VPh1kAXQ.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 { y as getDefaultExportFromCjs } from './dep-T98iZFpD.js';
1
+ import { y as getDefaultExportFromCjs } from './dep-VPh1kAXQ.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';
@@ -15796,8 +15796,15 @@ function manifestPlugin(config) {
15796
15796
  const fileNameToAssetMeta = new Map();
15797
15797
  const assets = generatedAssets.get(config);
15798
15798
  assets.forEach((asset, referenceId) => {
15799
- const fileName = this.getFileName(referenceId);
15800
- fileNameToAssetMeta.set(fileName, asset);
15799
+ try {
15800
+ const fileName = this.getFileName(referenceId);
15801
+ fileNameToAssetMeta.set(fileName, asset);
15802
+ }
15803
+ catch (error) {
15804
+ // The asset was generated as part of a different output option.
15805
+ // It was already handled during the previous run of this plugin.
15806
+ assets.delete(referenceId);
15807
+ }
15801
15808
  });
15802
15809
  const fileNameToAsset = new Map();
15803
15810
  for (const file in bundle) {
@@ -37223,6 +37230,12 @@ function buildHtmlPlugin(config) {
37223
37230
  attrs: {
37224
37231
  ...(isAsync ? { async: true } : {}),
37225
37232
  type: 'module',
37233
+ // crossorigin must be set not only for serving assets in a different origin
37234
+ // but also to make it possible to preload the script using `<link rel="preload">`.
37235
+ // `<script type="module">` used to fetch the script with credential mode `omit`,
37236
+ // however `crossorigin` attribute cannot specify that value.
37237
+ // https://developer.chrome.com/blog/modulepreload/#ok-so-why-doesnt-link-relpreload-work-for-modules:~:text=For%20%3Cscript%3E,of%20other%20modules.
37238
+ // Now `<script type="module">` uses `same origin`: https://github.com/whatwg/html/pull/3656#:~:text=Module%20scripts%20are%20always%20fetched%20with%20credentials%20mode%20%22same%2Dorigin%22%20by%20default%20and%20can%20no%20longer%0Ause%20%22omit%22
37226
37239
  crossorigin: true,
37227
37240
  src: toOutputPath(chunk.fileName),
37228
37241
  },
@@ -38011,11 +38024,11 @@ function cssPostPlugin(config) {
38011
38024
  return normalizePath$3(path$o.format({ ...path$o.parse(name), base: undefined, ext }));
38012
38025
  }
38013
38026
  if (config.build.cssCodeSplit) {
38014
- if (isPureCssChunk) {
38015
- // this is a shared CSS-only chunk that is empty.
38016
- pureCssChunks.add(chunk);
38017
- }
38018
38027
  if (opts.format === 'es' || opts.format === 'cjs') {
38028
+ if (isPureCssChunk) {
38029
+ // this is a shared CSS-only chunk that is empty.
38030
+ pureCssChunks.add(chunk);
38031
+ }
38019
38032
  const isEntry = chunk.isEntry && isPureCssChunk;
38020
38033
  const cssAssetName = ensureFileExt(chunk.name, '.css');
38021
38034
  const originalFilename = getChunkOriginalFileName(chunk, config.root, opts.format);
@@ -38496,8 +38509,8 @@ function createCachedImport(imp) {
38496
38509
  return cached;
38497
38510
  };
38498
38511
  }
38499
- const importPostcssImport = createCachedImport(() => import('./dep-M-BNPx05.js').then(function (n) { return n.i; }));
38500
- const importPostcssModules = createCachedImport(() => import('./dep-_v8GkZ9b.js').then(function (n) { return n.i; }));
38512
+ const importPostcssImport = createCachedImport(() => import('./dep-2UYu25Ks.js').then(function (n) { return n.i; }));
38513
+ const importPostcssModules = createCachedImport(() => import('./dep-1HTAyDZa.js').then(function (n) { return n.i; }));
38501
38514
  const importPostcss = createCachedImport(() => import('postcss'));
38502
38515
  /**
38503
38516
  * @experimental
@@ -57149,13 +57162,11 @@ function htmlFallbackMiddleware(root, spaFallback) {
57149
57162
  if (
57150
57163
  // Only accept GET or HEAD
57151
57164
  (req.method !== 'GET' && req.method !== 'HEAD') ||
57152
- // Require Accept header
57153
- !req.headers ||
57154
- typeof req.headers.accept !== 'string' ||
57155
57165
  // Ignore JSON requests
57156
- req.headers.accept.includes('application/json') ||
57166
+ req.headers.accept?.includes('application/json') ||
57157
57167
  // Require Accept: text/html or */*
57158
- !(req.headers.accept.includes('text/html') ||
57168
+ !(req.headers.accept === undefined || // equivalent to `Accept: */*`
57169
+ req.headers.accept.includes('text/html') ||
57159
57170
  req.headers.accept.includes('*/*'))) {
57160
57171
  return next();
57161
57172
  }
@@ -59064,8 +59075,9 @@ function propagateUpdate(node, traversedModules, boundaries, currentChain = [nod
59064
59075
  * @param nodeChain The chain of nodes/imports that lead to the node.
59065
59076
  * (The last node in the chain imports the `node` parameter)
59066
59077
  * @param currentChain The current chain tracked from the `node` parameter
59078
+ * @param traversedModules The set of modules that have traversed
59067
59079
  */
59068
- function isNodeWithinCircularImports(node, nodeChain, currentChain = [node]) {
59080
+ function isNodeWithinCircularImports(node, nodeChain, currentChain = [node], traversedModules = new Set()) {
59069
59081
  // To help visualize how each parameters work, imagine this import graph:
59070
59082
  //
59071
59083
  // A -> B -> C -> ACCEPTED -> D -> E -> NODE
@@ -59081,6 +59093,10 @@ function isNodeWithinCircularImports(node, nodeChain, currentChain = [node]) {
59081
59093
  //
59082
59094
  // It works by checking if any `node` importers are within `nodeChain`, which
59083
59095
  // means there's an import loop with a HMR-accepted module in it.
59096
+ if (traversedModules.has(node)) {
59097
+ return false;
59098
+ }
59099
+ traversedModules.add(node);
59084
59100
  for (const importer of node.importers) {
59085
59101
  // Node may import itself which is safe
59086
59102
  if (importer === node)
@@ -59107,7 +59123,7 @@ function isNodeWithinCircularImports(node, nodeChain, currentChain = [node]) {
59107
59123
  }
59108
59124
  // Continue recursively
59109
59125
  if (!currentChain.includes(importer)) {
59110
- const result = isNodeWithinCircularImports(importer, nodeChain, currentChain.concat(importer));
59126
+ const result = isNodeWithinCircularImports(importer, nodeChain, currentChain.concat(importer), traversedModules);
59111
59127
  if (result)
59112
59128
  return result;
59113
59129
  }
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 { x as colors, k as createLogger, r as resolveConfig } from './chunks/dep-T98iZFpD.js';
5
+ import { x as colors, k as createLogger, r as resolveConfig } from './chunks/dep-VPh1kAXQ.js';
6
6
  import { VERSION } from './constants.js';
7
7
  import 'node:fs/promises';
8
8
  import 'node:url';
@@ -759,7 +759,7 @@ cli
759
759
  filterDuplicateOptions(options);
760
760
  // output structure is preserved even after bundling so require()
761
761
  // is ok here
762
- const { createServer } = await import('./chunks/dep-T98iZFpD.js').then(function (n) { return n.A; });
762
+ const { createServer } = await import('./chunks/dep-VPh1kAXQ.js').then(function (n) { return n.A; });
763
763
  try {
764
764
  const server = await createServer({
765
765
  root,
@@ -839,7 +839,7 @@ cli
839
839
  .option('-w, --watch', `[boolean] rebuilds when modules have changed on disk`)
840
840
  .action(async (root, options) => {
841
841
  filterDuplicateOptions(options);
842
- const { build } = await import('./chunks/dep-T98iZFpD.js').then(function (n) { return n.C; });
842
+ const { build } = await import('./chunks/dep-VPh1kAXQ.js').then(function (n) { return n.C; });
843
843
  const buildOptions = cleanOptions(options);
844
844
  try {
845
845
  await build({
@@ -867,7 +867,7 @@ cli
867
867
  .option('--force', `[boolean] force the optimizer to ignore the cache and re-bundle`)
868
868
  .action(async (root, options) => {
869
869
  filterDuplicateOptions(options);
870
- const { optimizeDeps } = await import('./chunks/dep-T98iZFpD.js').then(function (n) { return n.B; });
870
+ const { optimizeDeps } = await import('./chunks/dep-VPh1kAXQ.js').then(function (n) { return n.B; });
871
871
  try {
872
872
  const config = await resolveConfig({
873
873
  root,
@@ -893,7 +893,7 @@ cli
893
893
  .option('--outDir <dir>', `[string] output directory (default: dist)`)
894
894
  .action(async (root, options) => {
895
895
  filterDuplicateOptions(options);
896
- const { preview } = await import('./chunks/dep-T98iZFpD.js').then(function (n) { return n.D; });
896
+ const { preview } = await import('./chunks/dep-VPh1kAXQ.js').then(function (n) { return n.D; });
897
897
  try {
898
898
  const server = await preview({
899
899
  root,
@@ -2760,6 +2760,7 @@ interface CSSModulesOptions {
2760
2760
  getJSON?: (cssFileName: string, json: Record<string, string>, outputFileName: string) => void;
2761
2761
  scopeBehaviour?: 'global' | 'local';
2762
2762
  globalModulePaths?: RegExp[];
2763
+ exportGlobals?: boolean;
2763
2764
  generateScopedName?: string | ((name: string, filename: string, css: string) => string);
2764
2765
  hashPrefix?: string;
2765
2766
  /**
@@ -1,6 +1,6 @@
1
1
  export { parseAst, parseAstAsync } from 'rollup/parseAst';
2
- import { i as isInNodeModules } from './chunks/dep-T98iZFpD.js';
3
- export { b as build, e as buildErrorMessage, h as createFilter, k as createLogger, c as createServer, d as defineConfig, f as formatPostcssSourceMap, u as isFileServingAllowed, l as loadConfigFromFile, v as loadEnv, g as mergeAlias, m as mergeConfig, n as normalizePath, o as optimizeDeps, a as preprocessCSS, p as preview, r as resolveConfig, w as resolveEnvPrefix, q as searchForWorkspaceRoot, j as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-T98iZFpD.js';
2
+ import { i as isInNodeModules } from './chunks/dep-VPh1kAXQ.js';
3
+ export { b as build, e as buildErrorMessage, h as createFilter, k as createLogger, c as createServer, d as defineConfig, f as formatPostcssSourceMap, u as isFileServingAllowed, l as loadConfigFromFile, v as loadEnv, g as mergeAlias, m as mergeConfig, n as normalizePath, o as optimizeDeps, a as preprocessCSS, p as preview, r as resolveConfig, w as resolveEnvPrefix, q as searchForWorkspaceRoot, j as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-VPh1kAXQ.js';
4
4
  export { VERSION as version } from './constants.js';
5
5
  export { version as esbuildVersion } from 'esbuild';
6
6
  export { VERSION as rollupVersion } from 'rollup';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite",
3
- "version": "5.0.0",
3
+ "version": "5.0.1",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Evan You",