vite 4.4.0 → 4.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of vite might be problematic. Click here for more details.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { F as commonjsGlobal, E as getDefaultExportFromCjs } from './dep-
|
|
1
|
+
import { F as commonjsGlobal, E as getDefaultExportFromCjs } from './dep-8609dc5d.js';
|
|
2
2
|
import require$$0__default from 'fs';
|
|
3
3
|
import require$$0 from 'postcss';
|
|
4
4
|
import require$$0$1 from 'path';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import fs$l from 'node:fs';
|
|
2
2
|
import fsp from 'node:fs/promises';
|
|
3
|
-
import path$o, { dirname as dirname$2, join as join$2,
|
|
3
|
+
import path$o, { dirname as dirname$2, join as join$2, posix as posix$1, isAbsolute as isAbsolute$2, relative as relative$2, basename as basename$2, extname as extname$1 } from 'node:path';
|
|
4
4
|
import { fileURLToPath, URL as URL$3, URLSearchParams, parse as parse$i, pathToFileURL } from 'node:url';
|
|
5
5
|
import { promisify as promisify$4, format as format$2, inspect } from 'node:util';
|
|
6
6
|
import { performance } from 'node:perf_hooks';
|
|
@@ -38634,6 +38634,49 @@ function createCSSResolvers(config) {
|
|
|
38634
38634
|
function getCssResolversKeys(resolvers) {
|
|
38635
38635
|
return Object.keys(resolvers);
|
|
38636
38636
|
}
|
|
38637
|
+
async function compileCSSPreprocessors(id, lang, code, config) {
|
|
38638
|
+
const { preprocessorOptions, devSourcemap } = config.css ?? {};
|
|
38639
|
+
const atImportResolvers = getAtImportResolvers(config);
|
|
38640
|
+
const preProcessor = preProcessors[lang];
|
|
38641
|
+
let opts = (preprocessorOptions && preprocessorOptions[lang]) || {};
|
|
38642
|
+
// support @import from node dependencies by default
|
|
38643
|
+
switch (lang) {
|
|
38644
|
+
case "scss" /* PreprocessLang.scss */:
|
|
38645
|
+
case "sass" /* PreprocessLang.sass */:
|
|
38646
|
+
opts = {
|
|
38647
|
+
includePaths: ['node_modules'],
|
|
38648
|
+
alias: config.resolve.alias,
|
|
38649
|
+
...opts,
|
|
38650
|
+
};
|
|
38651
|
+
break;
|
|
38652
|
+
case "less" /* PreprocessLang.less */:
|
|
38653
|
+
case "styl" /* PreprocessLang.styl */:
|
|
38654
|
+
case "stylus" /* PreprocessLang.stylus */:
|
|
38655
|
+
opts = {
|
|
38656
|
+
paths: ['node_modules'],
|
|
38657
|
+
alias: config.resolve.alias,
|
|
38658
|
+
...opts,
|
|
38659
|
+
};
|
|
38660
|
+
}
|
|
38661
|
+
// important: set this for relative import resolving
|
|
38662
|
+
opts.filename = cleanUrl(id);
|
|
38663
|
+
opts.enableSourcemap = devSourcemap ?? false;
|
|
38664
|
+
const preprocessResult = await preProcessor(code, config.root, opts, atImportResolvers);
|
|
38665
|
+
if (preprocessResult.error) {
|
|
38666
|
+
throw preprocessResult.error;
|
|
38667
|
+
}
|
|
38668
|
+
let deps;
|
|
38669
|
+
if (preprocessResult.deps) {
|
|
38670
|
+
const normalizedFilename = normalizePath$3(opts.filename);
|
|
38671
|
+
// sometimes sass registers the file itself as a dep
|
|
38672
|
+
deps = new Set([...preprocessResult.deps].filter((dep) => normalizePath$3(dep) !== normalizedFilename));
|
|
38673
|
+
}
|
|
38674
|
+
return {
|
|
38675
|
+
code: preprocessResult.code,
|
|
38676
|
+
map: combineSourcemapsIfExists(opts.filename, preprocessResult.map, preprocessResult.additionalMap),
|
|
38677
|
+
deps,
|
|
38678
|
+
};
|
|
38679
|
+
}
|
|
38637
38680
|
const configToAtImportResolvers = new WeakMap();
|
|
38638
38681
|
function getAtImportResolvers(config) {
|
|
38639
38682
|
let atImportResolvers = configToAtImportResolvers.get(config);
|
|
@@ -38647,7 +38690,7 @@ async function compileCSS(id, code, config, urlReplacer) {
|
|
|
38647
38690
|
if (config.css?.transformer === 'lightningcss') {
|
|
38648
38691
|
return compileLightningCSS(id, code, config, urlReplacer);
|
|
38649
38692
|
}
|
|
38650
|
-
const { modules: modulesOptions,
|
|
38693
|
+
const { modules: modulesOptions, devSourcemap } = config.css || {};
|
|
38651
38694
|
const isModule = modulesOptions !== false && cssModuleRE.test(id);
|
|
38652
38695
|
// although at serve time it can work without processing, we do need to
|
|
38653
38696
|
// crawl them in order to register watch dependencies.
|
|
@@ -38663,52 +38706,18 @@ async function compileCSS(id, code, config, urlReplacer) {
|
|
|
38663
38706
|
!hasUrl) {
|
|
38664
38707
|
return { code, map: null };
|
|
38665
38708
|
}
|
|
38666
|
-
let preprocessorMap;
|
|
38667
38709
|
let modules;
|
|
38668
38710
|
const deps = new Set();
|
|
38669
|
-
const atImportResolvers = getAtImportResolvers(config);
|
|
38670
38711
|
// 2. pre-processors: sass etc.
|
|
38712
|
+
let preprocessorMap;
|
|
38671
38713
|
if (isPreProcessor(lang)) {
|
|
38672
|
-
const
|
|
38673
|
-
|
|
38674
|
-
|
|
38675
|
-
|
|
38676
|
-
case "scss" /* PreprocessLang.scss */:
|
|
38677
|
-
case "sass" /* PreprocessLang.sass */:
|
|
38678
|
-
opts = {
|
|
38679
|
-
includePaths: ['node_modules'],
|
|
38680
|
-
alias: config.resolve.alias,
|
|
38681
|
-
...opts,
|
|
38682
|
-
};
|
|
38683
|
-
break;
|
|
38684
|
-
case "less" /* PreprocessLang.less */:
|
|
38685
|
-
case "styl" /* PreprocessLang.styl */:
|
|
38686
|
-
case "stylus" /* PreprocessLang.stylus */:
|
|
38687
|
-
opts = {
|
|
38688
|
-
paths: ['node_modules'],
|
|
38689
|
-
alias: config.resolve.alias,
|
|
38690
|
-
...opts,
|
|
38691
|
-
};
|
|
38692
|
-
}
|
|
38693
|
-
// important: set this for relative import resolving
|
|
38694
|
-
opts.filename = cleanUrl(id);
|
|
38695
|
-
opts.enableSourcemap = devSourcemap ?? false;
|
|
38696
|
-
const preprocessResult = await preProcessor(code, config.root, opts, atImportResolvers);
|
|
38697
|
-
if (preprocessResult.error) {
|
|
38698
|
-
throw preprocessResult.error;
|
|
38699
|
-
}
|
|
38700
|
-
code = preprocessResult.code;
|
|
38701
|
-
preprocessorMap = combineSourcemapsIfExists(opts.filename, preprocessResult.map, preprocessResult.additionalMap);
|
|
38702
|
-
if (preprocessResult.deps) {
|
|
38703
|
-
preprocessResult.deps.forEach((dep) => {
|
|
38704
|
-
// sometimes sass registers the file itself as a dep
|
|
38705
|
-
if (normalizePath$3(dep) !== normalizePath$3(opts.filename)) {
|
|
38706
|
-
deps.add(dep);
|
|
38707
|
-
}
|
|
38708
|
-
});
|
|
38709
|
-
}
|
|
38714
|
+
const preprocessorResult = await compileCSSPreprocessors(id, lang, code, config);
|
|
38715
|
+
code = preprocessorResult.code;
|
|
38716
|
+
preprocessorMap = preprocessorResult.map;
|
|
38717
|
+
preprocessorResult.deps?.forEach((dep) => deps.add(dep));
|
|
38710
38718
|
}
|
|
38711
38719
|
// 3. postcss
|
|
38720
|
+
const atImportResolvers = getAtImportResolvers(config);
|
|
38712
38721
|
const postcssOptions = (postcssConfig && postcssConfig.options) || {};
|
|
38713
38722
|
const postcssPlugins = postcssConfig && postcssConfig.plugins ? postcssConfig.plugins.slice() : [];
|
|
38714
38723
|
if (needInlineImport) {
|
|
@@ -38731,10 +38740,15 @@ async function compileCSS(id, code, config, urlReplacer) {
|
|
|
38731
38740
|
return id;
|
|
38732
38741
|
},
|
|
38733
38742
|
async load(id) {
|
|
38734
|
-
const code = fs$l.
|
|
38735
|
-
const
|
|
38736
|
-
|
|
38737
|
-
|
|
38743
|
+
const code = await fs$l.promises.readFile(id, 'utf-8');
|
|
38744
|
+
const lang = id.match(CSS_LANGS_RE)?.[1];
|
|
38745
|
+
if (isPreProcessor(lang)) {
|
|
38746
|
+
const result = await compileCSSPreprocessors(id, lang, code, config);
|
|
38747
|
+
result.deps?.forEach((dep) => deps.add(dep));
|
|
38748
|
+
// TODO: support source map
|
|
38749
|
+
return result.code;
|
|
38750
|
+
}
|
|
38751
|
+
return code;
|
|
38738
38752
|
},
|
|
38739
38753
|
nameLayer(index) {
|
|
38740
38754
|
return `vite--anon-layer-${getHash(id)}-${index}`;
|
|
@@ -38874,8 +38888,8 @@ function createCachedImport(imp) {
|
|
|
38874
38888
|
return cached;
|
|
38875
38889
|
};
|
|
38876
38890
|
}
|
|
38877
|
-
const importPostcssImport = createCachedImport(() => import('./dep-
|
|
38878
|
-
const importPostcssModules = createCachedImport(() => import('./dep-
|
|
38891
|
+
const importPostcssImport = createCachedImport(() => import('./dep-a00d73d3.js').then(function (n) { return n.i; }));
|
|
38892
|
+
const importPostcssModules = createCachedImport(() => import('./dep-1e231048.js').then(function (n) { return n.i; }));
|
|
38879
38893
|
const importPostcss = createCachedImport(() => import('postcss'));
|
|
38880
38894
|
/**
|
|
38881
38895
|
* @experimental
|
|
@@ -40903,7 +40917,7 @@ const createCssDefaultImportWarning = (globs, options) => `if (!${warnedCSSDefau
|
|
|
40903
40917
|
async function transformGlobImport(code, id, root, resolveId, isProduction, restoreQueryExtension = false) {
|
|
40904
40918
|
id = slash$1(id);
|
|
40905
40919
|
root = slash$1(root);
|
|
40906
|
-
const isVirtual =
|
|
40920
|
+
const isVirtual = isVirtualModule(id);
|
|
40907
40921
|
const dir = isVirtual ? undefined : dirname(id);
|
|
40908
40922
|
const matches = await parseImportGlob(code, isVirtual ? undefined : id, root, resolveId);
|
|
40909
40923
|
const matchedFiles = new Set();
|
|
@@ -41108,6 +41122,10 @@ function getCommonBase(globsResolved) {
|
|
|
41108
41122
|
commonAncestor = '/';
|
|
41109
41123
|
return commonAncestor;
|
|
41110
41124
|
}
|
|
41125
|
+
function isVirtualModule(id) {
|
|
41126
|
+
// https://vitejs.dev/guide/api-plugin.html#virtual-modules-convention
|
|
41127
|
+
return id.startsWith('virtual:') || id[0] === '\0' || !id.includes('/');
|
|
41128
|
+
}
|
|
41111
41129
|
|
|
41112
41130
|
const debugHmr = createDebugger('vite:hmr');
|
|
41113
41131
|
const whitespaceRE = /\s/;
|
|
@@ -41983,8 +42001,7 @@ function importAnalysisPlugin(config) {
|
|
|
41983
42001
|
// normalize and rewrite accepted urls
|
|
41984
42002
|
const normalizedAcceptedUrls = new Set();
|
|
41985
42003
|
for (const { url, start, end } of acceptedUrls) {
|
|
41986
|
-
const
|
|
41987
|
-
const [normalized] = await moduleGraph.resolveUrl(isRelative ? toAbsoluteUrl(url) : url, ssr);
|
|
42004
|
+
const [normalized] = await moduleGraph.resolveUrl(toAbsoluteUrl(url), ssr);
|
|
41988
42005
|
normalizedAcceptedUrls.add(normalized);
|
|
41989
42006
|
str().overwrite(start, end, JSON.stringify(normalized), {
|
|
41990
42007
|
contentOnly: true,
|
|
@@ -66068,18 +66085,19 @@ const _require = createRequire$1(import.meta.url);
|
|
|
66068
66085
|
async function loadConfigFromBundledFile(fileName, bundledCode, isESM) {
|
|
66069
66086
|
// for esm, before we can register loaders without requiring users to run node
|
|
66070
66087
|
// with --experimental-loader themselves, we have to do a hack here:
|
|
66071
|
-
//
|
|
66088
|
+
// write it to disk, load it with native Node ESM, then delete the file.
|
|
66072
66089
|
if (isESM) {
|
|
66090
|
+
const fileBase = `${fileName}.timestamp-${Date.now()}-${Math.random()
|
|
66091
|
+
.toString(16)
|
|
66092
|
+
.slice(2)}`;
|
|
66093
|
+
const fileNameTmp = `${fileBase}.mjs`;
|
|
66094
|
+
const fileUrl = `${pathToFileURL(fileBase)}.mjs`;
|
|
66095
|
+
await fsp.writeFile(fileNameTmp, bundledCode);
|
|
66073
66096
|
try {
|
|
66074
|
-
|
|
66075
|
-
const configTimestamp = `${fileName}.timestamp:${Date.now()}-${Math.random()
|
|
66076
|
-
.toString(16)
|
|
66077
|
-
.slice(2)}`;
|
|
66078
|
-
return (await dynamicImport('data:text/javascript;base64,' +
|
|
66079
|
-
Buffer.from(`${bundledCode}\n//${configTimestamp}`).toString('base64'))).default;
|
|
66097
|
+
return (await dynamicImport(fileUrl)).default;
|
|
66080
66098
|
}
|
|
66081
|
-
|
|
66082
|
-
|
|
66099
|
+
finally {
|
|
66100
|
+
fs$l.unlink(fileNameTmp, () => { }); // Ignore errors
|
|
66083
66101
|
}
|
|
66084
66102
|
}
|
|
66085
66103
|
// for cjs, we can register a custom loader via `_require.extensions`
|
package/dist/node/cli.js
CHANGED
|
@@ -2,7 +2,7 @@ import path from 'node:path';
|
|
|
2
2
|
import fs from 'node:fs';
|
|
3
3
|
import { performance } from 'node:perf_hooks';
|
|
4
4
|
import { EventEmitter } from 'events';
|
|
5
|
-
import { C as colors, D as bindShortcuts, x as createLogger, h as resolveConfig } from './chunks/dep-
|
|
5
|
+
import { C as colors, D as bindShortcuts, x as createLogger, h as resolveConfig } from './chunks/dep-8609dc5d.js';
|
|
6
6
|
import { VERSION } from './constants.js';
|
|
7
7
|
import 'node:fs/promises';
|
|
8
8
|
import 'node:url';
|
|
@@ -738,7 +738,7 @@ cli
|
|
|
738
738
|
filterDuplicateOptions(options);
|
|
739
739
|
// output structure is preserved even after bundling so require()
|
|
740
740
|
// is ok here
|
|
741
|
-
const { createServer } = await import('./chunks/dep-
|
|
741
|
+
const { createServer } = await import('./chunks/dep-8609dc5d.js').then(function (n) { return n.I; });
|
|
742
742
|
try {
|
|
743
743
|
const server = await createServer({
|
|
744
744
|
root,
|
|
@@ -816,7 +816,7 @@ cli
|
|
|
816
816
|
.option('-w, --watch', `[boolean] rebuilds when modules have changed on disk`)
|
|
817
817
|
.action(async (root, options) => {
|
|
818
818
|
filterDuplicateOptions(options);
|
|
819
|
-
const { build } = await import('./chunks/dep-
|
|
819
|
+
const { build } = await import('./chunks/dep-8609dc5d.js').then(function (n) { return n.H; });
|
|
820
820
|
const buildOptions = cleanOptions(options);
|
|
821
821
|
try {
|
|
822
822
|
await build({
|
|
@@ -844,7 +844,7 @@ cli
|
|
|
844
844
|
.option('--force', `[boolean] force the optimizer to ignore the cache and re-bundle`)
|
|
845
845
|
.action(async (root, options) => {
|
|
846
846
|
filterDuplicateOptions(options);
|
|
847
|
-
const { optimizeDeps } = await import('./chunks/dep-
|
|
847
|
+
const { optimizeDeps } = await import('./chunks/dep-8609dc5d.js').then(function (n) { return n.G; });
|
|
848
848
|
try {
|
|
849
849
|
const config = await resolveConfig({
|
|
850
850
|
root,
|
|
@@ -871,7 +871,7 @@ cli
|
|
|
871
871
|
.option('--outDir <dir>', `[string] output directory (default: dist)`)
|
|
872
872
|
.action(async (root, options) => {
|
|
873
873
|
filterDuplicateOptions(options);
|
|
874
|
-
const { preview } = await import('./chunks/dep-
|
|
874
|
+
const { preview } = await import('./chunks/dep-8609dc5d.js').then(function (n) { return n.J; });
|
|
875
875
|
try {
|
|
876
876
|
const server = await preview({
|
|
877
877
|
root,
|
package/dist/node/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as isInNodeModules } from './chunks/dep-
|
|
2
|
-
export { b as build, e as buildErrorMessage, v as createFilter, x as createLogger, c as createServer, g as defineConfig, f as formatPostcssSourceMap, k as getDepOptimizationConfig, m as isDepsOptimizerEnabled, z as isFileServingAllowed, l as loadConfigFromFile, A as loadEnv, u as mergeAlias, q as mergeConfig, n as normalizePath, o as optimizeDeps, a as preprocessCSS, p as preview, j as resolveBaseUrl, h as resolveConfig, B as resolveEnvPrefix, d as resolvePackageData, r as resolvePackageEntry, y as searchForWorkspaceRoot, w as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-
|
|
1
|
+
import { i as isInNodeModules } from './chunks/dep-8609dc5d.js';
|
|
2
|
+
export { b as build, e as buildErrorMessage, v as createFilter, x as createLogger, c as createServer, g as defineConfig, f as formatPostcssSourceMap, k as getDepOptimizationConfig, m as isDepsOptimizerEnabled, z as isFileServingAllowed, l as loadConfigFromFile, A as loadEnv, u as mergeAlias, q as mergeConfig, n as normalizePath, o as optimizeDeps, a as preprocessCSS, p as preview, j as resolveBaseUrl, h as resolveConfig, B as resolveEnvPrefix, d as resolvePackageData, r as resolvePackageEntry, y as searchForWorkspaceRoot, w as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-8609dc5d.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';
|