vite 6.0.0-alpha.18 → 6.0.0-alpha.19
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 +111 -144
- package/client.d.ts +4 -0
- package/dist/client/client.mjs +614 -612
- package/dist/client/env.mjs +18 -24
- package/dist/node/chunks/{dep-DXWVQosX.js → dep-BWEMV5Th.js} +49165 -46447
- package/dist/node/chunks/{dep-CrWVpuYf.js → dep-D-7KCb9p.js} +32 -2
- package/dist/node/chunks/{dep-70g8Z1cd.js → dep-MbEgMyUv.js} +10 -14
- package/dist/node/chunks/{dep-DlhHXrzk.js → dep-bCS_cgqC.js} +1 -1
- package/dist/node/cli.js +253 -263
- package/dist/node/constants.js +105 -108
- package/dist/node/index.d.ts +75 -74
- package/dist/node/index.js +125 -143
- package/dist/node/module-runner.d.ts +3 -0
- package/dist/node/module-runner.js +173 -108
- package/dist/node-cjs/publicUtils.cjs +536 -606
- package/package.json +16 -17
- package/dist/client/client.mjs.map +0 -1
- package/dist/client/env.mjs.map +0 -1
package/dist/node/index.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
export { parseAst, parseAstAsync } from 'rollup/parseAst';
|
2
|
-
import { i as isInNodeModules, a as arraify } from './chunks/dep-
|
3
|
-
export { B as BuildEnvironment, D as DevEnvironment, S as ServerHMRConnector, b as build, j as buildErrorMessage, e as createBuilder, x as createFilter, f as createIdResolver, A as createLogger, k as createNodeDevEnvironment, c as createServer, n as createServerModuleRunner, d as defineConfig, m as fetchModule, g as formatPostcssSourceMap, F as isFileLoadingAllowed, E as isFileServingAllowed, l as loadConfigFromFile, G as loadEnv, w as mergeAlias, v as mergeConfig, q as moduleRunnerTransform, u as normalizePath, o as optimizeDeps, h as preprocessCSS, p as preview, r as resolveConfig, H as resolveEnvPrefix, y as rollupVersion, C as searchForWorkspaceRoot, z as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-
|
2
|
+
import { i as isInNodeModules, a as arraify } from './chunks/dep-BWEMV5Th.js';
|
3
|
+
export { B as BuildEnvironment, D as DevEnvironment, S as ServerHMRConnector, b as build, j as buildErrorMessage, e as createBuilder, x as createFilter, f as createIdResolver, A as createLogger, k as createNodeDevEnvironment, c as createServer, n as createServerModuleRunner, d as defineConfig, m as fetchModule, g as formatPostcssSourceMap, F as isFileLoadingAllowed, E as isFileServingAllowed, l as loadConfigFromFile, G as loadEnv, w as mergeAlias, v as mergeConfig, q as moduleRunnerTransform, u as normalizePath, o as optimizeDeps, h as preprocessCSS, p as preview, r as resolveConfig, H as resolveEnvPrefix, y as rollupVersion, C as searchForWorkspaceRoot, z as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-BWEMV5Th.js';
|
4
4
|
export { VERSION as version } from './constants.js';
|
5
5
|
export { version as esbuildVersion } from 'esbuild';
|
6
6
|
import 'node:fs';
|
@@ -13,13 +13,15 @@ import 'node:module';
|
|
13
13
|
import 'tty';
|
14
14
|
import 'path';
|
15
15
|
import 'fs';
|
16
|
-
import 'events';
|
17
|
-
import '
|
16
|
+
import 'node:events';
|
17
|
+
import 'node:stream';
|
18
|
+
import 'node:string_decoder';
|
18
19
|
import 'node:child_process';
|
19
20
|
import 'node:http';
|
20
21
|
import 'node:https';
|
21
22
|
import 'util';
|
22
23
|
import 'net';
|
24
|
+
import 'events';
|
23
25
|
import 'url';
|
24
26
|
import 'http';
|
25
27
|
import 'stream';
|
@@ -33,7 +35,6 @@ import 'module';
|
|
33
35
|
import 'node:assert';
|
34
36
|
import 'node:v8';
|
35
37
|
import 'node:worker_threads';
|
36
|
-
import 'node:events';
|
37
38
|
import 'crypto';
|
38
39
|
import 'querystring';
|
39
40
|
import 'node:buffer';
|
@@ -42,161 +43,142 @@ import 'zlib';
|
|
42
43
|
import 'buffer';
|
43
44
|
import 'https';
|
44
45
|
import 'tls';
|
46
|
+
import 'assert';
|
45
47
|
import 'node:zlib';
|
46
48
|
|
47
|
-
|
48
|
-
//
|
49
|
-
|
50
|
-
|
51
|
-
/\.(css|less|sass|scss|styl|stylus|pcss|postcss|sss)(?:$|\?)/;
|
49
|
+
const CSS_LANGS_RE = (
|
50
|
+
// eslint-disable-next-line regexp/no-unused-capturing-group
|
51
|
+
/\.(css|less|sass|scss|styl|stylus|pcss|postcss|sss)(?:$|\?)/
|
52
|
+
);
|
52
53
|
const isCSSRequest = (request) => CSS_LANGS_RE.test(request);
|
53
|
-
// Use splitVendorChunkPlugin() to get the same manualChunks strategy as Vite 2.7
|
54
|
-
// We don't recommend using this strategy as a general solution moving forward
|
55
|
-
// splitVendorChunk is a simple index/vendor strategy that was used in Vite
|
56
|
-
// until v2.8. It is exposed to let people continue to use it in case it was
|
57
|
-
// working well for their setups.
|
58
|
-
// The cache needs to be reset on buildStart for watch mode to work correctly
|
59
|
-
// Don't use this manualChunks strategy for ssr, lib mode, and 'umd' or 'iife'
|
60
|
-
/**
|
61
|
-
* @deprecated use build.rollupOptions.output.manualChunks or framework specific configuration
|
62
|
-
*/
|
63
54
|
class SplitVendorChunkCache {
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
55
|
+
cache;
|
56
|
+
constructor() {
|
57
|
+
this.cache = /* @__PURE__ */ new Map();
|
58
|
+
}
|
59
|
+
reset() {
|
60
|
+
this.cache = /* @__PURE__ */ new Map();
|
61
|
+
}
|
71
62
|
}
|
72
|
-
/**
|
73
|
-
* @deprecated use build.rollupOptions.output.manualChunks or framework specific configuration
|
74
|
-
*/
|
75
63
|
function splitVendorChunk(options = {}) {
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
}
|
83
|
-
};
|
64
|
+
const cache = options.cache ?? new SplitVendorChunkCache();
|
65
|
+
return (id, { getModuleInfo }) => {
|
66
|
+
if (isInNodeModules(id) && !isCSSRequest(id) && staticImportedByEntry(id, getModuleInfo, cache.cache)) {
|
67
|
+
return "vendor";
|
68
|
+
}
|
69
|
+
};
|
84
70
|
}
|
85
71
|
function staticImportedByEntry(id, getModuleInfo, cache, importStack = []) {
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
72
|
+
if (cache.has(id)) {
|
73
|
+
return cache.get(id);
|
74
|
+
}
|
75
|
+
if (importStack.includes(id)) {
|
76
|
+
cache.set(id, false);
|
77
|
+
return false;
|
78
|
+
}
|
79
|
+
const mod = getModuleInfo(id);
|
80
|
+
if (!mod) {
|
81
|
+
cache.set(id, false);
|
82
|
+
return false;
|
83
|
+
}
|
84
|
+
if (mod.isEntry) {
|
85
|
+
cache.set(id, true);
|
86
|
+
return true;
|
87
|
+
}
|
88
|
+
const someImporterIs = mod.importers.some(
|
89
|
+
(importer) => staticImportedByEntry(
|
90
|
+
importer,
|
91
|
+
getModuleInfo,
|
92
|
+
cache,
|
93
|
+
importStack.concat(id)
|
94
|
+
)
|
95
|
+
);
|
96
|
+
cache.set(id, someImporterIs);
|
97
|
+
return someImporterIs;
|
106
98
|
}
|
107
|
-
/**
|
108
|
-
* @deprecated use build.rollupOptions.output.manualChunks or framework specific configuration
|
109
|
-
*/
|
110
99
|
function splitVendorChunkPlugin() {
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
}
|
100
|
+
const caches = [];
|
101
|
+
function createSplitVendorChunk(output, config) {
|
102
|
+
const cache = new SplitVendorChunkCache();
|
103
|
+
caches.push(cache);
|
104
|
+
const build = config.build ?? {};
|
105
|
+
const format = output?.format;
|
106
|
+
if (!build.ssr && !build.lib && format !== "umd" && format !== "iife") {
|
107
|
+
return splitVendorChunk({ cache });
|
120
108
|
}
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
}
|
137
|
-
else {
|
138
|
-
// else, leave the object form of manualChunks untouched, as
|
139
|
-
// we can't safely replicate rollup handling.
|
140
|
-
// eslint-disable-next-line no-console
|
141
|
-
console.warn("(!) the `splitVendorChunk` plugin doesn't have any effect when using the object form of `build.rollupOptions.output.manualChunks`. Consider using the function form instead.");
|
142
|
-
}
|
143
|
-
}
|
144
|
-
else {
|
145
|
-
output.manualChunks = viteManualChunks;
|
146
|
-
}
|
147
|
-
}
|
148
|
-
}
|
149
|
-
}
|
150
|
-
else {
|
151
|
-
return {
|
152
|
-
build: {
|
153
|
-
rollupOptions: {
|
154
|
-
output: {
|
155
|
-
manualChunks: createSplitVendorChunk({}, config),
|
156
|
-
},
|
157
|
-
},
|
158
|
-
},
|
109
|
+
}
|
110
|
+
return {
|
111
|
+
name: "vite:split-vendor-chunk",
|
112
|
+
config(config) {
|
113
|
+
let outputs = config?.build?.rollupOptions?.output;
|
114
|
+
if (outputs) {
|
115
|
+
outputs = arraify(outputs);
|
116
|
+
for (const output of outputs) {
|
117
|
+
const viteManualChunks = createSplitVendorChunk(output, config);
|
118
|
+
if (viteManualChunks) {
|
119
|
+
if (output.manualChunks) {
|
120
|
+
if (typeof output.manualChunks === "function") {
|
121
|
+
const userManualChunks = output.manualChunks;
|
122
|
+
output.manualChunks = (id, api) => {
|
123
|
+
return userManualChunks(id, api) ?? viteManualChunks(id, api);
|
159
124
|
};
|
125
|
+
} else {
|
126
|
+
console.warn(
|
127
|
+
"(!) the `splitVendorChunk` plugin doesn't have any effect when using the object form of `build.rollupOptions.output.manualChunks`. Consider using the function form instead."
|
128
|
+
);
|
129
|
+
}
|
130
|
+
} else {
|
131
|
+
output.manualChunks = viteManualChunks;
|
132
|
+
}
|
133
|
+
}
|
134
|
+
}
|
135
|
+
} else {
|
136
|
+
return {
|
137
|
+
build: {
|
138
|
+
rollupOptions: {
|
139
|
+
output: {
|
140
|
+
manualChunks: createSplitVendorChunk({}, config)
|
141
|
+
}
|
160
142
|
}
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
143
|
+
}
|
144
|
+
};
|
145
|
+
}
|
146
|
+
},
|
147
|
+
buildStart() {
|
148
|
+
caches.forEach((cache) => cache.reset());
|
149
|
+
}
|
150
|
+
};
|
166
151
|
}
|
167
152
|
|
168
153
|
class RemoteEnvironmentTransport {
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
r: result,
|
184
|
-
i: data.i,
|
185
|
-
});
|
186
|
-
}
|
187
|
-
catch (error) {
|
188
|
-
this.options.send({
|
189
|
-
__v: true,
|
190
|
-
e: {
|
191
|
-
name: error.name,
|
192
|
-
message: error.message,
|
193
|
-
stack: error.stack,
|
194
|
-
},
|
195
|
-
i: data.i,
|
196
|
-
});
|
197
|
-
}
|
154
|
+
constructor(options) {
|
155
|
+
this.options = options;
|
156
|
+
}
|
157
|
+
register(environment) {
|
158
|
+
this.options.onMessage(async (data) => {
|
159
|
+
if (typeof data !== "object" || !data || !data.__v) return;
|
160
|
+
const method = data.m;
|
161
|
+
const parameters = data.a;
|
162
|
+
try {
|
163
|
+
const result = await environment[method](...parameters);
|
164
|
+
this.options.send({
|
165
|
+
__v: true,
|
166
|
+
r: result,
|
167
|
+
i: data.i
|
198
168
|
});
|
199
|
-
|
169
|
+
} catch (error) {
|
170
|
+
this.options.send({
|
171
|
+
__v: true,
|
172
|
+
e: {
|
173
|
+
name: error.name,
|
174
|
+
message: error.message,
|
175
|
+
stack: error.stack
|
176
|
+
},
|
177
|
+
i: data.i
|
178
|
+
});
|
179
|
+
}
|
180
|
+
});
|
181
|
+
}
|
200
182
|
}
|
201
183
|
|
202
184
|
export { RemoteEnvironmentTransport, isCSSRequest, splitVendorChunk, splitVendorChunkPlugin };
|
@@ -122,6 +122,7 @@ declare class ModuleRunner {
|
|
122
122
|
private readonly envProxy;
|
123
123
|
private readonly transport;
|
124
124
|
private readonly resetSourceMapSupport?;
|
125
|
+
private readonly root;
|
125
126
|
private destroyed;
|
126
127
|
constructor(options: ModuleRunnerOptions, evaluator: ModuleEvaluator, debug?: ModuleRunnerDebugger | undefined);
|
127
128
|
/**
|
@@ -143,6 +144,8 @@ declare class ModuleRunner {
|
|
143
144
|
isDestroyed(): boolean;
|
144
145
|
private normalizeEntryUrl;
|
145
146
|
private processImport;
|
147
|
+
private isCircularModule;
|
148
|
+
private isCircularImport;
|
146
149
|
private cachedRequest;
|
147
150
|
private cachedModule;
|
148
151
|
protected directRequest(id: string, mod: ModuleCache, _callstack: string[]): Promise<any>;
|