vite 4.4.9 → 5.0.0-beta.0
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/client.d.ts +5 -5
- package/dist/client/client.mjs +6 -7
- package/dist/client/client.mjs.map +1 -1
- package/dist/node/chunks/{dep-e0331088.js → dep-1d1f72b4.js} +1 -1
- package/dist/node/chunks/{dep-73522cdf.js → dep-3d0847ee.js} +1 -1
- package/dist/node/chunks/{dep-df561101.js → dep-4033fb3a.js} +263 -173
- package/dist/node/cli.js +16 -7
- package/dist/node/index.d.ts +22 -97
- package/dist/node/index.js +3 -2
- package/dist/node-cjs/publicUtils.cjs +1268 -9
- package/package.json +18 -19
- package/types/importGlob.d.ts +0 -24
- package/types/importMeta.d.ts +0 -4
|
@@ -11901,15 +11901,17 @@ function testCaseInsensitiveFS() {
|
|
|
11901
11901
|
}
|
|
11902
11902
|
return fs$l.existsSync(CLIENT_ENTRY.replace('client.mjs', 'cLiEnT.mjs'));
|
|
11903
11903
|
}
|
|
11904
|
-
|
|
11905
|
-
|
|
11906
|
-
|
|
11907
|
-
|
|
11908
|
-
|
|
11909
|
-
|
|
11910
|
-
|
|
11911
|
-
|
|
11912
|
-
|
|
11904
|
+
const urlCanParse = URL$3.canParse ??
|
|
11905
|
+
// URL.canParse is supported from Node.js 18.17.0+, 20.0.0+
|
|
11906
|
+
((path, base) => {
|
|
11907
|
+
try {
|
|
11908
|
+
new URL$3(path, base);
|
|
11909
|
+
return true;
|
|
11910
|
+
}
|
|
11911
|
+
catch {
|
|
11912
|
+
return false;
|
|
11913
|
+
}
|
|
11914
|
+
});
|
|
11913
11915
|
const isCaseInsensitiveFS = testCaseInsensitiveFS();
|
|
11914
11916
|
const isWindows$4 = os$4.platform() === 'win32';
|
|
11915
11917
|
const VOLUME_RE = /^[A-Z]:/i;
|
|
@@ -12172,7 +12174,7 @@ function emptyDir(dir, skip) {
|
|
|
12172
12174
|
if (path$o.dirname(file) !== '.') {
|
|
12173
12175
|
const matched = file.match(splitFirstDirRE);
|
|
12174
12176
|
if (matched) {
|
|
12175
|
-
nested
|
|
12177
|
+
nested ??= new Map();
|
|
12176
12178
|
const [, nestedDir, skipPath] = matched;
|
|
12177
12179
|
let nestedSkip = nested.get(nestedDir);
|
|
12178
12180
|
if (!nestedSkip) {
|
|
@@ -12299,7 +12301,7 @@ const escapedSpaceCharacters = /( |\\t|\\n|\\f|\\r)+/g;
|
|
|
12299
12301
|
const imageSetUrlRE = /^(?:[\w\-]+\(.*?\)|'.*?'|".*?"|\S*)/;
|
|
12300
12302
|
function reduceSrcset(ret) {
|
|
12301
12303
|
return ret.reduce((prev, { url, descriptor }, index) => {
|
|
12302
|
-
descriptor
|
|
12304
|
+
descriptor ??= '';
|
|
12303
12305
|
return (prev +=
|
|
12304
12306
|
url + ` ${descriptor}${index === ret.length - 1 ? '' : ', '}`);
|
|
12305
12307
|
}, '');
|
|
@@ -13112,7 +13114,7 @@ function buildReporterPlugin(config) {
|
|
|
13112
13114
|
config.build.minify &&
|
|
13113
13115
|
!config.build.lib &&
|
|
13114
13116
|
!config.build.ssr) {
|
|
13115
|
-
config.logger.warn(colors$1.yellow(`\n(!) Some chunks are larger than ${chunkLimit}
|
|
13117
|
+
config.logger.warn(colors$1.yellow(`\n(!) Some chunks are larger than ${chunkLimit} kB after minification. Consider:\n` +
|
|
13116
13118
|
`- Using dynamic import() to code-split the application\n` +
|
|
13117
13119
|
`- Use build.rollupOptions.output.manualChunks to improve chunking: https://rollupjs.org/configuration-options/#output-manualchunks\n` +
|
|
13118
13120
|
`- Adjust chunk size limit for this warning via build.chunkSizeWarningLimit.`));
|
|
@@ -14353,7 +14355,7 @@ function terserPlugin(config) {
|
|
|
14353
14355
|
return null;
|
|
14354
14356
|
}
|
|
14355
14357
|
// Lazy load worker.
|
|
14356
|
-
worker
|
|
14358
|
+
worker ||= makeWorker();
|
|
14357
14359
|
const terserPath = loadTerserPath(config.root);
|
|
14358
14360
|
const res = await worker.run(terserPath, code, {
|
|
14359
14361
|
safari10: true,
|
|
@@ -16072,7 +16074,7 @@ function renderAssetUrlInJS(ctx, config, chunk, opts, code) {
|
|
|
16072
16074
|
// In both cases, the wrapping should already be fine
|
|
16073
16075
|
assetUrlRE.lastIndex = 0;
|
|
16074
16076
|
while ((match = assetUrlRE.exec(code))) {
|
|
16075
|
-
s
|
|
16077
|
+
s ||= new MagicString(code);
|
|
16076
16078
|
const [full, referenceId, postfix = ''] = match;
|
|
16077
16079
|
const file = ctx.getFileName(referenceId);
|
|
16078
16080
|
chunk.viteMetadata.importedAssets.add(cleanUrl(file));
|
|
@@ -16087,7 +16089,7 @@ function renderAssetUrlInJS(ctx, config, chunk, opts, code) {
|
|
|
16087
16089
|
const publicAssetUrlMap = publicAssetUrlCache.get(config);
|
|
16088
16090
|
publicAssetUrlRE.lastIndex = 0;
|
|
16089
16091
|
while ((match = publicAssetUrlRE.exec(code))) {
|
|
16090
|
-
s
|
|
16092
|
+
s ||= new MagicString(code);
|
|
16091
16093
|
const [full, hash] = match;
|
|
16092
16094
|
const publicUrl = publicAssetUrlMap.get(hash).slice(1);
|
|
16093
16095
|
const replacement = toOutputFilePathInJS(publicUrl, 'public', chunk.fileName, 'js', config, toRelativeRuntime);
|
|
@@ -16098,6 +16100,9 @@ function renderAssetUrlInJS(ctx, config, chunk, opts, code) {
|
|
|
16098
16100
|
}
|
|
16099
16101
|
return s;
|
|
16100
16102
|
}
|
|
16103
|
+
// During build, if we don't use a virtual file for public assets, rollup will
|
|
16104
|
+
// watch for these ids resulting in watching the root of the file system in Windows,
|
|
16105
|
+
const viteBuildPublicIdPrefix = '\0vite:asset:public';
|
|
16101
16106
|
/**
|
|
16102
16107
|
* Also supports loading plain strings with import text from './foo.txt?raw'
|
|
16103
16108
|
*/
|
|
@@ -16117,10 +16122,15 @@ function assetPlugin(config) {
|
|
|
16117
16122
|
// will fail to resolve in the main resolver. handle them here.
|
|
16118
16123
|
const publicFile = checkPublicFile(id, config);
|
|
16119
16124
|
if (publicFile) {
|
|
16120
|
-
return
|
|
16125
|
+
return config.command === 'build'
|
|
16126
|
+
? `${viteBuildPublicIdPrefix}${id}`
|
|
16127
|
+
: id;
|
|
16121
16128
|
}
|
|
16122
16129
|
},
|
|
16123
16130
|
async load(id) {
|
|
16131
|
+
if (id.startsWith(viteBuildPublicIdPrefix)) {
|
|
16132
|
+
id = id.slice(viteBuildPublicIdPrefix.length);
|
|
16133
|
+
}
|
|
16124
16134
|
if (id[0] === '\0') {
|
|
16125
16135
|
// Rollup convention, this id should be handled by the
|
|
16126
16136
|
// plugin that marked it with \0
|
|
@@ -16198,7 +16208,7 @@ async function fileToUrl(id, config, ctx) {
|
|
|
16198
16208
|
function fileToDevUrl(id, config) {
|
|
16199
16209
|
let rtn;
|
|
16200
16210
|
if (checkPublicFile(id, config)) {
|
|
16201
|
-
// in public dir, keep the url as-is
|
|
16211
|
+
// in public dir during dev, keep the url as-is
|
|
16202
16212
|
rtn = id;
|
|
16203
16213
|
}
|
|
16204
16214
|
else if (id.startsWith(config.root)) {
|
|
@@ -28652,7 +28662,7 @@ function resolvePackageEntry(id, { dir, data, setResolvedCache, getResolvedCache
|
|
|
28652
28662
|
}
|
|
28653
28663
|
}
|
|
28654
28664
|
}
|
|
28655
|
-
entryPoint
|
|
28665
|
+
entryPoint ||= data.main;
|
|
28656
28666
|
// try default entry when entry is not define
|
|
28657
28667
|
// https://nodejs.org/api/modules.html#all-together
|
|
28658
28668
|
const entryPoints = entryPoint
|
|
@@ -37561,9 +37571,9 @@ function buildHtmlPlugin(config) {
|
|
|
37561
37571
|
js += `\nimport "${id}?html-proxy&index=${inlineModuleIndex}.js"`;
|
|
37562
37572
|
shouldRemove = true;
|
|
37563
37573
|
}
|
|
37564
|
-
everyScriptIsAsync
|
|
37565
|
-
someScriptsAreAsync
|
|
37566
|
-
someScriptsAreDefer
|
|
37574
|
+
everyScriptIsAsync &&= isAsync;
|
|
37575
|
+
someScriptsAreAsync ||= isAsync;
|
|
37576
|
+
someScriptsAreDefer ||= !isAsync;
|
|
37567
37577
|
}
|
|
37568
37578
|
else if (url && !isPublicFile) {
|
|
37569
37579
|
if (!isExcludedUrl(url)) {
|
|
@@ -37864,7 +37874,7 @@ function buildHtmlPlugin(config) {
|
|
|
37864
37874
|
let s;
|
|
37865
37875
|
inlineCSSRE$1.lastIndex = 0;
|
|
37866
37876
|
while ((match = inlineCSSRE$1.exec(result))) {
|
|
37867
|
-
s
|
|
37877
|
+
s ||= new MagicString(result);
|
|
37868
37878
|
const { 0: full, 1: scopedName } = match;
|
|
37869
37879
|
const cssTransformedCode = htmlProxyResult.get(scopedName);
|
|
37870
37880
|
s.update(match.index, match.index + full.length, cssTransformedCode);
|
|
@@ -37884,7 +37894,7 @@ function buildHtmlPlugin(config) {
|
|
|
37884
37894
|
});
|
|
37885
37895
|
result = result.replace(publicAssetUrlRE, (_, fileHash) => {
|
|
37886
37896
|
const publicAssetPath = toOutputPublicAssetFilePath(getPublicAssetFilename(fileHash, config));
|
|
37887
|
-
return
|
|
37897
|
+
return urlCanParse(publicAssetPath)
|
|
37888
37898
|
? publicAssetPath
|
|
37889
37899
|
: normalizePath$3(publicAssetPath);
|
|
37890
37900
|
});
|
|
@@ -38426,7 +38436,7 @@ function cssPostPlugin(config) {
|
|
|
38426
38436
|
else {
|
|
38427
38437
|
let content = css;
|
|
38428
38438
|
if (config.build.cssMinify) {
|
|
38429
|
-
content = await minifyCSS(content, config);
|
|
38439
|
+
content = await minifyCSS(content, config, true);
|
|
38430
38440
|
}
|
|
38431
38441
|
code = `export default ${JSON.stringify(content)}`;
|
|
38432
38442
|
}
|
|
@@ -38506,9 +38516,10 @@ function cssPostPlugin(config) {
|
|
|
38506
38516
|
pureCssChunks.add(chunk);
|
|
38507
38517
|
}
|
|
38508
38518
|
if (opts.format === 'es' || opts.format === 'cjs') {
|
|
38509
|
-
const
|
|
38510
|
-
|
|
38511
|
-
|
|
38519
|
+
const isEntry = chunk.isEntry && isPureCssChunk;
|
|
38520
|
+
const cssAssetName = normalizePath$3(!isEntry && chunk.facadeModuleId
|
|
38521
|
+
? path$o.relative(config.root, chunk.facadeModuleId)
|
|
38522
|
+
: chunk.name);
|
|
38512
38523
|
const lang = path$o.extname(cssAssetName).slice(1);
|
|
38513
38524
|
const cssFileName = ensureFileExt(cssAssetName, '.css');
|
|
38514
38525
|
chunkCSS = resolveAssetUrlsInCss(chunkCSS, cssAssetName);
|
|
@@ -38532,7 +38543,6 @@ function cssPostPlugin(config) {
|
|
|
38532
38543
|
source: chunkCSS,
|
|
38533
38544
|
});
|
|
38534
38545
|
const originalName = isPreProcessor(lang) ? cssAssetName : cssFileName;
|
|
38535
|
-
const isEntry = chunk.isEntry && isPureCssChunk;
|
|
38536
38546
|
generatedAssets
|
|
38537
38547
|
.get(config)
|
|
38538
38548
|
.set(referenceId, { originalName, isEntry });
|
|
@@ -38605,19 +38615,12 @@ function cssPostPlugin(config) {
|
|
|
38605
38615
|
// remove empty css chunks and their imports
|
|
38606
38616
|
if (pureCssChunks.size) {
|
|
38607
38617
|
// map each pure css chunk (rendered chunk) to it's corresponding bundle
|
|
38608
|
-
// chunk. we check that by
|
|
38609
|
-
//
|
|
38610
|
-
const
|
|
38611
|
-
|
|
38612
|
-
|
|
38613
|
-
|
|
38614
|
-
if (bundleChunk.type === 'chunk' &&
|
|
38615
|
-
arrayEqual(bundleChunk.moduleIds, pureCssChunk.moduleIds)) {
|
|
38616
|
-
pureCssChunkNames.push(key);
|
|
38617
|
-
break;
|
|
38618
|
-
}
|
|
38619
|
-
}
|
|
38620
|
-
}
|
|
38618
|
+
// chunk. we check that by `preliminaryFileName` as they have different
|
|
38619
|
+
// `filename`s (rendered chunk has the !~{XXX}~ placeholder)
|
|
38620
|
+
const prelimaryNameToChunkMap = Object.fromEntries(Object.values(bundle)
|
|
38621
|
+
.filter((chunk) => chunk.type === 'chunk')
|
|
38622
|
+
.map((chunk) => [chunk.preliminaryFileName, chunk.fileName]));
|
|
38623
|
+
const pureCssChunkNames = [...pureCssChunks].map((pureCssChunk) => prelimaryNameToChunkMap[pureCssChunk.fileName]);
|
|
38621
38624
|
const emptyChunkFiles = pureCssChunkNames
|
|
38622
38625
|
.map((file) => path$o.basename(file))
|
|
38623
38626
|
.join('|')
|
|
@@ -38959,8 +38962,8 @@ function createCachedImport(imp) {
|
|
|
38959
38962
|
return cached;
|
|
38960
38963
|
};
|
|
38961
38964
|
}
|
|
38962
|
-
const importPostcssImport = createCachedImport(() => import('./dep-
|
|
38963
|
-
const importPostcssModules = createCachedImport(() => import('./dep-
|
|
38965
|
+
const importPostcssImport = createCachedImport(() => import('./dep-1d1f72b4.js').then(function (n) { return n.i; }));
|
|
38966
|
+
const importPostcssModules = createCachedImport(() => import('./dep-3d0847ee.js').then(function (n) { return n.i; }));
|
|
38964
38967
|
const importPostcss = createCachedImport(() => import('postcss'));
|
|
38965
38968
|
/**
|
|
38966
38969
|
* @experimental
|
|
@@ -39003,7 +39006,7 @@ async function finalizeCss(css, minify, config) {
|
|
|
39003
39006
|
css = await hoistAtRules(css);
|
|
39004
39007
|
}
|
|
39005
39008
|
if (minify && config.build.cssMinify) {
|
|
39006
|
-
css = await minifyCSS(css, config);
|
|
39009
|
+
css = await minifyCSS(css, config, false);
|
|
39007
39010
|
}
|
|
39008
39011
|
return css;
|
|
39009
39012
|
}
|
|
@@ -39164,7 +39167,10 @@ async function doImportCSSReplace(rawUrl, matched, replacer) {
|
|
|
39164
39167
|
}
|
|
39165
39168
|
return `@import ${wrap}${await replacer(rawUrl)}${wrap}`;
|
|
39166
39169
|
}
|
|
39167
|
-
async function minifyCSS(css, config) {
|
|
39170
|
+
async function minifyCSS(css, config, inlined) {
|
|
39171
|
+
// We want inlined CSS to not end with a linebreak, while ensuring that
|
|
39172
|
+
// regular CSS assets do end with a linebreak.
|
|
39173
|
+
// See https://github.com/vitejs/vite/pull/13893#issuecomment-1678628198
|
|
39168
39174
|
if (config.build.cssMinify === 'lightningcss') {
|
|
39169
39175
|
const { code, warnings } = (await importLightningCSS()).transform({
|
|
39170
39176
|
...config.css?.lightningcss,
|
|
@@ -39179,7 +39185,8 @@ async function minifyCSS(css, config) {
|
|
|
39179
39185
|
.map((w) => w.message)
|
|
39180
39186
|
.join('\n')}`));
|
|
39181
39187
|
}
|
|
39182
|
-
return
|
|
39188
|
+
// LightningCSS output does not return a linebreak at the end
|
|
39189
|
+
return code.toString() + (inlined ? '' : '\n');
|
|
39183
39190
|
}
|
|
39184
39191
|
try {
|
|
39185
39192
|
const { code, warnings } = await transform$1(css, {
|
|
@@ -39191,7 +39198,8 @@ async function minifyCSS(css, config) {
|
|
|
39191
39198
|
const msgs = await formatMessages(warnings, { kind: 'warning' });
|
|
39192
39199
|
config.logger.warn(colors$1.yellow(`warnings when minifying css:\n${msgs.join('\n')}`));
|
|
39193
39200
|
}
|
|
39194
|
-
return
|
|
39201
|
+
// esbuild output does return a linebreak at the end
|
|
39202
|
+
return inlined ? code.trimEnd() : code;
|
|
39195
39203
|
}
|
|
39196
39204
|
catch (e) {
|
|
39197
39205
|
if (e.errors) {
|
|
@@ -39482,6 +39490,9 @@ let ViteLessManager;
|
|
|
39482
39490
|
function createViteLessPlugin(less, rootFile, alias, resolvers) {
|
|
39483
39491
|
if (!ViteLessManager) {
|
|
39484
39492
|
ViteLessManager = class ViteManager extends less.FileManager {
|
|
39493
|
+
resolvers;
|
|
39494
|
+
rootFile;
|
|
39495
|
+
alias;
|
|
39485
39496
|
constructor(rootFile, resolvers, alias) {
|
|
39486
39497
|
super();
|
|
39487
39498
|
this.rootFile = rootFile;
|
|
@@ -39618,11 +39629,13 @@ async function compileLightningCSS(id, src, config, urlReplacer) {
|
|
|
39618
39629
|
? (await importLightningCSS()).transformStyleAttribute({
|
|
39619
39630
|
filename,
|
|
39620
39631
|
code: Buffer.from(src),
|
|
39621
|
-
targets: config.css?.lightningcss?.targets,
|
|
39622
39632
|
minify: config.isProduction && !!config.build.cssMinify,
|
|
39633
|
+
targets: config.css?.lightningcss?.targets,
|
|
39623
39634
|
analyzeDependencies: true,
|
|
39635
|
+
visitor: config.css?.lightningcss?.visitor,
|
|
39624
39636
|
})
|
|
39625
39637
|
: await (await importLightningCSS()).bundleAsync({
|
|
39638
|
+
...config.css?.lightningcss,
|
|
39626
39639
|
filename,
|
|
39627
39640
|
resolver: {
|
|
39628
39641
|
read(filePath) {
|
|
@@ -39648,14 +39661,12 @@ async function compileLightningCSS(id, src, config, urlReplacer) {
|
|
|
39648
39661
|
return id;
|
|
39649
39662
|
},
|
|
39650
39663
|
},
|
|
39651
|
-
targets: config.css?.lightningcss?.targets,
|
|
39652
39664
|
minify: config.isProduction && !!config.build.cssMinify,
|
|
39653
39665
|
sourceMap: config.css?.devSourcemap,
|
|
39654
39666
|
analyzeDependencies: true,
|
|
39655
39667
|
cssModules: cssModuleRE.test(id)
|
|
39656
39668
|
? config.css?.lightningcss?.cssModules ?? true
|
|
39657
39669
|
: undefined,
|
|
39658
|
-
drafts: config.css?.lightningcss?.drafts,
|
|
39659
39670
|
});
|
|
39660
39671
|
let css = res.code.toString();
|
|
39661
39672
|
for (const dep of res.dependencies) {
|
|
@@ -40784,8 +40795,11 @@ function getAffectedGlobModules(file, server) {
|
|
|
40784
40795
|
for (const [id, allGlobs] of server._importGlobMap) {
|
|
40785
40796
|
// (glob1 || glob2) && !glob3 && !glob4...
|
|
40786
40797
|
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
|
-
|
|
40798
|
+
(!negated.length || negated.every((glob) => isMatch$1(file, glob))))) {
|
|
40799
|
+
const mod = server.moduleGraph.getModuleById(id);
|
|
40800
|
+
if (mod)
|
|
40801
|
+
modules.push(mod);
|
|
40802
|
+
}
|
|
40789
40803
|
}
|
|
40790
40804
|
modules.forEach((i) => {
|
|
40791
40805
|
if (i?.file)
|
|
@@ -40822,7 +40836,7 @@ function importGlobPlugin(config) {
|
|
|
40822
40836
|
},
|
|
40823
40837
|
};
|
|
40824
40838
|
}
|
|
40825
|
-
const importGlobRE = /\bimport\.meta\.
|
|
40839
|
+
const importGlobRE = /\bimport\.meta\.glob(?:<\w+>)?\s*\(/g;
|
|
40826
40840
|
const knownOptions = {
|
|
40827
40841
|
as: ['string'],
|
|
40828
40842
|
eager: ['boolean'],
|
|
@@ -40887,7 +40901,6 @@ async function parseImportGlob(code, importer, root, resolveId) {
|
|
|
40887
40901
|
}
|
|
40888
40902
|
const matches = Array.from(cleanCode.matchAll(importGlobRE));
|
|
40889
40903
|
const tasks = matches.map(async (match, index) => {
|
|
40890
|
-
const type = match[1];
|
|
40891
40904
|
const start = match.index;
|
|
40892
40905
|
const err = (msg) => {
|
|
40893
40906
|
const e = new Error(`Invalid glob import syntax: ${msg}`);
|
|
@@ -40973,13 +40986,11 @@ async function parseImportGlob(code, importer, root, resolveId) {
|
|
|
40973
40986
|
const globsResolved = await Promise.all(globs.map((glob) => toAbsoluteGlob(glob, root, importer, resolveId)));
|
|
40974
40987
|
const isRelative = globs.every((i) => '.!'.includes(i[0]));
|
|
40975
40988
|
return {
|
|
40976
|
-
match,
|
|
40977
40989
|
index,
|
|
40978
40990
|
globs,
|
|
40979
40991
|
globsResolved,
|
|
40980
40992
|
isRelative,
|
|
40981
40993
|
options,
|
|
40982
|
-
type,
|
|
40983
40994
|
start,
|
|
40984
40995
|
end,
|
|
40985
40996
|
};
|
|
@@ -41006,15 +41017,6 @@ async function transformGlobImport(code, id, root, resolveId, isProduction, rest
|
|
|
41006
41017
|
const dir = isVirtual ? undefined : dirname(id);
|
|
41007
41018
|
const matches = await parseImportGlob(code, isVirtual ? undefined : id, root, resolveId);
|
|
41008
41019
|
const matchedFiles = new Set();
|
|
41009
|
-
// TODO: backwards compatibility
|
|
41010
|
-
matches.forEach((i) => {
|
|
41011
|
-
if (i.type === 'globEager')
|
|
41012
|
-
i.options.eager = true;
|
|
41013
|
-
if (i.type === 'globEagerDefault') {
|
|
41014
|
-
i.options.eager = true;
|
|
41015
|
-
i.options.import = 'default';
|
|
41016
|
-
}
|
|
41017
|
-
});
|
|
41018
41020
|
if (!matches.length)
|
|
41019
41021
|
return null;
|
|
41020
41022
|
const s = new MagicString(code);
|
|
@@ -41073,7 +41075,7 @@ async function transformGlobImport(code, id, root, resolveId, isProduction, rest
|
|
|
41073
41075
|
}
|
|
41074
41076
|
importPath = `${importPath}${importQuery}`;
|
|
41075
41077
|
const isCSS = !query && isCSSRequest(file) && !isModuleCSSRequest(file);
|
|
41076
|
-
includesCSS
|
|
41078
|
+
includesCSS ||= isCSS;
|
|
41077
41079
|
const importKey = options.import && options.import !== '*'
|
|
41078
41080
|
? options.import
|
|
41079
41081
|
: undefined;
|
|
@@ -42278,11 +42280,12 @@ function clientInjectionsPlugin(config) {
|
|
|
42278
42280
|
const timeout = hmrConfig?.timeout || 30000;
|
|
42279
42281
|
const overlay = hmrConfig?.overlay !== false;
|
|
42280
42282
|
const isHmrServerSpecified = !!hmrConfig?.server;
|
|
42283
|
+
const hmrConfigName = path$o.basename(config.configFile || 'vite.config.js');
|
|
42281
42284
|
// hmr.clientPort -> hmr.port
|
|
42282
42285
|
// -> (24678 if middleware mode and HMR server is not specified) -> new URL(import.meta.url).port
|
|
42283
42286
|
let port = hmrConfig?.clientPort || hmrConfig?.port || null;
|
|
42284
42287
|
if (config.server.middlewareMode && !isHmrServerSpecified) {
|
|
42285
|
-
port
|
|
42288
|
+
port ||= 24678;
|
|
42286
42289
|
}
|
|
42287
42290
|
let directTarget = hmrConfig?.host || resolvedServerHostname;
|
|
42288
42291
|
directTarget += `:${hmrConfig?.port || resolvedServerPort}`;
|
|
@@ -42303,6 +42306,7 @@ function clientInjectionsPlugin(config) {
|
|
|
42303
42306
|
const hmrBaseReplacement = escapeReplacement(hmrBase);
|
|
42304
42307
|
const hmrTimeoutReplacement = escapeReplacement(timeout);
|
|
42305
42308
|
const hmrEnableOverlayReplacement = escapeReplacement(overlay);
|
|
42309
|
+
const hmrConfigNameReplacement = escapeReplacement(hmrConfigName);
|
|
42306
42310
|
injectConfigValues = (code) => {
|
|
42307
42311
|
return code
|
|
42308
42312
|
.replace(`__MODE__`, modeReplacement)
|
|
@@ -42315,7 +42319,8 @@ function clientInjectionsPlugin(config) {
|
|
|
42315
42319
|
.replace(`__HMR_DIRECT_TARGET__`, hmrDirectTargetReplacement)
|
|
42316
42320
|
.replace(`__HMR_BASE__`, hmrBaseReplacement)
|
|
42317
42321
|
.replace(`__HMR_TIMEOUT__`, hmrTimeoutReplacement)
|
|
42318
|
-
.replace(`__HMR_ENABLE_OVERLAY__`, hmrEnableOverlayReplacement)
|
|
42322
|
+
.replace(`__HMR_ENABLE_OVERLAY__`, hmrEnableOverlayReplacement)
|
|
42323
|
+
.replace(`__HMR_CONFIG_NAME__`, hmrConfigNameReplacement);
|
|
42319
42324
|
};
|
|
42320
42325
|
},
|
|
42321
42326
|
transform(code, id, options) {
|
|
@@ -42627,7 +42632,7 @@ function webWorkerPlugin(config) {
|
|
|
42627
42632
|
? 'module'
|
|
42628
42633
|
: 'classic'
|
|
42629
42634
|
: 'module';
|
|
42630
|
-
const
|
|
42635
|
+
const workerTypeOption = workerType === 'classic' ? undefined : 'module';
|
|
42631
42636
|
if (isBuild) {
|
|
42632
42637
|
getDepsOptimizer(config, ssr)?.registerWorkersSource(id);
|
|
42633
42638
|
if (query.inline != null) {
|
|
@@ -42638,21 +42643,33 @@ function webWorkerPlugin(config) {
|
|
|
42638
42643
|
workerConstructor === 'Worker'
|
|
42639
42644
|
? `${encodedJs}
|
|
42640
42645
|
const blob = typeof window !== "undefined" && window.Blob && new Blob([atob(encodedJs)], { type: "text/javascript;charset=utf-8" });
|
|
42641
|
-
export default function WorkerWrapper() {
|
|
42646
|
+
export default function WorkerWrapper(options) {
|
|
42642
42647
|
let objURL;
|
|
42643
42648
|
try {
|
|
42644
42649
|
objURL = blob && (window.URL || window.webkitURL).createObjectURL(blob);
|
|
42645
42650
|
if (!objURL) throw ''
|
|
42646
|
-
return new ${workerConstructor}(objURL)
|
|
42651
|
+
return new ${workerConstructor}(objURL, { name: options?.name })
|
|
42647
42652
|
} catch(e) {
|
|
42648
|
-
return new ${workerConstructor}(
|
|
42653
|
+
return new ${workerConstructor}(
|
|
42654
|
+
"data:application/javascript;base64," + encodedJs,
|
|
42655
|
+
{
|
|
42656
|
+
${workerTypeOption ? `type: "${workerTypeOption}",` : ''}
|
|
42657
|
+
name: options?.name
|
|
42658
|
+
}
|
|
42659
|
+
);
|
|
42649
42660
|
} finally {
|
|
42650
42661
|
objURL && (window.URL || window.webkitURL).revokeObjectURL(objURL);
|
|
42651
42662
|
}
|
|
42652
42663
|
}`
|
|
42653
42664
|
: `${encodedJs}
|
|
42654
|
-
export default function WorkerWrapper() {
|
|
42655
|
-
return new ${workerConstructor}(
|
|
42665
|
+
export default function WorkerWrapper(options) {
|
|
42666
|
+
return new ${workerConstructor}(
|
|
42667
|
+
"data:application/javascript;base64," + encodedJs,
|
|
42668
|
+
{
|
|
42669
|
+
${workerTypeOption ? `type: "${workerTypeOption}",` : ''}
|
|
42670
|
+
name: options?.name
|
|
42671
|
+
}
|
|
42672
|
+
);
|
|
42656
42673
|
}
|
|
42657
42674
|
`;
|
|
42658
42675
|
return {
|
|
@@ -42677,8 +42694,14 @@ function webWorkerPlugin(config) {
|
|
|
42677
42694
|
};
|
|
42678
42695
|
}
|
|
42679
42696
|
return {
|
|
42680
|
-
code: `export default function WorkerWrapper() {
|
|
42681
|
-
return new ${workerConstructor}(
|
|
42697
|
+
code: `export default function WorkerWrapper(options) {
|
|
42698
|
+
return new ${workerConstructor}(
|
|
42699
|
+
${JSON.stringify(url)},
|
|
42700
|
+
{
|
|
42701
|
+
${workerTypeOption ? `type: "${workerTypeOption}",` : ''}
|
|
42702
|
+
name: options?.name
|
|
42703
|
+
}
|
|
42704
|
+
);
|
|
42682
42705
|
}`,
|
|
42683
42706
|
map: { mappings: '' }, // Empty sourcemap to suppress Rollup warning
|
|
42684
42707
|
};
|
|
@@ -43045,7 +43068,7 @@ function workerImportMetaUrlPlugin(config) {
|
|
|
43045
43068
|
if (rawUrl[0] === '`' && rawUrl.includes('${')) {
|
|
43046
43069
|
this.error(`\`new URL(url, import.meta.url)\` is not supported in dynamic template string.`, urlIndex);
|
|
43047
43070
|
}
|
|
43048
|
-
s
|
|
43071
|
+
s ||= new MagicString(code);
|
|
43049
43072
|
const workerType = getWorkerType(code, cleanString, index + allExp.length);
|
|
43050
43073
|
const url = rawUrl.slice(1, -1);
|
|
43051
43074
|
let file;
|
|
@@ -43054,15 +43077,16 @@ function workerImportMetaUrlPlugin(config) {
|
|
|
43054
43077
|
file = tryFsResolve(file, fsResolveOptions) ?? file;
|
|
43055
43078
|
}
|
|
43056
43079
|
else {
|
|
43057
|
-
workerResolver
|
|
43080
|
+
workerResolver ??= config.createResolver({
|
|
43058
43081
|
extensions: [],
|
|
43059
43082
|
tryIndex: false,
|
|
43060
43083
|
preferRelative: true,
|
|
43061
|
-
})
|
|
43084
|
+
});
|
|
43062
43085
|
file = await workerResolver(url, id);
|
|
43063
|
-
file
|
|
43064
|
-
|
|
43065
|
-
|
|
43086
|
+
file ??=
|
|
43087
|
+
url[0] === '/'
|
|
43088
|
+
? slash$1(path$o.join(config.publicDir, url))
|
|
43089
|
+
: slash$1(path$o.resolve(path$o.dirname(id), url));
|
|
43066
43090
|
}
|
|
43067
43091
|
let builtUrl;
|
|
43068
43092
|
if (isBuild) {
|
|
@@ -43166,16 +43190,17 @@ function assetImportMetaUrlPlugin(config) {
|
|
|
43166
43190
|
file = tryFsResolve(file, fsResolveOptions) ?? file;
|
|
43167
43191
|
}
|
|
43168
43192
|
else {
|
|
43169
|
-
assetResolver
|
|
43193
|
+
assetResolver ??= config.createResolver({
|
|
43170
43194
|
extensions: [],
|
|
43171
43195
|
mainFields: [],
|
|
43172
43196
|
tryIndex: false,
|
|
43173
43197
|
preferRelative: true,
|
|
43174
|
-
})
|
|
43198
|
+
});
|
|
43175
43199
|
file = await assetResolver(url, id);
|
|
43176
|
-
file
|
|
43177
|
-
|
|
43178
|
-
|
|
43200
|
+
file ??=
|
|
43201
|
+
url[0] === '/'
|
|
43202
|
+
? slash$1(path$o.join(config.publicDir, url))
|
|
43203
|
+
: slash$1(path$o.resolve(path$o.dirname(id), url));
|
|
43179
43204
|
}
|
|
43180
43205
|
// Get final asset URL. If the file does not exist,
|
|
43181
43206
|
// we fall back to the initial URL and let it resolve in runtime
|
|
@@ -43517,7 +43542,7 @@ function dynamicImportVarsPlugin(config) {
|
|
|
43517
43542
|
if (hasViteIgnoreRE.test(source.slice(expStart, expEnd))) {
|
|
43518
43543
|
continue;
|
|
43519
43544
|
}
|
|
43520
|
-
s
|
|
43545
|
+
s ||= new MagicString(source);
|
|
43521
43546
|
let result;
|
|
43522
43547
|
try {
|
|
43523
43548
|
// When import string is using backticks, es-module-lexer `end` captures
|
|
@@ -43895,15 +43920,15 @@ async function createPluginContainer(config, moduleGraph, watcher) {
|
|
|
43895
43920
|
// active plugin in that pipeline can be tracked in a concurrency-safe manner.
|
|
43896
43921
|
// using a class to make creating new contexts more efficient
|
|
43897
43922
|
class Context {
|
|
43923
|
+
meta = minimalContext.meta;
|
|
43924
|
+
ssr = false;
|
|
43925
|
+
_scan = false;
|
|
43926
|
+
_activePlugin;
|
|
43927
|
+
_activeId = null;
|
|
43928
|
+
_activeCode = null;
|
|
43929
|
+
_resolveSkips;
|
|
43930
|
+
_addedImports = null;
|
|
43898
43931
|
constructor(initialPlugin) {
|
|
43899
|
-
this.meta = minimalContext.meta;
|
|
43900
|
-
this.ssr = false;
|
|
43901
|
-
this._scan = false;
|
|
43902
|
-
this._activeId = null;
|
|
43903
|
-
this._activeCode = null;
|
|
43904
|
-
this._addedImports = null;
|
|
43905
|
-
this.debug = noop$3;
|
|
43906
|
-
this.info = noop$3;
|
|
43907
43932
|
this._activePlugin = initialPlugin || null;
|
|
43908
43933
|
}
|
|
43909
43934
|
parse(code, opts = {}) {
|
|
@@ -43988,6 +44013,8 @@ async function createPluginContainer(config, moduleGraph, watcher) {
|
|
|
43988
44013
|
// the the error middleware.
|
|
43989
44014
|
throw formatError(e, position, this);
|
|
43990
44015
|
}
|
|
44016
|
+
debug = noop$3;
|
|
44017
|
+
info = noop$3;
|
|
43991
44018
|
}
|
|
43992
44019
|
function formatError(e, position, ctx) {
|
|
43993
44020
|
const err = (typeof e === 'string' ? new Error(e) : e);
|
|
@@ -44048,7 +44075,7 @@ async function createPluginContainer(config, moduleGraph, watcher) {
|
|
|
44048
44075
|
typeof err.loc?.line === 'number' &&
|
|
44049
44076
|
typeof err.loc?.column === 'number') {
|
|
44050
44077
|
const rawSourceMap = ctx._getCombinedSourcemap();
|
|
44051
|
-
if (rawSourceMap) {
|
|
44078
|
+
if (rawSourceMap && 'version' in rawSourceMap) {
|
|
44052
44079
|
const traced = new TraceMap(rawSourceMap);
|
|
44053
44080
|
const { source, line, column } = originalPositionFor$1(traced, {
|
|
44054
44081
|
line: Number(err.loc.line),
|
|
@@ -44085,11 +44112,13 @@ async function createPluginContainer(config, moduleGraph, watcher) {
|
|
|
44085
44112
|
return err;
|
|
44086
44113
|
}
|
|
44087
44114
|
class TransformContext extends Context {
|
|
44115
|
+
filename;
|
|
44116
|
+
originalCode;
|
|
44117
|
+
originalSourcemap = null;
|
|
44118
|
+
sourcemapChain = [];
|
|
44119
|
+
combinedMap = null;
|
|
44088
44120
|
constructor(filename, code, inMap) {
|
|
44089
44121
|
super();
|
|
44090
|
-
this.originalSourcemap = null;
|
|
44091
|
-
this.sourcemapChain = [];
|
|
44092
|
-
this.combinedMap = null;
|
|
44093
44122
|
this.filename = filename;
|
|
44094
44123
|
this.originalCode = code;
|
|
44095
44124
|
if (inMap) {
|
|
@@ -44100,7 +44129,7 @@ async function createPluginContainer(config, moduleGraph, watcher) {
|
|
|
44100
44129
|
this.sourcemapChain.push(inMap);
|
|
44101
44130
|
}
|
|
44102
44131
|
}
|
|
44103
|
-
_getCombinedSourcemap(
|
|
44132
|
+
_getCombinedSourcemap() {
|
|
44104
44133
|
if (debugSourcemapCombine &&
|
|
44105
44134
|
debugSourcemapCombineFilter &&
|
|
44106
44135
|
this.filename.includes(debugSourcemapCombineFilter)) {
|
|
@@ -44110,13 +44139,24 @@ async function createPluginContainer(config, moduleGraph, watcher) {
|
|
|
44110
44139
|
debugSourcemapCombine('----------');
|
|
44111
44140
|
}
|
|
44112
44141
|
let combinedMap = this.combinedMap;
|
|
44142
|
+
// { mappings: '' }
|
|
44143
|
+
if (combinedMap &&
|
|
44144
|
+
!('version' in combinedMap) &&
|
|
44145
|
+
combinedMap.mappings === '') {
|
|
44146
|
+
this.sourcemapChain.length = 0;
|
|
44147
|
+
return combinedMap;
|
|
44148
|
+
}
|
|
44113
44149
|
for (let m of this.sourcemapChain) {
|
|
44114
44150
|
if (typeof m === 'string')
|
|
44115
44151
|
m = JSON.parse(m);
|
|
44116
44152
|
if (!('version' in m)) {
|
|
44153
|
+
// { mappings: '' }
|
|
44154
|
+
if (m.mappings === '') {
|
|
44155
|
+
combinedMap = { mappings: '' };
|
|
44156
|
+
break;
|
|
44157
|
+
}
|
|
44117
44158
|
// empty, nullified source map
|
|
44118
|
-
combinedMap =
|
|
44119
|
-
this.sourcemapChain.length = 0;
|
|
44159
|
+
combinedMap = null;
|
|
44120
44160
|
break;
|
|
44121
44161
|
}
|
|
44122
44162
|
if (!combinedMap) {
|
|
@@ -44129,15 +44169,6 @@ async function createPluginContainer(config, moduleGraph, watcher) {
|
|
|
44129
44169
|
]);
|
|
44130
44170
|
}
|
|
44131
44171
|
}
|
|
44132
|
-
if (!combinedMap) {
|
|
44133
|
-
return createIfNull
|
|
44134
|
-
? new MagicString(this.originalCode).generateMap({
|
|
44135
|
-
includeContent: true,
|
|
44136
|
-
hires: 'boundary',
|
|
44137
|
-
source: cleanUrl(this.filename),
|
|
44138
|
-
})
|
|
44139
|
-
: null;
|
|
44140
|
-
}
|
|
44141
44172
|
if (combinedMap !== this.combinedMap) {
|
|
44142
44173
|
this.combinedMap = combinedMap;
|
|
44143
44174
|
this.sourcemapChain.length = 0;
|
|
@@ -44145,7 +44176,15 @@ async function createPluginContainer(config, moduleGraph, watcher) {
|
|
|
44145
44176
|
return this.combinedMap;
|
|
44146
44177
|
}
|
|
44147
44178
|
getCombinedSourcemap() {
|
|
44148
|
-
|
|
44179
|
+
const map = this._getCombinedSourcemap();
|
|
44180
|
+
if (!map || (!('version' in map) && map.mappings === '')) {
|
|
44181
|
+
return new MagicString(this.originalCode).generateMap({
|
|
44182
|
+
includeContent: true,
|
|
44183
|
+
hires: 'boundary',
|
|
44184
|
+
source: cleanUrl(this.filename),
|
|
44185
|
+
});
|
|
44186
|
+
}
|
|
44187
|
+
return map;
|
|
44149
44188
|
}
|
|
44150
44189
|
}
|
|
44151
44190
|
let closed = false;
|
|
@@ -46058,7 +46097,11 @@ function newDepOptimizationProcessing() {
|
|
|
46058
46097
|
}
|
|
46059
46098
|
// Convert to { id: src }
|
|
46060
46099
|
function depsFromOptimizedDepInfo(depsInfo) {
|
|
46061
|
-
|
|
46100
|
+
const obj = {};
|
|
46101
|
+
for (const key in depsInfo) {
|
|
46102
|
+
obj[key] = depsInfo[key].src;
|
|
46103
|
+
}
|
|
46104
|
+
return obj;
|
|
46062
46105
|
}
|
|
46063
46106
|
function getOptimizedDepPath(id, config, ssr) {
|
|
46064
46107
|
return normalizePath$3(path$o.resolve(getDepsCacheDir(config, ssr), flattenId(id) + '.js'));
|
|
@@ -46336,7 +46379,7 @@ function findOptimizedDepInfoInRecord(dependenciesInfo, callbackFn) {
|
|
|
46336
46379
|
async function optimizedDepNeedsInterop(metadata, file, config, ssr) {
|
|
46337
46380
|
const depInfo = optimizedDepInfoFromFile(metadata, file);
|
|
46338
46381
|
if (depInfo?.src && depInfo.needsInterop === undefined) {
|
|
46339
|
-
depInfo.exportsData
|
|
46382
|
+
depInfo.exportsData ??= extractExportsData(depInfo.src, config, ssr);
|
|
46340
46383
|
depInfo.needsInterop = needsInterop(config, ssr, depInfo.id, await depInfo.exportsData);
|
|
46341
46384
|
}
|
|
46342
46385
|
return depInfo?.needsInterop;
|
|
@@ -46946,7 +46989,7 @@ function ssrManifestPlugin(config) {
|
|
|
46946
46989
|
if (chunk.code.includes(preloadMethod)) {
|
|
46947
46990
|
// generate css deps map
|
|
46948
46991
|
const code = chunk.code;
|
|
46949
|
-
let imports;
|
|
46992
|
+
let imports = [];
|
|
46950
46993
|
try {
|
|
46951
46994
|
imports = parse$e(code)[0].filter((i) => i.n && i.d > -1);
|
|
46952
46995
|
}
|
|
@@ -47214,11 +47257,18 @@ function send$2(req, res, content, type, options) {
|
|
|
47214
47257
|
}
|
|
47215
47258
|
}
|
|
47216
47259
|
// inject source map reference
|
|
47217
|
-
if (map && map.mappings) {
|
|
47260
|
+
if (map && 'version' in map && map.mappings) {
|
|
47218
47261
|
if (type === 'js' || type === 'css') {
|
|
47219
47262
|
content = getCodeWithSourcemap(type, content.toString(), map);
|
|
47220
47263
|
}
|
|
47221
47264
|
}
|
|
47265
|
+
else {
|
|
47266
|
+
if (type === 'js' && (!map || map.mappings !== '')) {
|
|
47267
|
+
const urlWithoutTimestamp = removeTimestampQuery(req.url);
|
|
47268
|
+
const ms = new MagicString(content.toString());
|
|
47269
|
+
content = getCodeWithSourcemap(type, content.toString(), ms.generateMap({ source: urlWithoutTimestamp, hires: 'boundary' }));
|
|
47270
|
+
}
|
|
47271
|
+
}
|
|
47222
47272
|
res.statusCode = 200;
|
|
47223
47273
|
res.end(content);
|
|
47224
47274
|
return;
|
|
@@ -47887,7 +47937,6 @@ async function build(inlineConfig = {}) {
|
|
|
47887
47937
|
await initDepsOptimizer(config);
|
|
47888
47938
|
}
|
|
47889
47939
|
const rollupOptions = {
|
|
47890
|
-
context: 'globalThis',
|
|
47891
47940
|
preserveEntrySignatures: ssr
|
|
47892
47941
|
? 'allow-extension'
|
|
47893
47942
|
: libOptions
|
|
@@ -48084,7 +48133,7 @@ function resolveLibFilename(libOptions, format, entryName, root, extension, pack
|
|
|
48084
48133
|
: entryName);
|
|
48085
48134
|
if (!name)
|
|
48086
48135
|
throw new Error('Name in package.json is required if option "build.lib.fileName" is not provided.');
|
|
48087
|
-
extension
|
|
48136
|
+
extension ??= resolveOutputJsExtension(format, packageJson?.type);
|
|
48088
48137
|
if (format === 'cjs' || format === 'es') {
|
|
48089
48138
|
return `${name}.${extension}`;
|
|
48090
48139
|
}
|
|
@@ -54943,7 +54992,7 @@ async function loadAndTransform(id, url, server, options, timestamp, mod, resolv
|
|
|
54943
54992
|
if (server._restartPromise && !ssr)
|
|
54944
54993
|
throwClosedServerError();
|
|
54945
54994
|
// ensure module in graph after successful load
|
|
54946
|
-
mod
|
|
54995
|
+
mod ??= await moduleGraph._ensureEntryFromUrl(url, ssr, undefined, resolved);
|
|
54947
54996
|
ensureWatchedFile(watcher, mod.file, root);
|
|
54948
54997
|
// transform
|
|
54949
54998
|
const transformStart = debugTransform ? performance.now() : 0;
|
|
@@ -54962,22 +55011,31 @@ async function loadAndTransform(id, url, server, options, timestamp, mod, resolv
|
|
|
54962
55011
|
code = transformResult.code;
|
|
54963
55012
|
map = transformResult.map;
|
|
54964
55013
|
}
|
|
54965
|
-
|
|
54966
|
-
|
|
54967
|
-
|
|
54968
|
-
|
|
55014
|
+
let normalizedMap;
|
|
55015
|
+
if (typeof map === 'string') {
|
|
55016
|
+
normalizedMap = JSON.parse(map);
|
|
55017
|
+
}
|
|
55018
|
+
else if (map) {
|
|
55019
|
+
normalizedMap = map;
|
|
55020
|
+
}
|
|
55021
|
+
else {
|
|
55022
|
+
normalizedMap = null;
|
|
55023
|
+
}
|
|
55024
|
+
if (normalizedMap && 'version' in normalizedMap && mod.file) {
|
|
55025
|
+
if (normalizedMap.mappings) {
|
|
55026
|
+
await injectSourcesContent(normalizedMap, mod.file, logger);
|
|
54969
55027
|
}
|
|
54970
55028
|
const sourcemapPath = `${mod.file}.map`;
|
|
54971
|
-
applySourcemapIgnoreList(
|
|
55029
|
+
applySourcemapIgnoreList(normalizedMap, sourcemapPath, config.server.sourcemapIgnoreList, logger);
|
|
54972
55030
|
if (path$o.isAbsolute(mod.file)) {
|
|
54973
|
-
for (let sourcesIndex = 0; sourcesIndex <
|
|
54974
|
-
const sourcePath =
|
|
55031
|
+
for (let sourcesIndex = 0; sourcesIndex < normalizedMap.sources.length; ++sourcesIndex) {
|
|
55032
|
+
const sourcePath = normalizedMap.sources[sourcesIndex];
|
|
54975
55033
|
if (sourcePath) {
|
|
54976
55034
|
// Rewrite sources to relative paths to give debuggers the chance
|
|
54977
55035
|
// to resolve and display them in a meaningful way (rather than
|
|
54978
55036
|
// with absolute paths).
|
|
54979
55037
|
if (path$o.isAbsolute(sourcePath)) {
|
|
54980
|
-
|
|
55038
|
+
normalizedMap.sources[sourcesIndex] = path$o.relative(path$o.dirname(mod.file), sourcePath);
|
|
54981
55039
|
}
|
|
54982
55040
|
}
|
|
54983
55041
|
}
|
|
@@ -54986,12 +55044,12 @@ async function loadAndTransform(id, url, server, options, timestamp, mod, resolv
|
|
|
54986
55044
|
if (server._restartPromise && !ssr)
|
|
54987
55045
|
throwClosedServerError();
|
|
54988
55046
|
const result = ssr && !server.config.experimental.skipSsrTransform
|
|
54989
|
-
? await server.ssrTransform(code,
|
|
54990
|
-
: {
|
|
55047
|
+
? await server.ssrTransform(code, normalizedMap, url, originalCode)
|
|
55048
|
+
: ({
|
|
54991
55049
|
code,
|
|
54992
|
-
map,
|
|
55050
|
+
map: normalizedMap,
|
|
54993
55051
|
etag: getEtag(code, { weak: true }),
|
|
54994
|
-
};
|
|
55052
|
+
});
|
|
54995
55053
|
// Only cache the result if the module wasn't invalidated while it was
|
|
54996
55054
|
// being processed, so it is re-processed next time if it is stale
|
|
54997
55055
|
if (timestamp > mod.lastInvalidationTimestamp) {
|
|
@@ -55500,7 +55558,10 @@ async function ssrTransformScript(code, inMap, url, originalCode) {
|
|
|
55500
55558
|
},
|
|
55501
55559
|
});
|
|
55502
55560
|
let map = s.generateMap({ hires: 'boundary' });
|
|
55503
|
-
if (inMap &&
|
|
55561
|
+
if (inMap &&
|
|
55562
|
+
inMap.mappings &&
|
|
55563
|
+
'sources' in inMap &&
|
|
55564
|
+
inMap.sources.length > 0) {
|
|
55504
55565
|
map = combineSourcemaps(url, [
|
|
55505
55566
|
{
|
|
55506
55567
|
...map,
|
|
@@ -55958,7 +56019,7 @@ async function instantiateModule(url, server, context = { global }, urlStack = [
|
|
|
55958
56019
|
}
|
|
55959
56020
|
}
|
|
55960
56021
|
let sourceMapSuffix = '';
|
|
55961
|
-
if (result.map) {
|
|
56022
|
+
if (result.map && 'version' in result.map) {
|
|
55962
56023
|
const moduleSourceMap = Object.assign({}, result.map, {
|
|
55963
56024
|
// currently we need to offset the line
|
|
55964
56025
|
// https://github.com/nodejs/node/issues/43047#issuecomment-1180632750
|
|
@@ -57309,8 +57370,13 @@ const BASE_PREVIEW_SHORTCUTS = [
|
|
|
57309
57370
|
key: 'o',
|
|
57310
57371
|
description: 'open in browser',
|
|
57311
57372
|
action(server) {
|
|
57312
|
-
const url = server.resolvedUrls
|
|
57313
|
-
|
|
57373
|
+
const url = server.resolvedUrls?.local[0] ?? server.resolvedUrls?.network[0];
|
|
57374
|
+
if (url) {
|
|
57375
|
+
openBrowser(url, true, server.config.logger);
|
|
57376
|
+
}
|
|
57377
|
+
else {
|
|
57378
|
+
server.config.logger.warn('No URL available to open in browser');
|
|
57379
|
+
}
|
|
57314
57380
|
},
|
|
57315
57381
|
},
|
|
57316
57382
|
{
|
|
@@ -61692,6 +61758,7 @@ function createWebSocketServer(server, config, httpsOptions) {
|
|
|
61692
61758
|
// TODO: the main server port may not have been chosen yet as it may use the next available
|
|
61693
61759
|
const portsAreCompatible = !hmrPort || hmrPort === config.server.port;
|
|
61694
61760
|
const wsServer = hmrServer || (portsAreCompatible && server);
|
|
61761
|
+
let hmrServerWsListener;
|
|
61695
61762
|
const customListeners = new Map();
|
|
61696
61763
|
const clientsMap = new WeakMap();
|
|
61697
61764
|
const port = hmrPort || 24678;
|
|
@@ -61703,14 +61770,15 @@ function createWebSocketServer(server, config, httpsOptions) {
|
|
|
61703
61770
|
hmrBase = path$o.posix.join(hmrBase, hmrPath);
|
|
61704
61771
|
}
|
|
61705
61772
|
wss = new WebSocketServerRaw({ noServer: true });
|
|
61706
|
-
|
|
61773
|
+
hmrServerWsListener = (req, socket, head) => {
|
|
61707
61774
|
if (req.headers['sec-websocket-protocol'] === HMR_HEADER &&
|
|
61708
61775
|
req.url === hmrBase) {
|
|
61709
61776
|
wss.handleUpgrade(req, socket, head, (ws) => {
|
|
61710
61777
|
wss.emit('connection', ws, req);
|
|
61711
61778
|
});
|
|
61712
61779
|
}
|
|
61713
|
-
}
|
|
61780
|
+
};
|
|
61781
|
+
wsServer.on('upgrade', hmrServerWsListener);
|
|
61714
61782
|
}
|
|
61715
61783
|
else {
|
|
61716
61784
|
// http server request handler keeps the same with
|
|
@@ -61852,6 +61920,11 @@ function createWebSocketServer(server, config, httpsOptions) {
|
|
|
61852
61920
|
});
|
|
61853
61921
|
},
|
|
61854
61922
|
close() {
|
|
61923
|
+
// should remove listener if hmr.server is set
|
|
61924
|
+
// otherwise the old listener swallows all WebSocket connections
|
|
61925
|
+
if (hmrServerWsListener && wsServer) {
|
|
61926
|
+
wsServer.off('upgrade', hmrServerWsListener);
|
|
61927
|
+
}
|
|
61855
61928
|
return new Promise((resolve, reject) => {
|
|
61856
61929
|
wss.clients.forEach((client) => {
|
|
61857
61930
|
client.terminate();
|
|
@@ -64198,9 +64271,10 @@ var history = /*@__PURE__*/getDefaultExportFromCjs(libExports);
|
|
|
64198
64271
|
|
|
64199
64272
|
function htmlFallbackMiddleware(root, spaFallback) {
|
|
64200
64273
|
const historyHtmlFallbackMiddleware = history({
|
|
64274
|
+
disableDotRule: true,
|
|
64201
64275
|
logger: createDebugger('vite:html-fallback'),
|
|
64202
|
-
// support /dir/ without explicit index.html
|
|
64203
64276
|
rewrites: [
|
|
64277
|
+
// support /dir/ without explicit index.html
|
|
64204
64278
|
{
|
|
64205
64279
|
from: /\/$/,
|
|
64206
64280
|
to({ parsedUrl, request }) {
|
|
@@ -64211,6 +64285,13 @@ function htmlFallbackMiddleware(root, spaFallback) {
|
|
|
64211
64285
|
return spaFallback ? `/index.html` : request.url;
|
|
64212
64286
|
},
|
|
64213
64287
|
},
|
|
64288
|
+
// don't rewrite paths ending with .html
|
|
64289
|
+
{
|
|
64290
|
+
from: /\.html$/,
|
|
64291
|
+
to({ request }) {
|
|
64292
|
+
return request.url;
|
|
64293
|
+
},
|
|
64294
|
+
},
|
|
64214
64295
|
],
|
|
64215
64296
|
});
|
|
64216
64297
|
// Keep the named function. The name is visible in debug logs via `DEBUG=connect:dispatcher ...`
|
|
@@ -64570,7 +64651,7 @@ const devHtmlHook = async (html, { path: htmlPath, filename, server, originalUrl
|
|
|
64570
64651
|
const result = await server.pluginContainer.transform(code, mod.id);
|
|
64571
64652
|
let content = '';
|
|
64572
64653
|
if (result) {
|
|
64573
|
-
if (result.map) {
|
|
64654
|
+
if (result.map && 'version' in result.map) {
|
|
64574
64655
|
if (result.map.mappings) {
|
|
64575
64656
|
await injectSourcesContent(result.map, proxyModulePath, config.logger);
|
|
64576
64657
|
}
|
|
@@ -64654,27 +64735,35 @@ function timeMiddleware(root) {
|
|
|
64654
64735
|
}
|
|
64655
64736
|
|
|
64656
64737
|
class ModuleNode {
|
|
64738
|
+
/**
|
|
64739
|
+
* Public served url path, starts with /
|
|
64740
|
+
*/
|
|
64741
|
+
url;
|
|
64742
|
+
/**
|
|
64743
|
+
* Resolved file system path + query
|
|
64744
|
+
*/
|
|
64745
|
+
id = null;
|
|
64746
|
+
file = null;
|
|
64747
|
+
type;
|
|
64748
|
+
info;
|
|
64749
|
+
meta;
|
|
64750
|
+
importers = new Set();
|
|
64751
|
+
clientImportedModules = new Set();
|
|
64752
|
+
ssrImportedModules = new Set();
|
|
64753
|
+
acceptedHmrDeps = new Set();
|
|
64754
|
+
acceptedHmrExports = null;
|
|
64755
|
+
importedBindings = null;
|
|
64756
|
+
isSelfAccepting;
|
|
64757
|
+
transformResult = null;
|
|
64758
|
+
ssrTransformResult = null;
|
|
64759
|
+
ssrModule = null;
|
|
64760
|
+
ssrError = null;
|
|
64761
|
+
lastHMRTimestamp = 0;
|
|
64762
|
+
lastInvalidationTimestamp = 0;
|
|
64657
64763
|
/**
|
|
64658
64764
|
* @param setIsSelfAccepting - set `false` to set `isSelfAccepting` later. e.g. #7870
|
|
64659
64765
|
*/
|
|
64660
64766
|
constructor(url, setIsSelfAccepting = true) {
|
|
64661
|
-
/**
|
|
64662
|
-
* Resolved file system path + query
|
|
64663
|
-
*/
|
|
64664
|
-
this.id = null;
|
|
64665
|
-
this.file = null;
|
|
64666
|
-
this.importers = new Set();
|
|
64667
|
-
this.clientImportedModules = new Set();
|
|
64668
|
-
this.ssrImportedModules = new Set();
|
|
64669
|
-
this.acceptedHmrDeps = new Set();
|
|
64670
|
-
this.acceptedHmrExports = null;
|
|
64671
|
-
this.importedBindings = null;
|
|
64672
|
-
this.transformResult = null;
|
|
64673
|
-
this.ssrTransformResult = null;
|
|
64674
|
-
this.ssrModule = null;
|
|
64675
|
-
this.ssrError = null;
|
|
64676
|
-
this.lastHMRTimestamp = 0;
|
|
64677
|
-
this.lastInvalidationTimestamp = 0;
|
|
64678
64767
|
this.url = url;
|
|
64679
64768
|
this.type = isDirectCSSRequest(url) ? 'css' : 'js';
|
|
64680
64769
|
if (setIsSelfAccepting) {
|
|
@@ -64690,21 +64779,22 @@ class ModuleNode {
|
|
|
64690
64779
|
}
|
|
64691
64780
|
}
|
|
64692
64781
|
class ModuleGraph {
|
|
64782
|
+
resolveId;
|
|
64783
|
+
urlToModuleMap = new Map();
|
|
64784
|
+
idToModuleMap = new Map();
|
|
64785
|
+
// a single file may corresponds to multiple modules with different queries
|
|
64786
|
+
fileToModulesMap = new Map();
|
|
64787
|
+
safeModulesPath = new Set();
|
|
64788
|
+
/**
|
|
64789
|
+
* @internal
|
|
64790
|
+
*/
|
|
64791
|
+
_unresolvedUrlToModuleMap = new Map();
|
|
64792
|
+
/**
|
|
64793
|
+
* @internal
|
|
64794
|
+
*/
|
|
64795
|
+
_ssrUnresolvedUrlToModuleMap = new Map();
|
|
64693
64796
|
constructor(resolveId) {
|
|
64694
64797
|
this.resolveId = resolveId;
|
|
64695
|
-
this.urlToModuleMap = new Map();
|
|
64696
|
-
this.idToModuleMap = new Map();
|
|
64697
|
-
// a single file may corresponds to multiple modules with different queries
|
|
64698
|
-
this.fileToModulesMap = new Map();
|
|
64699
|
-
this.safeModulesPath = new Set();
|
|
64700
|
-
/**
|
|
64701
|
-
* @internal
|
|
64702
|
-
*/
|
|
64703
|
-
this._unresolvedUrlToModuleMap = new Map();
|
|
64704
|
-
/**
|
|
64705
|
-
* @internal
|
|
64706
|
-
*/
|
|
64707
|
-
this._ssrUnresolvedUrlToModuleMap = new Map();
|
|
64708
64798
|
}
|
|
64709
64799
|
async getModuleByUrl(rawUrl, ssr) {
|
|
64710
64800
|
// Quick path, if we already have a module for this rawUrl (even without extension)
|
|
@@ -65637,7 +65727,7 @@ var preview$1 = {
|
|
|
65637
65727
|
};
|
|
65638
65728
|
|
|
65639
65729
|
function resolveSSROptions(ssr, preserveSymlinks, buildSsrCjsExternalHeuristics) {
|
|
65640
|
-
ssr
|
|
65730
|
+
ssr ??= {};
|
|
65641
65731
|
const optimizeDeps = ssr.optimizeDeps ?? {};
|
|
65642
65732
|
const format = buildSsrCjsExternalHeuristics ? 'cjs' : 'esm';
|
|
65643
65733
|
const target = 'node';
|
|
@@ -65721,7 +65811,7 @@ async function resolveConfig(inlineConfig, command, defaultMode = 'development',
|
|
|
65721
65811
|
optimizeDeps: { disabled: false },
|
|
65722
65812
|
ssr: { optimizeDeps: { disabled: false } },
|
|
65723
65813
|
});
|
|
65724
|
-
config.build
|
|
65814
|
+
config.build ??= {};
|
|
65725
65815
|
config.build.commonjsOptions = { include: [] };
|
|
65726
65816
|
}
|
|
65727
65817
|
// Define logger
|
|
@@ -66111,7 +66201,7 @@ async function bundleConfigFile(fileName, isESM) {
|
|
|
66111
66201
|
entryPoints: [fileName],
|
|
66112
66202
|
outfile: 'out.js',
|
|
66113
66203
|
write: false,
|
|
66114
|
-
target: ['
|
|
66204
|
+
target: ['node18'],
|
|
66115
66205
|
platform: 'node',
|
|
66116
66206
|
bundle: true,
|
|
66117
66207
|
format: isESM ? 'esm' : 'cjs',
|