vite 4.0.0-alpha.5 → 4.0.0-beta.0
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 +30 -31
- package/bin/vite.js +1 -1
- package/client.d.ts +25 -1
- package/dist/client/client.mjs +19 -20
- package/dist/client/client.mjs.map +1 -1
- package/dist/node/chunks/{dep-4ec4968a.js → dep-1e0f5bc1.js} +58 -18
- package/dist/node/chunks/{dep-72c42a3f.js → dep-753720be.js} +1 -1
- package/dist/node/chunks/{dep-fadb3c21.js → dep-a5101d9f.js} +3021 -2898
- package/dist/node/cli.js +13 -13
- package/dist/node/constants.js +9 -8
- package/dist/node/index.d.ts +124 -97
- package/dist/node/index.js +12 -10
- package/dist/node-cjs/publicUtils.cjs +191 -132
- package/index.cjs +3 -2
- package/package.json +14 -14
- package/types/customEvent.d.ts +1 -1
- package/types/hot.d.ts +4 -5
- package/types/importGlob.d.ts +8 -8
package/dist/node/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { b as build, q as createFilter, v as createLogger, c as createServer, e as defineConfig, f as formatPostcssSourceMap, i as getDepOptimizationConfig, j as isDepsOptimizerEnabled, l as loadConfigFromFile, x as loadEnv, k as mergeAlias, m as mergeConfig, n as normalizePath, o as optimizeDeps, a as preprocessCSS, p as preview, h as resolveBaseUrl, g as resolveConfig, y as resolveEnvPrefix, d as resolvePackageData, r as resolvePackageEntry, w as searchForWorkspaceRoot, u as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-
|
|
1
|
+
export { b as build, q as createFilter, v as createLogger, c as createServer, e as defineConfig, f as formatPostcssSourceMap, i as getDepOptimizationConfig, j as isDepsOptimizerEnabled, l as loadConfigFromFile, x as loadEnv, k as mergeAlias, m as mergeConfig, n as normalizePath, o as optimizeDeps, a as preprocessCSS, p as preview, h as resolveBaseUrl, g as resolveConfig, y as resolveEnvPrefix, d as resolvePackageData, r as resolvePackageEntry, w as searchForWorkspaceRoot, u as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-a5101d9f.js';
|
|
2
2
|
export { VERSION as version } from './constants.js';
|
|
3
3
|
export { version as esbuildVersion } from 'esbuild';
|
|
4
4
|
export { VERSION as rollupVersion } from 'rollup';
|
|
@@ -39,9 +39,11 @@ import 'node:child_process';
|
|
|
39
39
|
import 'node:zlib';
|
|
40
40
|
|
|
41
41
|
// This file will be built for both ESM and CJS. Avoid relying on other modules as possible.
|
|
42
|
-
|
|
43
|
-
const
|
|
44
|
-
|
|
42
|
+
// copy from constants.ts
|
|
43
|
+
const CSS_LANGS_RE =
|
|
44
|
+
// eslint-disable-next-line regexp/no-unused-capturing-group
|
|
45
|
+
/\.(css|less|sass|scss|styl|stylus|pcss|postcss|sss)(?:$|\\?)/;
|
|
46
|
+
const isCSSRequest = (request) => CSS_LANGS_RE.test(request);
|
|
45
47
|
// Use splitVendorChunkPlugin() to get the same manualChunks strategy as Vite 2.7
|
|
46
48
|
// We don't recommend using this strategy as a general solution moving forward
|
|
47
49
|
// splitVendorChunk is a simple index/vendor strategy that was used in Vite
|
|
@@ -130,17 +132,17 @@ function splitVendorChunkPlugin() {
|
|
|
130
132
|
build: {
|
|
131
133
|
rollupOptions: {
|
|
132
134
|
output: {
|
|
133
|
-
manualChunks: createSplitVendorChunk({}, config)
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
}
|
|
135
|
+
manualChunks: createSplitVendorChunk({}, config),
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
},
|
|
137
139
|
};
|
|
138
140
|
}
|
|
139
141
|
},
|
|
140
142
|
buildStart() {
|
|
141
143
|
caches.forEach((cache) => cache.reset());
|
|
142
|
-
}
|
|
144
|
+
},
|
|
143
145
|
};
|
|
144
146
|
}
|
|
145
147
|
|
|
146
|
-
export { splitVendorChunk, splitVendorChunkPlugin };
|
|
148
|
+
export { isCSSRequest, splitVendorChunk, splitVendorChunkPlugin };
|
|
@@ -16,8 +16,8 @@ var require$$1$1 = require('fs');
|
|
|
16
16
|
var readline = require('node:readline');
|
|
17
17
|
var require$$2 = require('os');
|
|
18
18
|
|
|
19
|
-
const { version } = JSON.parse(fs$1.readFileSync(new URL('../../package.json', (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('node-cjs/publicUtils.cjs', document.baseURI).href)))).toString());
|
|
20
|
-
const VERSION = version;
|
|
19
|
+
const { version: version$2 } = JSON.parse(fs$1.readFileSync(new URL('../../package.json', (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('node-cjs/publicUtils.cjs', document.baseURI).href)))).toString());
|
|
20
|
+
const VERSION = version$2;
|
|
21
21
|
const VITE_PACKAGE_DIR = path$3.resolve(
|
|
22
22
|
// import.meta.url is `dist/node/constants.js` after bundle
|
|
23
23
|
node_url.fileURLToPath((typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('node-cjs/publicUtils.cjs', document.baseURI).href))), '../../..');
|
|
@@ -26,9 +26,11 @@ path$3.resolve(VITE_PACKAGE_DIR, 'dist/client/env.mjs');
|
|
|
26
26
|
path$3.dirname(CLIENT_ENTRY);
|
|
27
27
|
|
|
28
28
|
// This file will be built for both ESM and CJS. Avoid relying on other modules as possible.
|
|
29
|
-
|
|
30
|
-
const
|
|
31
|
-
|
|
29
|
+
// copy from constants.ts
|
|
30
|
+
const CSS_LANGS_RE =
|
|
31
|
+
// eslint-disable-next-line regexp/no-unused-capturing-group
|
|
32
|
+
/\.(css|less|sass|scss|styl|stylus|pcss|postcss|sss)(?:$|\\?)/;
|
|
33
|
+
const isCSSRequest = (request) => CSS_LANGS_RE.test(request);
|
|
32
34
|
// Use splitVendorChunkPlugin() to get the same manualChunks strategy as Vite 2.7
|
|
33
35
|
// We don't recommend using this strategy as a general solution moving forward
|
|
34
36
|
// splitVendorChunk is a simple index/vendor strategy that was used in Vite
|
|
@@ -117,16 +119,16 @@ function splitVendorChunkPlugin() {
|
|
|
117
119
|
build: {
|
|
118
120
|
rollupOptions: {
|
|
119
121
|
output: {
|
|
120
|
-
manualChunks: createSplitVendorChunk({}, config)
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
122
|
+
manualChunks: createSplitVendorChunk({}, config),
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
},
|
|
124
126
|
};
|
|
125
127
|
}
|
|
126
128
|
},
|
|
127
129
|
buildStart() {
|
|
128
130
|
caches.forEach((cache) => cache.reset());
|
|
129
|
-
}
|
|
131
|
+
},
|
|
130
132
|
};
|
|
131
133
|
}
|
|
132
134
|
|
|
@@ -2961,11 +2963,11 @@ parse$2.fastpaths = (input, options) => {
|
|
|
2961
2963
|
return source;
|
|
2962
2964
|
};
|
|
2963
2965
|
|
|
2964
|
-
var parse_1 = parse$2;
|
|
2966
|
+
var parse_1$1 = parse$2;
|
|
2965
2967
|
|
|
2966
2968
|
const path$1 = require$$0$1;
|
|
2967
2969
|
const scan = scan_1;
|
|
2968
|
-
const parse$1 = parse_1;
|
|
2970
|
+
const parse$1 = parse_1$1;
|
|
2969
2971
|
const utils = utils$3;
|
|
2970
2972
|
const constants = constants$2;
|
|
2971
2973
|
const isObject$1 = val => val && typeof val === 'object' && !Array.isArray(val);
|
|
@@ -3592,12 +3594,12 @@ function normalizeAlias(o = []) {
|
|
|
3592
3594
|
? o.map(normalizeSingleAlias)
|
|
3593
3595
|
: Object.keys(o).map((find) => normalizeSingleAlias({
|
|
3594
3596
|
find,
|
|
3595
|
-
replacement: o[find]
|
|
3597
|
+
replacement: o[find],
|
|
3596
3598
|
}));
|
|
3597
3599
|
}
|
|
3598
3600
|
// https://github.com/vitejs/vite/issues/1363
|
|
3599
3601
|
// work around https://github.com/rollup/plugins/issues/759
|
|
3600
|
-
function normalizeSingleAlias({ find, replacement, customResolver }) {
|
|
3602
|
+
function normalizeSingleAlias({ find, replacement, customResolver, }) {
|
|
3601
3603
|
if (typeof find === 'string' &&
|
|
3602
3604
|
find.endsWith('/') &&
|
|
3603
3605
|
replacement.endsWith('/')) {
|
|
@@ -3606,7 +3608,7 @@ function normalizeSingleAlias({ find, replacement, customResolver }) {
|
|
|
3606
3608
|
}
|
|
3607
3609
|
const alias = {
|
|
3608
3610
|
find,
|
|
3609
|
-
replacement
|
|
3611
|
+
replacement,
|
|
3610
3612
|
};
|
|
3611
3613
|
if (customResolver) {
|
|
3612
3614
|
alias.customResolver = customResolver;
|
|
@@ -3746,7 +3748,7 @@ function stattag (stat) {
|
|
|
3746
3748
|
|
|
3747
3749
|
const isDebug = !!process.env.DEBUG;
|
|
3748
3750
|
createDebugger('vite:sourcemap', {
|
|
3749
|
-
onlyWhenFocused: true
|
|
3751
|
+
onlyWhenFocused: true,
|
|
3750
3752
|
});
|
|
3751
3753
|
function genSourceMapUrl(map) {
|
|
3752
3754
|
if (typeof map !== 'string') {
|
|
@@ -3771,10 +3773,10 @@ const alias = {
|
|
|
3771
3773
|
js: 'application/javascript',
|
|
3772
3774
|
css: 'text/css',
|
|
3773
3775
|
html: 'text/html',
|
|
3774
|
-
json: 'application/json'
|
|
3776
|
+
json: 'application/json',
|
|
3775
3777
|
};
|
|
3776
3778
|
function send(req, res, content, type, options) {
|
|
3777
|
-
const { etag = etag_1(content, { weak: true }), cacheControl = 'no-cache', headers, map } = options;
|
|
3779
|
+
const { etag = etag_1(content, { weak: true }), cacheControl = 'no-cache', headers, map, } = options;
|
|
3778
3780
|
if (res.writableEnded) {
|
|
3779
3781
|
return;
|
|
3780
3782
|
}
|
|
@@ -3807,7 +3809,7 @@ const LogLevels = {
|
|
|
3807
3809
|
silent: 0,
|
|
3808
3810
|
error: 1,
|
|
3809
3811
|
warn: 2,
|
|
3810
|
-
info: 3
|
|
3812
|
+
info: 3,
|
|
3811
3813
|
};
|
|
3812
3814
|
let lastType;
|
|
3813
3815
|
let lastMsg;
|
|
@@ -3896,7 +3898,7 @@ function createLogger(level = 'info', options = {}) {
|
|
|
3896
3898
|
},
|
|
3897
3899
|
hasErrorLogged(error) {
|
|
3898
3900
|
return loggedErrors.has(error);
|
|
3899
|
-
}
|
|
3901
|
+
},
|
|
3900
3902
|
};
|
|
3901
3903
|
return logger;
|
|
3902
3904
|
}
|
|
@@ -3912,7 +3914,7 @@ const ROOT_FILES = [
|
|
|
3912
3914
|
// 'workspace.json',
|
|
3913
3915
|
// 'nx.json',
|
|
3914
3916
|
// https://github.com/lerna/lerna#lernajson
|
|
3915
|
-
'lerna.json'
|
|
3917
|
+
'lerna.json',
|
|
3916
3918
|
];
|
|
3917
3919
|
// npm: https://docs.npmjs.com/cli/v7/using-npm/workspaces#installing-workspaces
|
|
3918
3920
|
// yarn: https://classic.yarnpkg.com/en/docs/workspaces/#toc-how-to-use-it
|
|
@@ -3960,88 +3962,133 @@ function searchForWorkspaceRoot(current, root = searchForPackageRoot(current)) {
|
|
|
3960
3962
|
|
|
3961
3963
|
var main$1 = {exports: {}};
|
|
3962
3964
|
|
|
3965
|
+
var name = "dotenv";
|
|
3966
|
+
var version$1 = "16.0.3";
|
|
3967
|
+
var description = "Loads environment variables from .env file";
|
|
3968
|
+
var main = "lib/main.js";
|
|
3969
|
+
var types = "lib/main.d.ts";
|
|
3970
|
+
var exports$1 = {
|
|
3971
|
+
".": {
|
|
3972
|
+
require: "./lib/main.js",
|
|
3973
|
+
types: "./lib/main.d.ts",
|
|
3974
|
+
"default": "./lib/main.js"
|
|
3975
|
+
},
|
|
3976
|
+
"./config": "./config.js",
|
|
3977
|
+
"./config.js": "./config.js",
|
|
3978
|
+
"./lib/env-options": "./lib/env-options.js",
|
|
3979
|
+
"./lib/env-options.js": "./lib/env-options.js",
|
|
3980
|
+
"./lib/cli-options": "./lib/cli-options.js",
|
|
3981
|
+
"./lib/cli-options.js": "./lib/cli-options.js",
|
|
3982
|
+
"./package.json": "./package.json"
|
|
3983
|
+
};
|
|
3984
|
+
var scripts = {
|
|
3985
|
+
"dts-check": "tsc --project tests/types/tsconfig.json",
|
|
3986
|
+
lint: "standard",
|
|
3987
|
+
"lint-readme": "standard-markdown",
|
|
3988
|
+
pretest: "npm run lint && npm run dts-check",
|
|
3989
|
+
test: "tap tests/*.js --100 -Rspec",
|
|
3990
|
+
prerelease: "npm test",
|
|
3991
|
+
release: "standard-version"
|
|
3992
|
+
};
|
|
3993
|
+
var repository = {
|
|
3994
|
+
type: "git",
|
|
3995
|
+
url: "git://github.com/motdotla/dotenv.git"
|
|
3996
|
+
};
|
|
3997
|
+
var keywords = [
|
|
3998
|
+
"dotenv",
|
|
3999
|
+
"env",
|
|
4000
|
+
".env",
|
|
4001
|
+
"environment",
|
|
4002
|
+
"variables",
|
|
4003
|
+
"config",
|
|
4004
|
+
"settings"
|
|
4005
|
+
];
|
|
4006
|
+
var readmeFilename = "README.md";
|
|
4007
|
+
var license = "BSD-2-Clause";
|
|
4008
|
+
var devDependencies = {
|
|
4009
|
+
"@types/node": "^17.0.9",
|
|
4010
|
+
decache: "^4.6.1",
|
|
4011
|
+
dtslint: "^3.7.0",
|
|
4012
|
+
sinon: "^12.0.1",
|
|
4013
|
+
standard: "^16.0.4",
|
|
4014
|
+
"standard-markdown": "^7.1.0",
|
|
4015
|
+
"standard-version": "^9.3.2",
|
|
4016
|
+
tap: "^15.1.6",
|
|
4017
|
+
tar: "^6.1.11",
|
|
4018
|
+
typescript: "^4.5.4"
|
|
4019
|
+
};
|
|
4020
|
+
var engines = {
|
|
4021
|
+
node: ">=12"
|
|
4022
|
+
};
|
|
4023
|
+
var require$$3 = {
|
|
4024
|
+
name: name,
|
|
4025
|
+
version: version$1,
|
|
4026
|
+
description: description,
|
|
4027
|
+
main: main,
|
|
4028
|
+
types: types,
|
|
4029
|
+
exports: exports$1,
|
|
4030
|
+
scripts: scripts,
|
|
4031
|
+
repository: repository,
|
|
4032
|
+
keywords: keywords,
|
|
4033
|
+
readmeFilename: readmeFilename,
|
|
4034
|
+
license: license,
|
|
4035
|
+
devDependencies: devDependencies,
|
|
4036
|
+
engines: engines
|
|
4037
|
+
};
|
|
4038
|
+
|
|
3963
4039
|
const fs = require$$1$1;
|
|
3964
4040
|
const path = require$$0$1;
|
|
3965
4041
|
const os = require$$2;
|
|
4042
|
+
const packageJson = require$$3;
|
|
3966
4043
|
|
|
3967
|
-
|
|
3968
|
-
console.log(`[dotenv][DEBUG] ${message}`);
|
|
3969
|
-
}
|
|
4044
|
+
const version = packageJson.version;
|
|
3970
4045
|
|
|
3971
|
-
const
|
|
3972
|
-
const RE_INI_KEY_VAL = /^\s*([\w.-]+)\s*=\s*("[^"]*"|'[^']*'|.*?)(\s+#.*)?$/;
|
|
3973
|
-
const RE_NEWLINES = /\\n/g;
|
|
3974
|
-
const NEWLINES_MATCH = /\r\n|\n|\r/;
|
|
4046
|
+
const LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
|
|
3975
4047
|
|
|
3976
|
-
//
|
|
3977
|
-
function parse (src
|
|
3978
|
-
const debug = Boolean(options && options.debug);
|
|
3979
|
-
const multiline = Boolean(options && options.multiline);
|
|
4048
|
+
// Parser src into an Object
|
|
4049
|
+
function parse (src) {
|
|
3980
4050
|
const obj = {};
|
|
3981
4051
|
|
|
3982
|
-
//
|
|
3983
|
-
|
|
3984
|
-
|
|
3985
|
-
for (let idx = 0; idx < lines.length; idx++) {
|
|
3986
|
-
let line = lines[idx];
|
|
3987
|
-
|
|
3988
|
-
// matching "KEY' and 'VAL' in 'KEY=VAL'
|
|
3989
|
-
const keyValueArr = line.match(RE_INI_KEY_VAL);
|
|
3990
|
-
// matched?
|
|
3991
|
-
if (keyValueArr != null) {
|
|
3992
|
-
const key = keyValueArr[1];
|
|
3993
|
-
// default undefined or missing values to empty string
|
|
3994
|
-
let val = (keyValueArr[2] || '');
|
|
3995
|
-
let end = val.length - 1;
|
|
3996
|
-
const isDoubleQuoted = val[0] === '"' && val[end] === '"';
|
|
3997
|
-
const isSingleQuoted = val[0] === "'" && val[end] === "'";
|
|
3998
|
-
|
|
3999
|
-
const isMultilineDoubleQuoted = val[0] === '"' && val[end] !== '"';
|
|
4000
|
-
const isMultilineSingleQuoted = val[0] === "'" && val[end] !== "'";
|
|
4001
|
-
|
|
4002
|
-
// if parsing line breaks and the value starts with a quote
|
|
4003
|
-
if (multiline && (isMultilineDoubleQuoted || isMultilineSingleQuoted)) {
|
|
4004
|
-
const quoteChar = isMultilineDoubleQuoted ? '"' : "'";
|
|
4005
|
-
|
|
4006
|
-
val = val.substring(1);
|
|
4007
|
-
|
|
4008
|
-
while (idx++ < lines.length - 1) {
|
|
4009
|
-
line = lines[idx];
|
|
4010
|
-
end = line.length - 1;
|
|
4011
|
-
if (line[end] === quoteChar) {
|
|
4012
|
-
val += NEWLINE + line.substring(0, end);
|
|
4013
|
-
break
|
|
4014
|
-
}
|
|
4015
|
-
val += NEWLINE + line;
|
|
4016
|
-
}
|
|
4017
|
-
// if single or double quoted, remove quotes
|
|
4018
|
-
} else if (isSingleQuoted || isDoubleQuoted) {
|
|
4019
|
-
val = val.substring(1, end);
|
|
4052
|
+
// Convert buffer to string
|
|
4053
|
+
let lines = src.toString();
|
|
4020
4054
|
|
|
4021
|
-
|
|
4022
|
-
|
|
4023
|
-
val = val.replace(RE_NEWLINES, NEWLINE);
|
|
4024
|
-
}
|
|
4025
|
-
} else {
|
|
4026
|
-
// remove surrounding whitespace
|
|
4027
|
-
val = val.trim();
|
|
4028
|
-
}
|
|
4055
|
+
// Convert line breaks to same format
|
|
4056
|
+
lines = lines.replace(/\r\n?/mg, '\n');
|
|
4029
4057
|
|
|
4030
|
-
|
|
4031
|
-
|
|
4032
|
-
|
|
4058
|
+
let match;
|
|
4059
|
+
while ((match = LINE.exec(lines)) != null) {
|
|
4060
|
+
const key = match[1];
|
|
4033
4061
|
|
|
4034
|
-
|
|
4035
|
-
|
|
4036
|
-
|
|
4037
|
-
|
|
4062
|
+
// Default undefined or null to empty string
|
|
4063
|
+
let value = (match[2] || '');
|
|
4064
|
+
|
|
4065
|
+
// Remove whitespace
|
|
4066
|
+
value = value.trim();
|
|
4067
|
+
|
|
4068
|
+
// Check if double quoted
|
|
4069
|
+
const maybeQuote = value[0];
|
|
4070
|
+
|
|
4071
|
+
// Remove surrounding quotes
|
|
4072
|
+
value = value.replace(/^(['"`])([\s\S]*)\1$/mg, '$2');
|
|
4073
|
+
|
|
4074
|
+
// Expand newlines if double quoted
|
|
4075
|
+
if (maybeQuote === '"') {
|
|
4076
|
+
value = value.replace(/\\n/g, '\n');
|
|
4077
|
+
value = value.replace(/\\r/g, '\r');
|
|
4038
4078
|
}
|
|
4079
|
+
|
|
4080
|
+
// Add to object
|
|
4081
|
+
obj[key] = value;
|
|
4039
4082
|
}
|
|
4040
4083
|
|
|
4041
4084
|
return obj
|
|
4042
4085
|
}
|
|
4043
4086
|
|
|
4044
|
-
function
|
|
4087
|
+
function _log (message) {
|
|
4088
|
+
console.log(`[dotenv@${version}][DEBUG] ${message}`);
|
|
4089
|
+
}
|
|
4090
|
+
|
|
4091
|
+
function _resolveHome (envPath) {
|
|
4045
4092
|
return envPath[0] === '~' ? path.join(os.homedir(), envPath.slice(1)) : envPath
|
|
4046
4093
|
}
|
|
4047
4094
|
|
|
@@ -4051,11 +4098,10 @@ function config (options) {
|
|
|
4051
4098
|
let encoding = 'utf8';
|
|
4052
4099
|
const debug = Boolean(options && options.debug);
|
|
4053
4100
|
const override = Boolean(options && options.override);
|
|
4054
|
-
const multiline = Boolean(options && options.multiline);
|
|
4055
4101
|
|
|
4056
4102
|
if (options) {
|
|
4057
4103
|
if (options.path != null) {
|
|
4058
|
-
dotenvPath =
|
|
4104
|
+
dotenvPath = _resolveHome(options.path);
|
|
4059
4105
|
}
|
|
4060
4106
|
if (options.encoding != null) {
|
|
4061
4107
|
encoding = options.encoding;
|
|
@@ -4063,8 +4109,8 @@ function config (options) {
|
|
|
4063
4109
|
}
|
|
4064
4110
|
|
|
4065
4111
|
try {
|
|
4066
|
-
//
|
|
4067
|
-
const parsed = DotenvModule.parse(fs.readFileSync(dotenvPath, { encoding })
|
|
4112
|
+
// Specifying an encoding returns a string instead of a buffer
|
|
4113
|
+
const parsed = DotenvModule.parse(fs.readFileSync(dotenvPath, { encoding }));
|
|
4068
4114
|
|
|
4069
4115
|
Object.keys(parsed).forEach(function (key) {
|
|
4070
4116
|
if (!Object.prototype.hasOwnProperty.call(process.env, key)) {
|
|
@@ -4076,9 +4122,9 @@ function config (options) {
|
|
|
4076
4122
|
|
|
4077
4123
|
if (debug) {
|
|
4078
4124
|
if (override === true) {
|
|
4079
|
-
|
|
4125
|
+
_log(`"${key}" is already defined in \`process.env\` and WAS overwritten`);
|
|
4080
4126
|
} else {
|
|
4081
|
-
|
|
4127
|
+
_log(`"${key}" is already defined in \`process.env\` and was NOT overwritten`);
|
|
4082
4128
|
}
|
|
4083
4129
|
}
|
|
4084
4130
|
}
|
|
@@ -4087,7 +4133,7 @@ function config (options) {
|
|
|
4087
4133
|
return { parsed }
|
|
4088
4134
|
} catch (e) {
|
|
4089
4135
|
if (debug) {
|
|
4090
|
-
|
|
4136
|
+
_log(`Failed to load ${dotenvPath} ${e.message}`);
|
|
4091
4137
|
}
|
|
4092
4138
|
|
|
4093
4139
|
return { error: e }
|
|
@@ -4100,53 +4146,67 @@ const DotenvModule = {
|
|
|
4100
4146
|
};
|
|
4101
4147
|
|
|
4102
4148
|
main$1.exports.config = DotenvModule.config;
|
|
4103
|
-
main$1.exports.parse = DotenvModule.parse;
|
|
4149
|
+
var parse_1 = main$1.exports.parse = DotenvModule.parse;
|
|
4104
4150
|
main$1.exports = DotenvModule;
|
|
4105
4151
|
|
|
4106
|
-
|
|
4107
|
-
|
|
4108
|
-
var environment = config.ignoreProcessEnv ? {} : process.env;
|
|
4152
|
+
function _interpolate (envValue, environment, config) {
|
|
4153
|
+
const matches = envValue.match(/(.?\${*[\w]*(?::-[\w/]*)?}*)/g) || [];
|
|
4109
4154
|
|
|
4110
|
-
|
|
4111
|
-
|
|
4155
|
+
return matches.reduce(function (newEnv, match, index) {
|
|
4156
|
+
const parts = /(.?)\${*([\w]*(?::-[\w/]*)?)?}*/g.exec(match);
|
|
4157
|
+
if (!parts || parts.length === 0) {
|
|
4158
|
+
return newEnv
|
|
4159
|
+
}
|
|
4112
4160
|
|
|
4113
|
-
|
|
4114
|
-
var parts = /(.?)\${?([a-zA-Z0-9_]+)?}?/g.exec(match);
|
|
4115
|
-
var prefix = parts[1];
|
|
4161
|
+
const prefix = parts[1];
|
|
4116
4162
|
|
|
4117
|
-
|
|
4163
|
+
let value, replacePart;
|
|
4118
4164
|
|
|
4119
|
-
|
|
4120
|
-
|
|
4121
|
-
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
|
|
4129
|
-
|
|
4165
|
+
if (prefix === '\\') {
|
|
4166
|
+
replacePart = parts[0];
|
|
4167
|
+
value = replacePart.replace('\\$', '$');
|
|
4168
|
+
} else {
|
|
4169
|
+
const keyParts = parts[2].split(':-');
|
|
4170
|
+
const key = keyParts[0];
|
|
4171
|
+
replacePart = parts[0].substring(prefix.length);
|
|
4172
|
+
// process.env value 'wins' over .env file's value
|
|
4173
|
+
value = Object.prototype.hasOwnProperty.call(environment, key)
|
|
4174
|
+
? environment[key]
|
|
4175
|
+
: (config.parsed[key] || keyParts[1] || '');
|
|
4176
|
+
|
|
4177
|
+
// If the value is found, remove nested expansions.
|
|
4178
|
+
if (keyParts.length > 1 && value) {
|
|
4179
|
+
const replaceNested = matches[index + 1];
|
|
4180
|
+
matches[index + 1] = '';
|
|
4181
|
+
|
|
4182
|
+
newEnv = newEnv.replace(replaceNested, '');
|
|
4130
4183
|
}
|
|
4184
|
+
// Resolve recursive interpolations
|
|
4185
|
+
value = _interpolate(value, environment, config);
|
|
4186
|
+
}
|
|
4131
4187
|
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
|
|
4188
|
+
return newEnv.replace(replacePart, value)
|
|
4189
|
+
}, envValue)
|
|
4190
|
+
}
|
|
4135
4191
|
|
|
4136
|
-
|
|
4137
|
-
|
|
4192
|
+
function expand (config) {
|
|
4193
|
+
// if ignoring process.env, use a blank object
|
|
4194
|
+
const environment = config.ignoreProcessEnv ? {} : process.env;
|
|
4195
|
+
|
|
4196
|
+
for (const configKey in config.parsed) {
|
|
4197
|
+
const value = Object.prototype.hasOwnProperty.call(environment, configKey) ? environment[configKey] : config.parsed[configKey];
|
|
4138
4198
|
|
|
4139
|
-
config.parsed[configKey] =
|
|
4199
|
+
config.parsed[configKey] = _interpolate(value, environment, config);
|
|
4140
4200
|
}
|
|
4141
4201
|
|
|
4142
|
-
for (
|
|
4202
|
+
for (const processKey in config.parsed) {
|
|
4143
4203
|
environment[processKey] = config.parsed[processKey];
|
|
4144
4204
|
}
|
|
4145
4205
|
|
|
4146
4206
|
return config
|
|
4147
|
-
}
|
|
4207
|
+
}
|
|
4148
4208
|
|
|
4149
|
-
var
|
|
4209
|
+
var expand_1 = expand;
|
|
4150
4210
|
|
|
4151
4211
|
function loadEnv(mode, envDir, prefixes = 'VITE_') {
|
|
4152
4212
|
if (mode === 'local') {
|
|
@@ -4159,27 +4219,25 @@ function loadEnv(mode, envDir, prefixes = 'VITE_') {
|
|
|
4159
4219
|
/** default file */ `.env`,
|
|
4160
4220
|
/** local file */ `.env.local`,
|
|
4161
4221
|
/** mode file */ `.env.${mode}`,
|
|
4162
|
-
/** mode local file */ `.env.${mode}.local
|
|
4222
|
+
/** mode local file */ `.env.${mode}.local`,
|
|
4163
4223
|
];
|
|
4164
4224
|
const parsed = Object.fromEntries(envFiles.flatMap((file) => {
|
|
4165
4225
|
const path = lookupFile(envDir, [file], {
|
|
4166
4226
|
pathOnly: true,
|
|
4167
|
-
rootDir: envDir
|
|
4227
|
+
rootDir: envDir,
|
|
4168
4228
|
});
|
|
4169
4229
|
if (!path)
|
|
4170
4230
|
return [];
|
|
4171
|
-
return Object.entries(
|
|
4172
|
-
debug: process.env.DEBUG?.includes('vite:dotenv')
|
|
4173
|
-
}));
|
|
4231
|
+
return Object.entries(parse_1(fs$1.readFileSync(path)));
|
|
4174
4232
|
}));
|
|
4175
4233
|
// let environment variables use each other
|
|
4176
|
-
const expandParsed =
|
|
4234
|
+
const expandParsed = expand_1({
|
|
4177
4235
|
parsed: {
|
|
4178
4236
|
...process.env,
|
|
4179
|
-
...parsed
|
|
4237
|
+
...parsed,
|
|
4180
4238
|
},
|
|
4181
4239
|
// prevent process.env mutation
|
|
4182
|
-
ignoreProcessEnv: true
|
|
4240
|
+
ignoreProcessEnv: true,
|
|
4183
4241
|
}).parsed;
|
|
4184
4242
|
Object.keys(parsed).forEach((key) => {
|
|
4185
4243
|
parsed[key] = expandParsed[key];
|
|
@@ -4204,7 +4262,7 @@ function loadEnv(mode, envDir, prefixes = 'VITE_') {
|
|
|
4204
4262
|
}
|
|
4205
4263
|
return env;
|
|
4206
4264
|
}
|
|
4207
|
-
function resolveEnvPrefix({ envPrefix = 'VITE_' }) {
|
|
4265
|
+
function resolveEnvPrefix({ envPrefix = 'VITE_', }) {
|
|
4208
4266
|
envPrefix = arraify(envPrefix);
|
|
4209
4267
|
if (envPrefix.some((prefix) => prefix === '')) {
|
|
4210
4268
|
throw new Error(`envPrefix option contains value '', which could lead unexpected exposure of sensitive information.`);
|
|
@@ -4216,6 +4274,7 @@ exports.esbuildVersion = esbuild.version;
|
|
|
4216
4274
|
exports.rollupVersion = rollup.VERSION;
|
|
4217
4275
|
exports.createFilter = createFilter;
|
|
4218
4276
|
exports.createLogger = createLogger;
|
|
4277
|
+
exports.isCSSRequest = isCSSRequest;
|
|
4219
4278
|
exports.loadEnv = loadEnv;
|
|
4220
4279
|
exports.mergeAlias = mergeAlias;
|
|
4221
4280
|
exports.mergeConfig = mergeConfig;
|
package/index.cjs
CHANGED
|
@@ -15,7 +15,8 @@ const asyncFunctions = [
|
|
|
15
15
|
'resolveConfig',
|
|
16
16
|
'optimizeDeps',
|
|
17
17
|
'formatPostcssSourceMap',
|
|
18
|
-
'loadConfigFromFile'
|
|
18
|
+
'loadConfigFromFile',
|
|
19
|
+
'preprocessCSS',
|
|
19
20
|
]
|
|
20
21
|
asyncFunctions.forEach((name) => {
|
|
21
22
|
module.exports[name] = (...args) =>
|
|
@@ -27,7 +28,7 @@ const unsupportedCJS = ['resolvePackageEntry', 'resolvePackageData']
|
|
|
27
28
|
unsupportedCJS.forEach((name) => {
|
|
28
29
|
module.exports[name] = () => {
|
|
29
30
|
throw new Error(
|
|
30
|
-
`"${name}" is not supported in CJS build of Vite 3.\nPlease use ESM or dynamic imports \`const { ${name} } = await import('vite')
|
|
31
|
+
`"${name}" is not supported in CJS build of Vite 3.\nPlease use ESM or dynamic imports \`const { ${name} } = await import('vite')\`.`,
|
|
31
32
|
)
|
|
32
33
|
}
|
|
33
34
|
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite",
|
|
3
|
-
"version": "4.0.0-
|
|
3
|
+
"version": "4.0.0-beta.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Evan You",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"build-types-pre-patch": "tsx scripts/prePatchTypes.ts",
|
|
52
52
|
"build-types-roll": "api-extractor run && rimraf temp",
|
|
53
53
|
"build-types-post-patch": "tsx scripts/postPatchTypes.ts",
|
|
54
|
-
"build-types-check": "tsc --project tsconfig.check.json",
|
|
54
|
+
"build-types-check": "tsx scripts/checkBuiltTypes.ts && tsc --project tsconfig.check.json",
|
|
55
55
|
"lint": "eslint --cache --ext .ts src/**",
|
|
56
56
|
"format": "prettier --write --cache --parser typescript \"src/**/*.ts\"",
|
|
57
57
|
"prepublishOnly": "npm run build"
|
|
@@ -61,24 +61,25 @@
|
|
|
61
61
|
"esbuild": "^0.15.9",
|
|
62
62
|
"postcss": "^8.4.19",
|
|
63
63
|
"resolve": "^1.22.1",
|
|
64
|
-
"rollup": "~3.
|
|
64
|
+
"rollup": "~3.5.1"
|
|
65
65
|
},
|
|
66
66
|
"optionalDependencies": {
|
|
67
67
|
"fsevents": "~2.3.2"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
70
|
"@ampproject/remapping": "^2.2.0",
|
|
71
|
-
"@babel/parser": "^7.20.
|
|
72
|
-
"@babel/types": "^7.20.
|
|
71
|
+
"@babel/parser": "^7.20.5",
|
|
72
|
+
"@babel/types": "^7.20.5",
|
|
73
73
|
"@jridgewell/trace-mapping": "^0.3.17",
|
|
74
74
|
"@rollup/plugin-alias": "^4.0.2",
|
|
75
|
-
"@rollup/plugin-commonjs": "^23.0.
|
|
75
|
+
"@rollup/plugin-commonjs": "^23.0.3",
|
|
76
76
|
"@rollup/plugin-dynamic-import-vars": "^2.0.1",
|
|
77
|
-
"@rollup/plugin-json": "^5.0.
|
|
77
|
+
"@rollup/plugin-json": "^5.0.2",
|
|
78
78
|
"@rollup/plugin-node-resolve": "15.0.1",
|
|
79
|
-
"@rollup/plugin-typescript": "^
|
|
80
|
-
"@rollup/pluginutils": "^
|
|
79
|
+
"@rollup/plugin-typescript": "^10.0.1",
|
|
80
|
+
"@rollup/pluginutils": "^5.0.2",
|
|
81
81
|
"acorn": "^8.8.1",
|
|
82
|
+
"acorn-walk": "^8.2.0",
|
|
82
83
|
"cac": "^6.7.14",
|
|
83
84
|
"chokidar": "^3.5.3",
|
|
84
85
|
"connect": "^3.7.0",
|
|
@@ -88,16 +89,15 @@
|
|
|
88
89
|
"cross-spawn": "^7.0.3",
|
|
89
90
|
"debug": "^4.3.4",
|
|
90
91
|
"dep-types": "link:./src/types",
|
|
91
|
-
"dotenv": "^
|
|
92
|
-
"dotenv-expand": "^
|
|
92
|
+
"dotenv": "^16.0.3",
|
|
93
|
+
"dotenv-expand": "^9.0.0",
|
|
93
94
|
"es-module-lexer": "^1.1.0",
|
|
94
95
|
"estree-walker": "^3.0.1",
|
|
95
96
|
"etag": "^1.8.1",
|
|
96
97
|
"fast-glob": "^3.2.12",
|
|
97
98
|
"http-proxy": "^1.18.1",
|
|
98
|
-
"json5": "^2.2.1",
|
|
99
99
|
"launch-editor-middleware": "^2.6.0",
|
|
100
|
-
"magic-string": "^0.
|
|
100
|
+
"magic-string": "^0.27.0",
|
|
101
101
|
"micromatch": "^4.0.5",
|
|
102
102
|
"mlly": "^0.5.17",
|
|
103
103
|
"mrmime": "^1.0.1",
|
|
@@ -107,7 +107,7 @@
|
|
|
107
107
|
"periscopic": "^3.0.4",
|
|
108
108
|
"picocolors": "^1.0.0",
|
|
109
109
|
"picomatch": "^2.3.1",
|
|
110
|
-
"postcss-import": "^15.0.
|
|
110
|
+
"postcss-import": "^15.0.1",
|
|
111
111
|
"postcss-load-config": "^4.0.1",
|
|
112
112
|
"postcss-modules": "^6.0.0",
|
|
113
113
|
"resolve.exports": "^1.1.0",
|