vite-node 0.26.2 → 0.27.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/dist/chunk-hmr.cjs +5 -4
- package/dist/chunk-hmr.mjs +4 -4
- package/dist/cli.cjs +10 -619
- package/dist/cli.d.ts +1 -1
- package/dist/cli.mjs +6 -620
- package/dist/client.cjs +49 -10
- package/dist/client.d.ts +1 -1
- package/dist/client.mjs +49 -10
- package/dist/hmr.cjs +1 -2
- package/dist/hmr.d.ts +1 -1
- package/dist/hmr.mjs +1 -2
- package/dist/index.d.ts +1 -1
- package/dist/server.cjs +33 -5
- package/dist/server.d.ts +1 -1
- package/dist/server.mjs +32 -5
- package/dist/source-map.d.ts +1 -1
- package/dist/{types-6a15e0b9.d.ts → types-63205a44.d.ts} +5 -0
- package/dist/types.d.ts +1 -1
- package/dist/utils.cjs +0 -4
- package/dist/utils.d.ts +2 -3
- package/dist/utils.mjs +1 -4
- package/package.json +4 -3
- package/dist/chunk-picocolors.cjs +0 -70
- package/dist/chunk-picocolors.mjs +0 -64
package/dist/client.cjs
CHANGED
|
@@ -87,19 +87,25 @@ class ModuleCacheMap extends Map {
|
|
|
87
87
|
Object.assign(super.get(fsPath), mod);
|
|
88
88
|
return this;
|
|
89
89
|
}
|
|
90
|
+
setByModuleId(modulePath, mod) {
|
|
91
|
+
return super.set(modulePath, mod);
|
|
92
|
+
}
|
|
90
93
|
set(fsPath, mod) {
|
|
91
|
-
|
|
92
|
-
|
|
94
|
+
return this.setByModuleId(this.normalizePath(fsPath), mod);
|
|
95
|
+
}
|
|
96
|
+
getByModuleId(modulePath) {
|
|
97
|
+
if (!super.has(modulePath))
|
|
98
|
+
super.set(modulePath, {});
|
|
99
|
+
return super.get(modulePath);
|
|
93
100
|
}
|
|
94
101
|
get(fsPath) {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
return super.
|
|
102
|
+
return this.getByModuleId(this.normalizePath(fsPath));
|
|
103
|
+
}
|
|
104
|
+
deleteByModuleId(modulePath) {
|
|
105
|
+
return super.delete(modulePath);
|
|
99
106
|
}
|
|
100
107
|
delete(fsPath) {
|
|
101
|
-
|
|
102
|
-
return super.delete(fsPath);
|
|
108
|
+
return this.deleteByModuleId(this.normalizePath(fsPath));
|
|
103
109
|
}
|
|
104
110
|
invalidateDepTree(ids, invalidated = /* @__PURE__ */ new Set()) {
|
|
105
111
|
for (const _id of ids) {
|
|
@@ -181,7 +187,7 @@ class ViteNodeRunner {
|
|
|
181
187
|
shouldResolveId(id, _importee) {
|
|
182
188
|
return !utils.isInternalRequest(id) && !mlly.isNodeBuiltin(id);
|
|
183
189
|
}
|
|
184
|
-
async
|
|
190
|
+
async _resolveUrl(id, importee) {
|
|
185
191
|
if (!this.shouldResolveId(id))
|
|
186
192
|
return [id, id];
|
|
187
193
|
if (importee && id.startsWith(utils.VALID_ID_PREFIX))
|
|
@@ -194,6 +200,15 @@ class ViteNodeRunner {
|
|
|
194
200
|
const fsPath = resolved ? resolvedId : utils.toFilePath(id, this.root);
|
|
195
201
|
return [resolvedId, fsPath];
|
|
196
202
|
}
|
|
203
|
+
async resolveUrl(id, importee) {
|
|
204
|
+
const resolveKey = `resolve:${id}`;
|
|
205
|
+
this.moduleCache.setByModuleId(resolveKey, { resolving: true });
|
|
206
|
+
try {
|
|
207
|
+
return await this._resolveUrl(id, importee);
|
|
208
|
+
} finally {
|
|
209
|
+
this.moduleCache.deleteByModuleId(resolveKey);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
197
212
|
async dependencyRequest(id, fsPath, callstack) {
|
|
198
213
|
var _a;
|
|
199
214
|
const getStack = () => {
|
|
@@ -220,7 +235,7 @@ ${getStack()}`), 2e3);
|
|
|
220
235
|
async directRequest(id, fsPath, _callstack) {
|
|
221
236
|
const moduleId = utils.normalizeModuleId(fsPath);
|
|
222
237
|
const callstack = [..._callstack, moduleId];
|
|
223
|
-
const mod = this.moduleCache.
|
|
238
|
+
const mod = this.moduleCache.getByModuleId(moduleId);
|
|
224
239
|
const request = async (dep) => {
|
|
225
240
|
const [id2, depFsPath] = await this.resolveUrl(dep, fsPath);
|
|
226
241
|
return this.dependencyRequest(id2, depFsPath, callstack);
|
|
@@ -329,6 +344,12 @@ ${getStack()}`), 2e3);
|
|
|
329
344
|
if (!this.shouldInterop(path, importedModule))
|
|
330
345
|
return importedModule;
|
|
331
346
|
const { mod, defaultExport } = interopModule(importedModule);
|
|
347
|
+
const modKeys = Reflect.ownKeys(mod);
|
|
348
|
+
let defaultKeys = !utils.isPrimitive(defaultExport) ? Reflect.ownKeys(defaultExport) : [];
|
|
349
|
+
if (typeof mod !== "function" && typeof defaultExport === "function") {
|
|
350
|
+
const reservedKeys = ["arguments", "caller", "prototype", "name", "length"];
|
|
351
|
+
defaultKeys = defaultKeys.filter((n) => typeof n === "string" && !reservedKeys.includes(n));
|
|
352
|
+
}
|
|
332
353
|
return new Proxy(mod, {
|
|
333
354
|
get(mod2, prop) {
|
|
334
355
|
if (prop === "default")
|
|
@@ -339,6 +360,24 @@ ${getStack()}`), 2e3);
|
|
|
339
360
|
if (prop === "default")
|
|
340
361
|
return defaultExport !== void 0;
|
|
341
362
|
return prop in mod2 || defaultExport && prop in defaultExport;
|
|
363
|
+
},
|
|
364
|
+
ownKeys() {
|
|
365
|
+
if (!defaultExport || utils.isPrimitive(defaultExport))
|
|
366
|
+
return modKeys;
|
|
367
|
+
const allKeys = [...modKeys, "default", ...defaultKeys];
|
|
368
|
+
return Array.from(new Set(allKeys));
|
|
369
|
+
},
|
|
370
|
+
getOwnPropertyDescriptor(mod2, prop) {
|
|
371
|
+
const descriptor = Reflect.getOwnPropertyDescriptor(mod2, prop);
|
|
372
|
+
if (descriptor)
|
|
373
|
+
return descriptor;
|
|
374
|
+
if (prop === "default" && defaultExport !== void 0) {
|
|
375
|
+
return {
|
|
376
|
+
value: defaultExport,
|
|
377
|
+
enumerable: true,
|
|
378
|
+
configurable: true
|
|
379
|
+
};
|
|
380
|
+
}
|
|
342
381
|
}
|
|
343
382
|
});
|
|
344
383
|
}
|
package/dist/client.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { j as DEFAULT_REQUEST_STUBS, M as ModuleCacheMap, h as ViteNodeRunner } from './types-
|
|
1
|
+
export { j as DEFAULT_REQUEST_STUBS, M as ModuleCacheMap, h as ViteNodeRunner } from './types-63205a44.js';
|
package/dist/client.mjs
CHANGED
|
@@ -60,19 +60,25 @@ class ModuleCacheMap extends Map {
|
|
|
60
60
|
Object.assign(super.get(fsPath), mod);
|
|
61
61
|
return this;
|
|
62
62
|
}
|
|
63
|
+
setByModuleId(modulePath, mod) {
|
|
64
|
+
return super.set(modulePath, mod);
|
|
65
|
+
}
|
|
63
66
|
set(fsPath, mod) {
|
|
64
|
-
|
|
65
|
-
|
|
67
|
+
return this.setByModuleId(this.normalizePath(fsPath), mod);
|
|
68
|
+
}
|
|
69
|
+
getByModuleId(modulePath) {
|
|
70
|
+
if (!super.has(modulePath))
|
|
71
|
+
super.set(modulePath, {});
|
|
72
|
+
return super.get(modulePath);
|
|
66
73
|
}
|
|
67
74
|
get(fsPath) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
return super.
|
|
75
|
+
return this.getByModuleId(this.normalizePath(fsPath));
|
|
76
|
+
}
|
|
77
|
+
deleteByModuleId(modulePath) {
|
|
78
|
+
return super.delete(modulePath);
|
|
72
79
|
}
|
|
73
80
|
delete(fsPath) {
|
|
74
|
-
|
|
75
|
-
return super.delete(fsPath);
|
|
81
|
+
return this.deleteByModuleId(this.normalizePath(fsPath));
|
|
76
82
|
}
|
|
77
83
|
invalidateDepTree(ids, invalidated = /* @__PURE__ */ new Set()) {
|
|
78
84
|
for (const _id of ids) {
|
|
@@ -154,7 +160,7 @@ class ViteNodeRunner {
|
|
|
154
160
|
shouldResolveId(id, _importee) {
|
|
155
161
|
return !isInternalRequest(id) && !isNodeBuiltin(id);
|
|
156
162
|
}
|
|
157
|
-
async
|
|
163
|
+
async _resolveUrl(id, importee) {
|
|
158
164
|
if (!this.shouldResolveId(id))
|
|
159
165
|
return [id, id];
|
|
160
166
|
if (importee && id.startsWith(VALID_ID_PREFIX))
|
|
@@ -167,6 +173,15 @@ class ViteNodeRunner {
|
|
|
167
173
|
const fsPath = resolved ? resolvedId : toFilePath(id, this.root);
|
|
168
174
|
return [resolvedId, fsPath];
|
|
169
175
|
}
|
|
176
|
+
async resolveUrl(id, importee) {
|
|
177
|
+
const resolveKey = `resolve:${id}`;
|
|
178
|
+
this.moduleCache.setByModuleId(resolveKey, { resolving: true });
|
|
179
|
+
try {
|
|
180
|
+
return await this._resolveUrl(id, importee);
|
|
181
|
+
} finally {
|
|
182
|
+
this.moduleCache.deleteByModuleId(resolveKey);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
170
185
|
async dependencyRequest(id, fsPath, callstack) {
|
|
171
186
|
var _a;
|
|
172
187
|
const getStack = () => {
|
|
@@ -193,7 +208,7 @@ ${getStack()}`), 2e3);
|
|
|
193
208
|
async directRequest(id, fsPath, _callstack) {
|
|
194
209
|
const moduleId = normalizeModuleId(fsPath);
|
|
195
210
|
const callstack = [..._callstack, moduleId];
|
|
196
|
-
const mod = this.moduleCache.
|
|
211
|
+
const mod = this.moduleCache.getByModuleId(moduleId);
|
|
197
212
|
const request = async (dep) => {
|
|
198
213
|
const [id2, depFsPath] = await this.resolveUrl(dep, fsPath);
|
|
199
214
|
return this.dependencyRequest(id2, depFsPath, callstack);
|
|
@@ -302,6 +317,12 @@ ${getStack()}`), 2e3);
|
|
|
302
317
|
if (!this.shouldInterop(path, importedModule))
|
|
303
318
|
return importedModule;
|
|
304
319
|
const { mod, defaultExport } = interopModule(importedModule);
|
|
320
|
+
const modKeys = Reflect.ownKeys(mod);
|
|
321
|
+
let defaultKeys = !isPrimitive(defaultExport) ? Reflect.ownKeys(defaultExport) : [];
|
|
322
|
+
if (typeof mod !== "function" && typeof defaultExport === "function") {
|
|
323
|
+
const reservedKeys = ["arguments", "caller", "prototype", "name", "length"];
|
|
324
|
+
defaultKeys = defaultKeys.filter((n) => typeof n === "string" && !reservedKeys.includes(n));
|
|
325
|
+
}
|
|
305
326
|
return new Proxy(mod, {
|
|
306
327
|
get(mod2, prop) {
|
|
307
328
|
if (prop === "default")
|
|
@@ -312,6 +333,24 @@ ${getStack()}`), 2e3);
|
|
|
312
333
|
if (prop === "default")
|
|
313
334
|
return defaultExport !== void 0;
|
|
314
335
|
return prop in mod2 || defaultExport && prop in defaultExport;
|
|
336
|
+
},
|
|
337
|
+
ownKeys() {
|
|
338
|
+
if (!defaultExport || isPrimitive(defaultExport))
|
|
339
|
+
return modKeys;
|
|
340
|
+
const allKeys = [...modKeys, "default", ...defaultKeys];
|
|
341
|
+
return Array.from(new Set(allKeys));
|
|
342
|
+
},
|
|
343
|
+
getOwnPropertyDescriptor(mod2, prop) {
|
|
344
|
+
const descriptor = Reflect.getOwnPropertyDescriptor(mod2, prop);
|
|
345
|
+
if (descriptor)
|
|
346
|
+
return descriptor;
|
|
347
|
+
if (prop === "default" && defaultExport !== void 0) {
|
|
348
|
+
return {
|
|
349
|
+
value: defaultExport,
|
|
350
|
+
enumerable: true,
|
|
351
|
+
configurable: true
|
|
352
|
+
};
|
|
353
|
+
}
|
|
315
354
|
}
|
|
316
355
|
});
|
|
317
356
|
}
|
package/dist/hmr.cjs
CHANGED
package/dist/hmr.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EventEmitter } from 'node:events';
|
|
2
2
|
import { HMRPayload, Plugin } from 'vite';
|
|
3
|
-
import { g as CustomEventMap, h as ViteNodeRunner, i as HMRPayload$1, H as HotContext } from './types-
|
|
3
|
+
import { g as CustomEventMap, h as ViteNodeRunner, i as HMRPayload$1, H as HotContext } from './types-63205a44.js';
|
|
4
4
|
|
|
5
5
|
type EventType = string | symbol;
|
|
6
6
|
type Handler<T = unknown> = (event: T) => void;
|
package/dist/hmr.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export { a as createHmrEmitter, c as createHotContext, g as getCache, h as handleMessage, r as reload, s as sendMessageBuffer, v as viteNodeHmrPlugin } from './chunk-hmr.mjs';
|
|
2
2
|
import 'node:events';
|
|
3
|
-
import '
|
|
4
|
-
import 'tty';
|
|
3
|
+
import 'picocolors';
|
|
5
4
|
import 'debug';
|
package/dist/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { A as Arrayable, C as CreateHotContextFunction, f as DebuggerOptions, D as DepsHandlingOptions, a as FetchFunction, F as FetchResult, H as HotContext, c as ModuleCache, M as ModuleCacheMap, N as Nullable, R as RawSourceMap, b as ResolveIdFunction, S as StartOfSourceMap, d as ViteNodeResolveId, V as ViteNodeRunnerOptions, e as ViteNodeServerOptions } from './types-
|
|
1
|
+
export { A as Arrayable, C as CreateHotContextFunction, f as DebuggerOptions, D as DepsHandlingOptions, a as FetchFunction, F as FetchResult, H as HotContext, c as ModuleCache, M as ModuleCacheMap, N as Nullable, R as RawSourceMap, b as ResolveIdFunction, S as StartOfSourceMap, d as ViteNodeResolveId, V as ViteNodeRunnerOptions, e as ViteNodeServerOptions } from './types-63205a44.js';
|
package/dist/server.cjs
CHANGED
|
@@ -8,21 +8,49 @@ var createDebug = require('debug');
|
|
|
8
8
|
var fs = require('fs');
|
|
9
9
|
var mlly = require('mlly');
|
|
10
10
|
var utils = require('./utils.cjs');
|
|
11
|
-
var
|
|
11
|
+
var c = require('picocolors');
|
|
12
12
|
var sourceMap = require('./source-map.cjs');
|
|
13
13
|
require('node:url');
|
|
14
|
-
require('tty');
|
|
15
14
|
require('source-map-support');
|
|
16
15
|
|
|
17
16
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
18
17
|
|
|
19
18
|
var createDebug__default = /*#__PURE__*/_interopDefaultLegacy(createDebug);
|
|
19
|
+
var c__default = /*#__PURE__*/_interopDefaultLegacy(c);
|
|
20
20
|
|
|
21
|
+
const KNOWN_ASSET_TYPES = [
|
|
22
|
+
"png",
|
|
23
|
+
"jpe?g",
|
|
24
|
+
"jfif",
|
|
25
|
+
"pjpeg",
|
|
26
|
+
"pjp",
|
|
27
|
+
"gif",
|
|
28
|
+
"svg",
|
|
29
|
+
"ico",
|
|
30
|
+
"webp",
|
|
31
|
+
"avif",
|
|
32
|
+
"mp4",
|
|
33
|
+
"webm",
|
|
34
|
+
"ogg",
|
|
35
|
+
"mp3",
|
|
36
|
+
"wav",
|
|
37
|
+
"flac",
|
|
38
|
+
"aac",
|
|
39
|
+
"woff2?",
|
|
40
|
+
"eot",
|
|
41
|
+
"ttf",
|
|
42
|
+
"otf",
|
|
43
|
+
"webmanifest",
|
|
44
|
+
"pdf",
|
|
45
|
+
"txt"
|
|
46
|
+
];
|
|
21
47
|
const ESM_EXT_RE = /\.(es|esm|esm-browser|esm-bundler|es6|module)\.js$/;
|
|
22
48
|
const ESM_FOLDER_RE = /\/(es|esm)\/(.*\.js)$/;
|
|
23
49
|
const defaultInline = [
|
|
24
50
|
/virtual:/,
|
|
25
|
-
/\.[mc]?ts
|
|
51
|
+
/\.[mc]?ts$/,
|
|
52
|
+
/[?&](init|raw|url|inline)\b/,
|
|
53
|
+
new RegExp(`\\.(${KNOWN_ASSET_TYPES.join("|")})$`)
|
|
26
54
|
];
|
|
27
55
|
const depsExternal = [
|
|
28
56
|
/\.cjs\.js$/,
|
|
@@ -119,9 +147,9 @@ class Debugger {
|
|
|
119
147
|
this.dumpDir = pathe.resolve(root, options.dumpModules === true ? ".vite-node/dump" : options.dumpModules);
|
|
120
148
|
if (this.dumpDir) {
|
|
121
149
|
if (options.loadDumppedModules)
|
|
122
|
-
console.info(
|
|
150
|
+
console.info(c__default["default"].gray(`[vite-node] [debug] load modules from ${this.dumpDir}`));
|
|
123
151
|
else
|
|
124
|
-
console.info(
|
|
152
|
+
console.info(c__default["default"].gray(`[vite-node] [debug] dump modules to ${this.dumpDir}`));
|
|
125
153
|
}
|
|
126
154
|
this.initPromise = this.clearDump();
|
|
127
155
|
}
|
package/dist/server.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TransformResult, ViteDevServer } from 'vite';
|
|
2
|
-
import { f as DebuggerOptions, D as DepsHandlingOptions, e as ViteNodeServerOptions, F as FetchResult, d as ViteNodeResolveId, R as RawSourceMap } from './types-
|
|
2
|
+
import { f as DebuggerOptions, D as DepsHandlingOptions, e as ViteNodeServerOptions, F as FetchResult, d as ViteNodeResolveId, R as RawSourceMap } from './types-63205a44.js';
|
|
3
3
|
|
|
4
4
|
declare class Debugger {
|
|
5
5
|
options: DebuggerOptions;
|
package/dist/server.mjs
CHANGED
|
@@ -4,17 +4,44 @@ import createDebug from 'debug';
|
|
|
4
4
|
import { existsSync, promises } from 'node:fs';
|
|
5
5
|
import { isNodeBuiltin, isValidNodeImport } from 'mlly';
|
|
6
6
|
import { slash, toArray, normalizeModuleId, toFilePath } from './utils.mjs';
|
|
7
|
-
import
|
|
7
|
+
import c from 'picocolors';
|
|
8
8
|
import { withInlineSourcemap } from './source-map.mjs';
|
|
9
9
|
import 'node:url';
|
|
10
|
-
import 'tty';
|
|
11
10
|
import 'source-map-support';
|
|
12
11
|
|
|
12
|
+
const KNOWN_ASSET_TYPES = [
|
|
13
|
+
"png",
|
|
14
|
+
"jpe?g",
|
|
15
|
+
"jfif",
|
|
16
|
+
"pjpeg",
|
|
17
|
+
"pjp",
|
|
18
|
+
"gif",
|
|
19
|
+
"svg",
|
|
20
|
+
"ico",
|
|
21
|
+
"webp",
|
|
22
|
+
"avif",
|
|
23
|
+
"mp4",
|
|
24
|
+
"webm",
|
|
25
|
+
"ogg",
|
|
26
|
+
"mp3",
|
|
27
|
+
"wav",
|
|
28
|
+
"flac",
|
|
29
|
+
"aac",
|
|
30
|
+
"woff2?",
|
|
31
|
+
"eot",
|
|
32
|
+
"ttf",
|
|
33
|
+
"otf",
|
|
34
|
+
"webmanifest",
|
|
35
|
+
"pdf",
|
|
36
|
+
"txt"
|
|
37
|
+
];
|
|
13
38
|
const ESM_EXT_RE = /\.(es|esm|esm-browser|esm-bundler|es6|module)\.js$/;
|
|
14
39
|
const ESM_FOLDER_RE = /\/(es|esm)\/(.*\.js)$/;
|
|
15
40
|
const defaultInline = [
|
|
16
41
|
/virtual:/,
|
|
17
|
-
/\.[mc]?ts
|
|
42
|
+
/\.[mc]?ts$/,
|
|
43
|
+
/[?&](init|raw|url|inline)\b/,
|
|
44
|
+
new RegExp(`\\.(${KNOWN_ASSET_TYPES.join("|")})$`)
|
|
18
45
|
];
|
|
19
46
|
const depsExternal = [
|
|
20
47
|
/\.cjs\.js$/,
|
|
@@ -111,9 +138,9 @@ class Debugger {
|
|
|
111
138
|
this.dumpDir = resolve(root, options.dumpModules === true ? ".vite-node/dump" : options.dumpModules);
|
|
112
139
|
if (this.dumpDir) {
|
|
113
140
|
if (options.loadDumppedModules)
|
|
114
|
-
console.info(
|
|
141
|
+
console.info(c.gray(`[vite-node] [debug] load modules from ${this.dumpDir}`));
|
|
115
142
|
else
|
|
116
|
-
console.info(
|
|
143
|
+
console.info(c.gray(`[vite-node] [debug] dump modules to ${this.dumpDir}`));
|
|
117
144
|
}
|
|
118
145
|
this.initPromise = this.clearDump();
|
|
119
146
|
}
|
package/dist/source-map.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TransformResult } from 'vite';
|
|
2
|
-
import { R as RawSourceMap } from './types-
|
|
2
|
+
import { R as RawSourceMap } from './types-63205a44.js';
|
|
3
3
|
|
|
4
4
|
interface InstallSourceMapSupportOptions {
|
|
5
5
|
getSourceMap: (source: string) => RawSourceMap | null | undefined;
|
|
@@ -140,8 +140,11 @@ declare class ModuleCacheMap extends Map<string, ModuleCache> {
|
|
|
140
140
|
* Assign partial data to the map
|
|
141
141
|
*/
|
|
142
142
|
update(fsPath: string, mod: Partial<ModuleCache>): this;
|
|
143
|
+
setByModuleId(modulePath: string, mod: ModuleCache): this;
|
|
143
144
|
set(fsPath: string, mod: ModuleCache): this;
|
|
145
|
+
getByModuleId(modulePath: string): ModuleCache;
|
|
144
146
|
get(fsPath: string): ModuleCache;
|
|
147
|
+
deleteByModuleId(modulePath: string): boolean;
|
|
145
148
|
delete(fsPath: string): boolean;
|
|
146
149
|
/**
|
|
147
150
|
* Invalidate modules that dependent on the given modules, up to the main entry
|
|
@@ -172,6 +175,7 @@ declare class ViteNodeRunner {
|
|
|
172
175
|
/** @internal */
|
|
173
176
|
cachedRequest(id: string, fsPath: string, callstack: string[]): Promise<any>;
|
|
174
177
|
shouldResolveId(id: string, _importee?: string): boolean;
|
|
178
|
+
private _resolveUrl;
|
|
175
179
|
resolveUrl(id: string, importee?: string): Promise<[url: string, fsPath: string]>;
|
|
176
180
|
/** @internal */
|
|
177
181
|
dependencyRequest(id: string, fsPath: string, callstack: string[]): Promise<any>;
|
|
@@ -224,6 +228,7 @@ interface ModuleCache {
|
|
|
224
228
|
promise?: Promise<any>;
|
|
225
229
|
exports?: any;
|
|
226
230
|
evaluated?: boolean;
|
|
231
|
+
resolving?: boolean;
|
|
227
232
|
code?: string;
|
|
228
233
|
map?: RawSourceMap;
|
|
229
234
|
/**
|
package/dist/types.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { A as Arrayable, C as CreateHotContextFunction, f as DebuggerOptions, D as DepsHandlingOptions, a as FetchFunction, F as FetchResult, H as HotContext, c as ModuleCache, M as ModuleCacheMap, N as Nullable, R as RawSourceMap, b as ResolveIdFunction, S as StartOfSourceMap, d as ViteNodeResolveId, V as ViteNodeRunnerOptions, e as ViteNodeServerOptions } from './types-
|
|
1
|
+
export { A as Arrayable, C as CreateHotContextFunction, f as DebuggerOptions, D as DepsHandlingOptions, a as FetchFunction, F as FetchResult, H as HotContext, c as ModuleCache, M as ModuleCacheMap, N as Nullable, R as RawSourceMap, b as ResolveIdFunction, S as StartOfSourceMap, d as ViteNodeResolveId, V as ViteNodeRunnerOptions, e as ViteNodeServerOptions } from './types-63205a44.js';
|
package/dist/utils.cjs
CHANGED
|
@@ -10,9 +10,6 @@ const isWindows = process.platform === "win32";
|
|
|
10
10
|
function slash(str) {
|
|
11
11
|
return str.replace(/\\/g, "/");
|
|
12
12
|
}
|
|
13
|
-
function mergeSlashes(str) {
|
|
14
|
-
return str.replace(/\/\//g, "/");
|
|
15
|
-
}
|
|
16
13
|
const VALID_ID_PREFIX = "/@id/";
|
|
17
14
|
function normalizeRequestId(id, base) {
|
|
18
15
|
if (base && id.startsWith(base))
|
|
@@ -65,7 +62,6 @@ exports.hashRE = hashRE;
|
|
|
65
62
|
exports.isInternalRequest = isInternalRequest;
|
|
66
63
|
exports.isPrimitive = isPrimitive;
|
|
67
64
|
exports.isWindows = isWindows;
|
|
68
|
-
exports.mergeSlashes = mergeSlashes;
|
|
69
65
|
exports.normalizeModuleId = normalizeModuleId;
|
|
70
66
|
exports.normalizeRequestId = normalizeRequestId;
|
|
71
67
|
exports.queryRE = queryRE;
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { N as Nullable, A as Arrayable } from './types-
|
|
1
|
+
import { N as Nullable, A as Arrayable } from './types-63205a44.js';
|
|
2
2
|
|
|
3
3
|
declare const isWindows: boolean;
|
|
4
4
|
declare function slash(str: string): string;
|
|
5
|
-
declare function mergeSlashes(str: string): string;
|
|
6
5
|
declare const VALID_ID_PREFIX = "/@id/";
|
|
7
6
|
declare function normalizeRequestId(id: string, base?: string): string;
|
|
8
7
|
declare const queryRE: RegExp;
|
|
@@ -19,4 +18,4 @@ declare function toFilePath(id: string, root: string): string;
|
|
|
19
18
|
*/
|
|
20
19
|
declare function toArray<T>(array?: Nullable<Arrayable<T>>): Array<T>;
|
|
21
20
|
|
|
22
|
-
export { VALID_ID_PREFIX, cleanUrl, hashRE, isInternalRequest, isPrimitive, isWindows,
|
|
21
|
+
export { VALID_ID_PREFIX, cleanUrl, hashRE, isInternalRequest, isPrimitive, isWindows, normalizeModuleId, normalizeRequestId, queryRE, slash, toArray, toFilePath };
|
package/dist/utils.mjs
CHANGED
|
@@ -6,9 +6,6 @@ const isWindows = process.platform === "win32";
|
|
|
6
6
|
function slash(str) {
|
|
7
7
|
return str.replace(/\\/g, "/");
|
|
8
8
|
}
|
|
9
|
-
function mergeSlashes(str) {
|
|
10
|
-
return str.replace(/\/\//g, "/");
|
|
11
|
-
}
|
|
12
9
|
const VALID_ID_PREFIX = "/@id/";
|
|
13
10
|
function normalizeRequestId(id, base) {
|
|
14
11
|
if (base && id.startsWith(base))
|
|
@@ -55,4 +52,4 @@ function toArray(array) {
|
|
|
55
52
|
return [array];
|
|
56
53
|
}
|
|
57
54
|
|
|
58
|
-
export { VALID_ID_PREFIX, cleanUrl, hashRE, isInternalRequest, isPrimitive, isWindows,
|
|
55
|
+
export { VALID_ID_PREFIX, cleanUrl, hashRE, isInternalRequest, isPrimitive, isWindows, normalizeModuleId, normalizeRequestId, queryRE, slash, toArray, toFilePath };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-node",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.27.0",
|
|
4
4
|
"description": "Vite as Node.js runtime",
|
|
5
5
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
"bugs": {
|
|
15
15
|
"url": "https://github.com/vitest-dev/vitest/issues"
|
|
16
16
|
},
|
|
17
|
+
"sideEffects": false,
|
|
17
18
|
"exports": {
|
|
18
19
|
".": {
|
|
19
20
|
"types": "./dist/index.d.ts",
|
|
@@ -69,9 +70,11 @@
|
|
|
69
70
|
"node": ">=v14.16.0"
|
|
70
71
|
},
|
|
71
72
|
"dependencies": {
|
|
73
|
+
"cac": "^6.7.14",
|
|
72
74
|
"debug": "^4.3.4",
|
|
73
75
|
"mlly": "^1.0.0",
|
|
74
76
|
"pathe": "^0.2.0",
|
|
77
|
+
"picocolors": "^1.0.0",
|
|
75
78
|
"source-map": "^0.6.1",
|
|
76
79
|
"source-map-support": "^0.5.21",
|
|
77
80
|
"vite": "^3.0.0 || ^4.0.0"
|
|
@@ -80,8 +83,6 @@
|
|
|
80
83
|
"@types/debug": "^4.1.7",
|
|
81
84
|
"@types/source-map": "^0.5.7",
|
|
82
85
|
"@types/source-map-support": "^0.5.6",
|
|
83
|
-
"cac": "^6.7.14",
|
|
84
|
-
"picocolors": "^1.0.0",
|
|
85
86
|
"rollup": "^2.79.1"
|
|
86
87
|
},
|
|
87
88
|
"scripts": {
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var require$$0 = require('tty');
|
|
4
|
-
|
|
5
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
6
|
-
|
|
7
|
-
var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0);
|
|
8
|
-
|
|
9
|
-
var picocolors = {exports: {}};
|
|
10
|
-
|
|
11
|
-
let tty = require$$0__default["default"];
|
|
12
|
-
|
|
13
|
-
let isColorSupported =
|
|
14
|
-
!("NO_COLOR" in process.env || process.argv.includes("--no-color")) &&
|
|
15
|
-
("FORCE_COLOR" in process.env ||
|
|
16
|
-
process.argv.includes("--color") ||
|
|
17
|
-
process.platform === "win32" ||
|
|
18
|
-
(tty.isatty(1) && process.env.TERM !== "dumb") ||
|
|
19
|
-
"CI" in process.env);
|
|
20
|
-
|
|
21
|
-
let formatter =
|
|
22
|
-
(open, close, replace = open) =>
|
|
23
|
-
input => {
|
|
24
|
-
let string = "" + input;
|
|
25
|
-
let index = string.indexOf(close, open.length);
|
|
26
|
-
return ~index
|
|
27
|
-
? open + replaceClose(string, close, replace, index) + close
|
|
28
|
-
: open + string + close
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
let replaceClose = (string, close, replace, index) => {
|
|
32
|
-
let start = string.substring(0, index) + replace;
|
|
33
|
-
let end = string.substring(index + close.length);
|
|
34
|
-
let nextIndex = end.indexOf(close);
|
|
35
|
-
return ~nextIndex ? start + replaceClose(end, close, replace, nextIndex) : start + end
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
let createColors = (enabled = isColorSupported) => ({
|
|
39
|
-
isColorSupported: enabled,
|
|
40
|
-
reset: enabled ? s => `\x1b[0m${s}\x1b[0m` : String,
|
|
41
|
-
bold: enabled ? formatter("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m") : String,
|
|
42
|
-
dim: enabled ? formatter("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m") : String,
|
|
43
|
-
italic: enabled ? formatter("\x1b[3m", "\x1b[23m") : String,
|
|
44
|
-
underline: enabled ? formatter("\x1b[4m", "\x1b[24m") : String,
|
|
45
|
-
inverse: enabled ? formatter("\x1b[7m", "\x1b[27m") : String,
|
|
46
|
-
hidden: enabled ? formatter("\x1b[8m", "\x1b[28m") : String,
|
|
47
|
-
strikethrough: enabled ? formatter("\x1b[9m", "\x1b[29m") : String,
|
|
48
|
-
black: enabled ? formatter("\x1b[30m", "\x1b[39m") : String,
|
|
49
|
-
red: enabled ? formatter("\x1b[31m", "\x1b[39m") : String,
|
|
50
|
-
green: enabled ? formatter("\x1b[32m", "\x1b[39m") : String,
|
|
51
|
-
yellow: enabled ? formatter("\x1b[33m", "\x1b[39m") : String,
|
|
52
|
-
blue: enabled ? formatter("\x1b[34m", "\x1b[39m") : String,
|
|
53
|
-
magenta: enabled ? formatter("\x1b[35m", "\x1b[39m") : String,
|
|
54
|
-
cyan: enabled ? formatter("\x1b[36m", "\x1b[39m") : String,
|
|
55
|
-
white: enabled ? formatter("\x1b[37m", "\x1b[39m") : String,
|
|
56
|
-
gray: enabled ? formatter("\x1b[90m", "\x1b[39m") : String,
|
|
57
|
-
bgBlack: enabled ? formatter("\x1b[40m", "\x1b[49m") : String,
|
|
58
|
-
bgRed: enabled ? formatter("\x1b[41m", "\x1b[49m") : String,
|
|
59
|
-
bgGreen: enabled ? formatter("\x1b[42m", "\x1b[49m") : String,
|
|
60
|
-
bgYellow: enabled ? formatter("\x1b[43m", "\x1b[49m") : String,
|
|
61
|
-
bgBlue: enabled ? formatter("\x1b[44m", "\x1b[49m") : String,
|
|
62
|
-
bgMagenta: enabled ? formatter("\x1b[45m", "\x1b[49m") : String,
|
|
63
|
-
bgCyan: enabled ? formatter("\x1b[46m", "\x1b[49m") : String,
|
|
64
|
-
bgWhite: enabled ? formatter("\x1b[47m", "\x1b[49m") : String,
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
picocolors.exports = createColors();
|
|
68
|
-
picocolors.exports.createColors = createColors;
|
|
69
|
-
|
|
70
|
-
exports.picocolors = picocolors;
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import require$$0 from 'tty';
|
|
2
|
-
|
|
3
|
-
var picocolors = {exports: {}};
|
|
4
|
-
|
|
5
|
-
let tty = require$$0;
|
|
6
|
-
|
|
7
|
-
let isColorSupported =
|
|
8
|
-
!("NO_COLOR" in process.env || process.argv.includes("--no-color")) &&
|
|
9
|
-
("FORCE_COLOR" in process.env ||
|
|
10
|
-
process.argv.includes("--color") ||
|
|
11
|
-
process.platform === "win32" ||
|
|
12
|
-
(tty.isatty(1) && process.env.TERM !== "dumb") ||
|
|
13
|
-
"CI" in process.env);
|
|
14
|
-
|
|
15
|
-
let formatter =
|
|
16
|
-
(open, close, replace = open) =>
|
|
17
|
-
input => {
|
|
18
|
-
let string = "" + input;
|
|
19
|
-
let index = string.indexOf(close, open.length);
|
|
20
|
-
return ~index
|
|
21
|
-
? open + replaceClose(string, close, replace, index) + close
|
|
22
|
-
: open + string + close
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
let replaceClose = (string, close, replace, index) => {
|
|
26
|
-
let start = string.substring(0, index) + replace;
|
|
27
|
-
let end = string.substring(index + close.length);
|
|
28
|
-
let nextIndex = end.indexOf(close);
|
|
29
|
-
return ~nextIndex ? start + replaceClose(end, close, replace, nextIndex) : start + end
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
let createColors = (enabled = isColorSupported) => ({
|
|
33
|
-
isColorSupported: enabled,
|
|
34
|
-
reset: enabled ? s => `\x1b[0m${s}\x1b[0m` : String,
|
|
35
|
-
bold: enabled ? formatter("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m") : String,
|
|
36
|
-
dim: enabled ? formatter("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m") : String,
|
|
37
|
-
italic: enabled ? formatter("\x1b[3m", "\x1b[23m") : String,
|
|
38
|
-
underline: enabled ? formatter("\x1b[4m", "\x1b[24m") : String,
|
|
39
|
-
inverse: enabled ? formatter("\x1b[7m", "\x1b[27m") : String,
|
|
40
|
-
hidden: enabled ? formatter("\x1b[8m", "\x1b[28m") : String,
|
|
41
|
-
strikethrough: enabled ? formatter("\x1b[9m", "\x1b[29m") : String,
|
|
42
|
-
black: enabled ? formatter("\x1b[30m", "\x1b[39m") : String,
|
|
43
|
-
red: enabled ? formatter("\x1b[31m", "\x1b[39m") : String,
|
|
44
|
-
green: enabled ? formatter("\x1b[32m", "\x1b[39m") : String,
|
|
45
|
-
yellow: enabled ? formatter("\x1b[33m", "\x1b[39m") : String,
|
|
46
|
-
blue: enabled ? formatter("\x1b[34m", "\x1b[39m") : String,
|
|
47
|
-
magenta: enabled ? formatter("\x1b[35m", "\x1b[39m") : String,
|
|
48
|
-
cyan: enabled ? formatter("\x1b[36m", "\x1b[39m") : String,
|
|
49
|
-
white: enabled ? formatter("\x1b[37m", "\x1b[39m") : String,
|
|
50
|
-
gray: enabled ? formatter("\x1b[90m", "\x1b[39m") : String,
|
|
51
|
-
bgBlack: enabled ? formatter("\x1b[40m", "\x1b[49m") : String,
|
|
52
|
-
bgRed: enabled ? formatter("\x1b[41m", "\x1b[49m") : String,
|
|
53
|
-
bgGreen: enabled ? formatter("\x1b[42m", "\x1b[49m") : String,
|
|
54
|
-
bgYellow: enabled ? formatter("\x1b[43m", "\x1b[49m") : String,
|
|
55
|
-
bgBlue: enabled ? formatter("\x1b[44m", "\x1b[49m") : String,
|
|
56
|
-
bgMagenta: enabled ? formatter("\x1b[45m", "\x1b[49m") : String,
|
|
57
|
-
bgCyan: enabled ? formatter("\x1b[46m", "\x1b[49m") : String,
|
|
58
|
-
bgWhite: enabled ? formatter("\x1b[47m", "\x1b[49m") : String,
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
picocolors.exports = createColors();
|
|
62
|
-
picocolors.exports.createColors = createColors;
|
|
63
|
-
|
|
64
|
-
export { picocolors as p };
|