vite 4.0.0-alpha.4 → 4.0.0-alpha.6
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 +31 -39
- package/client.d.ts +24 -0
- package/dist/client/client.mjs +16 -17
- package/dist/client/client.mjs.map +1 -1
- package/dist/node/chunks/{dep-adb60dd8.js → dep-31fe3c68.js} +228 -116
- package/dist/node/chunks/{dep-b73c4a2f.js → dep-68d444d0.js} +1244 -2263
- package/dist/node/chunks/{dep-2ed340b5.js → dep-cabd8261.js} +5438 -5403
- package/dist/node/cli.js +6 -6
- package/dist/node/constants.js +3 -2
- package/dist/node/index.d.ts +18 -3
- package/dist/node/index.js +7 -5
- package/dist/node-cjs/publicUtils.cjs +172 -113
- package/index.cjs +2 -1
- package/package.json +13 -13
- package/types/customEvent.d.ts +1 -0
- package/types/hot.d.ts +3 -3
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 { z as picocolors, v as createLogger, g as resolveConfig } from './chunks/dep-
|
|
5
|
+
import { z as picocolors, v as createLogger, g as resolveConfig } from './chunks/dep-68d444d0.js';
|
|
6
6
|
import { VERSION } from './constants.js';
|
|
7
7
|
import 'node:url';
|
|
8
8
|
import 'node:module';
|
|
@@ -720,7 +720,7 @@ cli
|
|
|
720
720
|
filterDuplicateOptions(options);
|
|
721
721
|
// output structure is preserved even after bundling so require()
|
|
722
722
|
// is ok here
|
|
723
|
-
const { createServer } = await import('./chunks/dep-
|
|
723
|
+
const { createServer } = await import('./chunks/dep-68d444d0.js').then(function (n) { return n.D; });
|
|
724
724
|
try {
|
|
725
725
|
const server = await createServer({
|
|
726
726
|
root,
|
|
@@ -773,7 +773,7 @@ cli
|
|
|
773
773
|
.option('-w, --watch', `[boolean] rebuilds when modules have changed on disk`)
|
|
774
774
|
.action(async (root, options) => {
|
|
775
775
|
filterDuplicateOptions(options);
|
|
776
|
-
const { build } = await import('./chunks/dep-
|
|
776
|
+
const { build } = await import('./chunks/dep-68d444d0.js').then(function (n) { return n.C; });
|
|
777
777
|
const buildOptions = cleanOptions(options);
|
|
778
778
|
try {
|
|
779
779
|
await build({
|
|
@@ -801,14 +801,14 @@ cli
|
|
|
801
801
|
.option('--force', `[boolean] force the optimizer to ignore the cache and re-bundle`)
|
|
802
802
|
.action(async (root, options) => {
|
|
803
803
|
filterDuplicateOptions(options);
|
|
804
|
-
const { optimizeDeps } = await import('./chunks/dep-
|
|
804
|
+
const { optimizeDeps } = await import('./chunks/dep-68d444d0.js').then(function (n) { return n.B; });
|
|
805
805
|
try {
|
|
806
806
|
const config = await resolveConfig({
|
|
807
807
|
root,
|
|
808
808
|
base: options.base,
|
|
809
809
|
configFile: options.config,
|
|
810
810
|
logLevel: options.logLevel
|
|
811
|
-
}, 'build'
|
|
811
|
+
}, 'build');
|
|
812
812
|
await optimizeDeps(config, options.force, true);
|
|
813
813
|
}
|
|
814
814
|
catch (e) {
|
|
@@ -826,7 +826,7 @@ cli
|
|
|
826
826
|
.option('--outDir <dir>', `[string] output directory (default: dist)`)
|
|
827
827
|
.action(async (root, options) => {
|
|
828
828
|
filterDuplicateOptions(options);
|
|
829
|
-
const { preview } = await import('./chunks/dep-
|
|
829
|
+
const { preview } = await import('./chunks/dep-68d444d0.js').then(function (n) { return n.E; });
|
|
830
830
|
try {
|
|
831
831
|
const server = await preview({
|
|
832
832
|
root,
|
package/dist/node/constants.js
CHANGED
|
@@ -17,7 +17,7 @@ const ESBUILD_MODULES_TARGET = [
|
|
|
17
17
|
'edge88',
|
|
18
18
|
'firefox78',
|
|
19
19
|
'chrome87',
|
|
20
|
-
'
|
|
20
|
+
'safari14'
|
|
21
21
|
];
|
|
22
22
|
const DEFAULT_EXTENSIONS = [
|
|
23
23
|
'.mjs',
|
|
@@ -37,6 +37,7 @@ const DEFAULT_CONFIG_FILES = [
|
|
|
37
37
|
'vite.config.cts'
|
|
38
38
|
];
|
|
39
39
|
const JS_TYPES_RE = /\.(?:j|t)sx?$|\.mjs$/;
|
|
40
|
+
const CSS_LANGS_RE = /\.(css|less|sass|scss|styl|stylus|pcss|postcss|sss)($|\\?)/;
|
|
40
41
|
const OPTIMIZABLE_ENTRY_RE = /\.[cm]?[jt]s$/;
|
|
41
42
|
const SPECIAL_QUERY_RE = /[?&](?:worker|sharedworker|raw|url)\b/;
|
|
42
43
|
/**
|
|
@@ -117,4 +118,4 @@ const wildcardHosts = new Set([
|
|
|
117
118
|
'0000:0000:0000:0000:0000:0000:0000:0000'
|
|
118
119
|
]);
|
|
119
120
|
|
|
120
|
-
export { CLIENT_DIR, CLIENT_ENTRY, CLIENT_PUBLIC_PATH, DEFAULT_ASSETS_RE, DEFAULT_CONFIG_FILES, DEFAULT_EXTENSIONS, DEFAULT_MAIN_FIELDS, DEP_VERSION_RE, ENV_ENTRY, ENV_PUBLIC_PATH, ESBUILD_MODULES_TARGET, FS_PREFIX, JS_TYPES_RE, KNOWN_ASSET_TYPES, NULL_BYTE_PLACEHOLDER, OPTIMIZABLE_ENTRY_RE, SPECIAL_QUERY_RE, VALID_ID_PREFIX, VERSION, VITE_PACKAGE_DIR, loopbackHosts, wildcardHosts };
|
|
121
|
+
export { CLIENT_DIR, CLIENT_ENTRY, CLIENT_PUBLIC_PATH, CSS_LANGS_RE, DEFAULT_ASSETS_RE, DEFAULT_CONFIG_FILES, DEFAULT_EXTENSIONS, DEFAULT_MAIN_FIELDS, DEP_VERSION_RE, ENV_ENTRY, ENV_PUBLIC_PATH, ESBUILD_MODULES_TARGET, FS_PREFIX, JS_TYPES_RE, KNOWN_ASSET_TYPES, NULL_BYTE_PLACEHOLDER, OPTIMIZABLE_ENTRY_RE, SPECIAL_QUERY_RE, VALID_ID_PREFIX, VERSION, VITE_PACKAGE_DIR, loopbackHosts, wildcardHosts };
|
package/dist/node/index.d.ts
CHANGED
|
@@ -1095,8 +1095,22 @@ export { ImportGlobFunction }
|
|
|
1095
1095
|
export { ImportGlobOptions }
|
|
1096
1096
|
|
|
1097
1097
|
export declare type IndexHtmlTransform = IndexHtmlTransformHook | {
|
|
1098
|
+
order?: 'pre' | 'post' | null;
|
|
1099
|
+
/**
|
|
1100
|
+
* @deprecated renamed to `order`
|
|
1101
|
+
*/
|
|
1098
1102
|
enforce?: 'pre' | 'post';
|
|
1103
|
+
/**
|
|
1104
|
+
* @deprecated renamed to `handler`
|
|
1105
|
+
*/
|
|
1099
1106
|
transform: IndexHtmlTransformHook;
|
|
1107
|
+
} | {
|
|
1108
|
+
order?: 'pre' | 'post' | null;
|
|
1109
|
+
/**
|
|
1110
|
+
* @deprecated renamed to `order`
|
|
1111
|
+
*/
|
|
1112
|
+
enforce?: 'pre' | 'post';
|
|
1113
|
+
handler: IndexHtmlTransformHook;
|
|
1100
1114
|
};
|
|
1101
1115
|
|
|
1102
1116
|
export declare interface IndexHtmlTransformContext {
|
|
@@ -1151,11 +1165,12 @@ export declare interface InternalResolveOptions extends Required<ResolveOptions>
|
|
|
1151
1165
|
ssrOptimizeCheck?: boolean;
|
|
1152
1166
|
getDepsOptimizer?: (ssr: boolean) => DepsOptimizer | undefined;
|
|
1153
1167
|
shouldExternalize?: (id: string) => boolean | undefined;
|
|
1154
|
-
isHookNodeResolve?: boolean;
|
|
1155
1168
|
}
|
|
1156
1169
|
|
|
1157
1170
|
export { InvalidatePayload }
|
|
1158
1171
|
|
|
1172
|
+
export declare const isCSSRequest: (request: string) => boolean;
|
|
1173
|
+
|
|
1159
1174
|
export declare function isDepsOptimizerEnabled(config: ResolvedConfig, ssr: boolean): boolean;
|
|
1160
1175
|
|
|
1161
1176
|
export declare interface JsonOptions {
|
|
@@ -1471,7 +1486,7 @@ declare interface Plugin_2 extends Plugin_3 {
|
|
|
1471
1486
|
*
|
|
1472
1487
|
* By default the transform is applied **after** vite's internal html
|
|
1473
1488
|
* transform. If you need to apply the transform before vite, use an object:
|
|
1474
|
-
* `{
|
|
1489
|
+
* `{ order: 'pre', handler: hook }`
|
|
1475
1490
|
*/
|
|
1476
1491
|
transformIndexHtml?: IndexHtmlTransform;
|
|
1477
1492
|
/**
|
|
@@ -1615,7 +1630,7 @@ export declare type RenderBuiltAssetUrl = (filename: string, type: {
|
|
|
1615
1630
|
*/
|
|
1616
1631
|
export declare function resolveBaseUrl(base: string | undefined, isBuild: boolean, logger: Logger): string;
|
|
1617
1632
|
|
|
1618
|
-
export declare function resolveConfig(inlineConfig: InlineConfig, command: 'build' | 'serve', defaultMode?: string): Promise<ResolvedConfig>;
|
|
1633
|
+
export declare function resolveConfig(inlineConfig: InlineConfig, command: 'build' | 'serve', defaultMode?: string, defaultNodeEnv?: string): Promise<ResolvedConfig>;
|
|
1619
1634
|
|
|
1620
1635
|
export declare interface ResolvedBuildOptions extends Required<Omit<BuildOptions, 'polyfillModulePreload'>> {
|
|
1621
1636
|
modulePreload: false | ResolvedModulePreloadOptions;
|
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-68d444d0.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
|
|
@@ -143,4 +145,4 @@ function splitVendorChunkPlugin() {
|
|
|
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
|
|
@@ -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);
|
|
@@ -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;
|
|
4109
|
-
|
|
4110
|
-
var interpolate = function (envValue) {
|
|
4111
|
-
var matches = envValue.match(/(.?\${?(?:[a-zA-Z0-9_]+)?}?)/g) || [];
|
|
4152
|
+
function _interpolate (envValue, environment, config) {
|
|
4153
|
+
const matches = envValue.match(/(.?\${*[\w]*(?::-[\w/]*)?}*)/g) || [];
|
|
4112
4154
|
|
|
4113
|
-
|
|
4114
|
-
|
|
4115
|
-
|
|
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
|
+
}
|
|
4116
4160
|
|
|
4117
|
-
|
|
4161
|
+
const prefix = parts[1];
|
|
4118
4162
|
|
|
4119
|
-
|
|
4120
|
-
replacePart = parts[0];
|
|
4121
|
-
value = replacePart.replace('\\$', '$');
|
|
4122
|
-
} else {
|
|
4123
|
-
var key = parts[2];
|
|
4124
|
-
replacePart = parts[0].substring(prefix.length);
|
|
4125
|
-
// process.env value 'wins' over .env file's value
|
|
4126
|
-
value = environment.hasOwnProperty(key) ? environment[key] : (config.parsed[key] || '');
|
|
4163
|
+
let value, replacePart;
|
|
4127
4164
|
|
|
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;
|
|
4138
4195
|
|
|
4139
|
-
|
|
4196
|
+
for (const configKey in config.parsed) {
|
|
4197
|
+
const value = Object.prototype.hasOwnProperty.call(environment, configKey) ? environment[configKey] : config.parsed[configKey];
|
|
4198
|
+
|
|
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') {
|
|
@@ -4168,12 +4228,10 @@ function loadEnv(mode, envDir, prefixes = 'VITE_') {
|
|
|
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
4237
|
...parsed
|
|
@@ -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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Evan You",
|
|
@@ -68,17 +68,18 @@
|
|
|
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,28 +89,27 @@
|
|
|
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
100
|
"magic-string": "^0.26.7",
|
|
101
101
|
"micromatch": "^4.0.5",
|
|
102
|
-
"mlly": "^0.5.
|
|
102
|
+
"mlly": "^0.5.17",
|
|
103
103
|
"mrmime": "^1.0.1",
|
|
104
104
|
"okie": "^1.0.1",
|
|
105
105
|
"open": "^8.4.0",
|
|
106
|
-
"parse5": "^7.1.
|
|
106
|
+
"parse5": "^7.1.2",
|
|
107
107
|
"periscopic": "^3.0.4",
|
|
108
108
|
"picocolors": "^1.0.0",
|
|
109
109
|
"picomatch": "^2.3.1",
|
|
110
110
|
"postcss-import": "^15.0.0",
|
|
111
111
|
"postcss-load-config": "^4.0.1",
|
|
112
|
-
"postcss-modules": "^
|
|
112
|
+
"postcss-modules": "^6.0.0",
|
|
113
113
|
"resolve.exports": "^1.1.0",
|
|
114
114
|
"sirv": "^2.0.2",
|
|
115
115
|
"source-map-js": "^1.0.2",
|
package/types/customEvent.d.ts
CHANGED
package/types/hot.d.ts
CHANGED
|
@@ -15,15 +15,15 @@ export interface ViteHotContext {
|
|
|
15
15
|
cb: (mods: Array<ModuleNamespace | undefined>) => void
|
|
16
16
|
): void
|
|
17
17
|
|
|
18
|
-
acceptExports(exportNames: string | readonly string[]): void
|
|
19
18
|
acceptExports(
|
|
20
19
|
exportNames: string | readonly string[],
|
|
21
|
-
cb
|
|
20
|
+
cb?: (mod: ModuleNamespace | undefined) => void
|
|
22
21
|
): void
|
|
23
22
|
|
|
24
23
|
dispose(cb: (data: any) => void): void
|
|
24
|
+
prune(cb: (data: any) => void): void
|
|
25
25
|
decline(): void
|
|
26
|
-
invalidate(): void
|
|
26
|
+
invalidate(message?: string): void
|
|
27
27
|
|
|
28
28
|
on<T extends string>(
|
|
29
29
|
event: T,
|