vite 4.4.9 → 4.4.10
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.
- package/client.d.ts +1 -1
- package/dist/node/chunks/{dep-df561101.js → dep-3bba9c7e.js} +157 -73
- package/dist/node/chunks/{dep-73522cdf.js → dep-809640fa.js} +1 -1
- package/dist/node/chunks/{dep-e0331088.js → dep-fdea5ef1.js} +1 -1
- package/dist/node/cli.js +28 -8
- package/dist/node/index.js +2 -2
- package/dist/node-cjs/publicUtils.cjs +35 -7
- package/package.json +4 -1
package/client.d.ts
CHANGED
|
@@ -11834,6 +11834,12 @@ const flattenId = (id) => id
|
|
|
11834
11834
|
.replace(replaceNestedIdRE, '___')
|
|
11835
11835
|
.replace(replaceHashRE, '____');
|
|
11836
11836
|
const normalizeId = (id) => id.replace(replaceNestedIdRE, ' > ');
|
|
11837
|
+
// Supported by Node, Deno, Bun
|
|
11838
|
+
const NODE_BUILTIN_NAMESPACE = 'node:';
|
|
11839
|
+
// Supported by Deno
|
|
11840
|
+
const NPM_BUILTIN_NAMESPACE = 'npm:';
|
|
11841
|
+
// Supported by Bun
|
|
11842
|
+
const BUN_BUILTIN_NAMESPACE = 'bun:';
|
|
11837
11843
|
//TODO: revisit later to see if the edge case that "compiling using node v12 code to be run in node v16 in the server" is what we intend to support.
|
|
11838
11844
|
const builtins = new Set([
|
|
11839
11845
|
...builtinModules,
|
|
@@ -11851,17 +11857,26 @@ const builtins = new Set([
|
|
|
11851
11857
|
'util/types',
|
|
11852
11858
|
'wasi',
|
|
11853
11859
|
]);
|
|
11854
|
-
|
|
11860
|
+
// Some runtimes like Bun injects namespaced modules here, which is not a node builtin
|
|
11861
|
+
const nodeBuiltins = [...builtins].filter((id) => !id.includes(':'));
|
|
11862
|
+
// TODO: Use `isBuiltin` from `node:module`, but Deno doesn't support it
|
|
11855
11863
|
function isBuiltin(id) {
|
|
11856
|
-
|
|
11857
|
-
|
|
11858
|
-
|
|
11864
|
+
if (process.versions.deno && id.startsWith(NPM_BUILTIN_NAMESPACE))
|
|
11865
|
+
return true;
|
|
11866
|
+
if (process.versions.bun && id.startsWith(BUN_BUILTIN_NAMESPACE))
|
|
11867
|
+
return true;
|
|
11868
|
+
return isNodeBuiltin(id);
|
|
11869
|
+
}
|
|
11870
|
+
function isNodeBuiltin(id) {
|
|
11871
|
+
if (id.startsWith(NODE_BUILTIN_NAMESPACE))
|
|
11872
|
+
return true;
|
|
11873
|
+
return nodeBuiltins.includes(id);
|
|
11859
11874
|
}
|
|
11860
11875
|
function isInNodeModules(id) {
|
|
11861
11876
|
return id.includes('node_modules');
|
|
11862
11877
|
}
|
|
11863
11878
|
function moduleListContains(moduleList, id) {
|
|
11864
|
-
return moduleList?.some((m) => m === id || id.startsWith(m
|
|
11879
|
+
return moduleList?.some((m) => m === id || id.startsWith(withTrailingSlash(m)));
|
|
11865
11880
|
}
|
|
11866
11881
|
function isOptimizable(id, optimizeDeps) {
|
|
11867
11882
|
const { extensions } = optimizeDeps;
|
|
@@ -11923,6 +11938,12 @@ function fsPathFromId(id) {
|
|
|
11923
11938
|
function fsPathFromUrl(url) {
|
|
11924
11939
|
return fsPathFromId(cleanUrl(url));
|
|
11925
11940
|
}
|
|
11941
|
+
function withTrailingSlash(path) {
|
|
11942
|
+
if (path[path.length - 1] !== '/') {
|
|
11943
|
+
return `${path}/`;
|
|
11944
|
+
}
|
|
11945
|
+
return path;
|
|
11946
|
+
}
|
|
11926
11947
|
/**
|
|
11927
11948
|
* Check if dir is a parent of file
|
|
11928
11949
|
*
|
|
@@ -11933,9 +11954,7 @@ function fsPathFromUrl(url) {
|
|
|
11933
11954
|
* @returns true if dir is a parent of file
|
|
11934
11955
|
*/
|
|
11935
11956
|
function isParentDirectory(dir, file) {
|
|
11936
|
-
|
|
11937
|
-
dir = `${dir}/`;
|
|
11938
|
-
}
|
|
11957
|
+
dir = withTrailingSlash(dir);
|
|
11939
11958
|
return (file.startsWith(dir) ||
|
|
11940
11959
|
(isCaseInsensitiveFS && file.toLowerCase().startsWith(dir.toLowerCase())));
|
|
11941
11960
|
}
|
|
@@ -12287,7 +12306,7 @@ function optimizeSafeRealPathSync() {
|
|
|
12287
12306
|
function ensureWatchedFile(watcher, file, root) {
|
|
12288
12307
|
if (file &&
|
|
12289
12308
|
// only need to watch if out of root
|
|
12290
|
-
!file.startsWith(root
|
|
12309
|
+
!file.startsWith(withTrailingSlash(root)) &&
|
|
12291
12310
|
// some rollup plugins use null bytes for private resolved Ids
|
|
12292
12311
|
!file.includes('\0') &&
|
|
12293
12312
|
fs$l.existsSync(file)) {
|
|
@@ -12727,7 +12746,7 @@ function stripBase(path, base) {
|
|
|
12727
12746
|
if (path === base) {
|
|
12728
12747
|
return '/';
|
|
12729
12748
|
}
|
|
12730
|
-
const devBase = base
|
|
12749
|
+
const devBase = withTrailingSlash(base);
|
|
12731
12750
|
return path.startsWith(devBase) ? path.slice(devBase.length - 1) : path;
|
|
12732
12751
|
}
|
|
12733
12752
|
function arrayEqual(a, b) {
|
|
@@ -13084,9 +13103,10 @@ function buildReporterPlugin(config) {
|
|
|
13084
13103
|
if (isLarge)
|
|
13085
13104
|
hasLargeChunks = true;
|
|
13086
13105
|
const sizeColor = isLarge ? colors$1.yellow : colors$1.dim;
|
|
13087
|
-
let log = colors$1.dim(relativeOutDir
|
|
13106
|
+
let log = colors$1.dim(withTrailingSlash(relativeOutDir));
|
|
13088
13107
|
log +=
|
|
13089
|
-
!config.build.lib &&
|
|
13108
|
+
!config.build.lib &&
|
|
13109
|
+
entry.name.startsWith(withTrailingSlash(assetsDir))
|
|
13090
13110
|
? colors$1.dim(assetsDir) +
|
|
13091
13111
|
group.color(entry.name
|
|
13092
13112
|
.slice(assetsDir.length)
|
|
@@ -13756,8 +13776,13 @@ function hasWorkspacePackageJSON(root) {
|
|
|
13756
13776
|
if (!isFileReadable(path)) {
|
|
13757
13777
|
return false;
|
|
13758
13778
|
}
|
|
13759
|
-
|
|
13760
|
-
|
|
13779
|
+
try {
|
|
13780
|
+
const content = JSON.parse(fs$l.readFileSync(path, 'utf-8')) || {};
|
|
13781
|
+
return !!content.workspaces;
|
|
13782
|
+
}
|
|
13783
|
+
catch {
|
|
13784
|
+
return false;
|
|
13785
|
+
}
|
|
13761
13786
|
}
|
|
13762
13787
|
function hasRootFile(root) {
|
|
13763
13788
|
return ROOT_FILES.some((file) => fs$l.existsSync(join$2(root, file)));
|
|
@@ -13794,8 +13819,8 @@ function searchForWorkspaceRoot(current, root = searchForPackageRoot(current)) {
|
|
|
13794
13819
|
}
|
|
13795
13820
|
|
|
13796
13821
|
const debug$f = createDebugger('vite:esbuild');
|
|
13797
|
-
|
|
13798
|
-
const
|
|
13822
|
+
// IIFE content looks like `var MyLib = function() {`. Spaces are removed when minified
|
|
13823
|
+
const IIFE_BEGIN_RE = /(const|var)\s+\S+\s*=\s*function\(\)\s*\{.*"use strict";/s;
|
|
13799
13824
|
const validExtensionRE = /\.\w+$/;
|
|
13800
13825
|
const jsxExtensionsRE = /\.(?:j|t)sx\b/;
|
|
13801
13826
|
let server;
|
|
@@ -14028,16 +14053,26 @@ const buildEsbuildPlugin = (config) => {
|
|
|
14028
14053
|
if (config.build.lib) {
|
|
14029
14054
|
// #7188, esbuild adds helpers out of the UMD and IIFE wrappers, and the
|
|
14030
14055
|
// names are minified potentially causing collision with other globals.
|
|
14031
|
-
// We
|
|
14056
|
+
// We inject the helpers inside the wrappers.
|
|
14057
|
+
// e.g. turn:
|
|
14058
|
+
// <esbuild helpers> (function(){ /*actual content/* })()
|
|
14059
|
+
// into:
|
|
14060
|
+
// (function(){ <esbuild helpers> /*actual content/* })()
|
|
14061
|
+
// Not using regex because it's too hard to rule out performance issues like #8738 #8099 #10900 #14065
|
|
14062
|
+
// Instead, using plain string index manipulation (indexOf, slice) which is simple and performant
|
|
14032
14063
|
// We don't need to create a MagicString here because both the helpers and
|
|
14033
14064
|
// the headers don't modify the sourcemap
|
|
14034
|
-
const
|
|
14035
|
-
|
|
14036
|
-
|
|
14037
|
-
|
|
14038
|
-
|
|
14039
|
-
|
|
14040
|
-
|
|
14065
|
+
const esbuildCode = res.code;
|
|
14066
|
+
const contentIndex = opts.format === 'iife'
|
|
14067
|
+
? esbuildCode.match(IIFE_BEGIN_RE)?.index || 0
|
|
14068
|
+
: opts.format === 'umd'
|
|
14069
|
+
? esbuildCode.indexOf(`(function(`) // same for minified or not
|
|
14070
|
+
: 0;
|
|
14071
|
+
if (contentIndex > 0) {
|
|
14072
|
+
const esbuildHelpers = esbuildCode.slice(0, contentIndex);
|
|
14073
|
+
res.code = esbuildCode
|
|
14074
|
+
.slice(contentIndex)
|
|
14075
|
+
.replace(`"use strict";`, `"use strict";` + esbuildHelpers);
|
|
14041
14076
|
}
|
|
14042
14077
|
}
|
|
14043
14078
|
return res;
|
|
@@ -16176,7 +16211,7 @@ function checkPublicFile(url, { publicDir }) {
|
|
|
16176
16211
|
return;
|
|
16177
16212
|
}
|
|
16178
16213
|
const publicFile = path$o.join(publicDir, cleanUrl(url));
|
|
16179
|
-
if (!publicFile.startsWith(publicDir)) {
|
|
16214
|
+
if (!normalizePath$3(publicFile).startsWith(withTrailingSlash(normalizePath$3(publicDir)))) {
|
|
16180
16215
|
// can happen if URL starts with '../'
|
|
16181
16216
|
return;
|
|
16182
16217
|
}
|
|
@@ -16201,7 +16236,7 @@ function fileToDevUrl(id, config) {
|
|
|
16201
16236
|
// in public dir, keep the url as-is
|
|
16202
16237
|
rtn = id;
|
|
16203
16238
|
}
|
|
16204
|
-
else if (id.startsWith(config.root)) {
|
|
16239
|
+
else if (id.startsWith(withTrailingSlash(config.root))) {
|
|
16205
16240
|
// in project root, infer short public path
|
|
16206
16241
|
rtn = '/' + path$o.posix.relative(config.root, id);
|
|
16207
16242
|
}
|
|
@@ -28086,7 +28121,9 @@ function resolvePlugin(resolveOptions) {
|
|
|
28086
28121
|
}
|
|
28087
28122
|
// URL
|
|
28088
28123
|
// /foo -> /fs-root/foo
|
|
28089
|
-
if (asSrc &&
|
|
28124
|
+
if (asSrc &&
|
|
28125
|
+
id[0] === '/' &&
|
|
28126
|
+
(rootInRoot || !id.startsWith(withTrailingSlash(root)))) {
|
|
28090
28127
|
const fsPath = path$o.resolve(root, id.slice(1));
|
|
28091
28128
|
if ((res = tryFsResolve(fsPath, options))) {
|
|
28092
28129
|
debug$d?.(`[url] ${colors$1.cyan(id)} -> ${colors$1.dim(res)}`);
|
|
@@ -28402,8 +28439,10 @@ function tryNodeResolve(id, importer, options, targetWeb, depsOptimizer, ssr = f
|
|
|
28402
28439
|
bareImportRE.test(id)) {
|
|
28403
28440
|
const mainPkg = findNearestMainPackageData(basedir, packageCache)?.data;
|
|
28404
28441
|
if (mainPkg) {
|
|
28405
|
-
|
|
28406
|
-
|
|
28442
|
+
const pkgName = getNpmPackageName(id);
|
|
28443
|
+
if (pkgName != null &&
|
|
28444
|
+
mainPkg.peerDependencies?.[pkgName] &&
|
|
28445
|
+
mainPkg.peerDependenciesMeta?.[pkgName]?.optional) {
|
|
28407
28446
|
return {
|
|
28408
28447
|
id: `${optionalPeerDepId}:${id}:${mainPkg.name}`,
|
|
28409
28448
|
};
|
|
@@ -28580,7 +28619,7 @@ async function tryOptimizedResolve(depsOptimizer, id, importer, preserveSymlinks
|
|
|
28580
28619
|
idPkgDir = normalizePath$3(idPkgDir);
|
|
28581
28620
|
}
|
|
28582
28621
|
// match by src to correctly identify if id belongs to nested dependency
|
|
28583
|
-
if (optimizedData.src.startsWith(idPkgDir)) {
|
|
28622
|
+
if (optimizedData.src.startsWith(withTrailingSlash(idPkgDir))) {
|
|
28584
28623
|
return depsOptimizer.getOptimizedDepId(optimizedData);
|
|
28585
28624
|
}
|
|
28586
28625
|
}
|
|
@@ -36691,7 +36730,7 @@ function _stripLiteralAcorn(code, options) {
|
|
|
36691
36730
|
|
|
36692
36731
|
const multilineCommentsRE = /\/\*([^*\/])*?\*\//gms;
|
|
36693
36732
|
const singlelineCommentsRE = /(?:^|\n|\r)\s*\/\/.*(?:\r|\n|$)/gm;
|
|
36694
|
-
const templateLiteralRE = /\$\{(\s*(?:|{.*}|(?!\$\{).|\n|\r)*?\s*)\}/g;
|
|
36733
|
+
const templateLiteralRE$1 = /\$\{(\s*(?:|{.*}|(?!\$\{).|\n|\r)*?\s*)\}/g;
|
|
36695
36734
|
const quotesRE = [
|
|
36696
36735
|
/(["'`])((?:\\\1|(?!\1)|.|\r)*?)\1/gm,
|
|
36697
36736
|
/([`])((?:\\\1|(?!\1)|.|\n|\r)*?)\1/gm
|
|
@@ -36705,7 +36744,7 @@ function stripLiteralRegex(code, options) {
|
|
|
36705
36744
|
let expanded = code;
|
|
36706
36745
|
for (let i = 0; i < 16; i++) {
|
|
36707
36746
|
const before = expanded;
|
|
36708
|
-
expanded = expanded.replace(templateLiteralRE, "` $1`");
|
|
36747
|
+
expanded = expanded.replace(templateLiteralRE$1, "` $1`");
|
|
36709
36748
|
if (expanded === before)
|
|
36710
36749
|
break;
|
|
36711
36750
|
}
|
|
@@ -38345,7 +38384,7 @@ function cssPostPlugin(config) {
|
|
|
38345
38384
|
};
|
|
38346
38385
|
return {
|
|
38347
38386
|
name: 'vite:css-post',
|
|
38348
|
-
|
|
38387
|
+
renderStart() {
|
|
38349
38388
|
// Ensure new caches for every build (i.e. rebuilding in watch mode)
|
|
38350
38389
|
pureCssChunks = new Set();
|
|
38351
38390
|
outputToExtractedCSSMap = new Map();
|
|
@@ -38633,9 +38672,9 @@ function cssPostPlugin(config) {
|
|
|
38633
38672
|
// chunks instead.
|
|
38634
38673
|
chunk.imports = chunk.imports.filter((file) => {
|
|
38635
38674
|
if (pureCssChunkNames.includes(file)) {
|
|
38636
|
-
const { importedCss } = bundle[file]
|
|
38637
|
-
.viteMetadata;
|
|
38675
|
+
const { importedCss, importedAssets } = bundle[file].viteMetadata;
|
|
38638
38676
|
importedCss.forEach((file) => chunk.viteMetadata.importedCss.add(file));
|
|
38677
|
+
importedAssets.forEach((file) => chunk.viteMetadata.importedAssets.add(file));
|
|
38639
38678
|
return false;
|
|
38640
38679
|
}
|
|
38641
38680
|
return true;
|
|
@@ -38649,6 +38688,7 @@ function cssPostPlugin(config) {
|
|
|
38649
38688
|
pureCssChunkNames.forEach((fileName) => {
|
|
38650
38689
|
removedPureCssFiles.set(fileName, bundle[fileName]);
|
|
38651
38690
|
delete bundle[fileName];
|
|
38691
|
+
delete bundle[`${fileName}.map`];
|
|
38652
38692
|
});
|
|
38653
38693
|
}
|
|
38654
38694
|
let extractedCss = outputToExtractedCSSMap.get(opts);
|
|
@@ -38959,8 +38999,8 @@ function createCachedImport(imp) {
|
|
|
38959
38999
|
return cached;
|
|
38960
39000
|
};
|
|
38961
39001
|
}
|
|
38962
|
-
const importPostcssImport = createCachedImport(() => import('./dep-
|
|
38963
|
-
const importPostcssModules = createCachedImport(() => import('./dep-
|
|
39002
|
+
const importPostcssImport = createCachedImport(() => import('./dep-fdea5ef1.js').then(function (n) { return n.i; }));
|
|
39003
|
+
const importPostcssModules = createCachedImport(() => import('./dep-809640fa.js').then(function (n) { return n.i; }));
|
|
38964
39004
|
const importPostcss = createCachedImport(() => import('postcss'));
|
|
38965
39005
|
/**
|
|
38966
39006
|
* @experimental
|
|
@@ -40274,7 +40314,8 @@ function cjsShouldExternalizeForSSR(id, externals) {
|
|
|
40274
40314
|
}
|
|
40275
40315
|
// deep imports, check ext before externalizing - only externalize
|
|
40276
40316
|
// extension-less imports and explicit .js imports
|
|
40277
|
-
if (id.startsWith(e
|
|
40317
|
+
if (id.startsWith(withTrailingSlash(e)) &&
|
|
40318
|
+
(!path$o.extname(id) || id.endsWith('.js'))) {
|
|
40278
40319
|
return true;
|
|
40279
40320
|
}
|
|
40280
40321
|
});
|
|
@@ -40784,8 +40825,11 @@ function getAffectedGlobModules(file, server) {
|
|
|
40784
40825
|
for (const [id, allGlobs] of server._importGlobMap) {
|
|
40785
40826
|
// (glob1 || glob2) && !glob3 && !glob4...
|
|
40786
40827
|
if (allGlobs.some(({ affirmed, negated }) => (!affirmed.length || affirmed.some((glob) => isMatch$1(file, glob))) &&
|
|
40787
|
-
(!negated.length || negated.every((glob) => isMatch$1(file, glob)))))
|
|
40788
|
-
|
|
40828
|
+
(!negated.length || negated.every((glob) => isMatch$1(file, glob))))) {
|
|
40829
|
+
const mod = server.moduleGraph.getModuleById(id);
|
|
40830
|
+
if (mod)
|
|
40831
|
+
modules.push(mod);
|
|
40832
|
+
}
|
|
40789
40833
|
}
|
|
40790
40834
|
modules.forEach((i) => {
|
|
40791
40835
|
if (i?.file)
|
|
@@ -41216,7 +41260,9 @@ const debugHmr = createDebugger('vite:hmr');
|
|
|
41216
41260
|
const whitespaceRE = /\s/;
|
|
41217
41261
|
const normalizedClientDir = normalizePath$3(CLIENT_DIR);
|
|
41218
41262
|
function getShortName(file, root) {
|
|
41219
|
-
return file.startsWith(
|
|
41263
|
+
return file.startsWith(withTrailingSlash(root))
|
|
41264
|
+
? path$o.posix.relative(root, file)
|
|
41265
|
+
: file;
|
|
41220
41266
|
}
|
|
41221
41267
|
async function handleHMRUpdate(file, server, configOnly) {
|
|
41222
41268
|
const { ws, config, moduleGraph } = server;
|
|
@@ -41243,7 +41289,7 @@ async function handleHMRUpdate(file, server, configOnly) {
|
|
|
41243
41289
|
}
|
|
41244
41290
|
debugHmr?.(`[file change] ${colors$1.dim(shortFile)}`);
|
|
41245
41291
|
// (dev only) the client itself cannot be hot updated.
|
|
41246
|
-
if (file.startsWith(normalizedClientDir)) {
|
|
41292
|
+
if (file.startsWith(withTrailingSlash(normalizedClientDir))) {
|
|
41247
41293
|
ws.send({
|
|
41248
41294
|
type: 'full-reload',
|
|
41249
41295
|
path: '*',
|
|
@@ -41607,6 +41653,7 @@ const hasImportInQueryParamsRE = /[?&]import=?\b/;
|
|
|
41607
41653
|
const hasViteIgnoreRE = /\/\*\s*@vite-ignore\s*\*\//;
|
|
41608
41654
|
const cleanUpRawUrlRE = /\/\*[\s\S]*?\*\/|([^\\:]|^)\/\/.*$/gm;
|
|
41609
41655
|
const urlIsStringRE = /^(?:'.*'|".*"|`.*`)$/;
|
|
41656
|
+
const templateLiteralRE = /^\s*`(.*)`\s*$/;
|
|
41610
41657
|
function isExplicitImportRequired(url) {
|
|
41611
41658
|
return !isJSRequest(cleanUrl(url)) && !isCSSRequest(url);
|
|
41612
41659
|
}
|
|
@@ -41764,7 +41811,6 @@ function importAnalysisPlugin(config) {
|
|
|
41764
41811
|
let needQueryInjectHelper = false;
|
|
41765
41812
|
let s;
|
|
41766
41813
|
const str = () => s || (s = new MagicString(source));
|
|
41767
|
-
const importedUrls = new Set();
|
|
41768
41814
|
let isPartiallySelfAccepting = false;
|
|
41769
41815
|
const importedBindings = enablePartialAccept
|
|
41770
41816
|
? new Map()
|
|
@@ -41804,7 +41850,7 @@ function importAnalysisPlugin(config) {
|
|
|
41804
41850
|
const isSelfImport = !isRelative && cleanUrl(url) === cleanUrl(importer);
|
|
41805
41851
|
// normalize all imports into resolved URLs
|
|
41806
41852
|
// e.g. `import 'foo'` -> `import '/@fs/.../node_modules/foo/index.js'`
|
|
41807
|
-
if (resolved.id.startsWith(root
|
|
41853
|
+
if (resolved.id.startsWith(withTrailingSlash(root))) {
|
|
41808
41854
|
// in root: infer short absolute path from root
|
|
41809
41855
|
url = resolved.id.slice(root.length);
|
|
41810
41856
|
}
|
|
@@ -41865,13 +41911,14 @@ function importAnalysisPlugin(config) {
|
|
|
41865
41911
|
}
|
|
41866
41912
|
return [url, resolved.id];
|
|
41867
41913
|
};
|
|
41914
|
+
const orderedImportedUrls = new Array(imports.length);
|
|
41868
41915
|
const orderedAcceptedUrls = new Array(imports.length);
|
|
41869
41916
|
const orderedAcceptedExports = new Array(imports.length);
|
|
41870
41917
|
await Promise.all(imports.map(async (importSpecifier, index) => {
|
|
41871
|
-
const { s: start, e: end, ss: expStart, se: expEnd, d: dynamicIndex,
|
|
41918
|
+
const { s: start, e: end, ss: expStart, se: expEnd, d: dynamicIndex, a: assertIndex, } = importSpecifier;
|
|
41872
41919
|
// #2083 User may use escape path,
|
|
41873
41920
|
// so use imports[index].n to get the unescaped string
|
|
41874
|
-
|
|
41921
|
+
let specifier = importSpecifier.n;
|
|
41875
41922
|
const rawUrl = source.slice(start, end);
|
|
41876
41923
|
// check import.meta usage
|
|
41877
41924
|
if (rawUrl === 'import.meta') {
|
|
@@ -41901,6 +41948,15 @@ function importAnalysisPlugin(config) {
|
|
|
41901
41948
|
}
|
|
41902
41949
|
return;
|
|
41903
41950
|
}
|
|
41951
|
+
else if (templateLiteralRE.test(rawUrl)) {
|
|
41952
|
+
// If the import has backticks but isn't transformed as a glob import
|
|
41953
|
+
// (as there's nothing to glob), check if it's simply a plain string.
|
|
41954
|
+
// If so, we can replace the specifier as a plain string to prevent
|
|
41955
|
+
// an incorrect "cannot be analyzed" warning.
|
|
41956
|
+
if (!(rawUrl.includes('${') && rawUrl.includes('}'))) {
|
|
41957
|
+
specifier = rawUrl.replace(templateLiteralRE, '$1');
|
|
41958
|
+
}
|
|
41959
|
+
}
|
|
41904
41960
|
const isDynamicImport = dynamicIndex > -1;
|
|
41905
41961
|
// strip import assertions as we can process them ourselves
|
|
41906
41962
|
if (!isDynamicImport && assertIndex > -1) {
|
|
@@ -42013,7 +42069,7 @@ function importAnalysisPlugin(config) {
|
|
|
42013
42069
|
const hmrUrl = unwrapId(stripBase(url, base));
|
|
42014
42070
|
const isLocalImport = !isExternalUrl(hmrUrl) && !isDataUrl(hmrUrl);
|
|
42015
42071
|
if (isLocalImport) {
|
|
42016
|
-
|
|
42072
|
+
orderedImportedUrls[index] = hmrUrl;
|
|
42017
42073
|
}
|
|
42018
42074
|
if (enablePartialAccept && importedBindings) {
|
|
42019
42075
|
extractImportedBindings(resolvedId, source, importSpecifier, importedBindings);
|
|
@@ -42036,7 +42092,7 @@ function importAnalysisPlugin(config) {
|
|
|
42036
42092
|
});
|
|
42037
42093
|
}
|
|
42038
42094
|
}
|
|
42039
|
-
else if (!importer.startsWith(clientDir)) {
|
|
42095
|
+
else if (!importer.startsWith(withTrailingSlash(clientDir))) {
|
|
42040
42096
|
if (!isInNodeModules(importer)) {
|
|
42041
42097
|
// check @vite-ignore which suppresses dynamic import warning
|
|
42042
42098
|
const hasViteIgnore = hasViteIgnoreRE.test(
|
|
@@ -42064,6 +42120,7 @@ function importAnalysisPlugin(config) {
|
|
|
42064
42120
|
}
|
|
42065
42121
|
}
|
|
42066
42122
|
}));
|
|
42123
|
+
const importedUrls = new Set(orderedImportedUrls.filter(Boolean));
|
|
42067
42124
|
const acceptedUrls = mergeAcceptedUrls(orderedAcceptedUrls);
|
|
42068
42125
|
const acceptedExports = mergeAcceptedUrls(orderedAcceptedExports);
|
|
42069
42126
|
if (hasEnv) {
|
|
@@ -42145,23 +42202,32 @@ function mergeAcceptedUrls(orderedUrls) {
|
|
|
42145
42202
|
function interopNamedImports(str, importSpecifier, rewrittenUrl, importIndex, importer, config) {
|
|
42146
42203
|
const source = str.original;
|
|
42147
42204
|
const { s: start, e: end, ss: expStart, se: expEnd, d: dynamicIndex, } = importSpecifier;
|
|
42205
|
+
const exp = source.slice(expStart, expEnd);
|
|
42148
42206
|
if (dynamicIndex > -1) {
|
|
42149
42207
|
// rewrite `import('package')` to expose the default directly
|
|
42150
|
-
str.overwrite(expStart, expEnd, `import('${rewrittenUrl}').then(m => m.default && m.default.__esModule ? m.default : ({ ...m.default, default: m.default }))
|
|
42208
|
+
str.overwrite(expStart, expEnd, `import('${rewrittenUrl}').then(m => m.default && m.default.__esModule ? m.default : ({ ...m.default, default: m.default }))` +
|
|
42209
|
+
getLineBreaks(exp), { contentOnly: true });
|
|
42151
42210
|
}
|
|
42152
42211
|
else {
|
|
42153
|
-
const exp = source.slice(expStart, expEnd);
|
|
42154
42212
|
const rawUrl = source.slice(start, end);
|
|
42155
42213
|
const rewritten = transformCjsImport(exp, rewrittenUrl, rawUrl, importIndex, importer, config);
|
|
42156
42214
|
if (rewritten) {
|
|
42157
|
-
str.overwrite(expStart, expEnd, rewritten, {
|
|
42215
|
+
str.overwrite(expStart, expEnd, rewritten + getLineBreaks(exp), {
|
|
42216
|
+
contentOnly: true,
|
|
42217
|
+
});
|
|
42158
42218
|
}
|
|
42159
42219
|
else {
|
|
42160
42220
|
// #1439 export * from '...'
|
|
42161
|
-
str.overwrite(start, end, rewrittenUrl
|
|
42221
|
+
str.overwrite(start, end, rewrittenUrl + getLineBreaks(source.slice(start, end)), {
|
|
42222
|
+
contentOnly: true,
|
|
42223
|
+
});
|
|
42162
42224
|
}
|
|
42163
42225
|
}
|
|
42164
42226
|
}
|
|
42227
|
+
// get line breaks to preserve line count for not breaking source maps
|
|
42228
|
+
function getLineBreaks(str) {
|
|
42229
|
+
return str.includes('\n') ? '\n'.repeat(str.split('\n').length - 1) : '';
|
|
42230
|
+
}
|
|
42165
42231
|
/**
|
|
42166
42232
|
* Detect import statements to a known optimized CJS dependency and provide
|
|
42167
42233
|
* ES named imports interop. We do this by rewriting named imports to a variable
|
|
@@ -42610,9 +42676,15 @@ function webWorkerPlugin(config) {
|
|
|
42610
42676
|
injectEnv = module?.transformResult?.code || '';
|
|
42611
42677
|
}
|
|
42612
42678
|
}
|
|
42613
|
-
|
|
42614
|
-
|
|
42615
|
-
|
|
42679
|
+
if (injectEnv) {
|
|
42680
|
+
const s = new MagicString(raw);
|
|
42681
|
+
s.prepend(injectEnv);
|
|
42682
|
+
return {
|
|
42683
|
+
code: s.toString(),
|
|
42684
|
+
map: s.generateMap({ hires: 'boundary' }),
|
|
42685
|
+
};
|
|
42686
|
+
}
|
|
42687
|
+
return;
|
|
42616
42688
|
}
|
|
42617
42689
|
if (query == null ||
|
|
42618
42690
|
(query && (query.worker ?? query.sharedworker) == null)) {
|
|
@@ -42805,7 +42877,7 @@ function matches(pattern, importee) {
|
|
|
42805
42877
|
if (importee === pattern) {
|
|
42806
42878
|
return true;
|
|
42807
42879
|
}
|
|
42808
|
-
return importee.startsWith(pattern
|
|
42880
|
+
return importee.startsWith(withTrailingSlash(pattern));
|
|
42809
42881
|
}
|
|
42810
42882
|
function getAliasPatterns(entries) {
|
|
42811
42883
|
if (!entries) {
|
|
@@ -45412,7 +45484,6 @@ async function createDepsOptimizer(config, server) {
|
|
|
45412
45484
|
if (closed) {
|
|
45413
45485
|
return;
|
|
45414
45486
|
}
|
|
45415
|
-
const crawlDeps = Object.keys(metadata.discovered);
|
|
45416
45487
|
// Await for the scan+optimize step running in the background
|
|
45417
45488
|
// It normally should be over by the time crawling of user code ended
|
|
45418
45489
|
await depsOptimizer.scanProcessing;
|
|
@@ -45420,6 +45491,7 @@ async function createDepsOptimizer(config, server) {
|
|
|
45420
45491
|
const result = await optimizationResult.result;
|
|
45421
45492
|
optimizationResult = undefined;
|
|
45422
45493
|
currentlyProcessing = false;
|
|
45494
|
+
const crawlDeps = Object.keys(metadata.discovered);
|
|
45423
45495
|
const scanDeps = Object.keys(result.metadata.optimized);
|
|
45424
45496
|
if (scanDeps.length === 0 && crawlDeps.length === 0) {
|
|
45425
45497
|
debug$8?.(colors$1.green(`✨ no dependencies found by the scanner or crawling static imports`));
|
|
@@ -45452,6 +45524,7 @@ async function createDepsOptimizer(config, server) {
|
|
|
45452
45524
|
}
|
|
45453
45525
|
}
|
|
45454
45526
|
else {
|
|
45527
|
+
const crawlDeps = Object.keys(metadata.discovered);
|
|
45455
45528
|
currentlyProcessing = false;
|
|
45456
45529
|
if (crawlDeps.length === 0) {
|
|
45457
45530
|
debug$8?.(colors$1.green(`✨ no dependencies found while crawling the static imports`));
|
|
@@ -46615,7 +46688,7 @@ function buildImportAnalysisPlugin(config) {
|
|
|
46615
46688
|
}
|
|
46616
46689
|
// normalize all imports into resolved URLs
|
|
46617
46690
|
// e.g. `import 'foo'` -> `import '/@fs/.../node_modules/foo/index.js'`
|
|
46618
|
-
if (resolved.id.startsWith(root
|
|
46691
|
+
if (resolved.id.startsWith(withTrailingSlash(root))) {
|
|
46619
46692
|
// in root: infer short absolute path from root
|
|
46620
46693
|
url = resolved.id.slice(root.length);
|
|
46621
46694
|
}
|
|
@@ -47614,7 +47687,7 @@ function serveStaticMiddleware(dir, server) {
|
|
|
47614
47687
|
}
|
|
47615
47688
|
if (redirectedPathname) {
|
|
47616
47689
|
// dir is pre-normalized to posix style
|
|
47617
|
-
if (redirectedPathname.startsWith(dir)) {
|
|
47690
|
+
if (redirectedPathname.startsWith(withTrailingSlash(dir))) {
|
|
47618
47691
|
redirectedPathname = redirectedPathname.slice(dir.length);
|
|
47619
47692
|
}
|
|
47620
47693
|
}
|
|
@@ -47622,7 +47695,7 @@ function serveStaticMiddleware(dir, server) {
|
|
|
47622
47695
|
let fileUrl = path$o.resolve(dir, removeLeadingSlash(resolvedPathname));
|
|
47623
47696
|
if (resolvedPathname[resolvedPathname.length - 1] === '/' &&
|
|
47624
47697
|
fileUrl[fileUrl.length - 1] !== '/') {
|
|
47625
|
-
fileUrl = fileUrl
|
|
47698
|
+
fileUrl = withTrailingSlash(fileUrl);
|
|
47626
47699
|
}
|
|
47627
47700
|
if (!ensureServingAccess(fileUrl, server, res, next)) {
|
|
47628
47701
|
return;
|
|
@@ -48027,7 +48100,7 @@ function prepareOutDir(outDirs, emptyOutDir, config) {
|
|
|
48027
48100
|
if (emptyOutDir == null) {
|
|
48028
48101
|
for (const outDir of nonDuplicateDirs) {
|
|
48029
48102
|
if (fs$l.existsSync(outDir) &&
|
|
48030
|
-
!normalizePath$3(outDir).startsWith(config.root
|
|
48103
|
+
!normalizePath$3(outDir).startsWith(withTrailingSlash(config.root))) {
|
|
48031
48104
|
// warn if outDir is outside of root
|
|
48032
48105
|
config.logger.warn(colors$1.yellow(`\n${colors$1.bold(`(!)`)} outDir ${colors$1.white(colors$1.dim(outDir))} is not inside project root and will not be emptied.\n` +
|
|
48033
48106
|
`Use --emptyOutDir to override.\n`));
|
|
@@ -48391,7 +48464,9 @@ const toOutputFilePathInHtml = toOutputFilePathWithoutRuntime;
|
|
|
48391
48464
|
function areSeparateFolders(a, b) {
|
|
48392
48465
|
const na = normalizePath$3(a);
|
|
48393
48466
|
const nb = normalizePath$3(b);
|
|
48394
|
-
return na !== nb &&
|
|
48467
|
+
return (na !== nb &&
|
|
48468
|
+
!na.startsWith(withTrailingSlash(nb)) &&
|
|
48469
|
+
!nb.startsWith(withTrailingSlash(na)));
|
|
48395
48470
|
}
|
|
48396
48471
|
|
|
48397
48472
|
var build$1 = {
|
|
@@ -55995,7 +56070,7 @@ async function instantiateModule(url, server, context = { global }, urlStack = [
|
|
|
55995
56070
|
// In node@12+ we can use dynamic import to load CJS and ESM
|
|
55996
56071
|
async function nodeImport(id, importer, resolveOptions) {
|
|
55997
56072
|
let url;
|
|
55998
|
-
if (id.startsWith('
|
|
56073
|
+
if (id.startsWith('data:') || isBuiltin(id)) {
|
|
55999
56074
|
url = id;
|
|
56000
56075
|
}
|
|
56001
56076
|
else {
|
|
@@ -61692,6 +61767,7 @@ function createWebSocketServer(server, config, httpsOptions) {
|
|
|
61692
61767
|
// TODO: the main server port may not have been chosen yet as it may use the next available
|
|
61693
61768
|
const portsAreCompatible = !hmrPort || hmrPort === config.server.port;
|
|
61694
61769
|
const wsServer = hmrServer || (portsAreCompatible && server);
|
|
61770
|
+
let hmrServerWsListener;
|
|
61695
61771
|
const customListeners = new Map();
|
|
61696
61772
|
const clientsMap = new WeakMap();
|
|
61697
61773
|
const port = hmrPort || 24678;
|
|
@@ -61703,14 +61779,15 @@ function createWebSocketServer(server, config, httpsOptions) {
|
|
|
61703
61779
|
hmrBase = path$o.posix.join(hmrBase, hmrPath);
|
|
61704
61780
|
}
|
|
61705
61781
|
wss = new WebSocketServerRaw({ noServer: true });
|
|
61706
|
-
|
|
61782
|
+
hmrServerWsListener = (req, socket, head) => {
|
|
61707
61783
|
if (req.headers['sec-websocket-protocol'] === HMR_HEADER &&
|
|
61708
61784
|
req.url === hmrBase) {
|
|
61709
61785
|
wss.handleUpgrade(req, socket, head, (ws) => {
|
|
61710
61786
|
wss.emit('connection', ws, req);
|
|
61711
61787
|
});
|
|
61712
61788
|
}
|
|
61713
|
-
}
|
|
61789
|
+
};
|
|
61790
|
+
wsServer.on('upgrade', hmrServerWsListener);
|
|
61714
61791
|
}
|
|
61715
61792
|
else {
|
|
61716
61793
|
// http server request handler keeps the same with
|
|
@@ -61852,6 +61929,11 @@ function createWebSocketServer(server, config, httpsOptions) {
|
|
|
61852
61929
|
});
|
|
61853
61930
|
},
|
|
61854
61931
|
close() {
|
|
61932
|
+
// should remove listener if hmr.server is set
|
|
61933
|
+
// otherwise the old listener swallows all WebSocket connections
|
|
61934
|
+
if (hmrServerWsListener && wsServer) {
|
|
61935
|
+
wsServer.off('upgrade', hmrServerWsListener);
|
|
61936
|
+
}
|
|
61855
61937
|
return new Promise((resolve, reject) => {
|
|
61856
61938
|
wss.clients.forEach((client) => {
|
|
61857
61939
|
client.terminate();
|
|
@@ -61909,7 +61991,7 @@ function baseMiddleware({ config, }) {
|
|
|
61909
61991
|
}
|
|
61910
61992
|
else if (req.headers.accept?.includes('text/html')) {
|
|
61911
61993
|
// non-based page visit
|
|
61912
|
-
const redirectPath = url
|
|
61994
|
+
const redirectPath = withTrailingSlash(url) !== base ? joinUrlSegments(base, url) : base;
|
|
61913
61995
|
res.writeHead(404, {
|
|
61914
61996
|
'Content-Type': 'text/html',
|
|
61915
61997
|
});
|
|
@@ -64289,10 +64371,10 @@ function transformMiddleware(server) {
|
|
|
64289
64371
|
// check if public dir is inside root dir
|
|
64290
64372
|
const publicDir = normalizePath$3(server.config.publicDir);
|
|
64291
64373
|
const rootDir = normalizePath$3(server.config.root);
|
|
64292
|
-
if (publicDir.startsWith(rootDir)) {
|
|
64374
|
+
if (publicDir.startsWith(withTrailingSlash(rootDir))) {
|
|
64293
64375
|
const publicPath = `${publicDir.slice(rootDir.length)}/`;
|
|
64294
64376
|
// warn explicit public paths
|
|
64295
|
-
if (url.startsWith(publicPath)) {
|
|
64377
|
+
if (url.startsWith(withTrailingSlash(publicPath))) {
|
|
64296
64378
|
let warning;
|
|
64297
64379
|
if (isImportRequest(url)) {
|
|
64298
64380
|
const rawUrl = removeImportQuery(url);
|
|
@@ -65871,7 +65953,7 @@ async function resolveConfig(inlineConfig, command, defaultMode = 'development',
|
|
|
65871
65953
|
configFileDependencies: configFileDependencies.map((name) => normalizePath$3(path$o.resolve(name))),
|
|
65872
65954
|
inlineConfig,
|
|
65873
65955
|
root: resolvedRoot,
|
|
65874
|
-
base: resolvedBase
|
|
65956
|
+
base: withTrailingSlash(resolvedBase),
|
|
65875
65957
|
rawBase: resolvedBase,
|
|
65876
65958
|
resolve: resolveOptions,
|
|
65877
65959
|
publicDir: resolvedPublicDir,
|
|
@@ -65994,7 +66076,7 @@ assetFileNames isn't equal for every build.rollupOptions.output. A single patter
|
|
|
65994
66076
|
if (config.legacy?.buildSsrCjsExternalHeuristics ||
|
|
65995
66077
|
config.ssr?.format === 'cjs') {
|
|
65996
66078
|
resolved.logger.warn(colors$1.yellow(`
|
|
65997
|
-
(!) Experimental legacy.buildSsrCjsExternalHeuristics and ssr.format: 'cjs' are going to be removed in Vite 5.
|
|
66079
|
+
(!) Experimental legacy.buildSsrCjsExternalHeuristics and ssr.format: 'cjs' are going to be removed in Vite 5.
|
|
65998
66080
|
Find more information and give feedback at https://github.com/vitejs/vite/discussions/13816.
|
|
65999
66081
|
`));
|
|
66000
66082
|
}
|
|
@@ -66158,11 +66240,13 @@ async function bundleConfigFile(fileName, isESM) {
|
|
|
66158
66240
|
build.onResolve({ filter: /^[^.].*/ }, async ({ path: id, importer, kind }) => {
|
|
66159
66241
|
if (kind === 'entry-point' ||
|
|
66160
66242
|
path$o.isAbsolute(id) ||
|
|
66161
|
-
|
|
66243
|
+
isNodeBuiltin(id)) {
|
|
66162
66244
|
return;
|
|
66163
66245
|
}
|
|
66164
|
-
//
|
|
66165
|
-
|
|
66246
|
+
// With the `isNodeBuiltin` check above, this check captures if the builtin is a
|
|
66247
|
+
// non-node built-in, which esbuild doesn't know how to handle. In that case, we
|
|
66248
|
+
// externalize it so the non-node runtime handles it instead.
|
|
66249
|
+
if (isBuiltin(id)) {
|
|
66166
66250
|
return { external: true };
|
|
66167
66251
|
}
|
|
66168
66252
|
const isImport = isESM || kind === 'dynamic-import';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { F as commonjsGlobal, E as getDefaultExportFromCjs } from './dep-
|
|
1
|
+
import { F as commonjsGlobal, E as getDefaultExportFromCjs } from './dep-3bba9c7e.js';
|
|
2
2
|
import require$$0__default from 'fs';
|
|
3
3
|
import require$$0 from 'postcss';
|
|
4
4
|
import require$$0$1 from 'path';
|
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-
|
|
5
|
+
import { C as colors, D as bindShortcuts, x as createLogger, h as resolveConfig } from './chunks/dep-3bba9c7e.js';
|
|
6
6
|
import { VERSION } from './constants.js';
|
|
7
7
|
import 'node:fs/promises';
|
|
8
8
|
import 'node:url';
|
|
@@ -714,9 +714,29 @@ function cleanOptions(options) {
|
|
|
714
714
|
}
|
|
715
715
|
return ret;
|
|
716
716
|
}
|
|
717
|
+
/**
|
|
718
|
+
* host may be a number (like 0), should convert to string
|
|
719
|
+
*/
|
|
720
|
+
const convertHost = (v) => {
|
|
721
|
+
if (typeof v === 'number') {
|
|
722
|
+
return String(v);
|
|
723
|
+
}
|
|
724
|
+
return v;
|
|
725
|
+
};
|
|
726
|
+
/**
|
|
727
|
+
* base may be a number (like 0), should convert to empty string
|
|
728
|
+
*/
|
|
729
|
+
const convertBase = (v) => {
|
|
730
|
+
if (v === 0) {
|
|
731
|
+
return '';
|
|
732
|
+
}
|
|
733
|
+
return v;
|
|
734
|
+
};
|
|
717
735
|
cli
|
|
718
736
|
.option('-c, --config <file>', `[string] use specified config file`)
|
|
719
|
-
.option('--base <path>', `[string] public base path (default: /)
|
|
737
|
+
.option('--base <path>', `[string] public base path (default: /)`, {
|
|
738
|
+
type: [convertBase],
|
|
739
|
+
})
|
|
720
740
|
.option('-l, --logLevel <level>', `[string] info | warn | error | silent`)
|
|
721
741
|
.option('--clearScreen', `[boolean] allow/disable clear screen when logging`)
|
|
722
742
|
.option('-d, --debug [feat]', `[string | boolean] show debug logs`)
|
|
@@ -727,7 +747,7 @@ cli
|
|
|
727
747
|
.command('[root]', 'start dev server') // default command
|
|
728
748
|
.alias('serve') // the command is called 'serve' in Vite's API
|
|
729
749
|
.alias('dev') // alias to align with the script name
|
|
730
|
-
.option('--host [host]', `[string] specify hostname
|
|
750
|
+
.option('--host [host]', `[string] specify hostname`, { type: [convertHost] })
|
|
731
751
|
.option('--port <port>', `[number] specify port`)
|
|
732
752
|
.option('--https', `[boolean] use TLS + HTTP/2`)
|
|
733
753
|
.option('--open [path]', `[boolean | string] open browser on startup`)
|
|
@@ -738,7 +758,7 @@ cli
|
|
|
738
758
|
filterDuplicateOptions(options);
|
|
739
759
|
// output structure is preserved even after bundling so require()
|
|
740
760
|
// is ok here
|
|
741
|
-
const { createServer } = await import('./chunks/dep-
|
|
761
|
+
const { createServer } = await import('./chunks/dep-3bba9c7e.js').then(function (n) { return n.I; });
|
|
742
762
|
try {
|
|
743
763
|
const server = await createServer({
|
|
744
764
|
root,
|
|
@@ -816,7 +836,7 @@ cli
|
|
|
816
836
|
.option('-w, --watch', `[boolean] rebuilds when modules have changed on disk`)
|
|
817
837
|
.action(async (root, options) => {
|
|
818
838
|
filterDuplicateOptions(options);
|
|
819
|
-
const { build } = await import('./chunks/dep-
|
|
839
|
+
const { build } = await import('./chunks/dep-3bba9c7e.js').then(function (n) { return n.H; });
|
|
820
840
|
const buildOptions = cleanOptions(options);
|
|
821
841
|
try {
|
|
822
842
|
await build({
|
|
@@ -844,7 +864,7 @@ cli
|
|
|
844
864
|
.option('--force', `[boolean] force the optimizer to ignore the cache and re-bundle`)
|
|
845
865
|
.action(async (root, options) => {
|
|
846
866
|
filterDuplicateOptions(options);
|
|
847
|
-
const { optimizeDeps } = await import('./chunks/dep-
|
|
867
|
+
const { optimizeDeps } = await import('./chunks/dep-3bba9c7e.js').then(function (n) { return n.G; });
|
|
848
868
|
try {
|
|
849
869
|
const config = await resolveConfig({
|
|
850
870
|
root,
|
|
@@ -863,7 +883,7 @@ cli
|
|
|
863
883
|
// preview
|
|
864
884
|
cli
|
|
865
885
|
.command('preview [root]', 'locally preview production build')
|
|
866
|
-
.option('--host [host]', `[string] specify hostname
|
|
886
|
+
.option('--host [host]', `[string] specify hostname`, { type: [convertHost] })
|
|
867
887
|
.option('--port <port>', `[number] specify port`)
|
|
868
888
|
.option('--strictPort', `[boolean] exit if specified port is already in use`)
|
|
869
889
|
.option('--https', `[boolean] use TLS + HTTP/2`)
|
|
@@ -871,7 +891,7 @@ cli
|
|
|
871
891
|
.option('--outDir <dir>', `[string] output directory (default: dist)`)
|
|
872
892
|
.action(async (root, options) => {
|
|
873
893
|
filterDuplicateOptions(options);
|
|
874
|
-
const { preview } = await import('./chunks/dep-
|
|
894
|
+
const { preview } = await import('./chunks/dep-3bba9c7e.js').then(function (n) { return n.J; });
|
|
875
895
|
try {
|
|
876
896
|
const server = await preview({
|
|
877
897
|
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-3bba9c7e.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-3bba9c7e.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';
|
|
@@ -3281,8 +3281,8 @@ const createFilter$1 = function createFilter(include, exclude, options) {
|
|
|
3281
3281
|
};
|
|
3282
3282
|
|
|
3283
3283
|
const reservedWords = 'break case class catch const continue debugger default delete do else export extends finally for function if import in instanceof let new return super switch this throw try typeof var void while with yield enum await implements package protected static interface private public';
|
|
3284
|
-
const builtins = 'arguments Infinity NaN undefined null true false eval uneval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent encodeURI encodeURIComponent escape unescape Object Function Boolean Symbol Error EvalError InternalError RangeError ReferenceError SyntaxError TypeError URIError Number Math Date String RegExp Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array Map Set WeakMap WeakSet SIMD ArrayBuffer DataView JSON Promise Generator GeneratorFunction Reflect Proxy Intl';
|
|
3285
|
-
const forbiddenIdentifiers = new Set(`${reservedWords} ${builtins}`.split(' '));
|
|
3284
|
+
const builtins$1 = 'arguments Infinity NaN undefined null true false eval uneval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent encodeURI encodeURIComponent escape unescape Object Function Boolean Symbol Error EvalError InternalError RangeError ReferenceError SyntaxError TypeError URIError Number Math Date String RegExp Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array Map Set WeakMap WeakSet SIMD ArrayBuffer DataView JSON Promise Generator GeneratorFunction Reflect Proxy Intl';
|
|
3285
|
+
const forbiddenIdentifiers = new Set(`${reservedWords} ${builtins$1}`.split(' '));
|
|
3286
3286
|
forbiddenIdentifiers.add('');
|
|
3287
3287
|
|
|
3288
3288
|
if (process.versions.pnp) {
|
|
@@ -3297,6 +3297,25 @@ const windowsSlashRE = /\\/g;
|
|
|
3297
3297
|
function slash(p) {
|
|
3298
3298
|
return p.replace(windowsSlashRE, '/');
|
|
3299
3299
|
}
|
|
3300
|
+
//TODO: revisit later to see if the edge case that "compiling using node v12 code to be run in node v16 in the server" is what we intend to support.
|
|
3301
|
+
const builtins = new Set([
|
|
3302
|
+
...node_module.builtinModules,
|
|
3303
|
+
'assert/strict',
|
|
3304
|
+
'diagnostics_channel',
|
|
3305
|
+
'dns/promises',
|
|
3306
|
+
'fs/promises',
|
|
3307
|
+
'path/posix',
|
|
3308
|
+
'path/win32',
|
|
3309
|
+
'readline/promises',
|
|
3310
|
+
'stream/consumers',
|
|
3311
|
+
'stream/promises',
|
|
3312
|
+
'stream/web',
|
|
3313
|
+
'timers/promises',
|
|
3314
|
+
'util/types',
|
|
3315
|
+
'wasi',
|
|
3316
|
+
]);
|
|
3317
|
+
// Some runtimes like Bun injects namespaced modules here, which is not a node builtin
|
|
3318
|
+
[...builtins].filter((id) => !id.includes(':'));
|
|
3300
3319
|
function isInNodeModules(id) {
|
|
3301
3320
|
return id.includes('node_modules');
|
|
3302
3321
|
}
|
|
@@ -3344,6 +3363,12 @@ function fsPathFromId(id) {
|
|
|
3344
3363
|
function fsPathFromUrl(url) {
|
|
3345
3364
|
return fsPathFromId(cleanUrl(url));
|
|
3346
3365
|
}
|
|
3366
|
+
function withTrailingSlash(path) {
|
|
3367
|
+
if (path[path.length - 1] !== '/') {
|
|
3368
|
+
return `${path}/`;
|
|
3369
|
+
}
|
|
3370
|
+
return path;
|
|
3371
|
+
}
|
|
3347
3372
|
/**
|
|
3348
3373
|
* Check if dir is a parent of file
|
|
3349
3374
|
*
|
|
@@ -3354,9 +3379,7 @@ function fsPathFromUrl(url) {
|
|
|
3354
3379
|
* @returns true if dir is a parent of file
|
|
3355
3380
|
*/
|
|
3356
3381
|
function isParentDirectory(dir, file) {
|
|
3357
|
-
|
|
3358
|
-
dir = `${dir}/`;
|
|
3359
|
-
}
|
|
3382
|
+
dir = withTrailingSlash(dir);
|
|
3360
3383
|
return (file.startsWith(dir) ||
|
|
3361
3384
|
(isCaseInsensitiveFS && file.toLowerCase().startsWith(dir.toLowerCase())));
|
|
3362
3385
|
}
|
|
@@ -3928,8 +3951,13 @@ function hasWorkspacePackageJSON(root) {
|
|
|
3928
3951
|
if (!isFileReadable(path)) {
|
|
3929
3952
|
return false;
|
|
3930
3953
|
}
|
|
3931
|
-
|
|
3932
|
-
|
|
3954
|
+
try {
|
|
3955
|
+
const content = JSON.parse(fs$1.readFileSync(path, 'utf-8')) || {};
|
|
3956
|
+
return !!content.workspaces;
|
|
3957
|
+
}
|
|
3958
|
+
catch {
|
|
3959
|
+
return false;
|
|
3960
|
+
}
|
|
3933
3961
|
}
|
|
3934
3962
|
function hasRootFile(root) {
|
|
3935
3963
|
return ROOT_FILES.some((file) => fs$1.existsSync(path$3.join(root, file)));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite",
|
|
3
|
-
"version": "4.4.
|
|
3
|
+
"version": "4.4.10",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Evan You",
|
|
@@ -28,6 +28,9 @@
|
|
|
28
28
|
"types": "./client.d.ts"
|
|
29
29
|
},
|
|
30
30
|
"./dist/client/*": "./dist/client/*",
|
|
31
|
+
"./types/*": {
|
|
32
|
+
"types": "./types/*"
|
|
33
|
+
},
|
|
31
34
|
"./package.json": "./package.json"
|
|
32
35
|
},
|
|
33
36
|
"files": [
|