vite 2.9.9 → 3.0.0-alpha.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.
- package/LICENSE.md +29 -1
- package/bin/vite.js +5 -5
- package/client.d.ts +4 -3
- package/dist/client/client.mjs +28 -30
- package/dist/client/client.mjs.map +1 -1
- package/dist/client/env.mjs.map +1 -1
- package/dist/node/build.d.ts +178 -0
- package/dist/node/certificate.d.ts +2 -0
- package/dist/node/chunks/{dep-ac1ae66b.js → dep-205b15fe.js} +40 -37
- package/dist/node/chunks/{dep-a9015192.js → dep-24157481.js} +20 -20
- package/dist/node/chunks/{dep-59dc6e00.js → dep-c15b7842.js} +42425 -44710
- package/dist/node/chunks/{dep-d2c728c0.js → dep-c6d28e94.js} +28 -30
- package/dist/node/chunks/{dep-739cc694.js → dep-df464a73.js} +12 -6
- package/dist/node/chunks/{dep-2056ae8a.js → dep-e8ca8d40.js} +9 -3
- package/dist/node/cli.d.ts +1 -0
- package/dist/node/cli.js +41 -42
- package/dist/node/config.d.ts +243 -0
- package/dist/node/constants.d.ts +35 -0
- package/dist/node/constants.js +82 -0
- package/dist/node/http.d.ts +88 -0
- package/dist/node/index.d.ts +234 -160
- package/dist/node/index.js +37 -61
- package/dist/node/logger.d.ts +31 -0
- package/dist/node/optimizer/esbuildDepPlugin.d.ts +4 -0
- package/dist/node/optimizer/index.d.ts +154 -0
- package/dist/node/optimizer/registerMissing.d.ts +3 -0
- package/dist/node/optimizer/scan.d.ts +8 -0
- package/dist/node/packages.d.ts +27 -0
- package/dist/node/plugin.d.ts +129 -0
- package/dist/node/plugins/asset.d.ts +68 -0
- package/dist/node/plugins/assetImportMetaUrl.d.ts +13 -0
- package/dist/node/plugins/clientInjections.d.ts +7 -0
- package/dist/node/plugins/css.d.ts +86 -0
- package/dist/node/plugins/dataUri.d.ts +5 -0
- package/dist/node/plugins/define.d.ts +3 -0
- package/dist/node/plugins/dynamicImportVars.d.ts +9 -0
- package/dist/node/plugins/ensureWatch.d.ts +5 -0
- package/dist/node/plugins/esbuild.d.ts +15 -0
- package/dist/node/plugins/html.d.ts +120 -0
- package/dist/node/plugins/importAnalysis.d.ts +47 -0
- package/dist/node/plugins/importAnalysisBuild.d.ts +16 -0
- package/dist/node/plugins/importMetaGlob.d.ts +34 -0
- package/dist/node/plugins/index.d.ts +3 -0
- package/dist/node/plugins/json.d.ts +23 -0
- package/dist/node/plugins/loadFallback.d.ts +5 -0
- package/dist/node/plugins/manifest.d.ts +14 -0
- package/dist/node/plugins/metadata.d.ts +9 -0
- package/dist/node/plugins/modulePreloadPolyfill.d.ts +4 -0
- package/dist/node/plugins/optimizedDeps.d.ts +4 -0
- package/dist/node/plugins/preAlias.d.ts +5 -0
- package/dist/node/plugins/reporter.d.ts +3 -0
- package/dist/node/plugins/resolve.d.ts +39 -0
- package/dist/node/plugins/splitVendorChunk.d.ts +12 -0
- package/dist/node/plugins/ssrRequireHook.d.ts +12 -0
- package/dist/node/plugins/terser.d.ts +3 -0
- package/dist/node/plugins/wasm.d.ts +4 -0
- package/dist/node/plugins/worker.d.ts +9 -0
- package/dist/node/plugins/workerImportMetaUrl.d.ts +3 -0
- package/dist/node/preview.d.ts +33 -0
- package/dist/node/publicUtils.d.ts +10 -0
- package/dist/node/server/hmr.d.ts +39 -0
- package/dist/node/server/index.d.ts +198 -0
- package/dist/node/server/middlewares/base.d.ts +3 -0
- package/dist/node/server/middlewares/compression.d.ts +1 -0
- package/dist/node/server/middlewares/error.d.ts +8 -0
- package/dist/node/server/middlewares/indexHtml.d.ts +4 -0
- package/dist/node/server/middlewares/proxy.d.ts +20 -0
- package/dist/node/server/middlewares/spaFallback.d.ts +2 -0
- package/dist/node/server/middlewares/static.d.ts +6 -0
- package/dist/node/server/middlewares/time.d.ts +2 -0
- package/dist/node/server/middlewares/transform.d.ts +3 -0
- package/dist/node/server/moduleGraph.d.ts +55 -0
- package/dist/node/server/openBrowser.d.ts +15 -0
- package/dist/node/server/pluginContainer.d.ts +41 -0
- package/dist/node/server/searchRoot.d.ts +8 -0
- package/dist/node/server/send.d.ts +10 -0
- package/dist/node/server/sourcemap.d.ts +11 -0
- package/dist/node/server/transformRequest.d.ts +14 -0
- package/dist/node/server/ws.d.ts +55 -0
- package/dist/node/ssr/ssrExternal.d.ts +11 -0
- package/dist/node/ssr/ssrManifestPlugin.d.ts +3 -0
- package/dist/node/ssr/ssrModuleLoader.d.ts +7 -0
- package/dist/node/ssr/ssrStacktrace.d.ts +3 -0
- package/dist/node/ssr/ssrTransform.d.ts +14 -0
- package/dist/node/utils.d.ts +145 -0
- package/dist/node-cjs/publicUtils.cjs +1788 -0
- package/dist/{node/terser.js → node-cjs/terser.cjs} +0 -0
- package/index.cjs +33 -0
- package/package.json +31 -27
- package/src/client/client.ts +27 -29
- package/src/client/tsconfig.json +1 -1
- package/types/chokidar.d.ts +4 -2
- package/types/hot.d.ts +0 -6
- package/types/importGlob.d.ts +87 -0
- package/types/importMeta.d.ts +5 -15
- package/types/shims.d.ts +6 -9
- package/types/terser.d.ts +0 -2
- package/types/ws.d.ts +2 -2
|
@@ -1,15 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import require$$0 from 'postcss';
|
|
2
|
+
import { v as commonjsGlobal } from './dep-c15b7842.js';
|
|
3
|
+
import path$2 from 'path';
|
|
4
|
+
import require$$1 from 'crypto';
|
|
5
|
+
import fs__default from 'fs';
|
|
6
|
+
import require$$0$1 from 'util';
|
|
7
|
+
import { l as lib$1 } from './dep-e8ca8d40.js';
|
|
8
|
+
|
|
9
|
+
import { fileURLToPath as __cjs_fileURLToPath } from 'url';
|
|
10
|
+
import { dirname as __cjs_dirname } from 'path';
|
|
11
|
+
import { createRequire as __cjs_createRequire } from 'module';
|
|
12
|
+
|
|
13
|
+
const __filename = __cjs_fileURLToPath(import.meta.url);
|
|
14
|
+
const __dirname = __cjs_dirname(__filename);
|
|
15
|
+
const require = __cjs_createRequire(import.meta.url);
|
|
16
|
+
const __require = require;
|
|
13
17
|
function _mergeNamespaces(n, m) {
|
|
14
18
|
for (var i = 0; i < m.length; i++) {
|
|
15
19
|
var e = m[i];
|
|
@@ -22,12 +26,6 @@ function _mergeNamespaces(n, m) {
|
|
|
22
26
|
return n;
|
|
23
27
|
}
|
|
24
28
|
|
|
25
|
-
var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0);
|
|
26
|
-
var path__default = /*#__PURE__*/_interopDefaultLegacy(path$2);
|
|
27
|
-
var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1);
|
|
28
|
-
var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
|
|
29
|
-
var require$$0__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$0$1);
|
|
30
|
-
|
|
31
29
|
var build$1 = {exports: {}};
|
|
32
30
|
|
|
33
31
|
/**
|
|
@@ -181,7 +179,7 @@ var deburredLetters = {
|
|
|
181
179
|
};
|
|
182
180
|
|
|
183
181
|
/** Detect free variable `global` from Node.js. */
|
|
184
|
-
var freeGlobal = typeof
|
|
182
|
+
var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
|
|
185
183
|
|
|
186
184
|
/** Detect free variable `self`. */
|
|
187
185
|
var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
|
|
@@ -1138,7 +1136,7 @@ function getHashDigest$1(buffer, algorithm, digestType, maxLength) {
|
|
|
1138
1136
|
hash = new BatchedHash(createMd4());
|
|
1139
1137
|
} else if (algorithm === "native-md4") {
|
|
1140
1138
|
if (typeof crypto === "undefined") {
|
|
1141
|
-
crypto = require$$
|
|
1139
|
+
crypto = require$$1;
|
|
1142
1140
|
|
|
1143
1141
|
if (BulkUpdateDecorator === undefined) {
|
|
1144
1142
|
BulkUpdateDecorator = BulkUpdateDecorator_1;
|
|
@@ -1148,7 +1146,7 @@ function getHashDigest$1(buffer, algorithm, digestType, maxLength) {
|
|
|
1148
1146
|
hash = new BulkUpdateDecorator(() => crypto.createHash("md4"), "md4");
|
|
1149
1147
|
} else {
|
|
1150
1148
|
if (typeof crypto === "undefined") {
|
|
1151
|
-
crypto = require$$
|
|
1149
|
+
crypto = require$$1;
|
|
1152
1150
|
|
|
1153
1151
|
if (BulkUpdateDecorator === undefined) {
|
|
1154
1152
|
BulkUpdateDecorator = BulkUpdateDecorator_1;
|
|
@@ -1180,7 +1178,7 @@ function getHashDigest$1(buffer, algorithm, digestType, maxLength) {
|
|
|
1180
1178
|
|
|
1181
1179
|
var getHashDigest_1 = getHashDigest$1;
|
|
1182
1180
|
|
|
1183
|
-
const path$1 =
|
|
1181
|
+
const path$1 = path$2;
|
|
1184
1182
|
const getHashDigest = getHashDigest_1;
|
|
1185
1183
|
|
|
1186
1184
|
function interpolateName$1(loaderContext, name, options = {}) {
|
|
@@ -1296,7 +1294,7 @@ function interpolateName$1(loaderContext, name, options = {}) {
|
|
|
1296
1294
|
var interpolateName_1 = interpolateName$1;
|
|
1297
1295
|
|
|
1298
1296
|
var interpolateName = interpolateName_1;
|
|
1299
|
-
var path =
|
|
1297
|
+
var path = path$2;
|
|
1300
1298
|
|
|
1301
1299
|
/**
|
|
1302
1300
|
* @param {string} pattern
|
|
@@ -1480,7 +1478,7 @@ Object.defineProperty(loader, "__esModule", {
|
|
|
1480
1478
|
value: true
|
|
1481
1479
|
});
|
|
1482
1480
|
|
|
1483
|
-
var _postcss$1 = require$$
|
|
1481
|
+
var _postcss$1 = require$$0;
|
|
1484
1482
|
|
|
1485
1483
|
var _postcss2$1 = _interopRequireDefault$5(_postcss$1);
|
|
1486
1484
|
|
|
@@ -1488,7 +1486,7 @@ var _fs$1 = fs__default;
|
|
|
1488
1486
|
|
|
1489
1487
|
var _fs2 = _interopRequireDefault$5(_fs$1);
|
|
1490
1488
|
|
|
1491
|
-
var _path =
|
|
1489
|
+
var _path = path$2;
|
|
1492
1490
|
|
|
1493
1491
|
var _path2 = _interopRequireDefault$5(_path);
|
|
1494
1492
|
|
|
@@ -3113,7 +3111,7 @@ var attribute$1 = {};
|
|
|
3113
3111
|
* For Node.js, simply re-export the core `util.deprecate` function.
|
|
3114
3112
|
*/
|
|
3115
3113
|
|
|
3116
|
-
var node = require$$
|
|
3114
|
+
var node = require$$0$1.deprecate;
|
|
3117
3115
|
|
|
3118
3116
|
(function (exports) {
|
|
3119
3117
|
|
|
@@ -5731,7 +5729,7 @@ var isUniversal = isNodeType.bind(null, _types.UNIVERSAL);
|
|
|
5731
5729
|
guards.isUniversal = isUniversal;
|
|
5732
5730
|
|
|
5733
5731
|
function isPseudoElement(node) {
|
|
5734
|
-
return isPseudo(node) && node.value && (node.value.startsWith("::") || node.value.toLowerCase() === ":before" || node.value.toLowerCase() === ":after");
|
|
5732
|
+
return isPseudo(node) && node.value && (node.value.startsWith("::") || node.value.toLowerCase() === ":before" || node.value.toLowerCase() === ":after" || node.value.toLowerCase() === ":first-letter" || node.value.toLowerCase() === ":first-line");
|
|
5735
5733
|
}
|
|
5736
5734
|
|
|
5737
5735
|
function isPseudoClass(node) {
|
|
@@ -6001,7 +5999,7 @@ var src$3 = {
|
|
|
6001
5999
|
};
|
|
6002
6000
|
|
|
6003
6001
|
const selectorParser$1 = dist.exports;
|
|
6004
|
-
const valueParser =
|
|
6002
|
+
const valueParser = lib$1;
|
|
6005
6003
|
const { extractICSS } = src$3;
|
|
6006
6004
|
|
|
6007
6005
|
const isSpacing = (node) => node.type === "combinator" && node.value === " ";
|
|
@@ -7315,7 +7313,7 @@ function isValidBehaviour(behaviour) {
|
|
|
7315
7313
|
return Object.keys(behaviours).map(key => behaviours[key]).indexOf(behaviour) > -1;
|
|
7316
7314
|
}
|
|
7317
7315
|
|
|
7318
|
-
var _postcss = require$$
|
|
7316
|
+
var _postcss = require$$0;
|
|
7319
7317
|
|
|
7320
7318
|
var _postcss2 = _interopRequireDefault(_postcss);
|
|
7321
7319
|
|
|
@@ -7504,4 +7502,4 @@ var index = /*#__PURE__*/_mergeNamespaces({
|
|
|
7504
7502
|
postcss: postcss
|
|
7505
7503
|
}, [build$1.exports]);
|
|
7506
7504
|
|
|
7507
|
-
|
|
7505
|
+
export { index as i };
|
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
import { w as getAugmentedNamespace, x as getDefaultExportFromCjs } from './dep-c15b7842.js';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import { fileURLToPath as __cjs_fileURLToPath } from 'url';
|
|
4
|
+
import { dirname as __cjs_dirname } from 'path';
|
|
5
|
+
import { createRequire as __cjs_createRequire } from 'module';
|
|
4
6
|
|
|
7
|
+
const __filename = __cjs_fileURLToPath(import.meta.url);
|
|
8
|
+
const __dirname = __cjs_dirname(__filename);
|
|
9
|
+
const require = __cjs_createRequire(import.meta.url);
|
|
10
|
+
const __require = require;
|
|
5
11
|
function _mergeNamespaces(n, m) {
|
|
6
12
|
for (var i = 0; i < m.length; i++) {
|
|
7
13
|
var e = m[i];
|
|
@@ -5642,9 +5648,9 @@ var compilerCore_esmBundler = {
|
|
|
5642
5648
|
generateCodeFrame: generateCodeFrame
|
|
5643
5649
|
};
|
|
5644
5650
|
|
|
5645
|
-
var require$$0 = /*@__PURE__*/
|
|
5651
|
+
var require$$0 = /*@__PURE__*/getAugmentedNamespace(compilerCore_esmBundler);
|
|
5646
5652
|
|
|
5647
|
-
var require$$1 = /*@__PURE__*/
|
|
5653
|
+
var require$$1 = /*@__PURE__*/getAugmentedNamespace(shared_esmBundler);
|
|
5648
5654
|
|
|
5649
5655
|
(function (exports) {
|
|
5650
5656
|
|
|
@@ -8747,11 +8753,11 @@ exports.parserOptions = parserOptions;
|
|
|
8747
8753
|
exports.transformStyle = transformStyle;
|
|
8748
8754
|
}(compilerDom_cjs$2));
|
|
8749
8755
|
|
|
8750
|
-
var compilerDom_cjs = /*@__PURE__*/
|
|
8756
|
+
var compilerDom_cjs = /*@__PURE__*/getDefaultExportFromCjs(compilerDom_cjs$2);
|
|
8751
8757
|
|
|
8752
8758
|
var compilerDom_cjs$1 = /*#__PURE__*/_mergeNamespaces({
|
|
8753
8759
|
__proto__: null,
|
|
8754
8760
|
'default': compilerDom_cjs
|
|
8755
8761
|
}, [compilerDom_cjs$2]);
|
|
8756
8762
|
|
|
8757
|
-
|
|
8763
|
+
export { compilerDom_cjs$1 as c };
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { fileURLToPath as __cjs_fileURLToPath } from 'url';
|
|
2
|
+
import { dirname as __cjs_dirname } from 'path';
|
|
3
|
+
import { createRequire as __cjs_createRequire } from 'module';
|
|
4
|
+
|
|
5
|
+
const __filename = __cjs_fileURLToPath(import.meta.url);
|
|
6
|
+
const __dirname = __cjs_dirname(__filename);
|
|
7
|
+
const require = __cjs_createRequire(import.meta.url);
|
|
8
|
+
const __require = require;
|
|
3
9
|
var openParentheses = "(".charCodeAt(0);
|
|
4
10
|
var closeParentheses = ")".charCodeAt(0);
|
|
5
11
|
var singleQuote = "'".charCodeAt(0);
|
|
@@ -544,4 +550,4 @@ ValueParser.stringify = stringify;
|
|
|
544
550
|
|
|
545
551
|
var lib = ValueParser;
|
|
546
552
|
|
|
547
|
-
|
|
553
|
+
export { lib as l };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/node/cli.js
CHANGED
|
@@ -1,30 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
require('readline');
|
|
1
|
+
import { performance } from 'perf_hooks';
|
|
2
|
+
import { EventEmitter } from 'events';
|
|
3
|
+
import { u as colors, k as createLogger, e as resolveConfig } from './chunks/dep-c15b7842.js';
|
|
4
|
+
import { VERSION } from './constants.js';
|
|
5
|
+
import 'fs';
|
|
6
|
+
import 'path';
|
|
7
|
+
import 'url';
|
|
8
|
+
import 'module';
|
|
9
|
+
import 'tty';
|
|
10
|
+
import 'os';
|
|
11
|
+
import 'esbuild';
|
|
12
|
+
import 'assert';
|
|
13
|
+
import 'resolve';
|
|
14
|
+
import 'util';
|
|
15
|
+
import 'net';
|
|
16
|
+
import 'http';
|
|
17
|
+
import 'stream';
|
|
18
|
+
import 'child_process';
|
|
19
|
+
import 'crypto';
|
|
20
|
+
import 'buffer';
|
|
21
|
+
import 'querystring';
|
|
22
|
+
import 'zlib';
|
|
23
|
+
import 'https';
|
|
24
|
+
import 'tls';
|
|
25
|
+
import 'worker_threads';
|
|
26
|
+
import 'readline';
|
|
28
27
|
|
|
29
28
|
function toArr(any) {
|
|
30
29
|
return any == null ? [] : Array.isArray(any) ? any : [any];
|
|
@@ -449,7 +448,7 @@ class GlobalCommand extends Command {
|
|
|
449
448
|
}
|
|
450
449
|
|
|
451
450
|
var __assign = Object.assign;
|
|
452
|
-
class CAC extends
|
|
451
|
+
class CAC extends EventEmitter {
|
|
453
452
|
constructor(name = "") {
|
|
454
453
|
super();
|
|
455
454
|
this.name = name;
|
|
@@ -683,7 +682,7 @@ cli
|
|
|
683
682
|
.action(async (root, options) => {
|
|
684
683
|
// output structure is preserved even after bundling so require()
|
|
685
684
|
// is ok here
|
|
686
|
-
const { createServer } = await
|
|
685
|
+
const { createServer } = await import('./chunks/dep-c15b7842.js').then(function (n) { return n.A; });
|
|
687
686
|
try {
|
|
688
687
|
const server = await createServer({
|
|
689
688
|
root,
|
|
@@ -699,20 +698,20 @@ cli
|
|
|
699
698
|
}
|
|
700
699
|
await server.listen();
|
|
701
700
|
const info = server.config.logger.info;
|
|
702
|
-
info(
|
|
703
|
-
|
|
701
|
+
info(colors.cyan(`\n vite v${VERSION}`) +
|
|
702
|
+
colors.green(` dev server running at:\n`), {
|
|
704
703
|
clear: !server.config.logger.hasWarned
|
|
705
704
|
});
|
|
706
705
|
server.printUrls();
|
|
707
706
|
// @ts-ignore
|
|
708
707
|
if (global.__vite_start_time) {
|
|
709
708
|
// @ts-ignore
|
|
710
|
-
const startupDuration =
|
|
711
|
-
info(`\n ${
|
|
709
|
+
const startupDuration = performance.now() - global.__vite_start_time;
|
|
710
|
+
info(`\n ${colors.cyan(`ready in ${Math.ceil(startupDuration)}ms.`)}\n`);
|
|
712
711
|
}
|
|
713
712
|
}
|
|
714
713
|
catch (e) {
|
|
715
|
-
|
|
714
|
+
createLogger(options.logLevel).error(colors.red(`error when starting dev server:\n${e.stack}`), { error: e });
|
|
716
715
|
process.exit(1);
|
|
717
716
|
}
|
|
718
717
|
});
|
|
@@ -732,7 +731,7 @@ cli
|
|
|
732
731
|
.option('--emptyOutDir', `[boolean] force empty outDir when it's outside of root`)
|
|
733
732
|
.option('-w, --watch', `[boolean] rebuilds when modules have changed on disk`)
|
|
734
733
|
.action(async (root, options) => {
|
|
735
|
-
const { build } = await
|
|
734
|
+
const { build } = await import('./chunks/dep-c15b7842.js').then(function (n) { return n.z; });
|
|
736
735
|
const buildOptions = cleanOptions(options);
|
|
737
736
|
try {
|
|
738
737
|
await build({
|
|
@@ -746,7 +745,7 @@ cli
|
|
|
746
745
|
});
|
|
747
746
|
}
|
|
748
747
|
catch (e) {
|
|
749
|
-
|
|
748
|
+
createLogger(options.logLevel).error(colors.red(`error during build:\n${e.stack}`), { error: e });
|
|
750
749
|
process.exit(1);
|
|
751
750
|
}
|
|
752
751
|
});
|
|
@@ -755,9 +754,9 @@ cli
|
|
|
755
754
|
.command('optimize [root]', 'pre-bundle dependencies')
|
|
756
755
|
.option('--force', `[boolean] force the optimizer to ignore the cache and re-bundle`)
|
|
757
756
|
.action(async (root, options) => {
|
|
758
|
-
const { optimizeDeps } = await
|
|
757
|
+
const { optimizeDeps } = await import('./chunks/dep-c15b7842.js').then(function (n) { return n.y; });
|
|
759
758
|
try {
|
|
760
|
-
const config = await
|
|
759
|
+
const config = await resolveConfig({
|
|
761
760
|
root,
|
|
762
761
|
base: options.base,
|
|
763
762
|
configFile: options.config,
|
|
@@ -766,7 +765,7 @@ cli
|
|
|
766
765
|
await optimizeDeps(config, options.force, true);
|
|
767
766
|
}
|
|
768
767
|
catch (e) {
|
|
769
|
-
|
|
768
|
+
createLogger(options.logLevel).error(colors.red(`error when optimizing deps:\n${e.stack}`), { error: e });
|
|
770
769
|
process.exit(1);
|
|
771
770
|
}
|
|
772
771
|
});
|
|
@@ -778,7 +777,7 @@ cli
|
|
|
778
777
|
.option('--https', `[boolean] use TLS + HTTP/2`)
|
|
779
778
|
.option('--open [path]', `[boolean | string] open browser on startup`)
|
|
780
779
|
.action(async (root, options) => {
|
|
781
|
-
const { preview } = await
|
|
780
|
+
const { preview } = await import('./chunks/dep-c15b7842.js').then(function (n) { return n.B; });
|
|
782
781
|
try {
|
|
783
782
|
const server = await preview({
|
|
784
783
|
root,
|
|
@@ -797,10 +796,10 @@ cli
|
|
|
797
796
|
server.printUrls();
|
|
798
797
|
}
|
|
799
798
|
catch (e) {
|
|
800
|
-
|
|
799
|
+
createLogger(options.logLevel).error(colors.red(`error when starting preview server:\n${e.stack}`), { error: e });
|
|
801
800
|
process.exit(1);
|
|
802
801
|
}
|
|
803
802
|
});
|
|
804
803
|
cli.help();
|
|
805
|
-
cli.version(
|
|
804
|
+
cli.version(VERSION);
|
|
806
805
|
cli.parse();
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import type { Alias, AliasOptions } from 'types/alias';
|
|
2
|
+
import type { RollupOptions } from 'rollup';
|
|
3
|
+
import type { Plugin } from './plugin';
|
|
4
|
+
import type { BuildOptions } from './build';
|
|
5
|
+
import type { ResolvedServerOptions, ServerOptions } from './server';
|
|
6
|
+
import type { PreviewOptions, ResolvedPreviewOptions } from './preview';
|
|
7
|
+
import type { CSSOptions } from './plugins/css';
|
|
8
|
+
import type { ESBuildOptions } from './plugins/esbuild';
|
|
9
|
+
import type { InternalResolveOptions, ResolveOptions } from './plugins/resolve';
|
|
10
|
+
import type { LogLevel, Logger } from './logger';
|
|
11
|
+
import type { DepOptimizationOptions } from './optimizer';
|
|
12
|
+
import type { JsonOptions } from './plugins/json';
|
|
13
|
+
import type { PackageCache } from './packages';
|
|
14
|
+
import type { ResolvedBuildOptions } from '.';
|
|
15
|
+
export interface ConfigEnv {
|
|
16
|
+
command: 'build' | 'serve';
|
|
17
|
+
mode: string;
|
|
18
|
+
}
|
|
19
|
+
export declare type UserConfigFn = (env: ConfigEnv) => UserConfig | Promise<UserConfig>;
|
|
20
|
+
export declare type UserConfigExport = UserConfig | Promise<UserConfig> | UserConfigFn;
|
|
21
|
+
/**
|
|
22
|
+
* Type helper to make it easier to use vite.config.ts
|
|
23
|
+
* accepts a direct {@link UserConfig} object, or a function that returns it.
|
|
24
|
+
* The function receives a {@link ConfigEnv} object that exposes two properties:
|
|
25
|
+
* `command` (either `'build'` or `'serve'`), and `mode`.
|
|
26
|
+
*/
|
|
27
|
+
export declare function defineConfig(config: UserConfigExport): UserConfigExport;
|
|
28
|
+
export declare type PluginOption = Plugin | false | null | undefined | PluginOption[];
|
|
29
|
+
export interface UserConfig {
|
|
30
|
+
/**
|
|
31
|
+
* Project root directory. Can be an absolute path, or a path relative from
|
|
32
|
+
* the location of the config file itself.
|
|
33
|
+
* @default process.cwd()
|
|
34
|
+
*/
|
|
35
|
+
root?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Base public path when served in development or production.
|
|
38
|
+
* @default '/'
|
|
39
|
+
*/
|
|
40
|
+
base?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Directory to serve as plain static assets. Files in this directory are
|
|
43
|
+
* served and copied to build dist dir as-is without transform. The value
|
|
44
|
+
* can be either an absolute file system path or a path relative to <root>.
|
|
45
|
+
*
|
|
46
|
+
* Set to `false` or an empty string to disable copied static assets to build dist dir.
|
|
47
|
+
* @default 'public'
|
|
48
|
+
*/
|
|
49
|
+
publicDir?: string | false;
|
|
50
|
+
/**
|
|
51
|
+
* Directory to save cache files. Files in this directory are pre-bundled
|
|
52
|
+
* deps or some other cache files that generated by vite, which can improve
|
|
53
|
+
* the performance. You can use `--force` flag or manually delete the directory
|
|
54
|
+
* to regenerate the cache files. The value can be either an absolute file
|
|
55
|
+
* system path or a path relative to <root>.
|
|
56
|
+
* Default to `.vite` when no `package.json` is detected.
|
|
57
|
+
* @default 'node_modules/.vite'
|
|
58
|
+
*/
|
|
59
|
+
cacheDir?: string;
|
|
60
|
+
/**
|
|
61
|
+
* Explicitly set a mode to run in. This will override the default mode for
|
|
62
|
+
* each command, and can be overridden by the command line --mode option.
|
|
63
|
+
*/
|
|
64
|
+
mode?: string;
|
|
65
|
+
/**
|
|
66
|
+
* Define global variable replacements.
|
|
67
|
+
* Entries will be defined on `window` during dev and replaced during build.
|
|
68
|
+
*/
|
|
69
|
+
define?: Record<string, any>;
|
|
70
|
+
/**
|
|
71
|
+
* Array of vite plugins to use.
|
|
72
|
+
*/
|
|
73
|
+
plugins?: PluginOption[];
|
|
74
|
+
/**
|
|
75
|
+
* Configure resolver
|
|
76
|
+
*/
|
|
77
|
+
resolve?: ResolveOptions & {
|
|
78
|
+
alias?: AliasOptions;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* CSS related options (preprocessors and CSS modules)
|
|
82
|
+
*/
|
|
83
|
+
css?: CSSOptions;
|
|
84
|
+
/**
|
|
85
|
+
* JSON loading options
|
|
86
|
+
*/
|
|
87
|
+
json?: JsonOptions;
|
|
88
|
+
/**
|
|
89
|
+
* Transform options to pass to esbuild.
|
|
90
|
+
* Or set to `false` to disable esbuild.
|
|
91
|
+
*/
|
|
92
|
+
esbuild?: ESBuildOptions | false;
|
|
93
|
+
/**
|
|
94
|
+
* Specify additional picomatch patterns to be treated as static assets.
|
|
95
|
+
*/
|
|
96
|
+
assetsInclude?: string | RegExp | (string | RegExp)[];
|
|
97
|
+
/**
|
|
98
|
+
* Server specific options, e.g. host, port, https...
|
|
99
|
+
*/
|
|
100
|
+
server?: ServerOptions;
|
|
101
|
+
/**
|
|
102
|
+
* Build specific options
|
|
103
|
+
*/
|
|
104
|
+
build?: BuildOptions;
|
|
105
|
+
/**
|
|
106
|
+
* Preview specific options, e.g. host, port, https...
|
|
107
|
+
*/
|
|
108
|
+
preview?: PreviewOptions;
|
|
109
|
+
/**
|
|
110
|
+
* Dep optimization options
|
|
111
|
+
*/
|
|
112
|
+
optimizeDeps?: DepOptimizationOptions;
|
|
113
|
+
/**
|
|
114
|
+
* SSR specific options
|
|
115
|
+
*/
|
|
116
|
+
ssr?: SSROptions;
|
|
117
|
+
/**
|
|
118
|
+
* Experimental features
|
|
119
|
+
*
|
|
120
|
+
* Features under this field are addressed to be changed that might NOT follow semver.
|
|
121
|
+
* Please be careful and always pin Vite's version when using them.
|
|
122
|
+
* @experimental
|
|
123
|
+
*/
|
|
124
|
+
experimental?: ExperimentalOptions;
|
|
125
|
+
/**
|
|
126
|
+
* Log level.
|
|
127
|
+
* Default: 'info'
|
|
128
|
+
*/
|
|
129
|
+
logLevel?: LogLevel;
|
|
130
|
+
/**
|
|
131
|
+
* Custom logger.
|
|
132
|
+
*/
|
|
133
|
+
customLogger?: Logger;
|
|
134
|
+
/**
|
|
135
|
+
* Default: true
|
|
136
|
+
*/
|
|
137
|
+
clearScreen?: boolean;
|
|
138
|
+
/**
|
|
139
|
+
* Environment files directory. Can be an absolute path, or a path relative from
|
|
140
|
+
* the location of the config file itself.
|
|
141
|
+
* @default root
|
|
142
|
+
*/
|
|
143
|
+
envDir?: string;
|
|
144
|
+
/**
|
|
145
|
+
* Env variables starts with `envPrefix` will be exposed to your client source code via import.meta.env.
|
|
146
|
+
* @default 'VITE_'
|
|
147
|
+
*/
|
|
148
|
+
envPrefix?: string | string[];
|
|
149
|
+
/**
|
|
150
|
+
* Worker bundle options
|
|
151
|
+
*/
|
|
152
|
+
worker?: {
|
|
153
|
+
/**
|
|
154
|
+
* Output format for worker bundle
|
|
155
|
+
* @default 'iife'
|
|
156
|
+
*/
|
|
157
|
+
format?: 'es' | 'iife';
|
|
158
|
+
/**
|
|
159
|
+
* Vite plugins that apply to worker bundle
|
|
160
|
+
*/
|
|
161
|
+
plugins?: PluginOption[];
|
|
162
|
+
/**
|
|
163
|
+
* Rollup options to build worker bundle
|
|
164
|
+
*/
|
|
165
|
+
rollupOptions?: Omit<RollupOptions, 'plugins' | 'input' | 'onwarn' | 'preserveEntrySignatures'>;
|
|
166
|
+
};
|
|
167
|
+
/**
|
|
168
|
+
* Whether your application is a Single Page Application (SPA). Set to `false`
|
|
169
|
+
* for other kinds of apps like MPAs.
|
|
170
|
+
* @default true
|
|
171
|
+
*/
|
|
172
|
+
spa?: boolean;
|
|
173
|
+
}
|
|
174
|
+
export interface ExperimentalOptions {
|
|
175
|
+
/**
|
|
176
|
+
* Append fake `&lang.(ext)` when queries are specified, to preseve the file extension for following plugins to process.
|
|
177
|
+
*
|
|
178
|
+
* @experimental
|
|
179
|
+
* @default false
|
|
180
|
+
*/
|
|
181
|
+
importGlobRestoreExtension?: boolean;
|
|
182
|
+
}
|
|
183
|
+
export declare type SSRTarget = 'node' | 'webworker';
|
|
184
|
+
export interface SSROptions {
|
|
185
|
+
external?: string[];
|
|
186
|
+
noExternal?: string | RegExp | (string | RegExp)[] | true;
|
|
187
|
+
/**
|
|
188
|
+
* Define the target for the ssr build. The browser field in package.json
|
|
189
|
+
* is ignored for node but used if webworker is the target
|
|
190
|
+
* Default: 'node'
|
|
191
|
+
*/
|
|
192
|
+
target?: SSRTarget;
|
|
193
|
+
}
|
|
194
|
+
export interface ResolveWorkerOptions {
|
|
195
|
+
format: 'es' | 'iife';
|
|
196
|
+
plugins: Plugin[];
|
|
197
|
+
rollupOptions: RollupOptions;
|
|
198
|
+
}
|
|
199
|
+
export interface InlineConfig extends UserConfig {
|
|
200
|
+
configFile?: string | false;
|
|
201
|
+
envFile?: false;
|
|
202
|
+
}
|
|
203
|
+
export declare type ResolvedConfig = Readonly<Omit<UserConfig, 'plugins' | 'assetsInclude' | 'optimizeDeps' | 'worker'> & {
|
|
204
|
+
configFile: string | undefined;
|
|
205
|
+
configFileDependencies: string[];
|
|
206
|
+
inlineConfig: InlineConfig;
|
|
207
|
+
root: string;
|
|
208
|
+
base: string;
|
|
209
|
+
publicDir: string;
|
|
210
|
+
cacheDir: string;
|
|
211
|
+
command: 'build' | 'serve';
|
|
212
|
+
mode: string;
|
|
213
|
+
isWorker: boolean;
|
|
214
|
+
/** @internal */
|
|
215
|
+
mainConfig: ResolvedConfig | null;
|
|
216
|
+
isProduction: boolean;
|
|
217
|
+
env: Record<string, any>;
|
|
218
|
+
resolve: ResolveOptions & {
|
|
219
|
+
alias: Alias[];
|
|
220
|
+
};
|
|
221
|
+
plugins: readonly Plugin[];
|
|
222
|
+
server: ResolvedServerOptions;
|
|
223
|
+
build: ResolvedBuildOptions;
|
|
224
|
+
preview: ResolvedPreviewOptions;
|
|
225
|
+
assetsInclude: (file: string) => boolean;
|
|
226
|
+
logger: Logger;
|
|
227
|
+
createResolver: (options?: Partial<InternalResolveOptions>) => ResolveFn;
|
|
228
|
+
optimizeDeps: DepOptimizationOptions;
|
|
229
|
+
/** @internal */
|
|
230
|
+
packageCache: PackageCache;
|
|
231
|
+
worker: ResolveWorkerOptions;
|
|
232
|
+
spa: boolean;
|
|
233
|
+
}>;
|
|
234
|
+
export declare type ResolveFn = (id: string, importer?: string, aliasOnly?: boolean, ssr?: boolean) => Promise<string | undefined>;
|
|
235
|
+
export declare function resolveConfig(inlineConfig: InlineConfig, command: 'build' | 'serve', defaultMode?: string): Promise<ResolvedConfig>;
|
|
236
|
+
export declare function sortUserPlugins(plugins: (Plugin | Plugin[])[] | undefined): [Plugin[], Plugin[], Plugin[]];
|
|
237
|
+
export declare function loadConfigFromFile(configEnv: ConfigEnv, configFile?: string, configRoot?: string, logLevel?: LogLevel): Promise<{
|
|
238
|
+
path: string;
|
|
239
|
+
config: UserConfig;
|
|
240
|
+
dependencies: string[];
|
|
241
|
+
} | null>;
|
|
242
|
+
export declare function loadEnv(mode: string, envDir: string, prefixes?: string | string[]): Record<string, string>;
|
|
243
|
+
export declare function resolveEnvPrefix({ envPrefix }: UserConfig): string[];
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export declare const VERSION: string;
|
|
2
|
+
export declare const DEFAULT_MAIN_FIELDS: string[];
|
|
3
|
+
export declare const DEFAULT_EXTENSIONS: string[];
|
|
4
|
+
export declare const JS_TYPES_RE: RegExp;
|
|
5
|
+
export declare const OPTIMIZABLE_ENTRY_RE: RegExp;
|
|
6
|
+
export declare const SPECIAL_QUERY_RE: RegExp;
|
|
7
|
+
/**
|
|
8
|
+
* Prefix for resolved fs paths, since windows paths may not be valid as URLs.
|
|
9
|
+
*/
|
|
10
|
+
export declare const FS_PREFIX = "/@fs/";
|
|
11
|
+
/**
|
|
12
|
+
* Prefix for resolved Ids that are not valid browser import specifiers
|
|
13
|
+
*/
|
|
14
|
+
export declare const VALID_ID_PREFIX = "/@id/";
|
|
15
|
+
/**
|
|
16
|
+
* Plugins that use 'virtual modules' (e.g. for helper functions), prefix the
|
|
17
|
+
* module ID with `\0`, a convention from the rollup ecosystem.
|
|
18
|
+
* This prevents other plugins from trying to process the id (like node resolution),
|
|
19
|
+
* and core features like sourcemaps can use this info to differentiate between
|
|
20
|
+
* virtual modules and regular files.
|
|
21
|
+
* `\0` is not a permitted char in import URLs so we have to replace them during
|
|
22
|
+
* import analysis. The id will be decoded back before entering the plugins pipeline.
|
|
23
|
+
* These encoded virtual ids are also prefixed by the VALID_ID_PREFIX, so virtual
|
|
24
|
+
* modules in the browser end up encoded as `/@id/__x00__{id}`
|
|
25
|
+
*/
|
|
26
|
+
export declare const NULL_BYTE_PLACEHOLDER = "__x00__";
|
|
27
|
+
export declare const CLIENT_PUBLIC_PATH = "/@vite/client";
|
|
28
|
+
export declare const ENV_PUBLIC_PATH = "/@vite/env";
|
|
29
|
+
export declare const VITE_PACKAGE_DIR: string;
|
|
30
|
+
export declare const CLIENT_ENTRY: string;
|
|
31
|
+
export declare const ENV_ENTRY: string;
|
|
32
|
+
export declare const CLIENT_DIR: string;
|
|
33
|
+
export declare const KNOWN_ASSET_TYPES: string[];
|
|
34
|
+
export declare const DEFAULT_ASSETS_RE: RegExp;
|
|
35
|
+
export declare const DEP_VERSION_RE: RegExp;
|