vite-node 0.1.21 → 0.1.25
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/client.d.ts +0 -1
- package/dist/cli.cjs +9 -12
- package/dist/cli.js +10 -13
- package/dist/client.cjs +9 -12
- package/dist/client.js +10 -13
- package/package.json +4 -4
package/client.d.ts
CHANGED
|
@@ -38,7 +38,6 @@ declare const DEFAULT_REQUEST_STUBS: {
|
|
|
38
38
|
declare class ViteNodeRunner {
|
|
39
39
|
options: ViteNodeRunnerOptions;
|
|
40
40
|
root: string;
|
|
41
|
-
externalCache: Map<string, string | Promise<false | string>>;
|
|
42
41
|
moduleCache: Map<string, ModuleCache>;
|
|
43
42
|
constructor(options: ViteNodeRunnerOptions);
|
|
44
43
|
executeFile(file: string): Promise<any>;
|
package/dist/cli.cjs
CHANGED
|
@@ -222,8 +222,6 @@ class ViteNodeRunner {
|
|
|
222
222
|
this.options = options;
|
|
223
223
|
this.root = options.root || process.cwd();
|
|
224
224
|
this.moduleCache = options.moduleCache || new Map();
|
|
225
|
-
this.externalCache = new Map();
|
|
226
|
-
module$1.builtinModules.forEach((m) => this.externalCache.set(m, m));
|
|
227
225
|
}
|
|
228
226
|
async executeFile(file) {
|
|
229
227
|
return await this.cachedRequest(`/@fs/${slash(pathe.resolve(file))}`, []);
|
|
@@ -234,11 +232,11 @@ class ViteNodeRunner {
|
|
|
234
232
|
async cachedRequest(rawId, callstack) {
|
|
235
233
|
var _a, _b;
|
|
236
234
|
const id = normalizeId(rawId, this.options.base);
|
|
235
|
+
if ((_a = this.moduleCache.get(id)) == null ? void 0 : _a.promise)
|
|
236
|
+
return (_b = this.moduleCache.get(id)) == null ? void 0 : _b.promise;
|
|
237
237
|
const fsPath = toFilePath(id, this.root);
|
|
238
|
-
if ((_a = this.moduleCache.get(fsPath)) == null ? void 0 : _a.promise)
|
|
239
|
-
return (_b = this.moduleCache.get(fsPath)) == null ? void 0 : _b.promise;
|
|
240
238
|
const promise = this.directRequest(id, fsPath, callstack);
|
|
241
|
-
this.setCache(
|
|
239
|
+
this.setCache(id, { promise });
|
|
242
240
|
return await promise;
|
|
243
241
|
}
|
|
244
242
|
async directRequest(id, fsPath, callstack) {
|
|
@@ -246,12 +244,11 @@ class ViteNodeRunner {
|
|
|
246
244
|
const request = async (dep) => {
|
|
247
245
|
var _a;
|
|
248
246
|
if (callstack.includes(dep)) {
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
throw new Error(`Circular dependency detected
|
|
247
|
+
if (!((_a = this.moduleCache.get(dep)) == null ? void 0 : _a.exports))
|
|
248
|
+
throw new Error(`[vite-node] Circular dependency detected
|
|
252
249
|
Stack:
|
|
253
250
|
${[...callstack, dep].reverse().map((p) => `- ${p}`).join("\n")}`);
|
|
254
|
-
return this.moduleCache.get(
|
|
251
|
+
return this.moduleCache.get(dep).exports;
|
|
255
252
|
}
|
|
256
253
|
return this.cachedRequest(dep, callstack);
|
|
257
254
|
};
|
|
@@ -261,14 +258,14 @@ ${[...callstack, dep].reverse().map((p) => `- ${p}`).join("\n")}`);
|
|
|
261
258
|
const { code: transformed, externalize } = await this.options.fetchModule(id);
|
|
262
259
|
if (externalize) {
|
|
263
260
|
const mod = await this.interopedImport(externalize);
|
|
264
|
-
this.setCache(
|
|
261
|
+
this.setCache(id, { exports: mod });
|
|
265
262
|
return mod;
|
|
266
263
|
}
|
|
267
264
|
if (transformed == null)
|
|
268
|
-
throw new Error(`
|
|
265
|
+
throw new Error(`[vite-node] Failed to load ${id}`);
|
|
269
266
|
const url$1 = url.pathToFileURL(fsPath).href;
|
|
270
267
|
const exports = {};
|
|
271
|
-
this.setCache(
|
|
268
|
+
this.setCache(id, { code: transformed, exports });
|
|
272
269
|
const __filename = url.fileURLToPath(url$1);
|
|
273
270
|
const moduleProxy = {
|
|
274
271
|
set exports(value) {
|
package/dist/cli.js
CHANGED
|
@@ -5,7 +5,7 @@ import { existsSync } from 'fs';
|
|
|
5
5
|
import { isNodeBuiltin, isValidNodeImport } from 'mlly';
|
|
6
6
|
import { fileURLToPath, pathToFileURL } from 'url';
|
|
7
7
|
import { dirname, resolve } from 'pathe';
|
|
8
|
-
import {
|
|
8
|
+
import { createRequire } from 'module';
|
|
9
9
|
import vm from 'vm';
|
|
10
10
|
|
|
11
11
|
const isWindows = process.platform === "win32";
|
|
@@ -197,8 +197,6 @@ class ViteNodeRunner {
|
|
|
197
197
|
this.options = options;
|
|
198
198
|
this.root = options.root || process.cwd();
|
|
199
199
|
this.moduleCache = options.moduleCache || new Map();
|
|
200
|
-
this.externalCache = new Map();
|
|
201
|
-
builtinModules.forEach((m) => this.externalCache.set(m, m));
|
|
202
200
|
}
|
|
203
201
|
async executeFile(file) {
|
|
204
202
|
return await this.cachedRequest(`/@fs/${slash(resolve(file))}`, []);
|
|
@@ -209,11 +207,11 @@ class ViteNodeRunner {
|
|
|
209
207
|
async cachedRequest(rawId, callstack) {
|
|
210
208
|
var _a, _b;
|
|
211
209
|
const id = normalizeId(rawId, this.options.base);
|
|
210
|
+
if ((_a = this.moduleCache.get(id)) == null ? void 0 : _a.promise)
|
|
211
|
+
return (_b = this.moduleCache.get(id)) == null ? void 0 : _b.promise;
|
|
212
212
|
const fsPath = toFilePath(id, this.root);
|
|
213
|
-
if ((_a = this.moduleCache.get(fsPath)) == null ? void 0 : _a.promise)
|
|
214
|
-
return (_b = this.moduleCache.get(fsPath)) == null ? void 0 : _b.promise;
|
|
215
213
|
const promise = this.directRequest(id, fsPath, callstack);
|
|
216
|
-
this.setCache(
|
|
214
|
+
this.setCache(id, { promise });
|
|
217
215
|
return await promise;
|
|
218
216
|
}
|
|
219
217
|
async directRequest(id, fsPath, callstack) {
|
|
@@ -221,12 +219,11 @@ class ViteNodeRunner {
|
|
|
221
219
|
const request = async (dep) => {
|
|
222
220
|
var _a;
|
|
223
221
|
if (callstack.includes(dep)) {
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
throw new Error(`Circular dependency detected
|
|
222
|
+
if (!((_a = this.moduleCache.get(dep)) == null ? void 0 : _a.exports))
|
|
223
|
+
throw new Error(`[vite-node] Circular dependency detected
|
|
227
224
|
Stack:
|
|
228
225
|
${[...callstack, dep].reverse().map((p) => `- ${p}`).join("\n")}`);
|
|
229
|
-
return this.moduleCache.get(
|
|
226
|
+
return this.moduleCache.get(dep).exports;
|
|
230
227
|
}
|
|
231
228
|
return this.cachedRequest(dep, callstack);
|
|
232
229
|
};
|
|
@@ -236,14 +233,14 @@ ${[...callstack, dep].reverse().map((p) => `- ${p}`).join("\n")}`);
|
|
|
236
233
|
const { code: transformed, externalize } = await this.options.fetchModule(id);
|
|
237
234
|
if (externalize) {
|
|
238
235
|
const mod = await this.interopedImport(externalize);
|
|
239
|
-
this.setCache(
|
|
236
|
+
this.setCache(id, { exports: mod });
|
|
240
237
|
return mod;
|
|
241
238
|
}
|
|
242
239
|
if (transformed == null)
|
|
243
|
-
throw new Error(`
|
|
240
|
+
throw new Error(`[vite-node] Failed to load ${id}`);
|
|
244
241
|
const url = pathToFileURL(fsPath).href;
|
|
245
242
|
const exports = {};
|
|
246
|
-
this.setCache(
|
|
243
|
+
this.setCache(id, { code: transformed, exports });
|
|
247
244
|
const __filename = fileURLToPath(url);
|
|
248
245
|
const moduleProxy = {
|
|
249
246
|
set exports(value) {
|
package/dist/client.cjs
CHANGED
|
@@ -68,8 +68,6 @@ class ViteNodeRunner {
|
|
|
68
68
|
this.options = options;
|
|
69
69
|
this.root = options.root || process.cwd();
|
|
70
70
|
this.moduleCache = options.moduleCache || new Map();
|
|
71
|
-
this.externalCache = new Map();
|
|
72
|
-
module$1.builtinModules.forEach((m) => this.externalCache.set(m, m));
|
|
73
71
|
}
|
|
74
72
|
async executeFile(file) {
|
|
75
73
|
return await this.cachedRequest(`/@fs/${slash(pathe.resolve(file))}`, []);
|
|
@@ -80,11 +78,11 @@ class ViteNodeRunner {
|
|
|
80
78
|
async cachedRequest(rawId, callstack) {
|
|
81
79
|
var _a, _b;
|
|
82
80
|
const id = normalizeId(rawId, this.options.base);
|
|
81
|
+
if ((_a = this.moduleCache.get(id)) == null ? void 0 : _a.promise)
|
|
82
|
+
return (_b = this.moduleCache.get(id)) == null ? void 0 : _b.promise;
|
|
83
83
|
const fsPath = toFilePath(id, this.root);
|
|
84
|
-
if ((_a = this.moduleCache.get(fsPath)) == null ? void 0 : _a.promise)
|
|
85
|
-
return (_b = this.moduleCache.get(fsPath)) == null ? void 0 : _b.promise;
|
|
86
84
|
const promise = this.directRequest(id, fsPath, callstack);
|
|
87
|
-
this.setCache(
|
|
85
|
+
this.setCache(id, { promise });
|
|
88
86
|
return await promise;
|
|
89
87
|
}
|
|
90
88
|
async directRequest(id, fsPath, callstack) {
|
|
@@ -92,12 +90,11 @@ class ViteNodeRunner {
|
|
|
92
90
|
const request = async (dep) => {
|
|
93
91
|
var _a;
|
|
94
92
|
if (callstack.includes(dep)) {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
throw new Error(`Circular dependency detected
|
|
93
|
+
if (!((_a = this.moduleCache.get(dep)) == null ? void 0 : _a.exports))
|
|
94
|
+
throw new Error(`[vite-node] Circular dependency detected
|
|
98
95
|
Stack:
|
|
99
96
|
${[...callstack, dep].reverse().map((p) => `- ${p}`).join("\n")}`);
|
|
100
|
-
return this.moduleCache.get(
|
|
97
|
+
return this.moduleCache.get(dep).exports;
|
|
101
98
|
}
|
|
102
99
|
return this.cachedRequest(dep, callstack);
|
|
103
100
|
};
|
|
@@ -107,14 +104,14 @@ ${[...callstack, dep].reverse().map((p) => `- ${p}`).join("\n")}`);
|
|
|
107
104
|
const { code: transformed, externalize } = await this.options.fetchModule(id);
|
|
108
105
|
if (externalize) {
|
|
109
106
|
const mod = await this.interopedImport(externalize);
|
|
110
|
-
this.setCache(
|
|
107
|
+
this.setCache(id, { exports: mod });
|
|
111
108
|
return mod;
|
|
112
109
|
}
|
|
113
110
|
if (transformed == null)
|
|
114
|
-
throw new Error(`
|
|
111
|
+
throw new Error(`[vite-node] Failed to load ${id}`);
|
|
115
112
|
const url$1 = url.pathToFileURL(fsPath).href;
|
|
116
113
|
const exports = {};
|
|
117
|
-
this.setCache(
|
|
114
|
+
this.setCache(id, { code: transformed, exports });
|
|
118
115
|
const __filename = url.fileURLToPath(url$1);
|
|
119
116
|
const moduleProxy = {
|
|
120
117
|
set exports(value) {
|
package/dist/client.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createRequire } from 'module';
|
|
2
2
|
import { fileURLToPath, pathToFileURL } from 'url';
|
|
3
3
|
import vm from 'vm';
|
|
4
4
|
import { dirname, resolve } from 'pathe';
|
|
@@ -42,8 +42,6 @@ class ViteNodeRunner {
|
|
|
42
42
|
this.options = options;
|
|
43
43
|
this.root = options.root || process.cwd();
|
|
44
44
|
this.moduleCache = options.moduleCache || new Map();
|
|
45
|
-
this.externalCache = new Map();
|
|
46
|
-
builtinModules.forEach((m) => this.externalCache.set(m, m));
|
|
47
45
|
}
|
|
48
46
|
async executeFile(file) {
|
|
49
47
|
return await this.cachedRequest(`/@fs/${slash(resolve(file))}`, []);
|
|
@@ -54,11 +52,11 @@ class ViteNodeRunner {
|
|
|
54
52
|
async cachedRequest(rawId, callstack) {
|
|
55
53
|
var _a, _b;
|
|
56
54
|
const id = normalizeId(rawId, this.options.base);
|
|
55
|
+
if ((_a = this.moduleCache.get(id)) == null ? void 0 : _a.promise)
|
|
56
|
+
return (_b = this.moduleCache.get(id)) == null ? void 0 : _b.promise;
|
|
57
57
|
const fsPath = toFilePath(id, this.root);
|
|
58
|
-
if ((_a = this.moduleCache.get(fsPath)) == null ? void 0 : _a.promise)
|
|
59
|
-
return (_b = this.moduleCache.get(fsPath)) == null ? void 0 : _b.promise;
|
|
60
58
|
const promise = this.directRequest(id, fsPath, callstack);
|
|
61
|
-
this.setCache(
|
|
59
|
+
this.setCache(id, { promise });
|
|
62
60
|
return await promise;
|
|
63
61
|
}
|
|
64
62
|
async directRequest(id, fsPath, callstack) {
|
|
@@ -66,12 +64,11 @@ class ViteNodeRunner {
|
|
|
66
64
|
const request = async (dep) => {
|
|
67
65
|
var _a;
|
|
68
66
|
if (callstack.includes(dep)) {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
throw new Error(`Circular dependency detected
|
|
67
|
+
if (!((_a = this.moduleCache.get(dep)) == null ? void 0 : _a.exports))
|
|
68
|
+
throw new Error(`[vite-node] Circular dependency detected
|
|
72
69
|
Stack:
|
|
73
70
|
${[...callstack, dep].reverse().map((p) => `- ${p}`).join("\n")}`);
|
|
74
|
-
return this.moduleCache.get(
|
|
71
|
+
return this.moduleCache.get(dep).exports;
|
|
75
72
|
}
|
|
76
73
|
return this.cachedRequest(dep, callstack);
|
|
77
74
|
};
|
|
@@ -81,14 +78,14 @@ ${[...callstack, dep].reverse().map((p) => `- ${p}`).join("\n")}`);
|
|
|
81
78
|
const { code: transformed, externalize } = await this.options.fetchModule(id);
|
|
82
79
|
if (externalize) {
|
|
83
80
|
const mod = await this.interopedImport(externalize);
|
|
84
|
-
this.setCache(
|
|
81
|
+
this.setCache(id, { exports: mod });
|
|
85
82
|
return mod;
|
|
86
83
|
}
|
|
87
84
|
if (transformed == null)
|
|
88
|
-
throw new Error(`
|
|
85
|
+
throw new Error(`[vite-node] Failed to load ${id}`);
|
|
89
86
|
const url = pathToFileURL(fsPath).href;
|
|
90
87
|
const exports = {};
|
|
91
|
-
this.setCache(
|
|
88
|
+
this.setCache(id, { code: transformed, exports });
|
|
92
89
|
const __filename = fileURLToPath(url);
|
|
93
90
|
const moduleProxy = {
|
|
94
91
|
set exports(value) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-node",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.25",
|
|
4
4
|
"description": "Vite as Node.js runtime",
|
|
5
5
|
"homepage": "https://github.com/vitest-dev/vitest#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -51,13 +51,13 @@
|
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"kolorist": "^1.5.1",
|
|
53
53
|
"minimist": "^1.2.5",
|
|
54
|
-
"mlly": "^0.3.
|
|
54
|
+
"mlly": "^0.3.19",
|
|
55
55
|
"pathe": "^0.2.0",
|
|
56
|
-
"vite": "^2.7.
|
|
56
|
+
"vite": "^2.7.13"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@types/minimist": "^1.2.2",
|
|
60
|
-
"rollup": "^2.
|
|
60
|
+
"rollup": "^2.64.0"
|
|
61
61
|
},
|
|
62
62
|
"engines": {
|
|
63
63
|
"node": ">=14.14.0"
|