vite 2.7.0-beta.7 → 2.7.0-beta.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.
Potentially problematic release.
This version of vite might be problematic. Click here for more details.
- package/CHANGELOG.md +18 -1
- package/dist/client/client.mjs +1 -3
- package/dist/client/client.mjs.map +1 -1
- package/dist/node/chunks/{dep-606d0866.js → dep-03d6dbab.js} +2 -2
- package/dist/node/chunks/{dep-606d0866.js.map → dep-03d6dbab.js.map} +1 -1
- package/dist/node/chunks/{dep-9a51c06c.js → dep-8fdf8f48.js} +2 -2
- package/dist/node/chunks/{dep-9a51c06c.js.map → dep-8fdf8f48.js.map} +1 -1
- package/dist/node/chunks/{dep-707302f6.js → dep-b192ffe4.js} +2 -2
- package/dist/node/chunks/{dep-707302f6.js.map → dep-b192ffe4.js.map} +1 -1
- package/dist/node/chunks/{dep-56ab4c22.js → dep-d87be5e9.js} +254 -113
- package/dist/node/chunks/dep-d87be5e9.js.map +1 -0
- package/dist/node/cli.js +4 -4
- package/dist/node/index.d.ts +15 -2
- package/dist/node/index.js +1 -1
- package/package.json +1 -1
- package/src/client/client.ts +2 -6
- package/dist/node/chunks/dep-56ab4c22.js.map +0 -1
|
@@ -2961,7 +2961,7 @@ if (typeof process === 'undefined' || process.type === 'renderer' || process.bro
|
|
|
2961
2961
|
src$2.exports = node$1.exports;
|
|
2962
2962
|
}
|
|
2963
2963
|
|
|
2964
|
-
var debug$
|
|
2964
|
+
var debug$g = src$2.exports;
|
|
2965
2965
|
|
|
2966
2966
|
const DEFAULT_MAIN_FIELDS = [
|
|
2967
2967
|
'module',
|
|
@@ -2988,9 +2988,15 @@ const FS_PREFIX = `/@fs/`;
|
|
|
2988
2988
|
*/
|
|
2989
2989
|
const VALID_ID_PREFIX = `/@id/`;
|
|
2990
2990
|
/**
|
|
2991
|
-
*
|
|
2992
|
-
*
|
|
2993
|
-
*
|
|
2991
|
+
* Plugins that use 'virtual modules' (e.g. for helper functions), prefix the
|
|
2992
|
+
* module ID with `\0`, a convention from the rollup ecosystem.
|
|
2993
|
+
* This prevents other plugins from trying to process the id (like node resolution),
|
|
2994
|
+
* and core features like sourcemaps can use this info to differentiate between
|
|
2995
|
+
* virtual modules and regular files.
|
|
2996
|
+
* `\0` is not a permitted char in import URLs so we have to replace them during
|
|
2997
|
+
* import analysis. The id will be decoded back before entering the plugins pipeline.
|
|
2998
|
+
* These encoded virtual ids are also prefixed by the VALID_ID_PREFIX, so virtual
|
|
2999
|
+
* modules in the browser end up encoded as `/@id/__x00__{id}`
|
|
2994
3000
|
*/
|
|
2995
3001
|
const NULL_BYTE_PLACEHOLDER = `__x00__`;
|
|
2996
3002
|
const CLIENT_PUBLIC_PATH = `/@vite/client`;
|
|
@@ -3924,7 +3930,7 @@ function nestedResolveFrom(id, basedir, preserveSymlinks = false) {
|
|
|
3924
3930
|
const filter$1 = process.env.VITE_DEBUG_FILTER;
|
|
3925
3931
|
const DEBUG$1 = process.env.DEBUG;
|
|
3926
3932
|
function createDebugger(namespace, options = {}) {
|
|
3927
|
-
const log = debug$
|
|
3933
|
+
const log = debug$g(namespace);
|
|
3928
3934
|
const { onlyWhenFocused } = options;
|
|
3929
3935
|
const focus = typeof onlyWhenFocused === 'string' ? onlyWhenFocused : namespace;
|
|
3930
3936
|
return (msg, ...args) => {
|
|
@@ -20386,7 +20392,7 @@ async function compileCSS(id, code, config, urlReplacer, atImportResolvers, serv
|
|
|
20386
20392
|
replacer: urlReplacer
|
|
20387
20393
|
}));
|
|
20388
20394
|
if (isModule) {
|
|
20389
|
-
postcssPlugins.unshift((await Promise.resolve().then(function () { return require('./dep-
|
|
20395
|
+
postcssPlugins.unshift((await Promise.resolve().then(function () { return require('./dep-b192ffe4.js'); }).then(function (n) { return n.index; })).default({
|
|
20390
20396
|
...modulesOptions,
|
|
20391
20397
|
getJSON(cssFileName, _modules, outputFileName) {
|
|
20392
20398
|
modules = _modules;
|
|
@@ -21091,7 +21097,7 @@ function buildImportAnalysisPlugin(config) {
|
|
|
21091
21097
|
}
|
|
21092
21098
|
// Differentiate CSS imports that use the default export from those that
|
|
21093
21099
|
// do not by injecting a ?used query - this allows us to avoid including
|
|
21094
|
-
// the CSS string when unnecessary (esbuild has trouble
|
|
21100
|
+
// the CSS string when unnecessary (esbuild has trouble tree-shaking
|
|
21095
21101
|
// them)
|
|
21096
21102
|
if (specifier &&
|
|
21097
21103
|
isCSSRequest(specifier) &&
|
|
@@ -21351,7 +21357,7 @@ const assetAttrsConfig = {
|
|
|
21351
21357
|
const isAsyncScriptMap = new WeakMap();
|
|
21352
21358
|
async function traverseHtml(html, filePath, visitor) {
|
|
21353
21359
|
// lazy load compiler
|
|
21354
|
-
const { parse, transform } = await Promise.resolve().then(function () { return require('./dep-
|
|
21360
|
+
const { parse, transform } = await Promise.resolve().then(function () { return require('./dep-8fdf8f48.js'); }).then(function (n) { return n.compilerDom_cjs; });
|
|
21355
21361
|
// @vue/compiler-core doesn't like lowercase doctypes
|
|
21356
21362
|
html = html.replace(/<!doctype\s/i, '<!DOCTYPE ');
|
|
21357
21363
|
try {
|
|
@@ -22300,7 +22306,7 @@ var TSConfckParseError = class extends Error {
|
|
|
22300
22306
|
}
|
|
22301
22307
|
};
|
|
22302
22308
|
|
|
22303
|
-
const debug$
|
|
22309
|
+
const debug$f = createDebugger('vite:esbuild');
|
|
22304
22310
|
let server;
|
|
22305
22311
|
async function transformWithEsbuild(code, filename, options, inMap) {
|
|
22306
22312
|
var _a, _b, _c;
|
|
@@ -22390,7 +22396,7 @@ async function transformWithEsbuild(code, filename, options, inMap) {
|
|
|
22390
22396
|
};
|
|
22391
22397
|
}
|
|
22392
22398
|
catch (e) {
|
|
22393
|
-
debug$
|
|
22399
|
+
debug$f(`esbuild error with options used: `, resolvedOptions);
|
|
22394
22400
|
// patch error information
|
|
22395
22401
|
if (e.errors) {
|
|
22396
22402
|
e.frame = '';
|
|
@@ -29949,6 +29955,126 @@ function resolve(pkg, entry='.', options={}) {
|
|
|
29949
29955
|
}
|
|
29950
29956
|
}
|
|
29951
29957
|
|
|
29958
|
+
const isDebug$6 = process.env.DEBUG;
|
|
29959
|
+
const debug$e = createDebugger('vite:resolve-details', {
|
|
29960
|
+
onlyWhenFocused: true
|
|
29961
|
+
});
|
|
29962
|
+
function invalidatePackageData(packageCache, pkgPath) {
|
|
29963
|
+
packageCache.delete(pkgPath);
|
|
29964
|
+
const pkgDir = path__default.dirname(pkgPath);
|
|
29965
|
+
packageCache.forEach((pkg, cacheKey) => {
|
|
29966
|
+
if (pkg.dir === pkgDir) {
|
|
29967
|
+
packageCache.delete(cacheKey);
|
|
29968
|
+
}
|
|
29969
|
+
});
|
|
29970
|
+
}
|
|
29971
|
+
function resolvePackageData(id, basedir, preserveSymlinks = false, packageCache) {
|
|
29972
|
+
let pkg;
|
|
29973
|
+
let cacheKey;
|
|
29974
|
+
if (packageCache) {
|
|
29975
|
+
cacheKey = `${id}&${basedir}&${preserveSymlinks}`;
|
|
29976
|
+
if ((pkg = packageCache.get(cacheKey))) {
|
|
29977
|
+
return pkg;
|
|
29978
|
+
}
|
|
29979
|
+
}
|
|
29980
|
+
let pkgPath;
|
|
29981
|
+
try {
|
|
29982
|
+
pkgPath = resolveFrom$3(`${id}/package.json`, basedir, preserveSymlinks);
|
|
29983
|
+
pkg = loadPackageData(pkgPath, true, packageCache);
|
|
29984
|
+
if (packageCache) {
|
|
29985
|
+
packageCache.set(cacheKey, pkg);
|
|
29986
|
+
}
|
|
29987
|
+
return pkg;
|
|
29988
|
+
}
|
|
29989
|
+
catch (e) {
|
|
29990
|
+
if (e instanceof SyntaxError) {
|
|
29991
|
+
isDebug$6 && debug$e(`Parsing failed: ${pkgPath}`);
|
|
29992
|
+
}
|
|
29993
|
+
// Ignore error for missing package.json
|
|
29994
|
+
else if (e.code !== 'MODULE_NOT_FOUND') {
|
|
29995
|
+
throw e;
|
|
29996
|
+
}
|
|
29997
|
+
}
|
|
29998
|
+
return null;
|
|
29999
|
+
}
|
|
30000
|
+
function loadPackageData(pkgPath, preserveSymlinks, packageCache) {
|
|
30001
|
+
if (!preserveSymlinks) {
|
|
30002
|
+
pkgPath = fs__default.realpathSync.native(pkgPath);
|
|
30003
|
+
}
|
|
30004
|
+
let cached;
|
|
30005
|
+
if ((cached = packageCache === null || packageCache === void 0 ? void 0 : packageCache.get(pkgPath))) {
|
|
30006
|
+
return cached;
|
|
30007
|
+
}
|
|
30008
|
+
const data = JSON.parse(fs__default.readFileSync(pkgPath, 'utf-8'));
|
|
30009
|
+
const pkgDir = path__default.dirname(pkgPath);
|
|
30010
|
+
const { sideEffects } = data;
|
|
30011
|
+
let hasSideEffects;
|
|
30012
|
+
if (typeof sideEffects === 'boolean') {
|
|
30013
|
+
hasSideEffects = () => sideEffects;
|
|
30014
|
+
}
|
|
30015
|
+
else if (Array.isArray(sideEffects)) {
|
|
30016
|
+
hasSideEffects = createFilter$1(sideEffects, null, { resolve: pkgDir });
|
|
30017
|
+
}
|
|
30018
|
+
else {
|
|
30019
|
+
hasSideEffects = () => true;
|
|
30020
|
+
}
|
|
30021
|
+
const pkg = {
|
|
30022
|
+
dir: pkgDir,
|
|
30023
|
+
data,
|
|
30024
|
+
hasSideEffects,
|
|
30025
|
+
webResolvedImports: {},
|
|
30026
|
+
nodeResolvedImports: {},
|
|
30027
|
+
setResolvedCache(key, entry, targetWeb) {
|
|
30028
|
+
if (targetWeb) {
|
|
30029
|
+
pkg.webResolvedImports[key] = entry;
|
|
30030
|
+
}
|
|
30031
|
+
else {
|
|
30032
|
+
pkg.nodeResolvedImports[key] = entry;
|
|
30033
|
+
}
|
|
30034
|
+
},
|
|
30035
|
+
getResolvedCache(key, targetWeb) {
|
|
30036
|
+
if (targetWeb) {
|
|
30037
|
+
return pkg.webResolvedImports[key];
|
|
30038
|
+
}
|
|
30039
|
+
else {
|
|
30040
|
+
return pkg.nodeResolvedImports[key];
|
|
30041
|
+
}
|
|
30042
|
+
}
|
|
30043
|
+
};
|
|
30044
|
+
packageCache === null || packageCache === void 0 ? void 0 : packageCache.set(pkgPath, pkg);
|
|
30045
|
+
return pkg;
|
|
30046
|
+
}
|
|
30047
|
+
function watchPackageDataPlugin(config) {
|
|
30048
|
+
const watchQueue = new Set();
|
|
30049
|
+
let watchFile = (id) => {
|
|
30050
|
+
watchQueue.add(id);
|
|
30051
|
+
};
|
|
30052
|
+
const { packageCache } = config;
|
|
30053
|
+
const setPackageData = packageCache.set.bind(packageCache);
|
|
30054
|
+
packageCache.set = (id, pkg) => {
|
|
30055
|
+
if (id.endsWith('.json')) {
|
|
30056
|
+
watchFile(id);
|
|
30057
|
+
}
|
|
30058
|
+
return setPackageData(id, pkg);
|
|
30059
|
+
};
|
|
30060
|
+
return {
|
|
30061
|
+
name: 'vite:watch-package-data',
|
|
30062
|
+
buildStart() {
|
|
30063
|
+
watchFile = this.addWatchFile;
|
|
30064
|
+
watchQueue.forEach(watchFile);
|
|
30065
|
+
watchQueue.clear();
|
|
30066
|
+
},
|
|
30067
|
+
buildEnd() {
|
|
30068
|
+
watchFile = (id) => watchQueue.add(id);
|
|
30069
|
+
},
|
|
30070
|
+
watchChange(id) {
|
|
30071
|
+
if (id.endsWith('/package.json')) {
|
|
30072
|
+
invalidatePackageData(packageCache, id);
|
|
30073
|
+
}
|
|
30074
|
+
}
|
|
30075
|
+
};
|
|
30076
|
+
}
|
|
30077
|
+
|
|
29952
30078
|
// special id for paths marked with browser: false
|
|
29953
30079
|
// https://github.com/defunctzombie/package-browser-field-spec#ignore-a-module
|
|
29954
30080
|
const browserExternalId = '__vite-browser-external';
|
|
@@ -30158,12 +30284,17 @@ function tryResolveFile(file, postfix, options, tryIndex, targetWeb, tryPrefix,
|
|
|
30158
30284
|
else if (tryIndex) {
|
|
30159
30285
|
if (!skipPackageJson) {
|
|
30160
30286
|
const pkgPath = file + '/package.json';
|
|
30161
|
-
|
|
30287
|
+
try {
|
|
30162
30288
|
// path points to a node package
|
|
30163
|
-
const pkg = loadPackageData(pkgPath);
|
|
30289
|
+
const pkg = loadPackageData(pkgPath, options.preserveSymlinks);
|
|
30164
30290
|
const resolved = resolvePackageEntry(file, pkg, targetWeb, options);
|
|
30165
30291
|
return resolved;
|
|
30166
30292
|
}
|
|
30293
|
+
catch (e) {
|
|
30294
|
+
if (e.code !== 'ENOENT') {
|
|
30295
|
+
throw e;
|
|
30296
|
+
}
|
|
30297
|
+
}
|
|
30167
30298
|
}
|
|
30168
30299
|
const index = tryFsResolve(file + '/index', options);
|
|
30169
30300
|
if (index)
|
|
@@ -30183,7 +30314,7 @@ function tryResolveFile(file, postfix, options, tryIndex, targetWeb, tryPrefix,
|
|
|
30183
30314
|
const idToPkgMap = new Map();
|
|
30184
30315
|
function tryNodeResolve(id, importer, options, targetWeb, server, ssr) {
|
|
30185
30316
|
var _a, _b, _c;
|
|
30186
|
-
const { root, dedupe, isBuild } = options;
|
|
30317
|
+
const { root, dedupe, isBuild, preserveSymlinks, packageCache } = options;
|
|
30187
30318
|
// split id by last '>' for nested selected packages, for example:
|
|
30188
30319
|
// 'foo > bar > baz' => 'foo > bar' & 'baz'
|
|
30189
30320
|
// 'foo' => '' & 'foo'
|
|
@@ -30224,11 +30355,11 @@ function tryNodeResolve(id, importer, options, targetWeb, server, ssr) {
|
|
|
30224
30355
|
}
|
|
30225
30356
|
// nested node module, step-by-step resolve to the basedir of the nestedPath
|
|
30226
30357
|
if (nestedRoot) {
|
|
30227
|
-
basedir = nestedResolveFrom(nestedRoot, basedir,
|
|
30358
|
+
basedir = nestedResolveFrom(nestedRoot, basedir, preserveSymlinks);
|
|
30228
30359
|
}
|
|
30229
30360
|
let pkg;
|
|
30230
30361
|
const pkgId = possiblePkgIds.reverse().find((pkgId) => {
|
|
30231
|
-
pkg = resolvePackageData(pkgId, basedir,
|
|
30362
|
+
pkg = resolvePackageData(pkgId, basedir, preserveSymlinks, packageCache);
|
|
30232
30363
|
return pkg;
|
|
30233
30364
|
});
|
|
30234
30365
|
if (!pkg) {
|
|
@@ -30346,60 +30477,6 @@ function tryOptimizedResolve(id, server, importer) {
|
|
|
30346
30477
|
}
|
|
30347
30478
|
}
|
|
30348
30479
|
}
|
|
30349
|
-
const packageCache = new Map();
|
|
30350
|
-
function resolvePackageData(id, basedir, preserveSymlinks = false) {
|
|
30351
|
-
const cacheKey = id + basedir;
|
|
30352
|
-
if (packageCache.has(cacheKey)) {
|
|
30353
|
-
return packageCache.get(cacheKey);
|
|
30354
|
-
}
|
|
30355
|
-
try {
|
|
30356
|
-
const pkgPath = resolveFrom$3(`${id}/package.json`, basedir, preserveSymlinks);
|
|
30357
|
-
return loadPackageData(pkgPath, cacheKey);
|
|
30358
|
-
}
|
|
30359
|
-
catch (e) {
|
|
30360
|
-
isDebug$5 && debug$d(`${source.red(`[failed loading package.json]`)} ${id}`);
|
|
30361
|
-
}
|
|
30362
|
-
}
|
|
30363
|
-
function loadPackageData(pkgPath, cacheKey = pkgPath) {
|
|
30364
|
-
const data = JSON.parse(fs__default.readFileSync(pkgPath, 'utf-8'));
|
|
30365
|
-
const pkgDir = path__default.dirname(pkgPath);
|
|
30366
|
-
const { sideEffects } = data;
|
|
30367
|
-
let hasSideEffects;
|
|
30368
|
-
if (typeof sideEffects === 'boolean') {
|
|
30369
|
-
hasSideEffects = () => sideEffects;
|
|
30370
|
-
}
|
|
30371
|
-
else if (Array.isArray(sideEffects)) {
|
|
30372
|
-
hasSideEffects = createFilter$1(sideEffects, null, { resolve: pkgDir });
|
|
30373
|
-
}
|
|
30374
|
-
else {
|
|
30375
|
-
hasSideEffects = () => true;
|
|
30376
|
-
}
|
|
30377
|
-
const pkg = {
|
|
30378
|
-
dir: pkgDir,
|
|
30379
|
-
data,
|
|
30380
|
-
hasSideEffects,
|
|
30381
|
-
webResolvedImports: {},
|
|
30382
|
-
nodeResolvedImports: {},
|
|
30383
|
-
setResolvedCache(key, entry, targetWeb) {
|
|
30384
|
-
if (targetWeb) {
|
|
30385
|
-
pkg.webResolvedImports[key] = entry;
|
|
30386
|
-
}
|
|
30387
|
-
else {
|
|
30388
|
-
pkg.nodeResolvedImports[key] = entry;
|
|
30389
|
-
}
|
|
30390
|
-
},
|
|
30391
|
-
getResolvedCache(key, targetWeb) {
|
|
30392
|
-
if (targetWeb) {
|
|
30393
|
-
return pkg.webResolvedImports[key];
|
|
30394
|
-
}
|
|
30395
|
-
else {
|
|
30396
|
-
return pkg.nodeResolvedImports[key];
|
|
30397
|
-
}
|
|
30398
|
-
}
|
|
30399
|
-
};
|
|
30400
|
-
packageCache.set(cacheKey, pkg);
|
|
30401
|
-
return pkg;
|
|
30402
|
-
}
|
|
30403
30480
|
function resolvePackageEntry(id, { dir, data, setResolvedCache, getResolvedCache }, targetWeb, options) {
|
|
30404
30481
|
var _a, _b;
|
|
30405
30482
|
const cached = getResolvedCache('.', targetWeb);
|
|
@@ -43264,6 +43341,7 @@ function resolveBuildPlugins(config) {
|
|
|
43264
43341
|
const options = config.build;
|
|
43265
43342
|
return {
|
|
43266
43343
|
pre: [
|
|
43344
|
+
watchPackageDataPlugin(config),
|
|
43267
43345
|
buildHtmlPlugin(config),
|
|
43268
43346
|
commonjs(options.commonjsOptions),
|
|
43269
43347
|
dataURIPlugin(),
|
|
@@ -49375,7 +49453,7 @@ function readFileIfExists(value) {
|
|
|
49375
49453
|
* https://github.com/webpack/webpack-dev-server/blob/master/LICENSE
|
|
49376
49454
|
*/
|
|
49377
49455
|
async function createCertificate() {
|
|
49378
|
-
const { generate } = await Promise.resolve().then(function () { return require('./dep-
|
|
49456
|
+
const { generate } = await Promise.resolve().then(function () { return require('./dep-03d6dbab.js'); }).then(function (n) { return n.index; });
|
|
49379
49457
|
const pems = generate(null, {
|
|
49380
49458
|
algorithm: 'sha256',
|
|
49381
49459
|
days: 30,
|
|
@@ -56556,16 +56634,20 @@ function walk(root, { onIdentifier, onImportMeta, onDynamicImport }) {
|
|
|
56556
56634
|
// so that we don't prefix them
|
|
56557
56635
|
node.params.forEach((p) => walk$1(p.type === 'AssignmentPattern' ? p.left : p, {
|
|
56558
56636
|
enter(child, parent) {
|
|
56559
|
-
if (child.type
|
|
56560
|
-
|
|
56561
|
-
|
|
56562
|
-
|
|
56563
|
-
|
|
56564
|
-
|
|
56565
|
-
|
|
56566
|
-
|
|
56567
|
-
|
|
56637
|
+
if (child.type !== 'Identifier')
|
|
56638
|
+
return;
|
|
56639
|
+
// do not record as scope variable if is a destructuring keyword
|
|
56640
|
+
if (isStaticPropertyKey(child, parent))
|
|
56641
|
+
return;
|
|
56642
|
+
// do not record if this is a default value
|
|
56643
|
+
// assignment of a destructuring variable
|
|
56644
|
+
if (((parent === null || parent === void 0 ? void 0 : parent.type) === 'AssignmentPattern' &&
|
|
56645
|
+
(parent === null || parent === void 0 ? void 0 : parent.right) === child) ||
|
|
56646
|
+
((parent === null || parent === void 0 ? void 0 : parent.type) === 'TemplateLiteral' &&
|
|
56647
|
+
(parent === null || parent === void 0 ? void 0 : parent.expressions.includes(child)))) {
|
|
56648
|
+
return;
|
|
56568
56649
|
}
|
|
56650
|
+
setScope(node, child.name);
|
|
56569
56651
|
}
|
|
56570
56652
|
}));
|
|
56571
56653
|
}
|
|
@@ -56585,6 +56667,11 @@ function walk(root, { onIdentifier, onImportMeta, onDynamicImport }) {
|
|
|
56585
56667
|
}
|
|
56586
56668
|
});
|
|
56587
56669
|
}
|
|
56670
|
+
else if (node.id.type === 'ArrayPattern') {
|
|
56671
|
+
node.id.elements.forEach((element) => {
|
|
56672
|
+
setScope(parentFunction, element.name);
|
|
56673
|
+
});
|
|
56674
|
+
}
|
|
56588
56675
|
else {
|
|
56589
56676
|
setScope(parentFunction, node.id.name);
|
|
56590
56677
|
}
|
|
@@ -57781,7 +57868,7 @@ async function handleHMRUpdate(file, server) {
|
|
|
57781
57868
|
// auto restart server
|
|
57782
57869
|
debugHmr(`[config change] ${source.dim(shortFile)}`);
|
|
57783
57870
|
config.logger.info(source.green(`${path__default.relative(process.cwd(), file)} changed, restarting server...`), { clear: true, timestamp: true });
|
|
57784
|
-
await
|
|
57871
|
+
await server.restart();
|
|
57785
57872
|
return;
|
|
57786
57873
|
}
|
|
57787
57874
|
debugHmr(`[file change] ${source.dim(shortFile)}`);
|
|
@@ -58124,34 +58211,6 @@ async function readModifiedFile(file) {
|
|
|
58124
58211
|
return content;
|
|
58125
58212
|
}
|
|
58126
58213
|
}
|
|
58127
|
-
async function restartServer(server) {
|
|
58128
|
-
// @ts-ignore
|
|
58129
|
-
global.__vite_start_time = perf_hooks.performance.now();
|
|
58130
|
-
const { port } = server.config.server;
|
|
58131
|
-
await server.close();
|
|
58132
|
-
let newServer = null;
|
|
58133
|
-
try {
|
|
58134
|
-
newServer = await createServer(server.config.inlineConfig);
|
|
58135
|
-
}
|
|
58136
|
-
catch (err) {
|
|
58137
|
-
server.config.logger.error(err.message, {
|
|
58138
|
-
timestamp: true
|
|
58139
|
-
});
|
|
58140
|
-
return;
|
|
58141
|
-
}
|
|
58142
|
-
for (const key in newServer) {
|
|
58143
|
-
if (key !== 'app') {
|
|
58144
|
-
// @ts-ignore
|
|
58145
|
-
server[key] = newServer[key];
|
|
58146
|
-
}
|
|
58147
|
-
}
|
|
58148
|
-
if (!server.config.server.middlewareMode) {
|
|
58149
|
-
await server.listen(port, true);
|
|
58150
|
-
}
|
|
58151
|
-
else {
|
|
58152
|
-
server.config.logger.info('server restarted.', { timestamp: true });
|
|
58153
|
-
}
|
|
58154
|
-
}
|
|
58155
58214
|
|
|
58156
58215
|
var isWsl$2 = {exports: {}};
|
|
58157
58216
|
|
|
@@ -67461,9 +67520,21 @@ async function createServer(inlineConfig = {}) {
|
|
|
67461
67520
|
throw new Error('cannot print server URLs in middleware mode.');
|
|
67462
67521
|
}
|
|
67463
67522
|
},
|
|
67523
|
+
async restart(forceOptimize) {
|
|
67524
|
+
if (!server._restartPromise) {
|
|
67525
|
+
server._forceOptimizeOnRestart = !!forceOptimize;
|
|
67526
|
+
server._restartPromise = restartServer(server).finally(() => {
|
|
67527
|
+
server._restartPromise = null;
|
|
67528
|
+
server._forceOptimizeOnRestart = false;
|
|
67529
|
+
});
|
|
67530
|
+
}
|
|
67531
|
+
return server._restartPromise;
|
|
67532
|
+
},
|
|
67464
67533
|
_optimizeDepsMetadata: null,
|
|
67465
67534
|
_ssrExternals: null,
|
|
67466
67535
|
_globImporters: Object.create(null),
|
|
67536
|
+
_restartPromise: null,
|
|
67537
|
+
_forceOptimizeOnRestart: false,
|
|
67467
67538
|
_isRunningOptimizer: false,
|
|
67468
67539
|
_registerMissingImport: null,
|
|
67469
67540
|
_pendingReload: null,
|
|
@@ -67482,8 +67553,19 @@ async function createServer(inlineConfig = {}) {
|
|
|
67482
67553
|
if (!middlewareMode && process.env.CI !== 'true') {
|
|
67483
67554
|
process.stdin.on('end', exitProcess);
|
|
67484
67555
|
}
|
|
67556
|
+
const { packageCache } = config;
|
|
67557
|
+
const setPackageData = packageCache.set.bind(packageCache);
|
|
67558
|
+
packageCache.set = (id, pkg) => {
|
|
67559
|
+
if (id.endsWith('.json')) {
|
|
67560
|
+
watcher.add(id);
|
|
67561
|
+
}
|
|
67562
|
+
return setPackageData(id, pkg);
|
|
67563
|
+
};
|
|
67485
67564
|
watcher.on('change', async (file) => {
|
|
67486
67565
|
file = normalizePath$4(file);
|
|
67566
|
+
if (file.endsWith('/package.json')) {
|
|
67567
|
+
return invalidatePackageData(packageCache, file);
|
|
67568
|
+
}
|
|
67487
67569
|
// invalidate module graph cache on file change
|
|
67488
67570
|
moduleGraph.onFileChange(file);
|
|
67489
67571
|
if (serverConfig.hmr !== false) {
|
|
@@ -67578,7 +67660,7 @@ async function createServer(inlineConfig = {}) {
|
|
|
67578
67660
|
if (config.cacheDir) {
|
|
67579
67661
|
server._isRunningOptimizer = true;
|
|
67580
67662
|
try {
|
|
67581
|
-
server._optimizeDepsMetadata = await optimizeDeps(config);
|
|
67663
|
+
server._optimizeDepsMetadata = await optimizeDeps(config, config.server.force || server._forceOptimizeOnRestart);
|
|
67582
67664
|
}
|
|
67583
67665
|
finally {
|
|
67584
67666
|
server._isRunningOptimizer = false;
|
|
@@ -67707,6 +67789,34 @@ function resolveServerOptions(root, raw) {
|
|
|
67707
67789
|
};
|
|
67708
67790
|
return server;
|
|
67709
67791
|
}
|
|
67792
|
+
async function restartServer(server) {
|
|
67793
|
+
// @ts-ignore
|
|
67794
|
+
global.__vite_start_time = perf_hooks.performance.now();
|
|
67795
|
+
const { port } = server.config.server;
|
|
67796
|
+
await server.close();
|
|
67797
|
+
let newServer = null;
|
|
67798
|
+
try {
|
|
67799
|
+
newServer = await createServer(server.config.inlineConfig);
|
|
67800
|
+
}
|
|
67801
|
+
catch (err) {
|
|
67802
|
+
server.config.logger.error(err.message, {
|
|
67803
|
+
timestamp: true
|
|
67804
|
+
});
|
|
67805
|
+
return;
|
|
67806
|
+
}
|
|
67807
|
+
for (const key in newServer) {
|
|
67808
|
+
if (key !== 'app') {
|
|
67809
|
+
// @ts-ignore
|
|
67810
|
+
server[key] = newServer[key];
|
|
67811
|
+
}
|
|
67812
|
+
}
|
|
67813
|
+
if (!server.config.server.middlewareMode) {
|
|
67814
|
+
await server.listen(port, true);
|
|
67815
|
+
}
|
|
67816
|
+
else {
|
|
67817
|
+
server.config.logger.info('server restarted.', { timestamp: true });
|
|
67818
|
+
}
|
|
67819
|
+
}
|
|
67710
67820
|
|
|
67711
67821
|
var index = {
|
|
67712
67822
|
__proto__: null,
|
|
@@ -80942,6 +81052,12 @@ function importAnalysisPlugin(config) {
|
|
|
80942
81052
|
if (pluginImports) {
|
|
80943
81053
|
(await Promise.all([...pluginImports].map((id) => normalizeUrl(id, 0)))).forEach(([url]) => importedUrls.add(url));
|
|
80944
81054
|
}
|
|
81055
|
+
// HMR transforms are no-ops in SSR, so an `accept` call will
|
|
81056
|
+
// never be injected. Avoid updating the `isSelfAccepting`
|
|
81057
|
+
// property for our module node in that case.
|
|
81058
|
+
if (ssr && importerModule.isSelfAccepting) {
|
|
81059
|
+
isSelfAccepting = true;
|
|
81060
|
+
}
|
|
80945
81061
|
const prunedImports = await moduleGraph.updateModuleInfo(importerModule, importedUrls, normalizedAcceptedUrls, isSelfAccepting);
|
|
80946
81062
|
if (hasHMR && prunedImports) {
|
|
80947
81063
|
handlePrunedModules(prunedImports, server);
|
|
@@ -81002,11 +81118,14 @@ function transformCjsImport(importExp, url, rawUrl, importIndex) {
|
|
|
81002
81118
|
ecmaVersion: 'latest',
|
|
81003
81119
|
sourceType: 'module'
|
|
81004
81120
|
}).body[0];
|
|
81005
|
-
if (node.type === 'ImportDeclaration'
|
|
81121
|
+
if (node.type === 'ImportDeclaration' ||
|
|
81122
|
+
node.type === 'ExportNamedDeclaration') {
|
|
81006
81123
|
if (!node.specifiers.length) {
|
|
81007
81124
|
return `import "${url}"`;
|
|
81008
81125
|
}
|
|
81009
81126
|
const importNames = [];
|
|
81127
|
+
const exportNames = [];
|
|
81128
|
+
let defaultExports = '';
|
|
81010
81129
|
for (const spec of node.specifiers) {
|
|
81011
81130
|
if (spec.type === 'ImportSpecifier' &&
|
|
81012
81131
|
spec.imported.type === 'Identifier') {
|
|
@@ -81023,6 +81142,21 @@ function transformCjsImport(importExp, url, rawUrl, importIndex) {
|
|
|
81023
81142
|
else if (spec.type === 'ImportNamespaceSpecifier') {
|
|
81024
81143
|
importNames.push({ importedName: '*', localName: spec.local.name });
|
|
81025
81144
|
}
|
|
81145
|
+
else if (spec.type === 'ExportSpecifier' &&
|
|
81146
|
+
spec.exported.type === 'Identifier') {
|
|
81147
|
+
// for ExportSpecifier, local name is same as imported name
|
|
81148
|
+
const importedName = spec.local.name;
|
|
81149
|
+
// we want to specify exported name as variable and re-export it
|
|
81150
|
+
const exportedName = spec.exported.name;
|
|
81151
|
+
if (exportedName === 'default') {
|
|
81152
|
+
defaultExports = makeLegalIdentifier$1(`__vite__cjsExportDefault_${importIndex}`);
|
|
81153
|
+
importNames.push({ importedName, localName: defaultExports });
|
|
81154
|
+
}
|
|
81155
|
+
else {
|
|
81156
|
+
importNames.push({ importedName, localName: exportedName });
|
|
81157
|
+
exportNames.push(exportedName);
|
|
81158
|
+
}
|
|
81159
|
+
}
|
|
81026
81160
|
}
|
|
81027
81161
|
// If there is multiple import for same id in one file,
|
|
81028
81162
|
// importIndex will prevent the cjsModuleName to be duplicate
|
|
@@ -81039,6 +81173,12 @@ function transformCjsImport(importExp, url, rawUrl, importIndex) {
|
|
|
81039
81173
|
lines.push(`const ${localName} = ${cjsModuleName}["${importedName}"]`);
|
|
81040
81174
|
}
|
|
81041
81175
|
});
|
|
81176
|
+
if (defaultExports) {
|
|
81177
|
+
lines.push(`export default ${defaultExports}`);
|
|
81178
|
+
}
|
|
81179
|
+
if (exportNames.length) {
|
|
81180
|
+
lines.push(`export { ${exportNames.join(', ')} }`);
|
|
81181
|
+
}
|
|
81042
81182
|
return lines.join('; ');
|
|
81043
81183
|
}
|
|
81044
81184
|
}
|
|
@@ -81396,6 +81536,7 @@ async function resolvePlugins(config, prePlugins, normalPlugins, postPlugins) {
|
|
|
81396
81536
|
root: config.root,
|
|
81397
81537
|
isProduction: config.isProduction,
|
|
81398
81538
|
isBuild,
|
|
81539
|
+
packageCache: config.packageCache,
|
|
81399
81540
|
ssrConfig: config.ssr,
|
|
81400
81541
|
asSrc: true
|
|
81401
81542
|
}),
|
|
@@ -81772,6 +81913,7 @@ async function resolveConfig(inlineConfig, command, defaultMode = 'development')
|
|
|
81772
81913
|
return DEFAULT_ASSETS_RE.test(file) || assetsFilter(file);
|
|
81773
81914
|
},
|
|
81774
81915
|
logger,
|
|
81916
|
+
packageCache: new Map(),
|
|
81775
81917
|
createResolver,
|
|
81776
81918
|
optimizeDeps: {
|
|
81777
81919
|
...config.optimizeDeps,
|
|
@@ -82067,8 +82209,7 @@ async function loadConfigFromFile(configEnv, configFile, configRoot = process.cw
|
|
|
82067
82209
|
if (!userConfig) {
|
|
82068
82210
|
// 2. if we reach here, the file is ts or using es import syntax, or
|
|
82069
82211
|
// the user has type: "module" in their package.json (#917)
|
|
82070
|
-
// transpile es import syntax to require syntax using
|
|
82071
|
-
// lazy require rollup (it's actually in dependencies)
|
|
82212
|
+
// transpile es import syntax to require syntax using esbuild.
|
|
82072
82213
|
const bundled = await bundleConfigFile(resolvedPath);
|
|
82073
82214
|
dependencies = bundled.dependencies;
|
|
82074
82215
|
userConfig = await loadConfigFromBundledFile(resolvedPath, bundled.code);
|
|
@@ -82239,4 +82380,4 @@ exports.send = send$1;
|
|
|
82239
82380
|
exports.sortUserPlugins = sortUserPlugins;
|
|
82240
82381
|
exports.source = source;
|
|
82241
82382
|
exports.transformWithEsbuild = transformWithEsbuild;
|
|
82242
|
-
//# sourceMappingURL=dep-
|
|
82383
|
+
//# sourceMappingURL=dep-d87be5e9.js.map
|