vite 5.0.0-beta.5 → 5.0.0-beta.6
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 { E as commonjsGlobal, D as getDefaultExportFromCjs } from './dep-
|
|
1
|
+
import { E as commonjsGlobal, D as getDefaultExportFromCjs } from './dep-db07a1ea.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,11 +11876,22 @@ const replaceSlashOrColonRE = /[/:]/g;
|
|
|
11876
11876
|
const replaceDotRE = /\./g;
|
|
11877
11877
|
const replaceNestedIdRE = /(\s*>\s*)/g;
|
|
11878
11878
|
const replaceHashRE = /#/g;
|
|
11879
|
-
const flattenId = (id) =>
|
|
11880
|
-
|
|
11881
|
-
|
|
11882
|
-
|
|
11883
|
-
|
|
11879
|
+
const flattenId = (id) => {
|
|
11880
|
+
const flatId = limitFlattenIdLength(id
|
|
11881
|
+
.replace(replaceSlashOrColonRE, '_')
|
|
11882
|
+
.replace(replaceDotRE, '__')
|
|
11883
|
+
.replace(replaceNestedIdRE, '___')
|
|
11884
|
+
.replace(replaceHashRE, '____'));
|
|
11885
|
+
return flatId;
|
|
11886
|
+
};
|
|
11887
|
+
const FLATTEN_ID_HASH_LENGTH = 8;
|
|
11888
|
+
const FLATTEN_ID_MAX_FILE_LENGTH = 170;
|
|
11889
|
+
const limitFlattenIdLength = (id, limit = FLATTEN_ID_MAX_FILE_LENGTH) => {
|
|
11890
|
+
if (id.length <= limit) {
|
|
11891
|
+
return id;
|
|
11892
|
+
}
|
|
11893
|
+
return id.slice(0, limit - (FLATTEN_ID_HASH_LENGTH + 1)) + '_' + getHash(id);
|
|
11894
|
+
};
|
|
11884
11895
|
const normalizeId = (id) => id.replace(replaceNestedIdRE, ' > ');
|
|
11885
11896
|
// Supported by Node, Deno, Bun
|
|
11886
11897
|
const NODE_BUILTIN_NAMESPACE = 'node:';
|
|
@@ -39148,13 +39159,7 @@ function cssPostPlugin(config) {
|
|
|
39148
39159
|
.filter((chunk) => chunk.type === 'chunk')
|
|
39149
39160
|
.map((chunk) => [chunk.preliminaryFileName, chunk.fileName]));
|
|
39150
39161
|
const pureCssChunkNames = [...pureCssChunks].map((pureCssChunk) => prelimaryNameToChunkMap[pureCssChunk.fileName]);
|
|
39151
|
-
const
|
|
39152
|
-
.map((file) => path$o.basename(file))
|
|
39153
|
-
.join('|')
|
|
39154
|
-
.replace(/\./g, '\\.');
|
|
39155
|
-
const emptyChunkRE = new RegExp(opts.format === 'es'
|
|
39156
|
-
? `\\bimport\\s*["'][^"']*(?:${emptyChunkFiles})["'];\n?`
|
|
39157
|
-
: `\\brequire\\(\\s*["'][^"']*(?:${emptyChunkFiles})["']\\);\n?`, 'g');
|
|
39162
|
+
const replaceEmptyChunk = getEmptyChunkReplacer(pureCssChunkNames, opts.format);
|
|
39158
39163
|
for (const file in bundle) {
|
|
39159
39164
|
const chunk = bundle[file];
|
|
39160
39165
|
if (chunk.type === 'chunk') {
|
|
@@ -39170,9 +39175,7 @@ function cssPostPlugin(config) {
|
|
|
39170
39175
|
}
|
|
39171
39176
|
return true;
|
|
39172
39177
|
});
|
|
39173
|
-
chunk.code = chunk.code
|
|
39174
|
-
// remove css import while preserving source map location
|
|
39175
|
-
(m) => `/* empty css ${''.padEnd(m.length - 15)}*/`);
|
|
39178
|
+
chunk.code = replaceEmptyChunk(chunk.code);
|
|
39176
39179
|
}
|
|
39177
39180
|
}
|
|
39178
39181
|
const removedPureCssFiles = removedPureCssFilesCache.get(config);
|
|
@@ -39213,6 +39216,23 @@ function cssPostPlugin(config) {
|
|
|
39213
39216
|
},
|
|
39214
39217
|
};
|
|
39215
39218
|
}
|
|
39219
|
+
/**
|
|
39220
|
+
* Create a replacer function that takes code and replaces given pure CSS chunk imports
|
|
39221
|
+
* @param pureCssChunkNames The chunks that only contain pure CSS and should be replaced
|
|
39222
|
+
* @param outputFormat The module output format to decide whether to replace `import` or `require`
|
|
39223
|
+
*/
|
|
39224
|
+
function getEmptyChunkReplacer(pureCssChunkNames, outputFormat) {
|
|
39225
|
+
const emptyChunkFiles = pureCssChunkNames
|
|
39226
|
+
.map((file) => path$o.basename(file))
|
|
39227
|
+
.join('|')
|
|
39228
|
+
.replace(/\./g, '\\.');
|
|
39229
|
+
const emptyChunkRE = new RegExp(outputFormat === 'es'
|
|
39230
|
+
? `\\bimport\\s*["'][^"']*(?:${emptyChunkFiles})["'];\n?`
|
|
39231
|
+
: `\\brequire\\(\\s*["'][^"']*(?:${emptyChunkFiles})["']\\);\n?`, 'g');
|
|
39232
|
+
return (code) => code.replace(emptyChunkRE,
|
|
39233
|
+
// remove css import while preserving source map location
|
|
39234
|
+
(m) => `/* empty css ${''.padEnd(m.length - 15)}*/`);
|
|
39235
|
+
}
|
|
39216
39236
|
function createCSSResolvers(config) {
|
|
39217
39237
|
let cssResolve;
|
|
39218
39238
|
let sassResolve;
|
|
@@ -39508,8 +39528,8 @@ function createCachedImport(imp) {
|
|
|
39508
39528
|
return cached;
|
|
39509
39529
|
};
|
|
39510
39530
|
}
|
|
39511
|
-
const importPostcssImport = createCachedImport(() => import('./dep-
|
|
39512
|
-
const importPostcssModules = createCachedImport(() => import('./dep-
|
|
39531
|
+
const importPostcssImport = createCachedImport(() => import('./dep-ce41d4ea.js').then(function (n) { return n.i; }));
|
|
39532
|
+
const importPostcssModules = createCachedImport(() => import('./dep-c3c41c00.js').then(function (n) { return n.i; }));
|
|
39513
39533
|
const importPostcss = createCachedImport(() => import('postcss'));
|
|
39514
39534
|
/**
|
|
39515
39535
|
* @experimental
|
|
@@ -47444,6 +47464,23 @@ function buildImportAnalysisPlugin(config) {
|
|
|
47444
47464
|
}
|
|
47445
47465
|
const s = new MagicString(code);
|
|
47446
47466
|
const rewroteMarkerStartPos = new Set(); // position of the leading double quote
|
|
47467
|
+
const fileDeps = [];
|
|
47468
|
+
const addFileDep = (url, runtime = false) => {
|
|
47469
|
+
const index = fileDeps.findIndex((dep) => dep.url === url);
|
|
47470
|
+
if (index === -1) {
|
|
47471
|
+
return fileDeps.push({ url, runtime }) - 1;
|
|
47472
|
+
}
|
|
47473
|
+
else {
|
|
47474
|
+
return index;
|
|
47475
|
+
}
|
|
47476
|
+
};
|
|
47477
|
+
const getFileDep = (index) => {
|
|
47478
|
+
const fileDep = fileDeps[index];
|
|
47479
|
+
if (!fileDep) {
|
|
47480
|
+
throw new Error(`Cannot find file dep at index ${index}`);
|
|
47481
|
+
}
|
|
47482
|
+
return fileDep;
|
|
47483
|
+
};
|
|
47447
47484
|
if (imports.length) {
|
|
47448
47485
|
for (let index = 0; index < imports.length; index++) {
|
|
47449
47486
|
// To handle escape sequences in specifier strings, the .n field will be provided where possible.
|
|
@@ -47471,12 +47508,12 @@ function buildImportAnalysisPlugin(config) {
|
|
|
47471
47508
|
analyzed.add(filename);
|
|
47472
47509
|
const chunk = bundle[filename];
|
|
47473
47510
|
if (chunk) {
|
|
47474
|
-
deps.add(chunk.fileName);
|
|
47511
|
+
deps.add(addFileDep(chunk.fileName));
|
|
47475
47512
|
chunk.imports.forEach(addDeps);
|
|
47476
47513
|
// Ensure that the css imported by current chunk is loaded after the dependencies.
|
|
47477
47514
|
// So the style of current chunk won't be overwritten unexpectedly.
|
|
47478
47515
|
chunk.viteMetadata.importedCss.forEach((file) => {
|
|
47479
|
-
deps.add(file);
|
|
47516
|
+
deps.add(addFileDep(file));
|
|
47480
47517
|
});
|
|
47481
47518
|
}
|
|
47482
47519
|
else {
|
|
@@ -47485,7 +47522,7 @@ function buildImportAnalysisPlugin(config) {
|
|
|
47485
47522
|
if (chunk) {
|
|
47486
47523
|
if (chunk.viteMetadata.importedCss.size) {
|
|
47487
47524
|
chunk.viteMetadata.importedCss.forEach((file) => {
|
|
47488
|
-
deps.add(file);
|
|
47525
|
+
deps.add(addFileDep(file));
|
|
47489
47526
|
});
|
|
47490
47527
|
hasRemovedPureCssChunk = true;
|
|
47491
47528
|
}
|
|
@@ -47508,7 +47545,7 @@ function buildImportAnalysisPlugin(config) {
|
|
|
47508
47545
|
? modulePreload === false
|
|
47509
47546
|
? // CSS deps use the same mechanism as module preloads, so even if disabled,
|
|
47510
47547
|
// we still need to pass these deps to the preload helper in dynamic imports.
|
|
47511
|
-
[...deps].filter((d) => d.endsWith('.css'))
|
|
47548
|
+
[...deps].filter((d) => getFileDep(d).url.endsWith('.css'))
|
|
47512
47549
|
: [...deps]
|
|
47513
47550
|
: [];
|
|
47514
47551
|
let renderedDeps;
|
|
@@ -47524,13 +47561,18 @@ function buildImportAnalysisPlugin(config) {
|
|
|
47524
47561
|
const cssDeps = [];
|
|
47525
47562
|
const otherDeps = [];
|
|
47526
47563
|
for (const dep of depsArray) {
|
|
47527
|
-
(dep.endsWith('.css')
|
|
47564
|
+
if (getFileDep(dep).url.endsWith('.css')) {
|
|
47565
|
+
cssDeps.push(dep);
|
|
47566
|
+
}
|
|
47567
|
+
else {
|
|
47568
|
+
otherDeps.push(dep);
|
|
47569
|
+
}
|
|
47528
47570
|
}
|
|
47529
47571
|
resolvedDeps = [
|
|
47530
|
-
...resolveDependencies(normalizedFile, otherDeps, {
|
|
47572
|
+
...resolveDependencies(normalizedFile, otherDeps.map((otherDep) => getFileDep(otherDep).url), {
|
|
47531
47573
|
hostId: file,
|
|
47532
47574
|
hostType: 'js',
|
|
47533
|
-
}),
|
|
47575
|
+
}).map((otherDep) => addFileDep(otherDep)),
|
|
47534
47576
|
...cssDeps,
|
|
47535
47577
|
];
|
|
47536
47578
|
}
|
|
@@ -47538,26 +47580,36 @@ function buildImportAnalysisPlugin(config) {
|
|
|
47538
47580
|
resolvedDeps = depsArray;
|
|
47539
47581
|
}
|
|
47540
47582
|
renderedDeps = resolvedDeps.map((dep) => {
|
|
47541
|
-
const replacement = toOutputFilePathInJS(dep, 'asset', chunk.fileName, 'js', config, toRelativePath);
|
|
47542
|
-
|
|
47543
|
-
|
|
47544
|
-
|
|
47545
|
-
return
|
|
47583
|
+
const replacement = toOutputFilePathInJS(getFileDep(dep).url, 'asset', chunk.fileName, 'js', config, toRelativePath);
|
|
47584
|
+
if (typeof replacement === 'string') {
|
|
47585
|
+
return addFileDep(replacement);
|
|
47586
|
+
}
|
|
47587
|
+
return addFileDep(replacement.runtime, true);
|
|
47546
47588
|
});
|
|
47547
47589
|
}
|
|
47548
47590
|
else {
|
|
47549
47591
|
renderedDeps = depsArray.map((d) =>
|
|
47550
47592
|
// Don't include the assets dir if the default asset file names
|
|
47551
47593
|
// are used, the path will be reconstructed by the import preload helper
|
|
47552
|
-
|
|
47553
|
-
? toRelativePath(d, file)
|
|
47554
|
-
: d)
|
|
47594
|
+
optimizeModulePreloadRelativePaths
|
|
47595
|
+
? addFileDep(toRelativePath(getFileDep(d).url, file))
|
|
47596
|
+
: d);
|
|
47555
47597
|
}
|
|
47556
|
-
s.update(markerStartPos, markerStartPos + preloadMarker.length + 2, `[${renderedDeps.join(',')}]`);
|
|
47598
|
+
s.update(markerStartPos, markerStartPos + preloadMarker.length + 2, `__vite__mapDeps([${renderedDeps.join(',')}])`);
|
|
47557
47599
|
rewroteMarkerStartPos.add(markerStartPos);
|
|
47558
47600
|
}
|
|
47559
47601
|
}
|
|
47560
47602
|
}
|
|
47603
|
+
const fileDepsCode = `[${fileDeps
|
|
47604
|
+
.map((fileDep) => fileDep.runtime ? fileDep.url : JSON.stringify(fileDep.url))
|
|
47605
|
+
.join(',')}]`;
|
|
47606
|
+
s.append(`\
|
|
47607
|
+
function __vite__mapDeps(indexes) {
|
|
47608
|
+
if (!__vite__mapDeps.viteFileDeps) {
|
|
47609
|
+
__vite__mapDeps.viteFileDeps = ${fileDepsCode}
|
|
47610
|
+
}
|
|
47611
|
+
return indexes.map((i) => __vite__mapDeps.viteFileDeps[i])
|
|
47612
|
+
}`);
|
|
47561
47613
|
// there may still be markers due to inlined dynamic imports, remove
|
|
47562
47614
|
// all the markers regardless
|
|
47563
47615
|
let markerStartPos = indexOfMatchInSlice(code, preloadMarkerWithQuote);
|
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, x as createLogger, h as resolveConfig } from './chunks/dep-
|
|
5
|
+
import { C as colors, x as createLogger, h as resolveConfig } from './chunks/dep-db07a1ea.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-
|
|
762
|
+
const { createServer } = await import('./chunks/dep-db07a1ea.js').then(function (n) { return n.H; });
|
|
763
763
|
try {
|
|
764
764
|
const server = await createServer({
|
|
765
765
|
root,
|
|
@@ -840,7 +840,7 @@ cli
|
|
|
840
840
|
.option('-w, --watch', `[boolean] rebuilds when modules have changed on disk`)
|
|
841
841
|
.action(async (root, options) => {
|
|
842
842
|
filterDuplicateOptions(options);
|
|
843
|
-
const { build } = await import('./chunks/dep-
|
|
843
|
+
const { build } = await import('./chunks/dep-db07a1ea.js').then(function (n) { return n.G; });
|
|
844
844
|
const buildOptions = cleanOptions(options);
|
|
845
845
|
try {
|
|
846
846
|
await build({
|
|
@@ -868,7 +868,7 @@ cli
|
|
|
868
868
|
.option('--force', `[boolean] force the optimizer to ignore the cache and re-bundle`)
|
|
869
869
|
.action(async (root, options) => {
|
|
870
870
|
filterDuplicateOptions(options);
|
|
871
|
-
const { optimizeDeps } = await import('./chunks/dep-
|
|
871
|
+
const { optimizeDeps } = await import('./chunks/dep-db07a1ea.js').then(function (n) { return n.F; });
|
|
872
872
|
try {
|
|
873
873
|
const config = await resolveConfig({
|
|
874
874
|
root,
|
|
@@ -895,7 +895,7 @@ cli
|
|
|
895
895
|
.option('--outDir <dir>', `[string] output directory (default: dist)`)
|
|
896
896
|
.action(async (root, options) => {
|
|
897
897
|
filterDuplicateOptions(options);
|
|
898
|
-
const { preview } = await import('./chunks/dep-
|
|
898
|
+
const { preview } = await import('./chunks/dep-db07a1ea.js').then(function (n) { return n.I; });
|
|
899
899
|
try {
|
|
900
900
|
const server = await preview({
|
|
901
901
|
root,
|
package/dist/node/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as isInNodeModules } from './chunks/dep-
|
|
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-
|
|
1
|
+
import { i as isInNodeModules } from './chunks/dep-db07a1ea.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-db07a1ea.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';
|