vite 6.0.0-alpha.2 → 6.0.0-alpha.4
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/dist/client/client.mjs +9 -8
- package/dist/client/client.mjs.map +1 -1
- package/dist/node/chunks/{dep-E4cF1RpV.js → dep-8UjKy9Ch.js} +27040 -27127
- package/dist/node/chunks/{dep-DKZVy3_n.js → dep-BJOLgJFH.js} +1 -1
- package/dist/node/chunks/dep-C7zR1Rh8.js +233 -0
- package/dist/node/chunks/{dep-DK04Q0H9.js → dep-m9gtlanK.js} +1 -1
- package/dist/node/cli.js +43 -73
- package/dist/node/index.d.ts +167 -83
- package/dist/node/index.js +9 -120
- package/dist/node/module-runner.d.ts +11 -10
- package/dist/node/module-runner.js +55 -44
- package/dist/node-cjs/publicUtils.cjs +72 -33
- package/index.cjs +1 -0
- package/package.json +3 -3
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import { b as commonjsGlobal, g as getDefaultExportFromCjs } from './dep-C7zR1Rh8.js';
|
2
2
|
import require$$0__default from 'fs';
|
3
3
|
import require$$0 from 'postcss';
|
4
4
|
import require$$0$1 from 'path';
|
@@ -0,0 +1,233 @@
|
|
1
|
+
import readline from 'node:readline';
|
2
|
+
import require$$0 from 'tty';
|
3
|
+
|
4
|
+
import { fileURLToPath as __cjs_fileURLToPath } from 'node:url';
|
5
|
+
import { dirname as __cjs_dirname } from 'node:path';
|
6
|
+
import { createRequire as __cjs_createRequire } from 'node:module';
|
7
|
+
|
8
|
+
const __filename = __cjs_fileURLToPath(import.meta.url);
|
9
|
+
const __dirname = __cjs_dirname(__filename);
|
10
|
+
const require = __cjs_createRequire(import.meta.url);
|
11
|
+
const __require = require;
|
12
|
+
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
13
|
+
|
14
|
+
function getDefaultExportFromCjs (x) {
|
15
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
16
|
+
}
|
17
|
+
|
18
|
+
function getAugmentedNamespace(n) {
|
19
|
+
if (n.__esModule) return n;
|
20
|
+
var f = n.default;
|
21
|
+
if (typeof f == "function") {
|
22
|
+
var a = function a () {
|
23
|
+
if (this instanceof a) {
|
24
|
+
return Reflect.construct(f, arguments, this.constructor);
|
25
|
+
}
|
26
|
+
return f.apply(this, arguments);
|
27
|
+
};
|
28
|
+
a.prototype = f.prototype;
|
29
|
+
} else a = {};
|
30
|
+
Object.defineProperty(a, '__esModule', {value: true});
|
31
|
+
Object.keys(n).forEach(function (k) {
|
32
|
+
var d = Object.getOwnPropertyDescriptor(n, k);
|
33
|
+
Object.defineProperty(a, k, d.get ? d : {
|
34
|
+
enumerable: true,
|
35
|
+
get: function () {
|
36
|
+
return n[k];
|
37
|
+
}
|
38
|
+
});
|
39
|
+
});
|
40
|
+
return a;
|
41
|
+
}
|
42
|
+
|
43
|
+
var picocolors = {exports: {}};
|
44
|
+
|
45
|
+
let tty = require$$0;
|
46
|
+
|
47
|
+
let isColorSupported =
|
48
|
+
!("NO_COLOR" in process.env || process.argv.includes("--no-color")) &&
|
49
|
+
("FORCE_COLOR" in process.env ||
|
50
|
+
process.argv.includes("--color") ||
|
51
|
+
process.platform === "win32" ||
|
52
|
+
(tty.isatty(1) && process.env.TERM !== "dumb") ||
|
53
|
+
"CI" in process.env);
|
54
|
+
|
55
|
+
let formatter =
|
56
|
+
(open, close, replace = open) =>
|
57
|
+
input => {
|
58
|
+
let string = "" + input;
|
59
|
+
let index = string.indexOf(close, open.length);
|
60
|
+
return ~index
|
61
|
+
? open + replaceClose(string, close, replace, index) + close
|
62
|
+
: open + string + close
|
63
|
+
};
|
64
|
+
|
65
|
+
let replaceClose = (string, close, replace, index) => {
|
66
|
+
let start = string.substring(0, index) + replace;
|
67
|
+
let end = string.substring(index + close.length);
|
68
|
+
let nextIndex = end.indexOf(close);
|
69
|
+
return ~nextIndex ? start + replaceClose(end, close, replace, nextIndex) : start + end
|
70
|
+
};
|
71
|
+
|
72
|
+
let createColors = (enabled = isColorSupported) => ({
|
73
|
+
isColorSupported: enabled,
|
74
|
+
reset: enabled ? s => `\x1b[0m${s}\x1b[0m` : String,
|
75
|
+
bold: enabled ? formatter("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m") : String,
|
76
|
+
dim: enabled ? formatter("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m") : String,
|
77
|
+
italic: enabled ? formatter("\x1b[3m", "\x1b[23m") : String,
|
78
|
+
underline: enabled ? formatter("\x1b[4m", "\x1b[24m") : String,
|
79
|
+
inverse: enabled ? formatter("\x1b[7m", "\x1b[27m") : String,
|
80
|
+
hidden: enabled ? formatter("\x1b[8m", "\x1b[28m") : String,
|
81
|
+
strikethrough: enabled ? formatter("\x1b[9m", "\x1b[29m") : String,
|
82
|
+
black: enabled ? formatter("\x1b[30m", "\x1b[39m") : String,
|
83
|
+
red: enabled ? formatter("\x1b[31m", "\x1b[39m") : String,
|
84
|
+
green: enabled ? formatter("\x1b[32m", "\x1b[39m") : String,
|
85
|
+
yellow: enabled ? formatter("\x1b[33m", "\x1b[39m") : String,
|
86
|
+
blue: enabled ? formatter("\x1b[34m", "\x1b[39m") : String,
|
87
|
+
magenta: enabled ? formatter("\x1b[35m", "\x1b[39m") : String,
|
88
|
+
cyan: enabled ? formatter("\x1b[36m", "\x1b[39m") : String,
|
89
|
+
white: enabled ? formatter("\x1b[37m", "\x1b[39m") : String,
|
90
|
+
gray: enabled ? formatter("\x1b[90m", "\x1b[39m") : String,
|
91
|
+
bgBlack: enabled ? formatter("\x1b[40m", "\x1b[49m") : String,
|
92
|
+
bgRed: enabled ? formatter("\x1b[41m", "\x1b[49m") : String,
|
93
|
+
bgGreen: enabled ? formatter("\x1b[42m", "\x1b[49m") : String,
|
94
|
+
bgYellow: enabled ? formatter("\x1b[43m", "\x1b[49m") : String,
|
95
|
+
bgBlue: enabled ? formatter("\x1b[44m", "\x1b[49m") : String,
|
96
|
+
bgMagenta: enabled ? formatter("\x1b[45m", "\x1b[49m") : String,
|
97
|
+
bgCyan: enabled ? formatter("\x1b[46m", "\x1b[49m") : String,
|
98
|
+
bgWhite: enabled ? formatter("\x1b[47m", "\x1b[49m") : String,
|
99
|
+
});
|
100
|
+
|
101
|
+
picocolors.exports = createColors();
|
102
|
+
picocolors.exports.createColors = createColors;
|
103
|
+
|
104
|
+
var picocolorsExports = picocolors.exports;
|
105
|
+
var colors = /*@__PURE__*/getDefaultExportFromCjs(picocolorsExports);
|
106
|
+
|
107
|
+
/* eslint no-console: 0 */
|
108
|
+
const LogLevels = {
|
109
|
+
silent: 0,
|
110
|
+
error: 1,
|
111
|
+
warn: 2,
|
112
|
+
info: 3,
|
113
|
+
};
|
114
|
+
let lastType;
|
115
|
+
let lastMsg;
|
116
|
+
let sameCount = 0;
|
117
|
+
function clearScreen() {
|
118
|
+
const repeatCount = process.stdout.rows - 2;
|
119
|
+
const blank = repeatCount > 0 ? '\n'.repeat(repeatCount) : '';
|
120
|
+
console.log(blank);
|
121
|
+
readline.cursorTo(process.stdout, 0, 0);
|
122
|
+
readline.clearScreenDown(process.stdout);
|
123
|
+
}
|
124
|
+
// Only initialize the timeFormatter when the timestamp option is used, and
|
125
|
+
// reuse it across all loggers
|
126
|
+
let timeFormatter;
|
127
|
+
function getTimeFormatter() {
|
128
|
+
timeFormatter ??= new Intl.DateTimeFormat(undefined, {
|
129
|
+
hour: 'numeric',
|
130
|
+
minute: 'numeric',
|
131
|
+
second: 'numeric',
|
132
|
+
});
|
133
|
+
return timeFormatter;
|
134
|
+
}
|
135
|
+
function createLogger(level = 'info', options = {}) {
|
136
|
+
if (options.customLogger) {
|
137
|
+
return options.customLogger;
|
138
|
+
}
|
139
|
+
const loggedErrors = new WeakSet();
|
140
|
+
const { prefix = '[vite]', allowClearScreen = true } = options;
|
141
|
+
const thresh = LogLevels[level];
|
142
|
+
const canClearScreen = allowClearScreen && process.stdout.isTTY && !process.env.CI;
|
143
|
+
const clear = canClearScreen ? clearScreen : () => { };
|
144
|
+
function format(type, msg, options = {}) {
|
145
|
+
if (options.timestamp) {
|
146
|
+
const color = type === 'info'
|
147
|
+
? colors.cyan
|
148
|
+
: type === 'warn'
|
149
|
+
? colors.yellow
|
150
|
+
: colors.red;
|
151
|
+
const tag = color(colors.bold(prefix));
|
152
|
+
const environment = options.environment ? options.environment + ' ' : '';
|
153
|
+
return `${colors.dim(getTimeFormatter().format(new Date()))} ${tag} ${environment}${msg}`;
|
154
|
+
}
|
155
|
+
else {
|
156
|
+
return msg;
|
157
|
+
}
|
158
|
+
}
|
159
|
+
function output(type, msg, options = {}) {
|
160
|
+
if (thresh >= LogLevels[type]) {
|
161
|
+
const method = type === 'info' ? 'log' : type;
|
162
|
+
if (options.error) {
|
163
|
+
loggedErrors.add(options.error);
|
164
|
+
}
|
165
|
+
if (canClearScreen) {
|
166
|
+
if (type === lastType && msg === lastMsg) {
|
167
|
+
sameCount++;
|
168
|
+
clear();
|
169
|
+
console[method](format(type, msg, options), colors.yellow(`(x${sameCount + 1})`));
|
170
|
+
}
|
171
|
+
else {
|
172
|
+
sameCount = 0;
|
173
|
+
lastMsg = msg;
|
174
|
+
lastType = type;
|
175
|
+
if (options.clear) {
|
176
|
+
clear();
|
177
|
+
}
|
178
|
+
console[method](format(type, msg, options));
|
179
|
+
}
|
180
|
+
}
|
181
|
+
else {
|
182
|
+
console[method](format(type, msg, options));
|
183
|
+
}
|
184
|
+
}
|
185
|
+
}
|
186
|
+
const warnedMessages = new Set();
|
187
|
+
const logger = {
|
188
|
+
hasWarned: false,
|
189
|
+
info(msg, opts) {
|
190
|
+
output('info', msg, opts);
|
191
|
+
},
|
192
|
+
warn(msg, opts) {
|
193
|
+
logger.hasWarned = true;
|
194
|
+
output('warn', msg, opts);
|
195
|
+
},
|
196
|
+
warnOnce(msg, opts) {
|
197
|
+
if (warnedMessages.has(msg))
|
198
|
+
return;
|
199
|
+
logger.hasWarned = true;
|
200
|
+
output('warn', msg, opts);
|
201
|
+
warnedMessages.add(msg);
|
202
|
+
},
|
203
|
+
error(msg, opts) {
|
204
|
+
logger.hasWarned = true;
|
205
|
+
output('error', msg, opts);
|
206
|
+
},
|
207
|
+
clearScreen(type) {
|
208
|
+
if (thresh >= LogLevels[type]) {
|
209
|
+
clear();
|
210
|
+
}
|
211
|
+
},
|
212
|
+
hasErrorLogged(error) {
|
213
|
+
return loggedErrors.has(error);
|
214
|
+
},
|
215
|
+
};
|
216
|
+
return logger;
|
217
|
+
}
|
218
|
+
function printServerUrls(urls, optionsHost, info) {
|
219
|
+
const colorUrl = (url) => colors.cyan(url.replace(/:(\d+)\//, (_, port) => `:${colors.bold(port)}/`));
|
220
|
+
for (const url of urls.local) {
|
221
|
+
info(` ${colors.green('➜')} ${colors.bold('Local')}: ${colorUrl(url)}`);
|
222
|
+
}
|
223
|
+
for (const url of urls.network) {
|
224
|
+
info(` ${colors.green('➜')} ${colors.bold('Network')}: ${colorUrl(url)}`);
|
225
|
+
}
|
226
|
+
if (urls.network.length === 0 && optionsHost === undefined) {
|
227
|
+
info(colors.dim(` ${colors.green('➜')} ${colors.bold('Network')}: use `) +
|
228
|
+
colors.bold('--host') +
|
229
|
+
colors.dim(' to expose'));
|
230
|
+
}
|
231
|
+
}
|
232
|
+
|
233
|
+
export { LogLevels as L, colors as a, commonjsGlobal as b, createLogger as c, getAugmentedNamespace as d, printServerUrls as e, getDefaultExportFromCjs as g, picocolorsExports as p };
|
package/dist/node/cli.js
CHANGED
@@ -2,45 +2,11 @@ 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 {
|
5
|
+
import { a as colors, c as createLogger } from './chunks/dep-C7zR1Rh8.js';
|
6
6
|
import { VERSION } from './constants.js';
|
7
|
-
import 'node:fs/promises';
|
8
|
-
import 'node:url';
|
9
|
-
import 'node:util';
|
10
|
-
import 'node:module';
|
11
|
-
import 'tty';
|
12
|
-
import 'path';
|
13
|
-
import 'esbuild';
|
14
|
-
import 'fs';
|
15
|
-
import 'assert';
|
16
|
-
import 'node:child_process';
|
17
|
-
import 'node:http';
|
18
|
-
import 'node:https';
|
19
|
-
import 'util';
|
20
|
-
import 'net';
|
21
|
-
import 'url';
|
22
|
-
import 'http';
|
23
|
-
import 'stream';
|
24
|
-
import 'os';
|
25
|
-
import 'child_process';
|
26
|
-
import 'node:os';
|
27
|
-
import 'node:crypto';
|
28
|
-
import 'node:dns';
|
29
|
-
import 'node:assert';
|
30
|
-
import 'node:v8';
|
31
|
-
import 'module';
|
32
|
-
import 'node:worker_threads';
|
33
|
-
import 'rollup/parseAst';
|
34
|
-
import 'node:events';
|
35
|
-
import 'crypto';
|
36
|
-
import 'node:buffer';
|
37
7
|
import 'node:readline';
|
38
|
-
import '
|
39
|
-
import '
|
40
|
-
import 'https';
|
41
|
-
import 'tls';
|
42
|
-
import 'querystring';
|
43
|
-
import 'node:zlib';
|
8
|
+
import 'tty';
|
9
|
+
import 'node:url';
|
44
10
|
|
45
11
|
function toArr(any) {
|
46
12
|
return any == null ? [] : Array.isArray(any) ? any : [any];
|
@@ -719,8 +685,7 @@ function cleanGlobalCLIOptions(options) {
|
|
719
685
|
*/
|
720
686
|
function cleanBuilderCLIOptions(options) {
|
721
687
|
const ret = { ...options };
|
722
|
-
delete ret.
|
723
|
-
delete ret.all;
|
688
|
+
delete ret.app;
|
724
689
|
return ret;
|
725
690
|
}
|
726
691
|
/**
|
@@ -766,7 +731,7 @@ cli
|
|
766
731
|
filterDuplicateOptions(options);
|
767
732
|
// output structure is preserved even after bundling so require()
|
768
733
|
// is ok here
|
769
|
-
const { createServer } = await import('./chunks/dep-
|
734
|
+
const { createServer } = await import('./chunks/dep-8UjKy9Ch.js').then(function (n) { return n.C; });
|
770
735
|
try {
|
771
736
|
const server = await createServer({
|
772
737
|
root,
|
@@ -844,10 +809,10 @@ cli
|
|
844
809
|
.option('--emptyOutDir', `[boolean] force empty outDir when it's outside of root`)
|
845
810
|
.option('-w, --watch', `[boolean] rebuilds when modules have changed on disk`)
|
846
811
|
.option('--environment [name]', `[string] build a single environment`)
|
847
|
-
.option('--
|
812
|
+
.option('--app', `[boolean] same as builder.entireApp`)
|
848
813
|
.action(async (root, options) => {
|
849
814
|
filterDuplicateOptions(options);
|
850
|
-
const {
|
815
|
+
const { createBuilder, buildEnvironment } = await import('./chunks/dep-8UjKy9Ch.js').then(function (n) { return n.E; });
|
851
816
|
const buildOptions = cleanGlobalCLIOptions(cleanBuilderCLIOptions(options));
|
852
817
|
const config = {
|
853
818
|
root,
|
@@ -859,22 +824,19 @@ cli
|
|
859
824
|
build: buildOptions,
|
860
825
|
};
|
861
826
|
try {
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
|
867
|
-
|
868
|
-
|
869
|
-
|
870
|
-
}
|
871
|
-
else {
|
872
|
-
// --all: build all environments
|
873
|
-
await builder.buildEnvironments();
|
874
|
-
}
|
827
|
+
const builder = await createBuilder(config);
|
828
|
+
// TODO: Backward compatibility with lib and single environment build
|
829
|
+
// Ideally we would move to only building the entire app with this command
|
830
|
+
if (builder.config.build.lib) {
|
831
|
+
await buildEnvironment(builder.config, builder.environments.client, builder.config.build.lib);
|
832
|
+
}
|
833
|
+
else if (builder.config.builder.entireApp || options.app) {
|
834
|
+
await builder.buildApp();
|
875
835
|
}
|
876
836
|
else {
|
877
|
-
|
837
|
+
const ssr = !!builder.config.build.ssr;
|
838
|
+
const environment = builder.environments[ssr ? 'ssr' : 'client'];
|
839
|
+
await builder.build(environment);
|
878
840
|
}
|
879
841
|
}
|
880
842
|
catch (e) {
|
@@ -890,23 +852,31 @@ cli
|
|
890
852
|
.command('optimize [root]', 'pre-bundle dependencies')
|
891
853
|
.option('--force', `[boolean] force the optimizer to ignore the cache and re-bundle`)
|
892
854
|
.action(async (root, options) => {
|
893
|
-
|
894
|
-
|
855
|
+
/* TODO: do we need this command?
|
856
|
+
|
857
|
+
filterDuplicateOptions(options)
|
858
|
+
const { optimizeDeps } = await import('./optimizer')
|
895
859
|
try {
|
896
|
-
|
897
|
-
|
898
|
-
|
899
|
-
|
900
|
-
|
901
|
-
|
902
|
-
|
903
|
-
|
904
|
-
|
905
|
-
|
906
|
-
|
907
|
-
|
908
|
-
|
909
|
-
|
860
|
+
const config = await resolveConfig(
|
861
|
+
{
|
862
|
+
root,
|
863
|
+
base: options.base,
|
864
|
+
configFile: options.config,
|
865
|
+
logLevel: options.logLevel,
|
866
|
+
mode: options.mode,
|
867
|
+
},
|
868
|
+
'serve',
|
869
|
+
)
|
870
|
+
const environment = new Environment('client', config)
|
871
|
+
await optimizeDeps(environment, options.force, true)
|
872
|
+
} catch (e) {
|
873
|
+
createLogger(options.logLevel).error(
|
874
|
+
colors.red(`error when optimizing deps:\n${e.stack}`),
|
875
|
+
{ error: e },
|
876
|
+
)
|
877
|
+
process.exit(1)
|
878
|
+
}
|
879
|
+
*/
|
910
880
|
});
|
911
881
|
// preview
|
912
882
|
cli
|
@@ -918,7 +888,7 @@ cli
|
|
918
888
|
.option('--outDir <dir>', `[string] output directory (default: dist)`)
|
919
889
|
.action(async (root, options) => {
|
920
890
|
filterDuplicateOptions(options);
|
921
|
-
const { preview } = await import('./chunks/dep-
|
891
|
+
const { preview } = await import('./chunks/dep-8UjKy9Ch.js').then(function (n) { return n.F; });
|
922
892
|
try {
|
923
893
|
const server = await preview({
|
924
894
|
root,
|