vite 5.0.0-beta.10 → 5.0.0-beta.11
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/dist/node/chunks/{dep-pNoMh5ox.js → dep-HpI8v4GP.js} +1 -1
- package/dist/node/chunks/{dep-RTfXXG9P.js → dep-kPX9VBbU.js} +242 -114
- package/dist/node/chunks/{dep-s3v9f2KI.js → dep-rMlk0HEr.js} +1 -1
- package/dist/node/cli.js +5 -8
- package/dist/node/index.d.ts +18 -5
- package/dist/node/index.js +2 -2
- package/dist/node-cjs/publicUtils.cjs +16 -0
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { z as commonjsGlobal, y as getDefaultExportFromCjs } from './dep-
|
|
1
|
+
import { z as commonjsGlobal, y as getDefaultExportFromCjs } from './dep-kPX9VBbU.js';
|
|
2
2
|
import require$$0__default from 'fs';
|
|
3
3
|
import require$$0 from 'postcss';
|
|
4
4
|
import require$$0$1 from 'path';
|
|
@@ -12220,6 +12220,24 @@ function lookupFile(dir, fileNames) {
|
|
|
12220
12220
|
dir = parentDir;
|
|
12221
12221
|
}
|
|
12222
12222
|
}
|
|
12223
|
+
function isFilePathESM(filePath, packageCache) {
|
|
12224
|
+
if (/\.m[jt]s$/.test(filePath)) {
|
|
12225
|
+
return true;
|
|
12226
|
+
}
|
|
12227
|
+
else if (/\.c[jt]s$/.test(filePath)) {
|
|
12228
|
+
return false;
|
|
12229
|
+
}
|
|
12230
|
+
else {
|
|
12231
|
+
// check package.json for type: "module"
|
|
12232
|
+
try {
|
|
12233
|
+
const pkg = findNearestPackageData(path$o.dirname(filePath), packageCache);
|
|
12234
|
+
return pkg?.data.type === 'module';
|
|
12235
|
+
}
|
|
12236
|
+
catch {
|
|
12237
|
+
return false;
|
|
12238
|
+
}
|
|
12239
|
+
}
|
|
12240
|
+
}
|
|
12223
12241
|
const splitRE = /\r?\n/;
|
|
12224
12242
|
const range = 2;
|
|
12225
12243
|
function pad$1(source, n = 2) {
|
|
@@ -12694,6 +12712,15 @@ function emptyCssComments(raw) {
|
|
|
12694
12712
|
function removeComments(raw) {
|
|
12695
12713
|
return raw.replace(multilineCommentsRE$1, '').replace(singlelineCommentsRE$1, '');
|
|
12696
12714
|
}
|
|
12715
|
+
function backwardCompatibleWorkerPlugins(plugins) {
|
|
12716
|
+
if (Array.isArray(plugins)) {
|
|
12717
|
+
return plugins;
|
|
12718
|
+
}
|
|
12719
|
+
if (typeof plugins === 'function') {
|
|
12720
|
+
return plugins();
|
|
12721
|
+
}
|
|
12722
|
+
return [];
|
|
12723
|
+
}
|
|
12697
12724
|
function mergeConfigRecursively(defaults, overrides, rootPath) {
|
|
12698
12725
|
const merged = { ...defaults };
|
|
12699
12726
|
for (const key in overrides) {
|
|
@@ -12721,6 +12748,13 @@ function mergeConfigRecursively(defaults, overrides, rootPath) {
|
|
|
12721
12748
|
merged[key] = true;
|
|
12722
12749
|
continue;
|
|
12723
12750
|
}
|
|
12751
|
+
else if (key === 'plugins' && rootPath === 'worker') {
|
|
12752
|
+
merged[key] = () => [
|
|
12753
|
+
...backwardCompatibleWorkerPlugins(existing),
|
|
12754
|
+
...backwardCompatibleWorkerPlugins(value),
|
|
12755
|
+
];
|
|
12756
|
+
continue;
|
|
12757
|
+
}
|
|
12724
12758
|
if (Array.isArray(existing) || Array.isArray(value)) {
|
|
12725
12759
|
merged[key] = [...arraify(existing ?? []), ...arraify(value ?? [])];
|
|
12726
12760
|
continue;
|
|
@@ -15470,12 +15504,16 @@ const viteBuildPublicIdPrefix = '\0vite:asset:public';
|
|
|
15470
15504
|
*/
|
|
15471
15505
|
function assetPlugin(config) {
|
|
15472
15506
|
registerCustomMime();
|
|
15507
|
+
let moduleGraph;
|
|
15473
15508
|
return {
|
|
15474
15509
|
name: 'vite:asset',
|
|
15475
15510
|
buildStart() {
|
|
15476
15511
|
assetCache.set(config, new Map());
|
|
15477
15512
|
generatedAssets.set(config, new Map());
|
|
15478
15513
|
},
|
|
15514
|
+
configureServer(server) {
|
|
15515
|
+
moduleGraph = server.moduleGraph;
|
|
15516
|
+
},
|
|
15479
15517
|
resolveId(id) {
|
|
15480
15518
|
if (!config.assetsInclude(cleanUrl(id)) && !urlRE.test(id)) {
|
|
15481
15519
|
return;
|
|
@@ -15509,8 +15547,15 @@ function assetPlugin(config) {
|
|
|
15509
15547
|
return;
|
|
15510
15548
|
}
|
|
15511
15549
|
id = id.replace(urlRE, '$1').replace(unnededFinalQueryCharRE, '');
|
|
15512
|
-
|
|
15513
|
-
|
|
15550
|
+
let url = await fileToUrl$1(id, config, this);
|
|
15551
|
+
// Inherit HMR timestamp if this asset was invalidated
|
|
15552
|
+
if (moduleGraph) {
|
|
15553
|
+
const mod = moduleGraph.getModuleById(id);
|
|
15554
|
+
if (mod && mod.lastHMRTimestamp > 0) {
|
|
15555
|
+
url = injectQuery(url, `t=${mod.lastHMRTimestamp}`);
|
|
15556
|
+
}
|
|
15557
|
+
}
|
|
15558
|
+
return `export default ${JSON.stringify(url)}`;
|
|
15514
15559
|
},
|
|
15515
15560
|
renderChunk(code, chunk, opts) {
|
|
15516
15561
|
const s = renderAssetUrlInJS(this, config, chunk, opts, code);
|
|
@@ -15631,16 +15676,22 @@ async function fileToBuiltUrl(id, config, pluginContext, skipPublicCheck = false
|
|
|
15631
15676
|
const content = await fsp.readFile(file);
|
|
15632
15677
|
let url;
|
|
15633
15678
|
if (config.build.lib ||
|
|
15634
|
-
|
|
15679
|
+
// Don't inline SVG with fragments, as they are meant to be reused
|
|
15680
|
+
(!(file.endsWith('.svg') && id.includes('#')) &&
|
|
15635
15681
|
!file.endsWith('.html') &&
|
|
15636
15682
|
content.length < Number(config.build.assetsInlineLimit) &&
|
|
15637
15683
|
!isGitLfsPlaceholder(content))) {
|
|
15638
15684
|
if (config.build.lib && isGitLfsPlaceholder(content)) {
|
|
15639
15685
|
config.logger.warn(colors$1.yellow(`Inlined file ${id} was not downloaded via Git LFS`));
|
|
15640
15686
|
}
|
|
15641
|
-
|
|
15642
|
-
|
|
15643
|
-
|
|
15687
|
+
if (file.endsWith('.svg')) {
|
|
15688
|
+
url = svgToDataURL(content);
|
|
15689
|
+
}
|
|
15690
|
+
else {
|
|
15691
|
+
const mimeType = lookup(file) ?? 'application/octet-stream';
|
|
15692
|
+
// base64 inlined as a string
|
|
15693
|
+
url = `data:${mimeType};base64,${content.toString('base64')}`;
|
|
15694
|
+
}
|
|
15644
15695
|
}
|
|
15645
15696
|
else {
|
|
15646
15697
|
// emit as asset
|
|
@@ -15670,6 +15721,29 @@ async function urlToBuiltUrl(url, importer, config, pluginContext) {
|
|
|
15670
15721
|
// skip public check since we just did it above
|
|
15671
15722
|
true);
|
|
15672
15723
|
}
|
|
15724
|
+
// Inspired by https://github.com/iconify/iconify/blob/main/packages/utils/src/svg/url.ts
|
|
15725
|
+
function svgToDataURL(content) {
|
|
15726
|
+
const stringContent = content.toString();
|
|
15727
|
+
// If the SVG contains some text, any transformation is unsafe, and given that double quotes would then
|
|
15728
|
+
// need to be escaped, the gain to use a data URI would be ridiculous if not negative
|
|
15729
|
+
if (stringContent.includes('<text')) {
|
|
15730
|
+
return `data:image/svg+xml;base64,${content.toString('base64')}`;
|
|
15731
|
+
}
|
|
15732
|
+
else {
|
|
15733
|
+
return ('data:image/svg+xml,' +
|
|
15734
|
+
stringContent
|
|
15735
|
+
.trim()
|
|
15736
|
+
.replaceAll('"', "'")
|
|
15737
|
+
.replaceAll('%', '%25')
|
|
15738
|
+
.replaceAll('#', '%23')
|
|
15739
|
+
.replaceAll('<', '%3c')
|
|
15740
|
+
.replaceAll('>', '%3e')
|
|
15741
|
+
// Spaces are not valid in srcset it has some use cases
|
|
15742
|
+
// it can make the uncompressed URI slightly higher than base64, but will compress way better
|
|
15743
|
+
// https://github.com/vitejs/vite/pull/14643#issuecomment-1766288673
|
|
15744
|
+
.replaceAll(/\s+/g, '%20'));
|
|
15745
|
+
}
|
|
15746
|
+
}
|
|
15673
15747
|
|
|
15674
15748
|
function manifestPlugin(config) {
|
|
15675
15749
|
const manifest = {};
|
|
@@ -27829,7 +27903,6 @@ function tryNodeResolve(id, importer, options, targetWeb, depsOptimizer, ssr = f
|
|
|
27829
27903
|
moduleSideEffects: pkg.hasSideEffects(resolved),
|
|
27830
27904
|
});
|
|
27831
27905
|
}
|
|
27832
|
-
const ext = path$o.extname(resolved);
|
|
27833
27906
|
if (!options.ssrOptimizeCheck &&
|
|
27834
27907
|
(!isInNodeModules$1(resolved) || // linked
|
|
27835
27908
|
!depsOptimizer || // resolving before listening to the server
|
|
@@ -27860,10 +27933,7 @@ function tryNodeResolve(id, importer, options, targetWeb, depsOptimizer, ssr = f
|
|
|
27860
27933
|
(!options.ssrOptimizeCheck && !isBuild && ssr) ||
|
|
27861
27934
|
// Only optimize non-external CJS deps during SSR by default
|
|
27862
27935
|
(ssr &&
|
|
27863
|
-
|
|
27864
|
-
(ext === '.js' &&
|
|
27865
|
-
findNearestPackageData(path$o.dirname(resolved), options.packageCache)
|
|
27866
|
-
?.data.type !== 'module')) &&
|
|
27936
|
+
isFilePathESM(resolved, options.packageCache) &&
|
|
27867
27937
|
!(include?.includes(pkgId) || include?.includes(id)));
|
|
27868
27938
|
if (options.ssrOptimizeCheck) {
|
|
27869
27939
|
return {
|
|
@@ -35895,10 +35965,12 @@ const addTypeScriptLoader = (options = {}, loader) => {
|
|
|
35895
35965
|
`.${moduleName}rc.yaml`,
|
|
35896
35966
|
`.${moduleName}rc.yml`,
|
|
35897
35967
|
`.${moduleName}rc.ts`,
|
|
35968
|
+
`.${moduleName}rc.cts`,
|
|
35898
35969
|
`.${moduleName}rc.js`,
|
|
35899
35970
|
`.${moduleName}rc.cjs`,
|
|
35900
35971
|
`.${moduleName}rc.mjs`,
|
|
35901
35972
|
`${moduleName}.config.ts`,
|
|
35973
|
+
`${moduleName}.config.cts`,
|
|
35902
35974
|
`${moduleName}.config.js`,
|
|
35903
35975
|
`${moduleName}.config.cjs`,
|
|
35904
35976
|
`${moduleName}.config.mjs`
|
|
@@ -35910,7 +35982,8 @@ const addTypeScriptLoader = (options = {}, loader) => {
|
|
|
35910
35982
|
'.js': importDefault,
|
|
35911
35983
|
'.cjs': importDefault,
|
|
35912
35984
|
'.mjs': importDefault,
|
|
35913
|
-
'.ts': loader
|
|
35985
|
+
'.ts': loader,
|
|
35986
|
+
'.cts': loader
|
|
35914
35987
|
}
|
|
35915
35988
|
}
|
|
35916
35989
|
};
|
|
@@ -35922,7 +35995,9 @@ const withTypeScriptLoader = (rcFunc) => {
|
|
|
35922
35995
|
|
|
35923
35996
|
try {
|
|
35924
35997
|
// Register TypeScript compiler instance
|
|
35925
|
-
registerer = __require('ts-node').register(
|
|
35998
|
+
registerer = __require('ts-node').register({
|
|
35999
|
+
moduleTypes: { '**/*.cts': 'cjs' }
|
|
36000
|
+
});
|
|
35926
36001
|
|
|
35927
36002
|
return __require(configFile)
|
|
35928
36003
|
} catch (err) {
|
|
@@ -37164,6 +37239,7 @@ function buildHtmlPlugin(config) {
|
|
|
37164
37239
|
tag: 'link',
|
|
37165
37240
|
attrs: {
|
|
37166
37241
|
rel: 'stylesheet',
|
|
37242
|
+
crossorigin: true,
|
|
37167
37243
|
href: toOutputPath(file),
|
|
37168
37244
|
},
|
|
37169
37245
|
});
|
|
@@ -37234,6 +37310,7 @@ function buildHtmlPlugin(config) {
|
|
|
37234
37310
|
tag: 'link',
|
|
37235
37311
|
attrs: {
|
|
37236
37312
|
rel: 'stylesheet',
|
|
37313
|
+
crossorigin: true,
|
|
37237
37314
|
href: toOutputAssetFilePath(cssChunk.fileName),
|
|
37238
37315
|
},
|
|
37239
37316
|
},
|
|
@@ -37261,7 +37338,11 @@ function buildHtmlPlugin(config) {
|
|
|
37261
37338
|
});
|
|
37262
37339
|
// resolve asset url references
|
|
37263
37340
|
result = result.replace(assetUrlRE, (_, fileHash, postfix = '') => {
|
|
37264
|
-
|
|
37341
|
+
const file = this.getFileName(fileHash);
|
|
37342
|
+
if (chunk) {
|
|
37343
|
+
chunk.viteMetadata.importedAssets.add(cleanUrl(file));
|
|
37344
|
+
}
|
|
37345
|
+
return toOutputAssetFilePath(file) + postfix;
|
|
37265
37346
|
});
|
|
37266
37347
|
result = result.replace(publicAssetUrlRE, (_, fileHash) => {
|
|
37267
37348
|
const publicAssetPath = toOutputPublicAssetFilePath(getPublicAssetFilename(fileHash, config));
|
|
@@ -38386,8 +38467,8 @@ function createCachedImport(imp) {
|
|
|
38386
38467
|
return cached;
|
|
38387
38468
|
};
|
|
38388
38469
|
}
|
|
38389
|
-
const importPostcssImport = createCachedImport(() => import('./dep-
|
|
38390
|
-
const importPostcssModules = createCachedImport(() => import('./dep-
|
|
38470
|
+
const importPostcssImport = createCachedImport(() => import('./dep-rMlk0HEr.js').then(function (n) { return n.i; }));
|
|
38471
|
+
const importPostcssModules = createCachedImport(() => import('./dep-HpI8v4GP.js').then(function (n) { return n.i; }));
|
|
38391
38472
|
const importPostcss = createCachedImport(() => import('postcss'));
|
|
38392
38473
|
/**
|
|
38393
38474
|
* @experimental
|
|
@@ -40571,8 +40652,15 @@ function updateModules(file, modules, timestamp, { config, ws, moduleGraph }, af
|
|
|
40571
40652
|
updates,
|
|
40572
40653
|
});
|
|
40573
40654
|
}
|
|
40574
|
-
async function handleFileAddUnlink(file, server) {
|
|
40655
|
+
async function handleFileAddUnlink(file, server, isUnlink) {
|
|
40575
40656
|
const modules = [...(server.moduleGraph.getModulesByFile(file) || [])];
|
|
40657
|
+
if (isUnlink) {
|
|
40658
|
+
for (const deletedMod of modules) {
|
|
40659
|
+
deletedMod.importedModules.forEach((importedMod) => {
|
|
40660
|
+
importedMod.importers.delete(deletedMod);
|
|
40661
|
+
});
|
|
40662
|
+
}
|
|
40663
|
+
}
|
|
40576
40664
|
modules.push(...getAffectedGlobModules(file, server));
|
|
40577
40665
|
if (modules.length > 0) {
|
|
40578
40666
|
updateModules(getShortName(file, server.config.root), unique(modules), Date.now(), server);
|
|
@@ -41676,29 +41764,14 @@ function saveEmitWorkerAsset(config, asset) {
|
|
|
41676
41764
|
const workerMap = workerCache.get(config.mainConfig || config);
|
|
41677
41765
|
workerMap.assets.set(fileName, asset);
|
|
41678
41766
|
}
|
|
41679
|
-
// Ensure that only one rollup build is called at the same time to avoid
|
|
41680
|
-
// leaking state in plugins between worker builds.
|
|
41681
|
-
// TODO: Review if we can parallelize the bundling of workers.
|
|
41682
|
-
const workerConfigSemaphore = new WeakMap();
|
|
41683
41767
|
async function bundleWorkerEntry(config, id, query) {
|
|
41684
|
-
const processing = workerConfigSemaphore.get(config);
|
|
41685
|
-
if (processing) {
|
|
41686
|
-
await processing;
|
|
41687
|
-
return bundleWorkerEntry(config, id, query);
|
|
41688
|
-
}
|
|
41689
|
-
const promise = serialBundleWorkerEntry(config, id, query);
|
|
41690
|
-
workerConfigSemaphore.set(config, promise);
|
|
41691
|
-
promise.then(() => workerConfigSemaphore.delete(config));
|
|
41692
|
-
return promise;
|
|
41693
|
-
}
|
|
41694
|
-
async function serialBundleWorkerEntry(config, id, query) {
|
|
41695
41768
|
// bundle the file as entry to support imports
|
|
41696
41769
|
const { rollup } = await import('rollup');
|
|
41697
41770
|
const { plugins, rollupOptions, format } = config.worker;
|
|
41698
41771
|
const bundle = await rollup({
|
|
41699
41772
|
...rollupOptions,
|
|
41700
41773
|
input: cleanUrl(id),
|
|
41701
|
-
plugins,
|
|
41774
|
+
plugins: await plugins(),
|
|
41702
41775
|
onwarn(warning, warn) {
|
|
41703
41776
|
onRollupWarning(warning, warn, config);
|
|
41704
41777
|
},
|
|
@@ -54161,8 +54234,6 @@ async function resolveHttpServer({ proxy }, app, httpsOptions) {
|
|
|
54161
54234
|
async function resolveHttpsConfig(https) {
|
|
54162
54235
|
if (!https)
|
|
54163
54236
|
return undefined;
|
|
54164
|
-
if (!isObject$1(https))
|
|
54165
|
-
return {};
|
|
54166
54237
|
const [ca, cert, key, pfx] = await Promise.all([
|
|
54167
54238
|
readFileIfExists(https.ca),
|
|
54168
54239
|
readFileIfExists(https.cert),
|
|
@@ -54790,12 +54861,20 @@ async function ssrTransformScript(code, inMap, url, originalCode) {
|
|
|
54790
54861
|
const declaredConst = new Set();
|
|
54791
54862
|
// hoist at the start of the file, after the hashbang
|
|
54792
54863
|
const hoistIndex = code.match(hashbangRE)?.[0].length ?? 0;
|
|
54793
|
-
function defineImport(source) {
|
|
54864
|
+
function defineImport(source, metadata) {
|
|
54794
54865
|
deps.add(source);
|
|
54795
54866
|
const importId = `__vite_ssr_import_${uid++}__`;
|
|
54867
|
+
// Reduce metadata to undefined if it's all default values
|
|
54868
|
+
if (metadata &&
|
|
54869
|
+
metadata.isExportAll !== true &&
|
|
54870
|
+
(metadata.namedImportSpecifiers == null ||
|
|
54871
|
+
metadata.namedImportSpecifiers.length === 0)) {
|
|
54872
|
+
metadata = undefined;
|
|
54873
|
+
}
|
|
54874
|
+
const metadataStr = metadata ? `, ${JSON.stringify(metadata)}` : '';
|
|
54796
54875
|
// There will be an error if the module is called before it is imported,
|
|
54797
54876
|
// so the module import statement is hoisted to the top
|
|
54798
|
-
s.appendLeft(hoistIndex, `const ${importId} = await ${ssrImportKey}(${JSON.stringify(source)});\n`);
|
|
54877
|
+
s.appendLeft(hoistIndex, `const ${importId} = await ${ssrImportKey}(${JSON.stringify(source)}${metadataStr});\n`);
|
|
54799
54878
|
return importId;
|
|
54800
54879
|
}
|
|
54801
54880
|
function defineExport(position, name, local = name) {
|
|
@@ -54808,7 +54887,11 @@ async function ssrTransformScript(code, inMap, url, originalCode) {
|
|
|
54808
54887
|
// import { baz } from 'foo' --> baz -> __import_foo__.baz
|
|
54809
54888
|
// import * as ok from 'foo' --> ok -> __import_foo__
|
|
54810
54889
|
if (node.type === 'ImportDeclaration') {
|
|
54811
|
-
const importId = defineImport(node.source.value
|
|
54890
|
+
const importId = defineImport(node.source.value, {
|
|
54891
|
+
namedImportSpecifiers: node.specifiers
|
|
54892
|
+
.map((s) => s.type === 'ImportSpecifier' && s.imported.name)
|
|
54893
|
+
.filter(Boolean),
|
|
54894
|
+
});
|
|
54812
54895
|
s.remove(node.start, node.end);
|
|
54813
54896
|
for (const spec of node.specifiers) {
|
|
54814
54897
|
if (spec.type === 'ImportSpecifier') {
|
|
@@ -54849,7 +54932,9 @@ async function ssrTransformScript(code, inMap, url, originalCode) {
|
|
|
54849
54932
|
s.remove(node.start, node.end);
|
|
54850
54933
|
if (node.source) {
|
|
54851
54934
|
// export { foo, bar } from './foo'
|
|
54852
|
-
const importId = defineImport(node.source.value
|
|
54935
|
+
const importId = defineImport(node.source.value, {
|
|
54936
|
+
namedImportSpecifiers: node.specifiers.map((s) => s.local.name),
|
|
54937
|
+
});
|
|
54853
54938
|
// hoist re-exports near the defined import so they are immediately exported
|
|
54854
54939
|
for (const spec of node.specifiers) {
|
|
54855
54940
|
defineExport(hoistIndex, spec.exported.name, `${importId}.${spec.local.name}`);
|
|
@@ -54887,7 +54972,9 @@ async function ssrTransformScript(code, inMap, url, originalCode) {
|
|
|
54887
54972
|
// export * from './foo'
|
|
54888
54973
|
if (node.type === 'ExportAllDeclaration') {
|
|
54889
54974
|
s.remove(node.start, node.end);
|
|
54890
|
-
const importId = defineImport(node.source.value
|
|
54975
|
+
const importId = defineImport(node.source.value, {
|
|
54976
|
+
isExportAll: true,
|
|
54977
|
+
});
|
|
54891
54978
|
// hoist re-exports near the defined import so they are immediately exported
|
|
54892
54979
|
if (node.exported) {
|
|
54893
54980
|
defineExport(hoistIndex, node.exported.name, `${importId}`);
|
|
@@ -55348,14 +55435,16 @@ async function instantiateModule(url, server, context = { global }, urlStack = [
|
|
|
55348
55435
|
isProduction,
|
|
55349
55436
|
root,
|
|
55350
55437
|
ssrConfig: ssr,
|
|
55438
|
+
legacyProxySsrExternalModules: server.config.legacy?.proxySsrExternalModules,
|
|
55439
|
+
packageCache: server.config.packageCache,
|
|
55351
55440
|
};
|
|
55352
55441
|
// Since dynamic imports can happen in parallel, we need to
|
|
55353
55442
|
// account for multiple pending deps and duplicate imports.
|
|
55354
55443
|
const pendingDeps = [];
|
|
55355
|
-
const ssrImport = async (dep) => {
|
|
55444
|
+
const ssrImport = async (dep, metadata) => {
|
|
55356
55445
|
try {
|
|
55357
55446
|
if (dep[0] !== '.' && dep[0] !== '/') {
|
|
55358
|
-
return await nodeImport(dep, mod.file, resolveOptions);
|
|
55447
|
+
return await nodeImport(dep, mod.file, resolveOptions, metadata);
|
|
55359
55448
|
}
|
|
55360
55449
|
// convert to rollup URL because `pendingImports`, `moduleGraph.urlToModuleMap` requires that
|
|
55361
55450
|
dep = unwrapId(dep);
|
|
@@ -55388,7 +55477,7 @@ async function instantiateModule(url, server, context = { global }, urlStack = [
|
|
|
55388
55477
|
if (dep[0] === '.') {
|
|
55389
55478
|
dep = path$o.posix.resolve(path$o.dirname(url), dep);
|
|
55390
55479
|
}
|
|
55391
|
-
return ssrImport(dep);
|
|
55480
|
+
return ssrImport(dep, { isDynamicImport: true });
|
|
55392
55481
|
};
|
|
55393
55482
|
function ssrExportAll(sourceModule) {
|
|
55394
55483
|
for (const key in sourceModule) {
|
|
@@ -55439,9 +55528,10 @@ async function instantiateModule(url, server, context = { global }, urlStack = [
|
|
|
55439
55528
|
return Object.freeze(ssrModule);
|
|
55440
55529
|
}
|
|
55441
55530
|
// In node@12+ we can use dynamic import to load CJS and ESM
|
|
55442
|
-
async function nodeImport(id, importer, resolveOptions) {
|
|
55531
|
+
async function nodeImport(id, importer, resolveOptions, metadata) {
|
|
55443
55532
|
let url;
|
|
55444
|
-
|
|
55533
|
+
const isRuntimeHandled = id.startsWith('data:') || isBuiltin(id);
|
|
55534
|
+
if (isRuntimeHandled) {
|
|
55445
55535
|
url = id;
|
|
55446
55536
|
}
|
|
55447
55537
|
else {
|
|
@@ -55454,7 +55544,16 @@ async function nodeImport(id, importer, resolveOptions) {
|
|
|
55454
55544
|
url = pathToFileURL(resolved.id).toString();
|
|
55455
55545
|
}
|
|
55456
55546
|
const mod = await import(url);
|
|
55457
|
-
|
|
55547
|
+
if (resolveOptions.legacyProxySsrExternalModules) {
|
|
55548
|
+
return proxyESM(mod);
|
|
55549
|
+
}
|
|
55550
|
+
else if (isRuntimeHandled) {
|
|
55551
|
+
return mod;
|
|
55552
|
+
}
|
|
55553
|
+
else {
|
|
55554
|
+
analyzeImportedModDifference(mod, url, id, metadata, resolveOptions.packageCache);
|
|
55555
|
+
return proxyGuardOnlyEsm(mod, id);
|
|
55556
|
+
}
|
|
55458
55557
|
}
|
|
55459
55558
|
// rollup-style default import interop for cjs
|
|
55460
55559
|
function proxyESM(mod) {
|
|
@@ -55479,6 +55578,49 @@ function proxyESM(mod) {
|
|
|
55479
55578
|
function isPrimitive(value) {
|
|
55480
55579
|
return !value || (typeof value !== 'object' && typeof value !== 'function');
|
|
55481
55580
|
}
|
|
55581
|
+
/**
|
|
55582
|
+
* Vite converts `import { } from 'foo'` to `const _ = __vite_ssr_import__('foo')`.
|
|
55583
|
+
* Top-level imports and dynamic imports work slightly differently in Node.js.
|
|
55584
|
+
* This function normalizes the differences so it matches prod behaviour.
|
|
55585
|
+
*/
|
|
55586
|
+
function analyzeImportedModDifference(mod, filePath, rawId, metadata, packageCache) {
|
|
55587
|
+
// No normalization needed if the user already dynamic imports this module
|
|
55588
|
+
if (metadata?.isDynamicImport)
|
|
55589
|
+
return;
|
|
55590
|
+
// If file path is ESM, everything should be fine
|
|
55591
|
+
if (isFilePathESM(filePath, packageCache))
|
|
55592
|
+
return;
|
|
55593
|
+
// For non-ESM, named imports is done via static analysis with cjs-module-lexer in Node.js.
|
|
55594
|
+
// If the user named imports a specifier that can't be analyzed, error.
|
|
55595
|
+
if (metadata?.namedImportSpecifiers?.length) {
|
|
55596
|
+
const missingBindings = metadata.namedImportSpecifiers.filter((s) => !(s in mod));
|
|
55597
|
+
if (missingBindings.length) {
|
|
55598
|
+
const lastBinding = missingBindings[missingBindings.length - 1];
|
|
55599
|
+
// Copied from Node.js
|
|
55600
|
+
throw new SyntaxError(`\
|
|
55601
|
+
Named export '${lastBinding}' not found. The requested module '${rawId}' is a CommonJS module, which may not support all module.exports as named exports.
|
|
55602
|
+
CommonJS modules can always be imported via the default export, for example using:
|
|
55603
|
+
|
|
55604
|
+
import pkg from '${rawId}';
|
|
55605
|
+
const {${missingBindings.join(', ')}} = pkg;
|
|
55606
|
+
`);
|
|
55607
|
+
}
|
|
55608
|
+
}
|
|
55609
|
+
}
|
|
55610
|
+
/**
|
|
55611
|
+
* Guard invalid named exports only, similar to how Node.js errors for top-level imports.
|
|
55612
|
+
* But since we transform as dynamic imports, we need to emulate the error manually.
|
|
55613
|
+
*/
|
|
55614
|
+
function proxyGuardOnlyEsm(mod, rawId) {
|
|
55615
|
+
return new Proxy(mod, {
|
|
55616
|
+
get(mod, prop) {
|
|
55617
|
+
if (prop !== 'then' && !(prop in mod)) {
|
|
55618
|
+
throw new SyntaxError(`The requested module '${rawId}' does not provide an export named '${prop.toString()}'`);
|
|
55619
|
+
}
|
|
55620
|
+
return mod[prop];
|
|
55621
|
+
},
|
|
55622
|
+
});
|
|
55623
|
+
}
|
|
55482
55624
|
|
|
55483
55625
|
var isWsl$2 = {exports: {}};
|
|
55484
55626
|
|
|
@@ -64770,9 +64912,9 @@ async function _createServer(inlineConfig = {}, options) {
|
|
|
64770
64912
|
}
|
|
64771
64913
|
}
|
|
64772
64914
|
};
|
|
64773
|
-
const onFileAddUnlink = async (file) => {
|
|
64915
|
+
const onFileAddUnlink = async (file, isUnlink) => {
|
|
64774
64916
|
file = normalizePath$3(file);
|
|
64775
|
-
await handleFileAddUnlink(file, server);
|
|
64917
|
+
await handleFileAddUnlink(file, server, isUnlink);
|
|
64776
64918
|
await onHMRUpdate(file, true);
|
|
64777
64919
|
};
|
|
64778
64920
|
watcher.on('change', async (file) => {
|
|
@@ -64781,8 +64923,8 @@ async function _createServer(inlineConfig = {}, options) {
|
|
|
64781
64923
|
moduleGraph.onFileChange(file);
|
|
64782
64924
|
await onHMRUpdate(file, false);
|
|
64783
64925
|
});
|
|
64784
|
-
watcher.on('add', onFileAddUnlink);
|
|
64785
|
-
watcher.on('unlink', onFileAddUnlink);
|
|
64926
|
+
watcher.on('add', (file) => onFileAddUnlink(file, false));
|
|
64927
|
+
watcher.on('unlink', (file) => onFileAddUnlink(file, true));
|
|
64786
64928
|
ws.on('vite:invalidate', async ({ path, message }) => {
|
|
64787
64929
|
const mod = moduleGraph.urlToModuleMap.get(path);
|
|
64788
64930
|
if (mod && mod.isSelfAccepting && mod.lastHMRTimestamp > 0) {
|
|
@@ -65336,10 +65478,6 @@ async function resolveConfig(inlineConfig, command, defaultMode = 'development',
|
|
|
65336
65478
|
return p.apply === command;
|
|
65337
65479
|
}
|
|
65338
65480
|
};
|
|
65339
|
-
// Some plugins that aren't intended to work in the bundling of workers (doing post-processing at build time for example).
|
|
65340
|
-
// And Plugins may also have cached that could be corrupted by being used in these extra rollup calls.
|
|
65341
|
-
// So we need to separate the worker plugin from the plugin that vite needs to run.
|
|
65342
|
-
const rawWorkerUserPlugins = (await asyncFlatten(config.worker?.plugins || [])).filter(filterPlugin);
|
|
65343
65481
|
// resolve plugins
|
|
65344
65482
|
const rawUserPlugins = (await asyncFlatten(config.plugins || [])).filter(filterPlugin);
|
|
65345
65483
|
const [prePlugins, normalPlugins, postPlugins] = sortUserPlugins(rawUserPlugins);
|
|
@@ -65489,24 +65627,48 @@ async function resolveConfig(inlineConfig, command, defaultMode = 'development',
|
|
|
65489
65627
|
const middlewareMode = config?.server?.middlewareMode;
|
|
65490
65628
|
const optimizeDeps = config.optimizeDeps || {};
|
|
65491
65629
|
const BASE_URL = resolvedBase;
|
|
65492
|
-
|
|
65493
|
-
let
|
|
65494
|
-
|
|
65495
|
-
|
|
65496
|
-
|
|
65497
|
-
|
|
65498
|
-
|
|
65499
|
-
|
|
65500
|
-
|
|
65501
|
-
|
|
65630
|
+
let resolved;
|
|
65631
|
+
let createUserWorkerPlugins = config.worker?.plugins;
|
|
65632
|
+
if (Array.isArray(createUserWorkerPlugins)) {
|
|
65633
|
+
// @ts-expect-error backward compatibility
|
|
65634
|
+
createUserWorkerPlugins = () => config.worker?.plugins;
|
|
65635
|
+
logger.warn(colors$1.yellow(`worker.plugins is now a function that returns an array of plugins. ` +
|
|
65636
|
+
`Please update your Vite config accordingly.\n`));
|
|
65637
|
+
}
|
|
65638
|
+
const createWorkerPlugins = async function () {
|
|
65639
|
+
// Some plugins that aren't intended to work in the bundling of workers (doing post-processing at build time for example).
|
|
65640
|
+
// And Plugins may also have cached that could be corrupted by being used in these extra rollup calls.
|
|
65641
|
+
// So we need to separate the worker plugin from the plugin that vite needs to run.
|
|
65642
|
+
const rawWorkerUserPlugins = (await asyncFlatten(createUserWorkerPlugins?.() || [])).filter(filterPlugin);
|
|
65643
|
+
// resolve worker
|
|
65644
|
+
let workerConfig = mergeConfig({}, config);
|
|
65645
|
+
const [workerPrePlugins, workerNormalPlugins, workerPostPlugins] = sortUserPlugins(rawWorkerUserPlugins);
|
|
65646
|
+
// run config hooks
|
|
65647
|
+
const workerUserPlugins = [
|
|
65648
|
+
...workerPrePlugins,
|
|
65649
|
+
...workerNormalPlugins,
|
|
65650
|
+
...workerPostPlugins,
|
|
65651
|
+
];
|
|
65652
|
+
workerConfig = await runConfigHook(workerConfig, workerUserPlugins, configEnv);
|
|
65653
|
+
const workerResolved = {
|
|
65654
|
+
...workerConfig,
|
|
65655
|
+
...resolved,
|
|
65656
|
+
isWorker: true,
|
|
65657
|
+
mainConfig: resolved,
|
|
65658
|
+
};
|
|
65659
|
+
const resolvedWorkerPlugins = await resolvePlugins(workerResolved, workerPrePlugins, workerNormalPlugins, workerPostPlugins);
|
|
65660
|
+
// run configResolved hooks
|
|
65661
|
+
createPluginHookUtils(resolvedWorkerPlugins)
|
|
65662
|
+
.getSortedPluginHooks('configResolved')
|
|
65663
|
+
.map((hook) => hook(workerResolved));
|
|
65664
|
+
return resolvedWorkerPlugins;
|
|
65665
|
+
};
|
|
65502
65666
|
const resolvedWorkerOptions = {
|
|
65503
|
-
format:
|
|
65504
|
-
plugins:
|
|
65505
|
-
rollupOptions:
|
|
65506
|
-
getSortedPlugins: undefined,
|
|
65507
|
-
getSortedPluginHooks: undefined,
|
|
65667
|
+
format: config.worker?.format || 'iife',
|
|
65668
|
+
plugins: createWorkerPlugins,
|
|
65669
|
+
rollupOptions: config.worker?.rollupOptions || {},
|
|
65508
65670
|
};
|
|
65509
|
-
|
|
65671
|
+
resolved = {
|
|
65510
65672
|
configFile: configFile ? normalizePath$3(configFile) : undefined,
|
|
65511
65673
|
configFileDependencies: configFileDependencies.map((name) => normalizePath$3(path$o.resolve(name))),
|
|
65512
65674
|
inlineConfig,
|
|
@@ -65565,29 +65727,16 @@ async function resolveConfig(inlineConfig, command, defaultMode = 'development',
|
|
|
65565
65727
|
getSortedPlugins: undefined,
|
|
65566
65728
|
getSortedPluginHooks: undefined,
|
|
65567
65729
|
};
|
|
65568
|
-
|
|
65730
|
+
resolved = {
|
|
65569
65731
|
...config,
|
|
65570
|
-
...
|
|
65732
|
+
...resolved,
|
|
65571
65733
|
};
|
|
65572
65734
|
resolved.plugins = await resolvePlugins(resolved, prePlugins, normalPlugins, postPlugins);
|
|
65573
65735
|
Object.assign(resolved, createPluginHookUtils(resolved.plugins));
|
|
65574
|
-
const workerResolved = {
|
|
65575
|
-
...workerConfig,
|
|
65576
|
-
...resolvedConfig,
|
|
65577
|
-
isWorker: true,
|
|
65578
|
-
mainConfig: resolved,
|
|
65579
|
-
};
|
|
65580
|
-
resolvedConfig.worker.plugins = await resolvePlugins(workerResolved, workerPrePlugins, workerNormalPlugins, workerPostPlugins);
|
|
65581
|
-
Object.assign(resolvedConfig.worker, createPluginHookUtils(resolvedConfig.worker.plugins));
|
|
65582
65736
|
// call configResolved hooks
|
|
65583
|
-
await Promise.all(
|
|
65584
|
-
|
|
65585
|
-
|
|
65586
|
-
.map((hook) => hook(resolved)),
|
|
65587
|
-
...resolvedConfig.worker
|
|
65588
|
-
.getSortedPluginHooks('configResolved')
|
|
65589
|
-
.map((hook) => hook(workerResolved)),
|
|
65590
|
-
]);
|
|
65737
|
+
await Promise.all(resolved
|
|
65738
|
+
.getSortedPluginHooks('configResolved')
|
|
65739
|
+
.map((hook) => hook(resolved)));
|
|
65591
65740
|
// validate config
|
|
65592
65741
|
if (middlewareMode === 'ssr') {
|
|
65593
65742
|
logger.warn(colors$1.yellow(`Setting server.middlewareMode to 'ssr' is deprecated, set server.middlewareMode to \`true\`${config.appType === 'custom' ? '' : ` and appType to 'custom'`} instead`));
|
|
@@ -65600,7 +65749,7 @@ async function resolveConfig(inlineConfig, command, defaultMode = 'development',
|
|
|
65600
65749
|
plugins: resolved.plugins.map((p) => p.name),
|
|
65601
65750
|
worker: {
|
|
65602
65751
|
...resolved.worker,
|
|
65603
|
-
plugins:
|
|
65752
|
+
plugins: `() => plugins`,
|
|
65604
65753
|
},
|
|
65605
65754
|
});
|
|
65606
65755
|
if (config.build?.terserOptions && config.build.minify !== 'terser') {
|
|
@@ -65702,22 +65851,7 @@ async function loadConfigFromFile(configEnv, configFile, configRoot = process.cw
|
|
|
65702
65851
|
debug?.('no config file found.');
|
|
65703
65852
|
return null;
|
|
65704
65853
|
}
|
|
65705
|
-
|
|
65706
|
-
if (/\.m[jt]s$/.test(resolvedPath)) {
|
|
65707
|
-
isESM = true;
|
|
65708
|
-
}
|
|
65709
|
-
else if (/\.c[jt]s$/.test(resolvedPath)) {
|
|
65710
|
-
isESM = false;
|
|
65711
|
-
}
|
|
65712
|
-
else {
|
|
65713
|
-
// check package.json for type: "module" and set `isESM` to true
|
|
65714
|
-
try {
|
|
65715
|
-
const pkg = lookupFile(configRoot, ['package.json']);
|
|
65716
|
-
isESM =
|
|
65717
|
-
!!pkg && JSON.parse(fs$l.readFileSync(pkg, 'utf-8')).type === 'module';
|
|
65718
|
-
}
|
|
65719
|
-
catch (e) { }
|
|
65720
|
-
}
|
|
65854
|
+
const isESM = isFilePathESM(resolvedPath);
|
|
65721
65855
|
try {
|
|
65722
65856
|
const bundled = await bundleConfigFile(resolvedPath, isESM);
|
|
65723
65857
|
const userConfig = await loadConfigFromBundledFile(resolvedPath, bundled.code, isESM);
|
|
@@ -65782,14 +65916,6 @@ async function bundleConfigFile(fileName, isESM) {
|
|
|
65782
65916
|
isRequire,
|
|
65783
65917
|
}, false)?.id;
|
|
65784
65918
|
};
|
|
65785
|
-
const isESMFile = (id) => {
|
|
65786
|
-
if (id.endsWith('.mjs'))
|
|
65787
|
-
return true;
|
|
65788
|
-
if (id.endsWith('.cjs'))
|
|
65789
|
-
return false;
|
|
65790
|
-
const nearestPackageJson = findNearestPackageData(path$o.dirname(id), packageCache);
|
|
65791
|
-
return (!!nearestPackageJson && nearestPackageJson.data.type === 'module');
|
|
65792
|
-
};
|
|
65793
65919
|
// externalize bare imports
|
|
65794
65920
|
build.onResolve({ filter: /^[^.].*/ }, async ({ path: id, importer, kind }) => {
|
|
65795
65921
|
if (kind === 'entry-point' ||
|
|
@@ -65824,7 +65950,9 @@ async function bundleConfigFile(fileName, isESM) {
|
|
|
65824
65950
|
if (idFsPath && isImport) {
|
|
65825
65951
|
idFsPath = pathToFileURL(idFsPath).href;
|
|
65826
65952
|
}
|
|
65827
|
-
if (idFsPath &&
|
|
65953
|
+
if (idFsPath &&
|
|
65954
|
+
!isImport &&
|
|
65955
|
+
isFilePathESM(idFsPath, packageCache)) {
|
|
65828
65956
|
throw new Error(`${JSON.stringify(id)} resolved to an ESM file. ESM file cannot be loaded by \`require\`. See http://vitejs.dev/guide/troubleshooting.html#this-package-is-esm-only for more details.`);
|
|
65829
65957
|
}
|
|
65830
65958
|
return {
|
package/dist/node/cli.js
CHANGED
|
@@ -2,7 +2,7 @@ import path from 'node:path';
|
|
|
2
2
|
import fs from 'node:fs';
|
|
3
3
|
import { performance } from 'node:perf_hooks';
|
|
4
4
|
import { EventEmitter } from 'events';
|
|
5
|
-
import { x as colors, k as createLogger, r as resolveConfig } from './chunks/dep-
|
|
5
|
+
import { x as colors, k as createLogger, r as resolveConfig } from './chunks/dep-kPX9VBbU.js';
|
|
6
6
|
import { VERSION } from './constants.js';
|
|
7
7
|
import 'node:fs/promises';
|
|
8
8
|
import 'node:url';
|
|
@@ -751,7 +751,6 @@ cli
|
|
|
751
751
|
.alias('dev') // alias to align with the script name
|
|
752
752
|
.option('--host [host]', `[string] specify hostname`, { type: [convertHost] })
|
|
753
753
|
.option('--port <port>', `[number] specify port`)
|
|
754
|
-
.option('--https', `[boolean] use TLS + HTTP/2`)
|
|
755
754
|
.option('--open [path]', `[boolean | string] open browser on startup`)
|
|
756
755
|
.option('--cors', `[boolean] enable CORS`)
|
|
757
756
|
.option('--strictPort', `[boolean] exit if specified port is already in use`)
|
|
@@ -760,7 +759,7 @@ cli
|
|
|
760
759
|
filterDuplicateOptions(options);
|
|
761
760
|
// output structure is preserved even after bundling so require()
|
|
762
761
|
// is ok here
|
|
763
|
-
const { createServer } = await import('./chunks/dep-
|
|
762
|
+
const { createServer } = await import('./chunks/dep-kPX9VBbU.js').then(function (n) { return n.C; });
|
|
764
763
|
try {
|
|
765
764
|
const server = await createServer({
|
|
766
765
|
root,
|
|
@@ -841,7 +840,7 @@ cli
|
|
|
841
840
|
.option('-w, --watch', `[boolean] rebuilds when modules have changed on disk`)
|
|
842
841
|
.action(async (root, options) => {
|
|
843
842
|
filterDuplicateOptions(options);
|
|
844
|
-
const { build } = await import('./chunks/dep-
|
|
843
|
+
const { build } = await import('./chunks/dep-kPX9VBbU.js').then(function (n) { return n.B; });
|
|
845
844
|
const buildOptions = cleanOptions(options);
|
|
846
845
|
try {
|
|
847
846
|
await build({
|
|
@@ -869,7 +868,7 @@ cli
|
|
|
869
868
|
.option('--force', `[boolean] force the optimizer to ignore the cache and re-bundle`)
|
|
870
869
|
.action(async (root, options) => {
|
|
871
870
|
filterDuplicateOptions(options);
|
|
872
|
-
const { optimizeDeps } = await import('./chunks/dep-
|
|
871
|
+
const { optimizeDeps } = await import('./chunks/dep-kPX9VBbU.js').then(function (n) { return n.A; });
|
|
873
872
|
try {
|
|
874
873
|
const config = await resolveConfig({
|
|
875
874
|
root,
|
|
@@ -891,12 +890,11 @@ cli
|
|
|
891
890
|
.option('--host [host]', `[string] specify hostname`, { type: [convertHost] })
|
|
892
891
|
.option('--port <port>', `[number] specify port`)
|
|
893
892
|
.option('--strictPort', `[boolean] exit if specified port is already in use`)
|
|
894
|
-
.option('--https', `[boolean] use TLS + HTTP/2`)
|
|
895
893
|
.option('--open [path]', `[boolean | string] open browser on startup`)
|
|
896
894
|
.option('--outDir <dir>', `[string] output directory (default: dist)`)
|
|
897
895
|
.action(async (root, options) => {
|
|
898
896
|
filterDuplicateOptions(options);
|
|
899
|
-
const { preview } = await import('./chunks/dep-
|
|
897
|
+
const { preview } = await import('./chunks/dep-kPX9VBbU.js').then(function (n) { return n.D; });
|
|
900
898
|
try {
|
|
901
899
|
const server = await preview({
|
|
902
900
|
root,
|
|
@@ -911,7 +909,6 @@ cli
|
|
|
911
909
|
port: options.port,
|
|
912
910
|
strictPort: options.strictPort,
|
|
913
911
|
host: options.host,
|
|
914
|
-
https: options.https,
|
|
915
912
|
open: options.open,
|
|
916
913
|
},
|
|
917
914
|
});
|
package/dist/node/index.d.ts
CHANGED
|
@@ -639,7 +639,7 @@ interface CommonServerOptions {
|
|
|
639
639
|
* Enable TLS + HTTP/2.
|
|
640
640
|
* Note: this downgrades to TLS only when the proxy option is also used.
|
|
641
641
|
*/
|
|
642
|
-
https?:
|
|
642
|
+
https?: HttpsServerOptions;
|
|
643
643
|
/**
|
|
644
644
|
* Open browser window on startup
|
|
645
645
|
*/
|
|
@@ -3095,9 +3095,11 @@ interface UserConfig {
|
|
|
3095
3095
|
*/
|
|
3096
3096
|
format?: 'es' | 'iife';
|
|
3097
3097
|
/**
|
|
3098
|
-
* Vite plugins that apply to worker bundle
|
|
3098
|
+
* Vite plugins that apply to worker bundle. The plugins retured by this function
|
|
3099
|
+
* should be new instances every time it is called, because they are used for each
|
|
3100
|
+
* rollup worker bundling process.
|
|
3099
3101
|
*/
|
|
3100
|
-
plugins?: PluginOption[];
|
|
3102
|
+
plugins?: () => PluginOption[];
|
|
3101
3103
|
/**
|
|
3102
3104
|
* Rollup options to build worker bundle
|
|
3103
3105
|
*/
|
|
@@ -3142,10 +3144,21 @@ interface ExperimentalOptions {
|
|
|
3142
3144
|
skipSsrTransform?: boolean;
|
|
3143
3145
|
}
|
|
3144
3146
|
interface LegacyOptions {
|
|
3147
|
+
/**
|
|
3148
|
+
* In Vite 4, SSR-externalized modules (modules not bundled and loaded by Node.js at runtime)
|
|
3149
|
+
* are implicitly proxied in dev to automatically handle `default` and `__esModule` access.
|
|
3150
|
+
* However, this does not correctly reflect how it works in the Node.js runtime, causing
|
|
3151
|
+
* inconsistencies between dev and prod.
|
|
3152
|
+
*
|
|
3153
|
+
* In Vite 5, the proxy is removed so dev and prod are consistent, but if you still require
|
|
3154
|
+
* the old behaviour, you can enable this option. If so, please leave your feedback at
|
|
3155
|
+
* https:
|
|
3156
|
+
*/
|
|
3157
|
+
proxySsrExternalModules?: boolean;
|
|
3145
3158
|
}
|
|
3146
|
-
interface ResolvedWorkerOptions
|
|
3159
|
+
interface ResolvedWorkerOptions {
|
|
3147
3160
|
format: 'es' | 'iife';
|
|
3148
|
-
plugins: Plugin[]
|
|
3161
|
+
plugins: () => Promise<Plugin[]>;
|
|
3149
3162
|
rollupOptions: RollupOptions;
|
|
3150
3163
|
}
|
|
3151
3164
|
interface InlineConfig extends UserConfig {
|
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, h as createFilter, k as createLogger, c as createServer, d as defineConfig, f as formatPostcssSourceMap, u as isFileServingAllowed, l as loadConfigFromFile, v as loadEnv, g as mergeAlias, m as mergeConfig, n as normalizePath, o as optimizeDeps, a as preprocessCSS, p as preview, r as resolveConfig, w as resolveEnvPrefix, q as searchForWorkspaceRoot, j as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-
|
|
1
|
+
import { i as isInNodeModules } from './chunks/dep-kPX9VBbU.js';
|
|
2
|
+
export { b as build, e as buildErrorMessage, h as createFilter, k as createLogger, c as createServer, d as defineConfig, f as formatPostcssSourceMap, u as isFileServingAllowed, l as loadConfigFromFile, v as loadEnv, g as mergeAlias, m as mergeConfig, n as normalizePath, o as optimizeDeps, a as preprocessCSS, p as preview, r as resolveConfig, w as resolveEnvPrefix, q as searchForWorkspaceRoot, j as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-kPX9VBbU.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';
|
|
@@ -3488,6 +3488,15 @@ function arraify(target) {
|
|
|
3488
3488
|
return Array.isArray(target) ? target : [target];
|
|
3489
3489
|
}
|
|
3490
3490
|
path$3.dirname(node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('node-cjs/publicUtils.cjs', document.baseURI).href))));
|
|
3491
|
+
function backwardCompatibleWorkerPlugins(plugins) {
|
|
3492
|
+
if (Array.isArray(plugins)) {
|
|
3493
|
+
return plugins;
|
|
3494
|
+
}
|
|
3495
|
+
if (typeof plugins === 'function') {
|
|
3496
|
+
return plugins();
|
|
3497
|
+
}
|
|
3498
|
+
return [];
|
|
3499
|
+
}
|
|
3491
3500
|
function mergeConfigRecursively(defaults, overrides, rootPath) {
|
|
3492
3501
|
const merged = { ...defaults };
|
|
3493
3502
|
for (const key in overrides) {
|
|
@@ -3515,6 +3524,13 @@ function mergeConfigRecursively(defaults, overrides, rootPath) {
|
|
|
3515
3524
|
merged[key] = true;
|
|
3516
3525
|
continue;
|
|
3517
3526
|
}
|
|
3527
|
+
else if (key === 'plugins' && rootPath === 'worker') {
|
|
3528
|
+
merged[key] = () => [
|
|
3529
|
+
...backwardCompatibleWorkerPlugins(existing),
|
|
3530
|
+
...backwardCompatibleWorkerPlugins(value),
|
|
3531
|
+
];
|
|
3532
|
+
continue;
|
|
3533
|
+
}
|
|
3518
3534
|
if (Array.isArray(existing) || Array.isArray(value)) {
|
|
3519
3535
|
merged[key] = [...arraify(existing ?? []), ...arraify(value ?? [])];
|
|
3520
3536
|
continue;
|