vite 6.0.0-alpha.6 → 6.0.0-alpha.8
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.
@@ -15161,6 +15161,7 @@ function terserPlugin(config) {
|
|
15161
15161
|
async function resolveBoundedPlugins(environment) {
|
15162
15162
|
const resolvedPlugins = [];
|
15163
15163
|
for (const plugin of environment.config.plugins) {
|
15164
|
+
resolvedPlugins.push(plugin);
|
15164
15165
|
if (plugin.create) {
|
15165
15166
|
const boundedPlugin = await plugin.create(environment);
|
15166
15167
|
if (boundedPlugin) {
|
@@ -15168,9 +15169,6 @@ async function resolveBoundedPlugins(environment) {
|
|
15168
15169
|
resolvedPlugins.push(...flatPlugins);
|
15169
15170
|
}
|
15170
15171
|
}
|
15171
|
-
else {
|
15172
|
-
resolvedPlugins.push(plugin);
|
15173
|
-
}
|
15174
15172
|
}
|
15175
15173
|
return resolvedPlugins;
|
15176
15174
|
}
|
@@ -15675,7 +15673,7 @@ function checkPublicFile(url, config) {
|
|
15675
15673
|
const assetUrlRE = /__VITE_ASSET__([\w$]+)__(?:\$_(.*?)__)?/g;
|
15676
15674
|
const jsSourceMapRE = /\.[cm]?js\.map$/;
|
15677
15675
|
const assetCache = new WeakMap();
|
15678
|
-
const
|
15676
|
+
const generatedAssetsMap = new WeakMap();
|
15679
15677
|
// add own dictionary entry by directly assigning mrmime
|
15680
15678
|
function registerCustomMime() {
|
15681
15679
|
// https://github.com/lukeed/mrmime/issues/3
|
@@ -15685,7 +15683,9 @@ function registerCustomMime() {
|
|
15685
15683
|
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types
|
15686
15684
|
mimes['eot'] = 'application/vnd.ms-fontobject';
|
15687
15685
|
}
|
15688
|
-
function renderAssetUrlInJS(ctx,
|
15686
|
+
function renderAssetUrlInJS(ctx, chunk, opts, code) {
|
15687
|
+
const environment = ctx.environment;
|
15688
|
+
const { config } = environment;
|
15689
15689
|
const toRelativeRuntime = createToImportMetaURLBasedRelativeRuntime(opts.format, config.isWorker);
|
15690
15690
|
let match;
|
15691
15691
|
let s;
|
@@ -15733,8 +15733,10 @@ function assetPlugin(config) {
|
|
15733
15733
|
return {
|
15734
15734
|
name: 'vite:asset',
|
15735
15735
|
buildStart() {
|
15736
|
-
|
15737
|
-
|
15736
|
+
if (!this.environment)
|
15737
|
+
return;
|
15738
|
+
assetCache.set(this.environment, new Map());
|
15739
|
+
generatedAssetsMap.set(this.environment, new Map());
|
15738
15740
|
},
|
15739
15741
|
resolveId(id) {
|
15740
15742
|
if (!config.assetsInclude(cleanUrl(id)) && !urlRE.test(id)) {
|
@@ -15769,7 +15771,7 @@ function assetPlugin(config) {
|
|
15769
15771
|
return;
|
15770
15772
|
}
|
15771
15773
|
id = removeUrlQuery(id);
|
15772
|
-
let url = await fileToUrl$1(
|
15774
|
+
let url = await fileToUrl$1(this, id);
|
15773
15775
|
// Inherit HMR timestamp if this asset was invalidated
|
15774
15776
|
const environment = this.environment;
|
15775
15777
|
const mod = environment?.mode === 'dev' &&
|
@@ -15787,11 +15789,11 @@ function assetPlugin(config) {
|
|
15787
15789
|
};
|
15788
15790
|
},
|
15789
15791
|
renderChunk(code, chunk, opts) {
|
15790
|
-
const s = renderAssetUrlInJS(this,
|
15792
|
+
const s = renderAssetUrlInJS(this, chunk, opts, code);
|
15791
15793
|
if (s) {
|
15792
15794
|
return {
|
15793
15795
|
code: s.toString(),
|
15794
|
-
map:
|
15796
|
+
map: this.environment?.options.build.sourcemap
|
15795
15797
|
? s.generateMap({ hires: 'boundary' })
|
15796
15798
|
: null,
|
15797
15799
|
};
|
@@ -15801,6 +15803,7 @@ function assetPlugin(config) {
|
|
15801
15803
|
}
|
15802
15804
|
},
|
15803
15805
|
generateBundle(_, bundle) {
|
15806
|
+
const environment = this.environment;
|
15804
15807
|
// Remove empty entry point file
|
15805
15808
|
for (const file in bundle) {
|
15806
15809
|
const chunk = bundle[file];
|
@@ -15812,9 +15815,7 @@ function assetPlugin(config) {
|
|
15812
15815
|
}
|
15813
15816
|
}
|
15814
15817
|
// do not emit assets for SSR build
|
15815
|
-
if (config.command === 'build' &&
|
15816
|
-
config.build.ssr &&
|
15817
|
-
!config.build.emitAssets) {
|
15818
|
+
if (config.command === 'build' && !environment.options.build.emitAssets) {
|
15818
15819
|
for (const file in bundle) {
|
15819
15820
|
if (bundle[file].type === 'asset' &&
|
15820
15821
|
!file.endsWith('ssr-manifest.json') &&
|
@@ -15826,12 +15827,13 @@ function assetPlugin(config) {
|
|
15826
15827
|
},
|
15827
15828
|
};
|
15828
15829
|
}
|
15829
|
-
async function fileToUrl$1(
|
15830
|
-
|
15831
|
-
|
15830
|
+
async function fileToUrl$1(ctx, id) {
|
15831
|
+
const environment = ctx.environment;
|
15832
|
+
if (environment.config.command === 'serve') {
|
15833
|
+
return fileToDevUrl(id, environment.config);
|
15832
15834
|
}
|
15833
15835
|
else {
|
15834
|
-
return fileToBuiltUrl(
|
15836
|
+
return fileToBuiltUrl(ctx, id);
|
15835
15837
|
}
|
15836
15838
|
}
|
15837
15839
|
function fileToDevUrl(id, config) {
|
@@ -15884,11 +15886,13 @@ function isGitLfsPlaceholder(content) {
|
|
15884
15886
|
* Register an asset to be emitted as part of the bundle (if necessary)
|
15885
15887
|
* and returns the resolved public URL
|
15886
15888
|
*/
|
15887
|
-
async function fileToBuiltUrl(
|
15889
|
+
async function fileToBuiltUrl(pluginContext, id, skipPublicCheck = false, forceInline) {
|
15890
|
+
const environment = pluginContext.environment;
|
15891
|
+
const { config } = environment;
|
15888
15892
|
if (!skipPublicCheck && checkPublicFile(id, config)) {
|
15889
15893
|
return publicFileToBuiltUrl(id, config);
|
15890
15894
|
}
|
15891
|
-
const cache = assetCache.get(
|
15895
|
+
const cache = assetCache.get(environment);
|
15892
15896
|
const cached = cache.get(id);
|
15893
15897
|
if (cached) {
|
15894
15898
|
return cached;
|
@@ -15896,7 +15900,7 @@ async function fileToBuiltUrl(id, config, pluginContext, skipPublicCheck = false
|
|
15896
15900
|
const file = cleanUrl(id);
|
15897
15901
|
const content = await fsp.readFile(file);
|
15898
15902
|
let url;
|
15899
|
-
if (shouldInline(
|
15903
|
+
if (shouldInline(pluginContext, file, id, content, forceInline)) {
|
15900
15904
|
if (config.build.lib && isGitLfsPlaceholder(content)) {
|
15901
15905
|
config.logger.warn(colors$1.yellow(`Inlined file ${id} was not downloaded via Git LFS`));
|
15902
15906
|
}
|
@@ -15920,24 +15924,29 @@ async function fileToBuiltUrl(id, config, pluginContext, skipPublicCheck = false
|
|
15920
15924
|
source: content,
|
15921
15925
|
});
|
15922
15926
|
const originalName = normalizePath$3(path$o.relative(config.root, file));
|
15923
|
-
|
15927
|
+
generatedAssetsMap.get(environment).set(referenceId, { originalName });
|
15924
15928
|
url = `__VITE_ASSET__${referenceId}__${postfix ? `$_${postfix}__` : ``}`; // TODO_BASE
|
15925
15929
|
}
|
15926
15930
|
cache.set(id, url);
|
15927
15931
|
return url;
|
15928
15932
|
}
|
15929
|
-
async function urlToBuiltUrl(url, importer,
|
15933
|
+
async function urlToBuiltUrl(pluginContext, url, importer, forceInline) {
|
15934
|
+
const environment = pluginContext.environment;
|
15935
|
+
const { config } = environment;
|
15930
15936
|
if (checkPublicFile(url, config)) {
|
15931
15937
|
return publicFileToBuiltUrl(url, config);
|
15932
15938
|
}
|
15933
15939
|
const file = url[0] === '/'
|
15934
15940
|
? path$o.join(config.root, url)
|
15935
15941
|
: path$o.join(path$o.dirname(importer), url);
|
15936
|
-
return fileToBuiltUrl(
|
15942
|
+
return fileToBuiltUrl(pluginContext, file,
|
15937
15943
|
// skip public check since we just did it above
|
15938
15944
|
true, forceInline);
|
15939
15945
|
}
|
15940
|
-
const shouldInline = (
|
15946
|
+
const shouldInline = (pluginContext, file, id, content, forceInline) => {
|
15947
|
+
const environment = pluginContext.environment;
|
15948
|
+
const { config } = environment;
|
15949
|
+
const { assetsInlineLimit } = environment.options.build;
|
15941
15950
|
if (config.build.lib)
|
15942
15951
|
return true;
|
15943
15952
|
if (pluginContext.getModuleInfo(id)?.isEntry)
|
@@ -15945,14 +15954,14 @@ const shouldInline = (config, file, id, content, pluginContext, forceInline) =>
|
|
15945
15954
|
if (forceInline !== undefined)
|
15946
15955
|
return forceInline;
|
15947
15956
|
let limit;
|
15948
|
-
if (typeof
|
15949
|
-
const userShouldInline =
|
15957
|
+
if (typeof assetsInlineLimit === 'function') {
|
15958
|
+
const userShouldInline = assetsInlineLimit(file, content);
|
15950
15959
|
if (userShouldInline != null)
|
15951
15960
|
return userShouldInline;
|
15952
15961
|
limit = DEFAULT_ASSETS_INLINE_LIMIT;
|
15953
15962
|
}
|
15954
15963
|
else {
|
15955
|
-
limit = Number(
|
15964
|
+
limit = Number(assetsInlineLimit);
|
15956
15965
|
}
|
15957
15966
|
if (file.endsWith('.html'))
|
15958
15967
|
return false;
|
@@ -15990,7 +15999,7 @@ function svgToDataURL(content) {
|
|
15990
15999
|
}
|
15991
16000
|
|
15992
16001
|
const endsWithJSRE = /\.[cm]?js$/;
|
15993
|
-
function manifestPlugin(
|
16002
|
+
function manifestPlugin() {
|
15994
16003
|
const manifest = {};
|
15995
16004
|
let outputCount;
|
15996
16005
|
return {
|
@@ -15999,8 +16008,12 @@ function manifestPlugin(config) {
|
|
15999
16008
|
outputCount = 0;
|
16000
16009
|
},
|
16001
16010
|
generateBundle({ format }, bundle) {
|
16011
|
+
if (!this.environment)
|
16012
|
+
return;
|
16013
|
+
const { root } = this.environment.config;
|
16014
|
+
const buildOptions = this.environment.options.build;
|
16002
16015
|
function getChunkName(chunk) {
|
16003
|
-
return getChunkOriginalFileName(chunk,
|
16016
|
+
return getChunkOriginalFileName(chunk, root, format);
|
16004
16017
|
}
|
16005
16018
|
function getInternalImports(imports) {
|
16006
16019
|
const filteredImports = [];
|
@@ -16056,7 +16069,7 @@ function manifestPlugin(config) {
|
|
16056
16069
|
return manifestChunk;
|
16057
16070
|
}
|
16058
16071
|
const fileNameToAssetMeta = new Map();
|
16059
|
-
const assets =
|
16072
|
+
const assets = generatedAssetsMap.get(this.environment);
|
16060
16073
|
assets.forEach((asset, referenceId) => {
|
16061
16074
|
try {
|
16062
16075
|
const fileName = this.getFileName(referenceId);
|
@@ -16099,12 +16112,12 @@ function manifestPlugin(config) {
|
|
16099
16112
|
}
|
16100
16113
|
});
|
16101
16114
|
outputCount++;
|
16102
|
-
const output =
|
16115
|
+
const output = buildOptions.rollupOptions?.output;
|
16103
16116
|
const outputLength = Array.isArray(output) ? output.length : 1;
|
16104
16117
|
if (outputCount >= outputLength) {
|
16105
16118
|
this.emitFile({
|
16106
|
-
fileName: typeof
|
16107
|
-
?
|
16119
|
+
fileName: typeof buildOptions.manifest === 'string'
|
16120
|
+
? buildOptions.manifest
|
16108
16121
|
: '.vite/manifest.json',
|
16109
16122
|
type: 'asset',
|
16110
16123
|
source: JSON.stringify(sortObjectKeys(manifest), undefined, 2),
|
@@ -29222,6 +29235,17 @@ const environmentColors = [
|
|
29222
29235
|
colors$1.green,
|
29223
29236
|
colors$1.gray,
|
29224
29237
|
];
|
29238
|
+
function cachedByEnvironment(create) {
|
29239
|
+
const cache = new WeakMap();
|
29240
|
+
return function (environment) {
|
29241
|
+
let data = cache.get(environment);
|
29242
|
+
if (!data) {
|
29243
|
+
data = create(environment);
|
29244
|
+
cache.set(environment, data);
|
29245
|
+
}
|
29246
|
+
return data;
|
29247
|
+
};
|
29248
|
+
}
|
29225
29249
|
|
29226
29250
|
// An implementation of fsUtils without caching
|
29227
29251
|
const commonFsUtils = {
|
@@ -58022,6 +58046,9 @@ function buildHtmlPlugin(config) {
|
|
58022
58046
|
name: 'vite:build-html',
|
58023
58047
|
async transform(html, id) {
|
58024
58048
|
if (id.endsWith('.html')) {
|
58049
|
+
if (!this.environment)
|
58050
|
+
return;
|
58051
|
+
const { modulePreload } = this.environment.options.build;
|
58025
58052
|
id = normalizePath$3(id);
|
58026
58053
|
const relativeUrlPath = path$o.posix.relative(config.root, id);
|
58027
58054
|
const publicPath = `/${relativeUrlPath}`;
|
@@ -58083,7 +58110,7 @@ function buildHtmlPlugin(config) {
|
|
58083
58110
|
!namedOutput.includes(removeLeadingSlash(url)) // Allow for absolute references as named output can't be an absolute path
|
58084
58111
|
) {
|
58085
58112
|
try {
|
58086
|
-
return await urlToBuiltUrl(url, id,
|
58113
|
+
return await urlToBuiltUrl(this, url, id, shouldInline);
|
58087
58114
|
}
|
58088
58115
|
catch (e) {
|
58089
58116
|
if (e.code !== 'ENOENT') {
|
@@ -58247,7 +58274,7 @@ function buildHtmlPlugin(config) {
|
|
58247
58274
|
s.update(start, end, partialEncodeURIPath(toOutputPublicFilePath(url)));
|
58248
58275
|
}
|
58249
58276
|
else if (!isExcludedUrl(url)) {
|
58250
|
-
s.update(start, end, partialEncodeURIPath(await urlToBuiltUrl(url, id
|
58277
|
+
s.update(start, end, partialEncodeURIPath(await urlToBuiltUrl(this, url, id)));
|
58251
58278
|
}
|
58252
58279
|
}
|
58253
58280
|
// ignore <link rel="stylesheet"> if its url can't be resolved
|
@@ -58267,7 +58294,6 @@ function buildHtmlPlugin(config) {
|
|
58267
58294
|
}
|
58268
58295
|
processedHtml.set(id, s.toString());
|
58269
58296
|
// inject module preload polyfill only when configured and needed
|
58270
|
-
const { modulePreload } = config.build;
|
58271
58297
|
if (modulePreload !== false &&
|
58272
58298
|
modulePreload.polyfill &&
|
58273
58299
|
(someScriptsAreAsync || someScriptsAreDefer)) {
|
@@ -58279,6 +58305,9 @@ function buildHtmlPlugin(config) {
|
|
58279
58305
|
}
|
58280
58306
|
},
|
58281
58307
|
async generateBundle(options, bundle) {
|
58308
|
+
if (!this.environment)
|
58309
|
+
return;
|
58310
|
+
const { modulePreload } = this.environment.options.build;
|
58282
58311
|
const analyzedChunk = new Map();
|
58283
58312
|
const inlineEntryChunk = new Set();
|
58284
58313
|
const getImportedChunks = (chunk, seen = new Set()) => {
|
@@ -58380,7 +58409,6 @@ function buildHtmlPlugin(config) {
|
|
58380
58409
|
}
|
58381
58410
|
else {
|
58382
58411
|
assetTags = [toScriptTag(chunk, toOutputAssetFilePath, isAsync)];
|
58383
|
-
const { modulePreload } = config.build;
|
58384
58412
|
if (modulePreload !== false) {
|
58385
58413
|
const resolveDependencies = typeof modulePreload === 'object' &&
|
58386
58414
|
modulePreload.resolveDependencies;
|
@@ -58398,7 +58426,7 @@ function buildHtmlPlugin(config) {
|
|
58398
58426
|
result = injectToHead(result, assetTags);
|
58399
58427
|
}
|
58400
58428
|
// inject css link when cssCodeSplit is false
|
58401
|
-
if (
|
58429
|
+
if (this.environment?.options.build.cssCodeSplit === false) {
|
58402
58430
|
const cssChunk = Object.values(bundle).find((chunk) => chunk.type === 'asset' && chunk.name === 'style.css');
|
58403
58431
|
if (cssChunk) {
|
58404
58432
|
result = injectToHead(result, [
|
@@ -62567,11 +62595,9 @@ function definePlugin(config) {
|
|
62567
62595
|
return {
|
62568
62596
|
name: 'vite:define',
|
62569
62597
|
async transform(code, id) {
|
62570
|
-
|
62571
|
-
if (!environment) {
|
62598
|
+
if (!this.environment)
|
62572
62599
|
return;
|
62573
|
-
|
62574
|
-
if (environment.name === 'client' && !isBuild) {
|
62600
|
+
if (this.environment.name === 'client' && !isBuild) {
|
62575
62601
|
// for dev we inject actual global defines in the vite client to
|
62576
62602
|
// avoid the transform cost. see the `clientInjection` and
|
62577
62603
|
// `importAnalysis` plugin.
|
@@ -62585,18 +62611,18 @@ function definePlugin(config) {
|
|
62585
62611
|
config.assetsInclude(id)) {
|
62586
62612
|
return;
|
62587
62613
|
}
|
62588
|
-
const [define, pattern] = getPattern(environment);
|
62614
|
+
const [define, pattern] = getPattern(this.environment);
|
62589
62615
|
if (!pattern)
|
62590
62616
|
return;
|
62591
62617
|
// Check if our code needs any replacements before running esbuild
|
62592
62618
|
pattern.lastIndex = 0;
|
62593
62619
|
if (!pattern.test(code))
|
62594
62620
|
return;
|
62595
|
-
return await replaceDefine(code, id, define
|
62621
|
+
return await replaceDefine(this.environment, code, id, define);
|
62596
62622
|
},
|
62597
62623
|
};
|
62598
62624
|
}
|
62599
|
-
async function replaceDefine(code, id, define
|
62625
|
+
async function replaceDefine(environment, code, id, define) {
|
62600
62626
|
// Because esbuild only allows JSON-serializable values, and `import.meta.env`
|
62601
62627
|
// may contain values with raw identifiers, making it non-JSON-serializable,
|
62602
62628
|
// we replace it with a temporary marker and then replace it back after to
|
@@ -62609,14 +62635,16 @@ async function replaceDefine(code, id, define, config) {
|
|
62609
62635
|
replacementMarkers[marker] = env;
|
62610
62636
|
define = { ...define, 'import.meta.env': marker };
|
62611
62637
|
}
|
62612
|
-
const esbuildOptions = config.esbuild || {};
|
62638
|
+
const esbuildOptions = environment.config.esbuild || {};
|
62613
62639
|
const result = await transform$1(code, {
|
62614
62640
|
loader: 'js',
|
62615
62641
|
charset: esbuildOptions.charset ?? 'utf8',
|
62616
62642
|
platform: 'neutral',
|
62617
62643
|
define,
|
62618
62644
|
sourcefile: id,
|
62619
|
-
sourcemap: config.command === 'build'
|
62645
|
+
sourcemap: environment.config.command === 'build'
|
62646
|
+
? !!environment.options.build.sourcemap
|
62647
|
+
: true,
|
62620
62648
|
});
|
62621
62649
|
// remove esbuild's <define:...> source entries
|
62622
62650
|
// since they would confuse source map remapping/collapsing which expects a single source
|
@@ -62697,8 +62725,8 @@ async function bundleWorkerEntry(config, id) {
|
|
62697
62725
|
// bundle the file as entry to support imports
|
62698
62726
|
const { rollup } = await import('rollup');
|
62699
62727
|
const { plugins, rollupOptions, format } = config.worker;
|
62700
|
-
const
|
62701
|
-
const
|
62728
|
+
const { plugins: resolvedPlugins, config: workerConfig } = await plugins(newBundleChain);
|
62729
|
+
const workerEnvironment = new BuildEnvironment('client', workerConfig); // TODO: should this be 'worker'?
|
62702
62730
|
const bundle = await rollup({
|
62703
62731
|
...rollupOptions,
|
62704
62732
|
input,
|
@@ -62939,7 +62967,7 @@ function webWorkerPlugin(config) {
|
|
62939
62967
|
}
|
62940
62968
|
}
|
62941
62969
|
else {
|
62942
|
-
let url = await fileToUrl$1(cleanUrl(id)
|
62970
|
+
let url = await fileToUrl$1(this, cleanUrl(id));
|
62943
62971
|
url = injectQuery(url, `${WORKER_FILE_ID}&type=${workerType}`);
|
62944
62972
|
urlCode = JSON.stringify(url);
|
62945
62973
|
}
|
@@ -63233,12 +63261,11 @@ function importAnalysisPlugin(config) {
|
|
63233
63261
|
}
|
63234
63262
|
return {
|
63235
63263
|
name: 'vite:import-analysis',
|
63236
|
-
async transform(source, importer
|
63237
|
-
|
63238
|
-
const environment = this.environment;
|
63239
|
-
if (!environment) {
|
63264
|
+
async transform(source, importer) {
|
63265
|
+
if (!this.environment)
|
63240
63266
|
return;
|
63241
|
-
|
63267
|
+
const environment = this.environment;
|
63268
|
+
const ssr = environment.name !== 'client'; // TODO
|
63242
63269
|
const moduleGraph = environment.moduleGraph;
|
63243
63270
|
if (canSkipImportAnalysis(importer)) {
|
63244
63271
|
debug$1?.(colors$1.dim(`[skipped] ${prettifyUrl(importer, root)}`));
|
@@ -63879,21 +63906,25 @@ function clientInjectionsPlugin(config) {
|
|
63879
63906
|
.replace(`__HMR_CONFIG_NAME__`, hmrConfigNameReplacement);
|
63880
63907
|
};
|
63881
63908
|
},
|
63882
|
-
async transform(code, id
|
63909
|
+
async transform(code, id) {
|
63910
|
+
if (!this.environment)
|
63911
|
+
return;
|
63912
|
+
// TODO: !environment.options.nodeCompatible ?
|
63913
|
+
const ssr = this.environment.name !== 'client';
|
63883
63914
|
if (id === normalizedClientEntry || id === normalizedEnvEntry) {
|
63884
63915
|
return injectConfigValues(code);
|
63885
63916
|
}
|
63886
|
-
else if (!
|
63917
|
+
else if (!ssr && code.includes('process.env.NODE_ENV')) {
|
63887
63918
|
// replace process.env.NODE_ENV instead of defining a global
|
63888
63919
|
// for it to avoid shimming a `process` object during dev,
|
63889
63920
|
// avoiding inconsistencies between dev and build
|
63890
63921
|
const nodeEnv = config.define?.['process.env.NODE_ENV'] ||
|
63891
63922
|
JSON.stringify(process.env.NODE_ENV || config.mode);
|
63892
|
-
return await replaceDefine(code, id, {
|
63923
|
+
return await replaceDefine(this.environment, code, id, {
|
63893
63924
|
'process.env.NODE_ENV': nodeEnv,
|
63894
63925
|
'global.process.env.NODE_ENV': nodeEnv,
|
63895
63926
|
'globalThis.process.env.NODE_ENV': nodeEnv,
|
63896
|
-
}
|
63927
|
+
});
|
63897
63928
|
}
|
63898
63929
|
},
|
63899
63930
|
};
|
@@ -63959,7 +63990,7 @@ const wasmHelperPlugin = (config) => {
|
|
63959
63990
|
if (!id.endsWith('.wasm?init')) {
|
63960
63991
|
return;
|
63961
63992
|
}
|
63962
|
-
const url = await fileToUrl$1(
|
63993
|
+
const url = await fileToUrl$1(this, id);
|
63963
63994
|
return `
|
63964
63995
|
import initWasm from "${wasmHelperId}"
|
63965
63996
|
export default opts => initWasm(opts, ${JSON.stringify(url)})
|
@@ -64107,7 +64138,7 @@ function workerImportMetaUrlPlugin(config) {
|
|
64107
64138
|
builtUrl = await workerFileToUrl(config, file);
|
64108
64139
|
}
|
64109
64140
|
else {
|
64110
|
-
builtUrl = await fileToUrl$1(cleanUrl(file)
|
64141
|
+
builtUrl = await fileToUrl$1(this, cleanUrl(file));
|
64111
64142
|
builtUrl = injectQuery(builtUrl, `${WORKER_FILE_ID}&type=${workerType}`);
|
64112
64143
|
}
|
64113
64144
|
s.update(expStart, expEnd,
|
@@ -64220,10 +64251,10 @@ function assetImportMetaUrlPlugin(config) {
|
|
64220
64251
|
try {
|
64221
64252
|
if (publicDir && isParentDirectory(publicDir, file)) {
|
64222
64253
|
const publicPath = '/' + path$o.posix.relative(publicDir, file);
|
64223
|
-
builtUrl = await fileToUrl$1(
|
64254
|
+
builtUrl = await fileToUrl$1(this, publicPath);
|
64224
64255
|
}
|
64225
64256
|
else {
|
64226
|
-
builtUrl = await fileToUrl$1(
|
64257
|
+
builtUrl = await fileToUrl$1(this, file);
|
64227
64258
|
}
|
64228
64259
|
}
|
64229
64260
|
catch {
|
@@ -64531,8 +64562,10 @@ function dynamicImportVarsPlugin(config) {
|
|
64531
64562
|
tryIndex: false,
|
64532
64563
|
extensions: [],
|
64533
64564
|
});
|
64534
|
-
const
|
64535
|
-
|
64565
|
+
const getFilter = cachedByEnvironment((environment) => {
|
64566
|
+
const { include, exclude } = environment.options.build.dynamicImportVarsOptions;
|
64567
|
+
return createFilter(include, exclude);
|
64568
|
+
});
|
64536
64569
|
return {
|
64537
64570
|
name: 'vite:dynamic-import-vars',
|
64538
64571
|
resolveId(id) {
|
@@ -64548,7 +64581,7 @@ function dynamicImportVarsPlugin(config) {
|
|
64548
64581
|
async transform(source, importer) {
|
64549
64582
|
const { environment } = this;
|
64550
64583
|
if (!environment ||
|
64551
|
-
!
|
64584
|
+
!getFilter(environment)(importer) ||
|
64552
64585
|
importer === CLIENT_ENTRY ||
|
64553
64586
|
!hasDynamicImportRE.test(source)) {
|
64554
64587
|
return;
|
@@ -64581,7 +64614,7 @@ function dynamicImportVarsPlugin(config) {
|
|
64581
64614
|
result = await transformDynamicImport(source.slice(start, end), importer, (id, importer) => resolve(environment, id, importer), config.root);
|
64582
64615
|
}
|
64583
64616
|
catch (error) {
|
64584
|
-
if (warnOnError) {
|
64617
|
+
if (environment.options.build.dynamicImportVarsOptions.warnOnError) {
|
64585
64618
|
this.warn(error);
|
64586
64619
|
}
|
64587
64620
|
else {
|
@@ -64646,7 +64679,7 @@ async function resolvePlugins(config, prePlugins, normalPlugins, postPlugins) {
|
|
64646
64679
|
namedExports: true,
|
64647
64680
|
...config.json,
|
64648
64681
|
}, isBuild),
|
64649
|
-
wasmHelperPlugin(
|
64682
|
+
wasmHelperPlugin(),
|
64650
64683
|
webWorkerPlugin(config),
|
64651
64684
|
assetPlugin(config),
|
64652
64685
|
...normalPlugins,
|
@@ -65507,7 +65540,7 @@ function cssPlugin(config) {
|
|
65507
65540
|
}
|
65508
65541
|
const resolved = await resolveUrl(decodedUrl, importer);
|
65509
65542
|
if (resolved) {
|
65510
|
-
return fileToUrl$1(
|
65543
|
+
return fileToUrl$1(this, resolved);
|
65511
65544
|
}
|
65512
65545
|
if (config.command === 'build') {
|
65513
65546
|
const isExternal = config.build.rollupOptions.external
|
@@ -65673,6 +65706,9 @@ function cssPostPlugin(config) {
|
|
65673
65706
|
};
|
65674
65707
|
},
|
65675
65708
|
async renderChunk(code, chunk, opts) {
|
65709
|
+
if (!this.environment)
|
65710
|
+
return;
|
65711
|
+
const generatedAssets = generatedAssetsMap.get(this.environment);
|
65676
65712
|
let chunkCSS = '';
|
65677
65713
|
let isPureCssChunk = true;
|
65678
65714
|
const ids = Object.keys(chunk.modules);
|
@@ -65764,9 +65800,7 @@ function cssPostPlugin(config) {
|
|
65764
65800
|
type: 'asset',
|
65765
65801
|
source: content,
|
65766
65802
|
});
|
65767
|
-
generatedAssets
|
65768
|
-
.get(config)
|
65769
|
-
.set(referenceId, { originalName: originalFilename });
|
65803
|
+
generatedAssets.set(referenceId, { originalName: originalFilename });
|
65770
65804
|
const replacement = toOutputFilePathInJS(this.getFileName(referenceId), 'asset', chunk.fileName, 'js', config, toRelativeRuntime);
|
65771
65805
|
const replacementString = typeof replacement === 'string'
|
65772
65806
|
? JSON.stringify(encodeURIPath(replacement)).slice(1, -1)
|
@@ -65802,9 +65836,10 @@ function cssPostPlugin(config) {
|
|
65802
65836
|
type: 'asset',
|
65803
65837
|
source: chunkCSS,
|
65804
65838
|
});
|
65805
|
-
generatedAssets
|
65806
|
-
|
65807
|
-
|
65839
|
+
generatedAssets.set(referenceId, {
|
65840
|
+
originalName: originalFilename,
|
65841
|
+
isEntry,
|
65842
|
+
});
|
65808
65843
|
chunk.viteMetadata.importedCss.add(this.getFileName(referenceId));
|
65809
65844
|
}
|
65810
65845
|
else if (!config.build.ssr) {
|
@@ -65817,7 +65852,8 @@ function cssPostPlugin(config) {
|
|
65817
65852
|
chunkCSS = await finalizeCss(chunkCSS, true, config);
|
65818
65853
|
let cssString = JSON.stringify(chunkCSS);
|
65819
65854
|
cssString =
|
65820
|
-
renderAssetUrlInJS(this,
|
65855
|
+
renderAssetUrlInJS(this, chunk, opts, cssString)?.toString() ||
|
65856
|
+
cssString;
|
65821
65857
|
const style = `__vite_style__`;
|
65822
65858
|
const injectCode = `var ${style} = document.createElement('style');` +
|
65823
65859
|
`${style}.textContent = ${cssString};` +
|
@@ -65969,7 +66005,7 @@ function cssAnalysisPlugin(config) {
|
|
65969
66005
|
for (const file of pluginImports) {
|
65970
66006
|
depModules.add(isCSSRequest(file)
|
65971
66007
|
? moduleGraph.createFileOnlyEntry(file)
|
65972
|
-
: await moduleGraph.ensureEntryFromUrl(stripBase(await fileToUrl$1(
|
66008
|
+
: await moduleGraph.ensureEntryFromUrl(stripBase(await fileToUrl$1(this, file), (config.server?.origin ?? '') + devBase)));
|
65973
66009
|
}
|
65974
66010
|
moduleGraph.updateModuleInfo(thisModule, depModules, null,
|
65975
66011
|
// The root CSS proxy module is self-accepting and should not
|
@@ -67412,43 +67448,24 @@ function preload(baseModule, deps, importerUrl) {
|
|
67412
67448
|
}
|
67413
67449
|
});
|
67414
67450
|
}
|
67451
|
+
function getModulePreloadData(environment) {
|
67452
|
+
const { modulePreload } = environment.options.build;
|
67453
|
+
const { config } = environment;
|
67454
|
+
const resolveModulePreloadDependencies = modulePreload && modulePreload.resolveDependencies;
|
67455
|
+
const renderBuiltUrl = config.experimental.renderBuiltUrl;
|
67456
|
+
const customModulePreloadPaths = !!(resolveModulePreloadDependencies || renderBuiltUrl);
|
67457
|
+
const isRelativeBase = config.base === './' || config.base === '';
|
67458
|
+
const optimizeModulePreloadRelativePaths = isRelativeBase && !customModulePreloadPaths;
|
67459
|
+
return {
|
67460
|
+
customModulePreloadPaths,
|
67461
|
+
optimizeModulePreloadRelativePaths,
|
67462
|
+
};
|
67463
|
+
}
|
67415
67464
|
/**
|
67416
67465
|
* Build only. During serve this is performed as part of ./importAnalysis.
|
67417
67466
|
*/
|
67418
67467
|
function buildImportAnalysisPlugin(config) {
|
67419
|
-
const ssr = !!config.build.ssr;
|
67420
67468
|
const isWorker = config.isWorker;
|
67421
|
-
const insertPreload = !(ssr || !!config.build.lib || isWorker);
|
67422
|
-
const resolveModulePreloadDependencies = config.build.modulePreload && config.build.modulePreload.resolveDependencies;
|
67423
|
-
const renderBuiltUrl = config.experimental.renderBuiltUrl;
|
67424
|
-
const customModulePreloadPaths = !!(resolveModulePreloadDependencies || renderBuiltUrl);
|
67425
|
-
const isRelativeBase = config.base === './' || config.base === '';
|
67426
|
-
const optimizeModulePreloadRelativePaths = isRelativeBase && !customModulePreloadPaths;
|
67427
|
-
const { modulePreload } = config.build;
|
67428
|
-
const scriptRel = modulePreload && modulePreload.polyfill
|
67429
|
-
? `'modulepreload'`
|
67430
|
-
: `(${detectScriptRel.toString()})()`;
|
67431
|
-
// There are three different cases for the preload list format in __vitePreload
|
67432
|
-
//
|
67433
|
-
// __vitePreload(() => import(asyncChunk), [ ...deps... ])
|
67434
|
-
//
|
67435
|
-
// This is maintained to keep backwards compatibility as some users developed plugins
|
67436
|
-
// using regex over this list to workaround the fact that module preload wasn't
|
67437
|
-
// configurable.
|
67438
|
-
const assetsURL = customModulePreloadPaths
|
67439
|
-
? // If `experimental.renderBuiltUrl` or `build.modulePreload.resolveDependencies` are used
|
67440
|
-
// the dependencies are already resolved. To avoid the need for `new URL(dep, import.meta.url)`
|
67441
|
-
// a helper `__vitePreloadRelativeDep` is used to resolve from relative paths which can be minimized.
|
67442
|
-
`function(dep, importerUrl) { return dep[0] === '.' ? new URL(dep, importerUrl).href : dep }`
|
67443
|
-
: optimizeModulePreloadRelativePaths
|
67444
|
-
? // If there isn't custom resolvers affecting the deps list, deps in the list are relative
|
67445
|
-
// to the current chunk and are resolved to absolute URL by the __vitePreload helper itself.
|
67446
|
-
// The importerUrl is passed as third parameter to __vitePreload in this case
|
67447
|
-
`function(dep, importerUrl) { return new URL(dep, importerUrl).href }`
|
67448
|
-
: // If the base isn't relative, then the deps are relative to the projects `outDir` and the base
|
67449
|
-
// is appended inside __vitePreload too.
|
67450
|
-
`function(dep) { return ${JSON.stringify(config.base)}+dep }`;
|
67451
|
-
const preloadCode = `const scriptRel = ${scriptRel};const assetsURL = ${assetsURL};const seen = {};export const ${preloadMethod} = ${preload.toString()}`;
|
67452
67469
|
return {
|
67453
67470
|
name: 'vite:build-import-analysis',
|
67454
67471
|
resolveId(id) {
|
@@ -67457,12 +67474,41 @@ function buildImportAnalysisPlugin(config) {
|
|
67457
67474
|
}
|
67458
67475
|
},
|
67459
67476
|
load(id) {
|
67460
|
-
|
67477
|
+
const { environment } = this;
|
67478
|
+
if (environment && id === preloadHelperId) {
|
67479
|
+
const { modulePreload } = environment.options.build;
|
67480
|
+
const { customModulePreloadPaths, optimizeModulePreloadRelativePaths } = getModulePreloadData(environment);
|
67481
|
+
const scriptRel = modulePreload && modulePreload.polyfill
|
67482
|
+
? `'modulepreload'`
|
67483
|
+
: `(${detectScriptRel.toString()})()`;
|
67484
|
+
// There are three different cases for the preload list format in __vitePreload
|
67485
|
+
//
|
67486
|
+
// __vitePreload(() => import(asyncChunk), [ ...deps... ])
|
67487
|
+
//
|
67488
|
+
// This is maintained to keep backwards compatibility as some users developed plugins
|
67489
|
+
// using regex over this list to workaround the fact that module preload wasn't
|
67490
|
+
// configurable.
|
67491
|
+
const assetsURL = customModulePreloadPaths
|
67492
|
+
? // If `experimental.renderBuiltUrl` or `build.modulePreload.resolveDependencies` are used
|
67493
|
+
// the dependencies are already resolved. To avoid the need for `new URL(dep, import.meta.url)`
|
67494
|
+
// a helper `__vitePreloadRelativeDep` is used to resolve from relative paths which can be minimized.
|
67495
|
+
`function(dep, importerUrl) { return dep[0] === '.' ? new URL(dep, importerUrl).href : dep }`
|
67496
|
+
: optimizeModulePreloadRelativePaths
|
67497
|
+
? // If there isn't custom resolvers affecting the deps list, deps in the list are relative
|
67498
|
+
// to the current chunk and are resolved to absolute URL by the __vitePreload helper itself.
|
67499
|
+
// The importerUrl is passed as third parameter to __vitePreload in this case
|
67500
|
+
`function(dep, importerUrl) { return new URL(dep, importerUrl).href }`
|
67501
|
+
: // If the base isn't relative, then the deps are relative to the projects `outDir` and the base
|
67502
|
+
// is appended inside __vitePreload too.
|
67503
|
+
`function(dep) { return ${JSON.stringify(config.base)}+dep }`;
|
67504
|
+
const preloadCode = `const scriptRel = ${scriptRel};const assetsURL = ${assetsURL};const seen = {};export const ${preloadMethod} = ${preload.toString()}`;
|
67461
67505
|
return preloadCode;
|
67462
67506
|
}
|
67463
67507
|
},
|
67464
67508
|
async transform(source, importer) {
|
67465
|
-
|
67509
|
+
const { environment } = this;
|
67510
|
+
if (!environment ||
|
67511
|
+
(isInNodeModules$1(importer) && !dynamicImportPrefixRE.test(source))) {
|
67466
67512
|
return;
|
67467
67513
|
}
|
67468
67514
|
await init;
|
@@ -67481,6 +67527,9 @@ function buildImportAnalysisPlugin(config) {
|
|
67481
67527
|
let s;
|
67482
67528
|
const str = () => s || (s = new MagicString(source));
|
67483
67529
|
let needPreloadHelper = false;
|
67530
|
+
const ssr = environment.options.build.ssr;
|
67531
|
+
const insertPreload = !(ssr || !!config.build.lib || isWorker);
|
67532
|
+
const { customModulePreloadPaths, optimizeModulePreloadRelativePaths } = getModulePreloadData(environment);
|
67484
67533
|
for (let index = 0; index < imports.length; index++) {
|
67485
67534
|
const { e: end, ss: expStart, se: expEnd, d: dynamicIndex, a: attributeIndex, } = imports[index];
|
67486
67535
|
const isDynamicImport = dynamicIndex > -1;
|
@@ -67504,7 +67553,7 @@ function buildImportAnalysisPlugin(config) {
|
|
67504
67553
|
if (s) {
|
67505
67554
|
return {
|
67506
67555
|
code: s.toString(),
|
67507
|
-
map:
|
67556
|
+
map: environment.options.build.sourcemap
|
67508
67557
|
? s.generateMap({ hires: 'boundary' })
|
67509
67558
|
: null,
|
67510
67559
|
};
|
@@ -67512,10 +67561,11 @@ function buildImportAnalysisPlugin(config) {
|
|
67512
67561
|
},
|
67513
67562
|
renderChunk(code, _, { format }) {
|
67514
67563
|
// make sure we only perform the preload logic in modern builds.
|
67515
|
-
|
67564
|
+
const { environment } = this;
|
67565
|
+
if (environment && code.indexOf(isModernFlag) > -1) {
|
67516
67566
|
const re = new RegExp(isModernFlag, 'g');
|
67517
67567
|
const isModern = String(format === 'es');
|
67518
|
-
if (
|
67568
|
+
if (environment.options.build.sourcemap) {
|
67519
67569
|
const s = new MagicString(code);
|
67520
67570
|
let match;
|
67521
67571
|
while ((match = re.exec(code))) {
|
@@ -67533,9 +67583,15 @@ function buildImportAnalysisPlugin(config) {
|
|
67533
67583
|
return null;
|
67534
67584
|
},
|
67535
67585
|
generateBundle({ format }, bundle) {
|
67586
|
+
if (!this.environment)
|
67587
|
+
return;
|
67588
|
+
const ssr = this.environment.name !== 'client'; // TODO
|
67536
67589
|
if (format !== 'es' || ssr || isWorker) {
|
67537
67590
|
return;
|
67538
67591
|
}
|
67592
|
+
const buildSourcemap = this.environment.options.build.sourcemap;
|
67593
|
+
const { modulePreload } = this.environment.options.build;
|
67594
|
+
const { customModulePreloadPaths, optimizeModulePreloadRelativePaths } = getModulePreloadData(this.environment);
|
67539
67595
|
for (const file in bundle) {
|
67540
67596
|
const chunk = bundle[file];
|
67541
67597
|
// can't use chunk.dynamicImports.length here since some modules e.g.
|
@@ -67712,7 +67768,7 @@ function buildImportAnalysisPlugin(config) {
|
|
67712
67768
|
}
|
67713
67769
|
if (s.hasChanged()) {
|
67714
67770
|
chunk.code = s.toString();
|
67715
|
-
if (
|
67771
|
+
if (buildSourcemap && chunk.map) {
|
67716
67772
|
const nextMap = s.generateMap({
|
67717
67773
|
source: chunk.fileName,
|
67718
67774
|
hires: 'boundary',
|
@@ -67723,11 +67779,11 @@ function buildImportAnalysisPlugin(config) {
|
|
67723
67779
|
]);
|
67724
67780
|
map.toUrl = () => genSourceMapUrl(map);
|
67725
67781
|
chunk.map = map;
|
67726
|
-
if (
|
67782
|
+
if (buildSourcemap === 'inline') {
|
67727
67783
|
chunk.code = chunk.code.replace(convertSourceMap.mapFileCommentRegex, '');
|
67728
67784
|
chunk.code += `\n//# sourceMappingURL=${genSourceMapUrl(map)}`;
|
67729
67785
|
}
|
67730
|
-
else if (
|
67786
|
+
else if (buildSourcemap) {
|
67731
67787
|
const mapAsset = bundle[chunk.fileName + '.map'];
|
67732
67788
|
if (mapAsset && mapAsset.type === 'asset') {
|
67733
67789
|
mapAsset.source = map.toString();
|
@@ -67988,7 +68044,7 @@ async function resolveBuildPlugins(config) {
|
|
67988
68044
|
...(options.minify ? [terserPlugin(config)] : []),
|
67989
68045
|
...(!config.isWorker
|
67990
68046
|
? [
|
67991
|
-
...(options.manifest ? [manifestPlugin(
|
68047
|
+
...(options.manifest ? [manifestPlugin()] : []),
|
67992
68048
|
...(options.ssrManifest ? [ssrManifestPlugin(config)] : []),
|
67993
68049
|
buildReporterPlugin(config),
|
67994
68050
|
]
|
@@ -68378,13 +68434,19 @@ function isExternal(id, test) {
|
|
68378
68434
|
return test.test(id);
|
68379
68435
|
}
|
68380
68436
|
}
|
68437
|
+
// TODO:
|
68438
|
+
// - Could we get Rollup to let us extends PluginContext in a more performant way?
|
68439
|
+
// - Extend for all hooks?
|
68381
68440
|
function injectEnvironmentToHooks(plugin, environment) {
|
68382
|
-
const { resolveId, load, transform } = plugin;
|
68441
|
+
const { buildStart, resolveId, load, transform, generateBundle, renderChunk, } = plugin;
|
68383
68442
|
return {
|
68384
68443
|
...plugin,
|
68385
68444
|
resolveId: wrapEnvironmentResolveId(resolveId, environment),
|
68386
68445
|
load: wrapEnvironmentLoad(load, environment),
|
68387
68446
|
transform: wrapEnvironmentTransform(transform, environment),
|
68447
|
+
buildStart: wrapEnvironmentHook(buildStart, environment),
|
68448
|
+
generateBundle: wrapEnvironmentHook(generateBundle, environment),
|
68449
|
+
renderChunk: wrapEnvironmentHook(renderChunk, environment),
|
68388
68450
|
};
|
68389
68451
|
}
|
68390
68452
|
function wrapEnvironmentResolveId(hook, environment) {
|
@@ -68438,6 +68500,23 @@ function wrapEnvironmentTransform(hook, environment) {
|
|
68438
68500
|
return handler;
|
68439
68501
|
}
|
68440
68502
|
}
|
68503
|
+
function wrapEnvironmentHook(hook, environment) {
|
68504
|
+
if (!hook)
|
68505
|
+
return;
|
68506
|
+
const fn = getHookHandler(hook);
|
68507
|
+
const handler = function (...args) {
|
68508
|
+
return fn.call(injectEnvironmentInContext(this, environment), ...args);
|
68509
|
+
};
|
68510
|
+
if ('handler' in hook) {
|
68511
|
+
return {
|
68512
|
+
...hook,
|
68513
|
+
handler,
|
68514
|
+
};
|
68515
|
+
}
|
68516
|
+
else {
|
68517
|
+
return handler;
|
68518
|
+
}
|
68519
|
+
}
|
68441
68520
|
function injectEnvironmentInContext(context, environment) {
|
68442
68521
|
return new Proxy(context, {
|
68443
68522
|
get(target, prop, receiver) {
|
@@ -68493,6 +68572,7 @@ const customRelativeUrlMechanisms = {
|
|
68493
68572
|
...relativeUrlMechanisms,
|
68494
68573
|
'worker-iife': (relativePath) => getResolveUrl(`'${escapeId(partialEncodeURIPath(relativePath))}', self.location.href`),
|
68495
68574
|
};
|
68575
|
+
// TODO: experimental.renderBuiltUrl => environment.build.renderBuiltUrl?
|
68496
68576
|
function toOutputFilePathInJS(filename, type, hostId, hostType, config, toRelative) {
|
68497
68577
|
const { renderBuiltUrl } = config.experimental;
|
68498
68578
|
let relative = config.base === '' || config.base === './';
|
@@ -69283,6 +69363,7 @@ async function resolveConfig(inlineConfig, command, defaultMode = 'development',
|
|
69283
69363
|
logger.warn(colors$1.yellow(`worker.plugins is now a function that returns an array of plugins. ` +
|
69284
69364
|
`Please update your Vite config accordingly.\n`));
|
69285
69365
|
}
|
69366
|
+
// TODO: Workers as environments could allow us to remove a lot of complexity
|
69286
69367
|
const createWorkerPlugins = async function (bundleChain) {
|
69287
69368
|
// Some plugins that aren't intended to work in the bundling of workers (doing post-processing at build time for example).
|
69288
69369
|
// And Plugins may also have cached that could be corrupted by being used in these extra rollup calls.
|
@@ -69310,7 +69391,7 @@ async function resolveConfig(inlineConfig, command, defaultMode = 'development',
|
|
69310
69391
|
await Promise.all(createPluginHookUtils(resolvedWorkerPlugins)
|
69311
69392
|
.getSortedPluginHooks('configResolved')
|
69312
69393
|
.map((hook) => hook(workerResolved)));
|
69313
|
-
return resolvedWorkerPlugins;
|
69394
|
+
return { plugins: resolvedWorkerPlugins, config: workerResolved };
|
69314
69395
|
};
|
69315
69396
|
const resolvedWorkerOptions = {
|
69316
69397
|
format: config.worker?.format || 'iife',
|
package/dist/node/cli.js
CHANGED
@@ -731,7 +731,7 @@ cli
|
|
731
731
|
filterDuplicateOptions(options);
|
732
732
|
// output structure is preserved even after bundling so require()
|
733
733
|
// is ok here
|
734
|
-
const { createServer } = await import('./chunks/dep-
|
734
|
+
const { createServer } = await import('./chunks/dep-8PNdpITG.js').then(function (n) { return n.C; });
|
735
735
|
try {
|
736
736
|
const server = await createServer({
|
737
737
|
root,
|
@@ -812,7 +812,7 @@ cli
|
|
812
812
|
.option('--app', `[boolean] same as builder.entireApp`)
|
813
813
|
.action(async (root, options) => {
|
814
814
|
filterDuplicateOptions(options);
|
815
|
-
const { createBuilder, buildEnvironment } = await import('./chunks/dep-
|
815
|
+
const { createBuilder, buildEnvironment } = await import('./chunks/dep-8PNdpITG.js').then(function (n) { return n.E; });
|
816
816
|
const buildOptions = cleanGlobalCLIOptions(cleanBuilderCLIOptions(options));
|
817
817
|
const config = {
|
818
818
|
root,
|
@@ -888,7 +888,7 @@ cli
|
|
888
888
|
.option('--outDir <dir>', `[string] output directory (default: dist)`)
|
889
889
|
.action(async (root, options) => {
|
890
890
|
filterDuplicateOptions(options);
|
891
|
-
const { preview } = await import('./chunks/dep-
|
891
|
+
const { preview } = await import('./chunks/dep-8PNdpITG.js').then(function (n) { return n.F; });
|
892
892
|
try {
|
893
893
|
const server = await preview({
|
894
894
|
root,
|
package/dist/node/index.d.ts
CHANGED
@@ -3252,6 +3252,15 @@ interface TransformPluginContext extends rollup.TransformPluginContext {
|
|
3252
3252
|
* Environment Plugins are closer to regular rollup plugins. They can't define
|
3253
3253
|
* app level hooks (like config, configResolved, configureServer, etc).
|
3254
3254
|
*/
|
3255
|
+
type ModifyFunctionContext<Function_, NewContext> = Function_ extends (this: infer This, ...parameters: infer Arguments) => infer Return ? (this: NewContext, ...parameters: Arguments) => Return : never;
|
3256
|
+
type ModifyObjectHookContext<Handler, Object_ extends {
|
3257
|
+
handler: Handler;
|
3258
|
+
}, NewContext> = Object_ & {
|
3259
|
+
handler: ModifyFunctionContext<Handler, NewContext>;
|
3260
|
+
};
|
3261
|
+
type ModifyHookContext<Hook, NewContext> = Hook extends {
|
3262
|
+
handler: infer Handler;
|
3263
|
+
} ? ModifyObjectHookContext<Handler, Hook, NewContext> : ModifyFunctionContext<Hook, NewContext>;
|
3255
3264
|
interface BasePlugin<A = any> extends rollup.Plugin<A> {
|
3256
3265
|
/**
|
3257
3266
|
* Perform custom handling of HMR updates.
|
@@ -3293,6 +3302,9 @@ interface BasePlugin<A = any> extends rollup.Plugin<A> {
|
|
3293
3302
|
*/
|
3294
3303
|
ssr?: boolean;
|
3295
3304
|
}) => Promise<rollup.TransformResult> | rollup.TransformResult>;
|
3305
|
+
buildStart?: ModifyHookContext<rollup.Plugin<A>['buildStart'], PluginContext>;
|
3306
|
+
generateBundle?: ModifyHookContext<rollup.Plugin<A>['generateBundle'], PluginContext>;
|
3307
|
+
renderChunk?: ModifyHookContext<rollup.Plugin<A>['renderChunk'], PluginContext>;
|
3296
3308
|
}
|
3297
3309
|
type BoundedPlugin<A = any> = BasePlugin<A>;
|
3298
3310
|
interface Plugin<A = any> extends BasePlugin<A> {
|
@@ -3825,7 +3837,10 @@ interface LegacyOptions {
|
|
3825
3837
|
}
|
3826
3838
|
interface ResolvedWorkerOptions {
|
3827
3839
|
format: 'es' | 'iife';
|
3828
|
-
plugins: (bundleChain: string[]) => Promise<
|
3840
|
+
plugins: (bundleChain: string[]) => Promise<{
|
3841
|
+
plugins: Plugin[];
|
3842
|
+
config: ResolvedConfig;
|
3843
|
+
}>;
|
3829
3844
|
rollupOptions: RollupOptions;
|
3830
3845
|
}
|
3831
3846
|
interface InlineConfig extends UserConfig {
|
package/dist/node/index.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
export { parseAst, parseAstAsync } from 'rollup/parseAst';
|
2
|
-
import { i as isInNodeModules, a as arraify } from './chunks/dep-
|
3
|
-
export { B as BuildEnvironment, D as DevEnvironment, S as ServerHMRConnector, b as build, h as buildErrorMessage, e as createBuilder, u as createFilter, j as createNodeDevEnvironment, c as createServer, m as createServerModuleRunner, d as defineConfig, k as fetchModule, f as formatPostcssSourceMap, y as isFileServingAllowed, l as loadConfigFromFile, z as loadEnv, q as mergeAlias, o as mergeConfig, n as normalizePath, g as preprocessCSS, p as preview, r as resolveConfig, A as resolveEnvPrefix, v as rollupVersion, x as searchForWorkspaceRoot, w as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-
|
2
|
+
import { i as isInNodeModules, a as arraify } from './chunks/dep-8PNdpITG.js';
|
3
|
+
export { B as BuildEnvironment, D as DevEnvironment, S as ServerHMRConnector, b as build, h as buildErrorMessage, e as createBuilder, u as createFilter, j as createNodeDevEnvironment, c as createServer, m as createServerModuleRunner, d as defineConfig, k as fetchModule, f as formatPostcssSourceMap, y as isFileServingAllowed, l as loadConfigFromFile, z as loadEnv, q as mergeAlias, o as mergeConfig, n as normalizePath, g as preprocessCSS, p as preview, r as resolveConfig, A as resolveEnvPrefix, v as rollupVersion, x as searchForWorkspaceRoot, w as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-8PNdpITG.js';
|
4
4
|
export { VERSION as version } from './constants.js';
|
5
5
|
export { version as esbuildVersion } from 'esbuild';
|
6
6
|
export { c as createLogger } from './chunks/dep-C7zR1Rh8.js';
|