vite-node 0.29.7 → 0.30.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/cli.cjs +3 -3
- package/dist/cli.d.ts +1 -1
- package/dist/cli.mjs +2 -2
- package/dist/client.cjs +25 -2
- package/dist/client.d.ts +1 -1
- package/dist/client.mjs +25 -2
- package/dist/hmr.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/server.cjs +15 -4
- package/dist/server.d.ts +2 -2
- package/dist/server.mjs +15 -4
- package/dist/source-map.cjs +12 -1
- package/dist/source-map.d.ts +4 -1
- package/dist/source-map.mjs +12 -1
- package/dist/{types-e6d31da0.d.ts → types-c39b64bb.d.ts} +1 -26
- package/dist/types.d.ts +1 -1
- package/dist/utils.cjs +29 -3
- package/dist/utils.d.ts +5 -4
- package/dist/utils.mjs +29 -4
- package/package.json +3 -3
package/dist/cli.cjs
CHANGED
|
@@ -6,16 +6,16 @@ var vite = require('vite');
|
|
|
6
6
|
var server = require('./server.cjs');
|
|
7
7
|
var client = require('./client.cjs');
|
|
8
8
|
var utils = require('./utils.cjs');
|
|
9
|
-
var sourceMap = require('./source-map.cjs');
|
|
10
9
|
var hmr = require('./chunk-hmr.cjs');
|
|
10
|
+
var sourceMap = require('./source-map.cjs');
|
|
11
11
|
require('perf_hooks');
|
|
12
12
|
require('fs');
|
|
13
13
|
require('pathe');
|
|
14
14
|
require('debug');
|
|
15
15
|
require('mlly');
|
|
16
16
|
require('node:url');
|
|
17
|
-
require('path');
|
|
18
17
|
require('module');
|
|
18
|
+
require('path');
|
|
19
19
|
require('vm');
|
|
20
20
|
require('node:events');
|
|
21
21
|
|
|
@@ -24,7 +24,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
24
24
|
var cac__default = /*#__PURE__*/_interopDefaultLegacy(cac);
|
|
25
25
|
var c__default = /*#__PURE__*/_interopDefaultLegacy(c);
|
|
26
26
|
|
|
27
|
-
var version = "0.
|
|
27
|
+
var version = "0.30.0";
|
|
28
28
|
|
|
29
29
|
const cli = cac__default["default"]("vite-node");
|
|
30
30
|
cli.version(version).option("-r, --root <path>", "Use specified root directory").option("-c, --config <path>", "Use specified config file").option("-m, --mode <mode>", "Set env mode").option("-w, --watch", 'Restart on file changes, similar to "nodemon"').option("--script", "Use vite-node as a script runner").option("--options <options>", "Use specified Vite server options").help();
|
package/dist/cli.d.ts
CHANGED
package/dist/cli.mjs
CHANGED
|
@@ -12,12 +12,12 @@ import 'pathe';
|
|
|
12
12
|
import 'debug';
|
|
13
13
|
import 'mlly';
|
|
14
14
|
import 'node:url';
|
|
15
|
-
import 'node:path';
|
|
16
15
|
import 'node:module';
|
|
16
|
+
import 'node:path';
|
|
17
17
|
import 'node:vm';
|
|
18
18
|
import 'node:events';
|
|
19
19
|
|
|
20
|
-
var version = "0.
|
|
20
|
+
var version = "0.30.0";
|
|
21
21
|
|
|
22
22
|
const cli = cac("vite-node");
|
|
23
23
|
cli.version(version).option("-r, --root <path>", "Use specified root directory").option("-c, --config <path>", "Use specified config file").option("-m, --mode <mode>", "Set env mode").option("-w, --watch", 'Restart on file changes, similar to "nodemon"').option("--script", "Use vite-node as a script runner").option("--options <options>", "Use specified Vite server options").help();
|
package/dist/client.cjs
CHANGED
|
@@ -6,7 +6,6 @@ var module$1 = require('module');
|
|
|
6
6
|
var path = require('path');
|
|
7
7
|
var node_url = require('node:url');
|
|
8
8
|
var vm = require('vm');
|
|
9
|
-
var mlly = require('mlly');
|
|
10
9
|
var pathe = require('pathe');
|
|
11
10
|
var createDebug = require('debug');
|
|
12
11
|
var utils = require('./utils.cjs');
|
|
@@ -79,6 +78,9 @@ class ModuleCacheMap extends Map {
|
|
|
79
78
|
normalizePath(fsPath) {
|
|
80
79
|
return utils.normalizeModuleId(fsPath);
|
|
81
80
|
}
|
|
81
|
+
/**
|
|
82
|
+
* Assign partial data to the map
|
|
83
|
+
*/
|
|
82
84
|
update(fsPath, mod) {
|
|
83
85
|
fsPath = this.normalizePath(fsPath);
|
|
84
86
|
if (!super.has(fsPath))
|
|
@@ -114,6 +116,9 @@ class ModuleCacheMap extends Map {
|
|
|
114
116
|
delete mod.exports;
|
|
115
117
|
return true;
|
|
116
118
|
}
|
|
119
|
+
/**
|
|
120
|
+
* Invalidate modules that dependent on the given modules, up to the main entry
|
|
121
|
+
*/
|
|
117
122
|
invalidateDepTree(ids, invalidated = /* @__PURE__ */ new Set()) {
|
|
118
123
|
for (const _id of ids) {
|
|
119
124
|
const id = this.normalizePath(_id);
|
|
@@ -127,6 +132,9 @@ class ModuleCacheMap extends Map {
|
|
|
127
132
|
}
|
|
128
133
|
return invalidated;
|
|
129
134
|
}
|
|
135
|
+
/**
|
|
136
|
+
* Invalidate dependency modules of the given modules, down to the bottom-level dependencies
|
|
137
|
+
*/
|
|
130
138
|
invalidateSubDepTree(ids, invalidated = /* @__PURE__ */ new Set()) {
|
|
131
139
|
for (const _id of ids) {
|
|
132
140
|
const id = this.normalizePath(_id);
|
|
@@ -142,6 +150,9 @@ class ModuleCacheMap extends Map {
|
|
|
142
150
|
}
|
|
143
151
|
return invalidated;
|
|
144
152
|
}
|
|
153
|
+
/**
|
|
154
|
+
* Return parsed source map based on inlined source map of the module
|
|
155
|
+
*/
|
|
145
156
|
getSourceMap(id) {
|
|
146
157
|
const cache = this.get(id);
|
|
147
158
|
if (cache.map)
|
|
@@ -169,6 +180,7 @@ class ViteNodeRunner {
|
|
|
169
180
|
const [id, url] = await this.resolveUrl(rawId);
|
|
170
181
|
return await this.cachedRequest(id, url, []);
|
|
171
182
|
}
|
|
183
|
+
/** @internal */
|
|
172
184
|
async cachedRequest(id, fsPath, callstack) {
|
|
173
185
|
const importee = callstack[callstack.length - 1];
|
|
174
186
|
const mod = this.moduleCache.get(fsPath);
|
|
@@ -189,7 +201,7 @@ class ViteNodeRunner {
|
|
|
189
201
|
}
|
|
190
202
|
}
|
|
191
203
|
shouldResolveId(id, _importee) {
|
|
192
|
-
return !utils.isInternalRequest(id) && !
|
|
204
|
+
return !utils.isInternalRequest(id) && !utils.isNodeBuiltin(id);
|
|
193
205
|
}
|
|
194
206
|
async _resolveUrl(id, importer) {
|
|
195
207
|
if (importer && id.startsWith(utils.VALID_ID_PREFIX))
|
|
@@ -214,6 +226,7 @@ class ViteNodeRunner {
|
|
|
214
226
|
this.moduleCache.deleteByModuleId(resolveKey);
|
|
215
227
|
}
|
|
216
228
|
}
|
|
229
|
+
/** @internal */
|
|
217
230
|
async dependencyRequest(id, fsPath, callstack) {
|
|
218
231
|
var _a;
|
|
219
232
|
const getStack = () => {
|
|
@@ -237,6 +250,7 @@ ${getStack()}`), 2e3);
|
|
|
237
250
|
clearTimeout(debugTimer);
|
|
238
251
|
}
|
|
239
252
|
}
|
|
253
|
+
/** @internal */
|
|
240
254
|
async directRequest(id, fsPath, _callstack) {
|
|
241
255
|
const moduleId = utils.normalizeModuleId(fsPath);
|
|
242
256
|
const callstack = [..._callstack, moduleId];
|
|
@@ -317,11 +331,13 @@ ${getStack()}`), 2e3);
|
|
|
317
331
|
});
|
|
318
332
|
}
|
|
319
333
|
const context = this.prepareContext({
|
|
334
|
+
// esm transformed by Vite
|
|
320
335
|
__vite_ssr_import__: request,
|
|
321
336
|
__vite_ssr_dynamic_import__: request,
|
|
322
337
|
__vite_ssr_exports__: exports,
|
|
323
338
|
__vite_ssr_exportAll__: (obj) => exportAll(exports, obj),
|
|
324
339
|
__vite_ssr_import_meta__: meta,
|
|
340
|
+
// cjs compact
|
|
325
341
|
require: module$1.createRequire(href),
|
|
326
342
|
exports: cjsExports,
|
|
327
343
|
module: moduleProxy,
|
|
@@ -345,11 +361,18 @@ ${getStack()}`), 2e3);
|
|
|
345
361
|
prepareContext(context) {
|
|
346
362
|
return context;
|
|
347
363
|
}
|
|
364
|
+
/**
|
|
365
|
+
* Define if a module should be interop-ed
|
|
366
|
+
* This function mostly for the ability to override by subclass
|
|
367
|
+
*/
|
|
348
368
|
shouldInterop(path, mod) {
|
|
349
369
|
if (this.options.interopDefault === false)
|
|
350
370
|
return false;
|
|
351
371
|
return !path.endsWith(".mjs") && "default" in mod;
|
|
352
372
|
}
|
|
373
|
+
/**
|
|
374
|
+
* Import a module and interop it
|
|
375
|
+
*/
|
|
353
376
|
async interopedImport(path) {
|
|
354
377
|
const importedModule = await (function (t) { return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(t)); }); })(path);
|
|
355
378
|
if (!this.shouldInterop(path, importedModule))
|
package/dist/client.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import './types.d-1e7e3fdf.js';
|
|
2
|
-
export { j as DEFAULT_REQUEST_STUBS, M as ModuleCacheMap, h as ViteNodeRunner } from './types-
|
|
2
|
+
export { j as DEFAULT_REQUEST_STUBS, M as ModuleCacheMap, h as ViteNodeRunner } from './types-c39b64bb.js';
|
package/dist/client.mjs
CHANGED
|
@@ -2,10 +2,9 @@ import { createRequire } from 'node:module';
|
|
|
2
2
|
import { dirname } from 'node:path';
|
|
3
3
|
import { pathToFileURL, fileURLToPath } from 'node:url';
|
|
4
4
|
import vm from 'node:vm';
|
|
5
|
-
import { isNodeBuiltin } from 'mlly';
|
|
6
5
|
import { resolve } from 'pathe';
|
|
7
6
|
import createDebug from 'debug';
|
|
8
|
-
import { normalizeModuleId, slash, isInternalRequest, VALID_ID_PREFIX, normalizeRequestId, toFilePath, cleanUrl, isPrimitive } from './utils.mjs';
|
|
7
|
+
import { normalizeModuleId, slash, isInternalRequest, isNodeBuiltin, VALID_ID_PREFIX, normalizeRequestId, toFilePath, cleanUrl, isPrimitive } from './utils.mjs';
|
|
9
8
|
import { extractSourceMap } from './source-map.mjs';
|
|
10
9
|
import 'node:fs';
|
|
11
10
|
|
|
@@ -52,6 +51,9 @@ class ModuleCacheMap extends Map {
|
|
|
52
51
|
normalizePath(fsPath) {
|
|
53
52
|
return normalizeModuleId(fsPath);
|
|
54
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* Assign partial data to the map
|
|
56
|
+
*/
|
|
55
57
|
update(fsPath, mod) {
|
|
56
58
|
fsPath = this.normalizePath(fsPath);
|
|
57
59
|
if (!super.has(fsPath))
|
|
@@ -87,6 +89,9 @@ class ModuleCacheMap extends Map {
|
|
|
87
89
|
delete mod.exports;
|
|
88
90
|
return true;
|
|
89
91
|
}
|
|
92
|
+
/**
|
|
93
|
+
* Invalidate modules that dependent on the given modules, up to the main entry
|
|
94
|
+
*/
|
|
90
95
|
invalidateDepTree(ids, invalidated = /* @__PURE__ */ new Set()) {
|
|
91
96
|
for (const _id of ids) {
|
|
92
97
|
const id = this.normalizePath(_id);
|
|
@@ -100,6 +105,9 @@ class ModuleCacheMap extends Map {
|
|
|
100
105
|
}
|
|
101
106
|
return invalidated;
|
|
102
107
|
}
|
|
108
|
+
/**
|
|
109
|
+
* Invalidate dependency modules of the given modules, down to the bottom-level dependencies
|
|
110
|
+
*/
|
|
103
111
|
invalidateSubDepTree(ids, invalidated = /* @__PURE__ */ new Set()) {
|
|
104
112
|
for (const _id of ids) {
|
|
105
113
|
const id = this.normalizePath(_id);
|
|
@@ -115,6 +123,9 @@ class ModuleCacheMap extends Map {
|
|
|
115
123
|
}
|
|
116
124
|
return invalidated;
|
|
117
125
|
}
|
|
126
|
+
/**
|
|
127
|
+
* Return parsed source map based on inlined source map of the module
|
|
128
|
+
*/
|
|
118
129
|
getSourceMap(id) {
|
|
119
130
|
const cache = this.get(id);
|
|
120
131
|
if (cache.map)
|
|
@@ -142,6 +153,7 @@ class ViteNodeRunner {
|
|
|
142
153
|
const [id, url] = await this.resolveUrl(rawId);
|
|
143
154
|
return await this.cachedRequest(id, url, []);
|
|
144
155
|
}
|
|
156
|
+
/** @internal */
|
|
145
157
|
async cachedRequest(id, fsPath, callstack) {
|
|
146
158
|
const importee = callstack[callstack.length - 1];
|
|
147
159
|
const mod = this.moduleCache.get(fsPath);
|
|
@@ -187,6 +199,7 @@ class ViteNodeRunner {
|
|
|
187
199
|
this.moduleCache.deleteByModuleId(resolveKey);
|
|
188
200
|
}
|
|
189
201
|
}
|
|
202
|
+
/** @internal */
|
|
190
203
|
async dependencyRequest(id, fsPath, callstack) {
|
|
191
204
|
var _a;
|
|
192
205
|
const getStack = () => {
|
|
@@ -210,6 +223,7 @@ ${getStack()}`), 2e3);
|
|
|
210
223
|
clearTimeout(debugTimer);
|
|
211
224
|
}
|
|
212
225
|
}
|
|
226
|
+
/** @internal */
|
|
213
227
|
async directRequest(id, fsPath, _callstack) {
|
|
214
228
|
const moduleId = normalizeModuleId(fsPath);
|
|
215
229
|
const callstack = [..._callstack, moduleId];
|
|
@@ -290,11 +304,13 @@ ${getStack()}`), 2e3);
|
|
|
290
304
|
});
|
|
291
305
|
}
|
|
292
306
|
const context = this.prepareContext({
|
|
307
|
+
// esm transformed by Vite
|
|
293
308
|
__vite_ssr_import__: request,
|
|
294
309
|
__vite_ssr_dynamic_import__: request,
|
|
295
310
|
__vite_ssr_exports__: exports,
|
|
296
311
|
__vite_ssr_exportAll__: (obj) => exportAll(exports, obj),
|
|
297
312
|
__vite_ssr_import_meta__: meta,
|
|
313
|
+
// cjs compact
|
|
298
314
|
require: createRequire(href),
|
|
299
315
|
exports: cjsExports,
|
|
300
316
|
module: moduleProxy,
|
|
@@ -318,11 +334,18 @@ ${getStack()}`), 2e3);
|
|
|
318
334
|
prepareContext(context) {
|
|
319
335
|
return context;
|
|
320
336
|
}
|
|
337
|
+
/**
|
|
338
|
+
* Define if a module should be interop-ed
|
|
339
|
+
* This function mostly for the ability to override by subclass
|
|
340
|
+
*/
|
|
321
341
|
shouldInterop(path, mod) {
|
|
322
342
|
if (this.options.interopDefault === false)
|
|
323
343
|
return false;
|
|
324
344
|
return !path.endsWith(".mjs") && "default" in mod;
|
|
325
345
|
}
|
|
346
|
+
/**
|
|
347
|
+
* Import a module and interop it
|
|
348
|
+
*/
|
|
326
349
|
async interopedImport(path) {
|
|
327
350
|
const importedModule = await import(path);
|
|
328
351
|
if (!this.shouldInterop(path, importedModule))
|
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-c39b64bb.js';
|
|
4
4
|
import './types.d-1e7e3fdf.js';
|
|
5
5
|
|
|
6
6
|
type EventType = string | symbol;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
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-c39b64bb.js';
|
|
2
2
|
export { D as DecodedSourceMap, E as EncodedSourceMap } from './types.d-1e7e3fdf.js';
|
package/dist/server.cjs
CHANGED
|
@@ -11,6 +11,7 @@ var utils = require('./utils.cjs');
|
|
|
11
11
|
var c = require('picocolors');
|
|
12
12
|
var sourceMap = require('./source-map.cjs');
|
|
13
13
|
require('node:url');
|
|
14
|
+
require('module');
|
|
14
15
|
require('path');
|
|
15
16
|
|
|
16
17
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
@@ -19,6 +20,7 @@ var createDebug__default = /*#__PURE__*/_interopDefaultLegacy(createDebug);
|
|
|
19
20
|
var c__default = /*#__PURE__*/_interopDefaultLegacy(c);
|
|
20
21
|
|
|
21
22
|
const KNOWN_ASSET_TYPES = [
|
|
23
|
+
// images
|
|
22
24
|
"png",
|
|
23
25
|
"jpe?g",
|
|
24
26
|
"jfif",
|
|
@@ -29,6 +31,7 @@ const KNOWN_ASSET_TYPES = [
|
|
|
29
31
|
"ico",
|
|
30
32
|
"webp",
|
|
31
33
|
"avif",
|
|
34
|
+
// media
|
|
32
35
|
"mp4",
|
|
33
36
|
"webm",
|
|
34
37
|
"ogg",
|
|
@@ -36,10 +39,12 @@ const KNOWN_ASSET_TYPES = [
|
|
|
36
39
|
"wav",
|
|
37
40
|
"flac",
|
|
38
41
|
"aac",
|
|
42
|
+
// fonts
|
|
39
43
|
"woff2?",
|
|
40
44
|
"eot",
|
|
41
45
|
"ttf",
|
|
42
46
|
"otf",
|
|
47
|
+
// other
|
|
43
48
|
"webmanifest",
|
|
44
49
|
"pdf",
|
|
45
50
|
"txt"
|
|
@@ -49,7 +54,9 @@ const ESM_FOLDER_RE = /\/(es|esm)\/(.*\.js)$/;
|
|
|
49
54
|
const defaultInline = [
|
|
50
55
|
/virtual:/,
|
|
51
56
|
/\.[mc]?ts$/,
|
|
57
|
+
// special Vite query strings
|
|
52
58
|
/[?&](init|raw|url|inline)\b/,
|
|
59
|
+
// Vite returns a string for assets imports, even if it's inside "node_modules"
|
|
53
60
|
new RegExp(`\\.(${KNOWN_ASSET_TYPES.join("|")})$`)
|
|
54
61
|
];
|
|
55
62
|
const depsExternal = [
|
|
@@ -197,7 +204,7 @@ ${result.code}`, "utf-8");
|
|
|
197
204
|
if (!this.dumpDir)
|
|
198
205
|
return;
|
|
199
206
|
const info = JSON.stringify({
|
|
200
|
-
time: new Date().toLocaleString(),
|
|
207
|
+
time: (/* @__PURE__ */ new Date()).toLocaleString(),
|
|
201
208
|
externalize: Object.fromEntries(this.externalizeMap.entries())
|
|
202
209
|
}, null, 2);
|
|
203
210
|
return fs.promises.writeFile(pathe.join(this.dumpDir, "info.json"), info, "utf-8");
|
|
@@ -341,8 +348,12 @@ class ViteNodeServer {
|
|
|
341
348
|
});
|
|
342
349
|
return result;
|
|
343
350
|
}
|
|
344
|
-
async processTransformResult(result) {
|
|
345
|
-
|
|
351
|
+
async processTransformResult(id, result) {
|
|
352
|
+
const mod = this.server.moduleGraph.getModuleById(id);
|
|
353
|
+
return sourceMap.withInlineSourcemap(result, {
|
|
354
|
+
filepath: (mod == null ? void 0 : mod.file) || id,
|
|
355
|
+
root: this.server.config.root
|
|
356
|
+
});
|
|
346
357
|
}
|
|
347
358
|
async _transformRequest(id, customTransformMode) {
|
|
348
359
|
var _a, _b, _c, _d;
|
|
@@ -363,7 +374,7 @@ class ViteNodeServer {
|
|
|
363
374
|
}
|
|
364
375
|
const sourcemap = this.options.sourcemap ?? "inline";
|
|
365
376
|
if (sourcemap === "inline" && result && !id.includes("node_modules"))
|
|
366
|
-
result = await this.processTransformResult(result);
|
|
377
|
+
result = await this.processTransformResult(id, result);
|
|
367
378
|
if ((_c = this.options.debug) == null ? void 0 : _c.dumpModules)
|
|
368
379
|
await ((_d = this.debugger) == null ? void 0 : _d.dumpFile(id, result));
|
|
369
380
|
return result;
|
package/dist/server.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TransformResult, ViteDevServer } from 'vite';
|
|
2
2
|
import { E as EncodedSourceMap } from './types.d-1e7e3fdf.js';
|
|
3
|
-
import { f as DebuggerOptions, D as DepsHandlingOptions, e as ViteNodeServerOptions, F as FetchResult, d as ViteNodeResolveId } from './types-
|
|
3
|
+
import { f as DebuggerOptions, D as DepsHandlingOptions, e as ViteNodeServerOptions, F as FetchResult, d as ViteNodeResolveId } from './types-c39b64bb.js';
|
|
4
4
|
|
|
5
5
|
declare class Debugger {
|
|
6
6
|
options: DebuggerOptions;
|
|
@@ -41,7 +41,7 @@ declare class ViteNodeServer {
|
|
|
41
41
|
transformRequest(id: string): Promise<TransformResult | null | undefined>;
|
|
42
42
|
getTransformMode(id: string): "web" | "ssr";
|
|
43
43
|
private _fetchModule;
|
|
44
|
-
protected processTransformResult(result: TransformResult): Promise<TransformResult>;
|
|
44
|
+
protected processTransformResult(id: string, result: TransformResult): Promise<TransformResult>;
|
|
45
45
|
private _transformRequest;
|
|
46
46
|
}
|
|
47
47
|
|
package/dist/server.mjs
CHANGED
|
@@ -7,9 +7,11 @@ import { slash, toArray, normalizeModuleId, toFilePath } from './utils.mjs';
|
|
|
7
7
|
import c from 'picocolors';
|
|
8
8
|
import { withInlineSourcemap } from './source-map.mjs';
|
|
9
9
|
import 'node:url';
|
|
10
|
+
import 'node:module';
|
|
10
11
|
import 'node:path';
|
|
11
12
|
|
|
12
13
|
const KNOWN_ASSET_TYPES = [
|
|
14
|
+
// images
|
|
13
15
|
"png",
|
|
14
16
|
"jpe?g",
|
|
15
17
|
"jfif",
|
|
@@ -20,6 +22,7 @@ const KNOWN_ASSET_TYPES = [
|
|
|
20
22
|
"ico",
|
|
21
23
|
"webp",
|
|
22
24
|
"avif",
|
|
25
|
+
// media
|
|
23
26
|
"mp4",
|
|
24
27
|
"webm",
|
|
25
28
|
"ogg",
|
|
@@ -27,10 +30,12 @@ const KNOWN_ASSET_TYPES = [
|
|
|
27
30
|
"wav",
|
|
28
31
|
"flac",
|
|
29
32
|
"aac",
|
|
33
|
+
// fonts
|
|
30
34
|
"woff2?",
|
|
31
35
|
"eot",
|
|
32
36
|
"ttf",
|
|
33
37
|
"otf",
|
|
38
|
+
// other
|
|
34
39
|
"webmanifest",
|
|
35
40
|
"pdf",
|
|
36
41
|
"txt"
|
|
@@ -40,7 +45,9 @@ const ESM_FOLDER_RE = /\/(es|esm)\/(.*\.js)$/;
|
|
|
40
45
|
const defaultInline = [
|
|
41
46
|
/virtual:/,
|
|
42
47
|
/\.[mc]?ts$/,
|
|
48
|
+
// special Vite query strings
|
|
43
49
|
/[?&](init|raw|url|inline)\b/,
|
|
50
|
+
// Vite returns a string for assets imports, even if it's inside "node_modules"
|
|
44
51
|
new RegExp(`\\.(${KNOWN_ASSET_TYPES.join("|")})$`)
|
|
45
52
|
];
|
|
46
53
|
const depsExternal = [
|
|
@@ -188,7 +195,7 @@ ${result.code}`, "utf-8");
|
|
|
188
195
|
if (!this.dumpDir)
|
|
189
196
|
return;
|
|
190
197
|
const info = JSON.stringify({
|
|
191
|
-
time: new Date().toLocaleString(),
|
|
198
|
+
time: (/* @__PURE__ */ new Date()).toLocaleString(),
|
|
192
199
|
externalize: Object.fromEntries(this.externalizeMap.entries())
|
|
193
200
|
}, null, 2);
|
|
194
201
|
return promises.writeFile(join(this.dumpDir, "info.json"), info, "utf-8");
|
|
@@ -332,8 +339,12 @@ class ViteNodeServer {
|
|
|
332
339
|
});
|
|
333
340
|
return result;
|
|
334
341
|
}
|
|
335
|
-
async processTransformResult(result) {
|
|
336
|
-
|
|
342
|
+
async processTransformResult(id, result) {
|
|
343
|
+
const mod = this.server.moduleGraph.getModuleById(id);
|
|
344
|
+
return withInlineSourcemap(result, {
|
|
345
|
+
filepath: (mod == null ? void 0 : mod.file) || id,
|
|
346
|
+
root: this.server.config.root
|
|
347
|
+
});
|
|
337
348
|
}
|
|
338
349
|
async _transformRequest(id, customTransformMode) {
|
|
339
350
|
var _a, _b, _c, _d;
|
|
@@ -354,7 +365,7 @@ class ViteNodeServer {
|
|
|
354
365
|
}
|
|
355
366
|
const sourcemap = this.options.sourcemap ?? "inline";
|
|
356
367
|
if (sourcemap === "inline" && result && !id.includes("node_modules"))
|
|
357
|
-
result = await this.processTransformResult(result);
|
|
368
|
+
result = await this.processTransformResult(id, result);
|
|
358
369
|
if ((_c = this.options.debug) == null ? void 0 : _c.dumpModules)
|
|
359
370
|
await ((_d = this.debugger) == null ? void 0 : _d.dumpFile(id, result));
|
|
360
371
|
return result;
|
package/dist/source-map.cjs
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var pathe = require('pathe');
|
|
5
6
|
var path = require('path');
|
|
6
7
|
var fs = require('fs');
|
|
7
8
|
|
|
@@ -864,11 +865,21 @@ SOURCEMAPPING_URL += "ppingURL";
|
|
|
864
865
|
const VITE_NODE_SOURCEMAPPING_SOURCE = "//# sourceMappingSource=vite-node";
|
|
865
866
|
const VITE_NODE_SOURCEMAPPING_URL = `${SOURCEMAPPING_URL}=data:application/json;charset=utf-8`;
|
|
866
867
|
const VITE_NODE_SOURCEMAPPING_REGEXP = new RegExp(`//# ${VITE_NODE_SOURCEMAPPING_URL};base64,(.+)`);
|
|
867
|
-
function withInlineSourcemap(result) {
|
|
868
|
+
function withInlineSourcemap(result, options) {
|
|
869
|
+
var _a;
|
|
868
870
|
const map = result.map;
|
|
869
871
|
let code = result.code;
|
|
870
872
|
if (!map || code.includes(VITE_NODE_SOURCEMAPPING_SOURCE))
|
|
871
873
|
return result;
|
|
874
|
+
map.sources = (_a = map.sources) == null ? void 0 : _a.map((source) => {
|
|
875
|
+
if (!source)
|
|
876
|
+
return source;
|
|
877
|
+
if (!pathe.isAbsolute(source))
|
|
878
|
+
return pathe.resolve(pathe.dirname(options.filepath), source);
|
|
879
|
+
if (!source.startsWith(options.root))
|
|
880
|
+
return pathe.join(options.root, source);
|
|
881
|
+
return source;
|
|
882
|
+
});
|
|
872
883
|
const OTHER_SOURCE_MAP_REGEXP = new RegExp(`//# ${SOURCEMAPPING_URL}=data:application/json[^,]+base64,(.+)`, "g");
|
|
873
884
|
while (OTHER_SOURCE_MAP_REGEXP.test(code))
|
|
874
885
|
code = code.replace(OTHER_SOURCE_MAP_REGEXP, "");
|
package/dist/source-map.d.ts
CHANGED
|
@@ -4,7 +4,10 @@ import { E as EncodedSourceMap } from './types.d-1e7e3fdf.js';
|
|
|
4
4
|
interface InstallSourceMapSupportOptions {
|
|
5
5
|
getSourceMap: (source: string) => EncodedSourceMap | null | undefined;
|
|
6
6
|
}
|
|
7
|
-
declare function withInlineSourcemap(result: TransformResult
|
|
7
|
+
declare function withInlineSourcemap(result: TransformResult, options: {
|
|
8
|
+
root: string;
|
|
9
|
+
filepath: string;
|
|
10
|
+
}): TransformResult;
|
|
8
11
|
declare function extractSourceMap(code: string): EncodedSourceMap | null;
|
|
9
12
|
declare function installSourcemapsSupport(options: InstallSourceMapSupportOptions): void;
|
|
10
13
|
|
package/dist/source-map.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isAbsolute, resolve as resolve$2, dirname, join } from 'pathe';
|
|
1
2
|
import path from 'node:path';
|
|
2
3
|
import fs from 'node:fs';
|
|
3
4
|
|
|
@@ -855,11 +856,21 @@ SOURCEMAPPING_URL += "ppingURL";
|
|
|
855
856
|
const VITE_NODE_SOURCEMAPPING_SOURCE = "//# sourceMappingSource=vite-node";
|
|
856
857
|
const VITE_NODE_SOURCEMAPPING_URL = `${SOURCEMAPPING_URL}=data:application/json;charset=utf-8`;
|
|
857
858
|
const VITE_NODE_SOURCEMAPPING_REGEXP = new RegExp(`//# ${VITE_NODE_SOURCEMAPPING_URL};base64,(.+)`);
|
|
858
|
-
function withInlineSourcemap(result) {
|
|
859
|
+
function withInlineSourcemap(result, options) {
|
|
860
|
+
var _a;
|
|
859
861
|
const map = result.map;
|
|
860
862
|
let code = result.code;
|
|
861
863
|
if (!map || code.includes(VITE_NODE_SOURCEMAPPING_SOURCE))
|
|
862
864
|
return result;
|
|
865
|
+
map.sources = (_a = map.sources) == null ? void 0 : _a.map((source) => {
|
|
866
|
+
if (!source)
|
|
867
|
+
return source;
|
|
868
|
+
if (!isAbsolute(source))
|
|
869
|
+
return resolve$2(dirname(options.filepath), source);
|
|
870
|
+
if (!source.startsWith(options.root))
|
|
871
|
+
return join(options.root, source);
|
|
872
|
+
return source;
|
|
873
|
+
});
|
|
863
874
|
const OTHER_SOURCE_MAP_REGEXP = new RegExp(`//# ${SOURCEMAPPING_URL}=data:application/json[^,]+base64,(.+)`, "g");
|
|
864
875
|
while (OTHER_SOURCE_MAP_REGEXP.test(code))
|
|
865
876
|
code = code.replace(OTHER_SOURCE_MAP_REGEXP, "");
|
|
@@ -110,32 +110,7 @@ interface ViteHotContext {
|
|
|
110
110
|
send<T extends string>(event: T, data?: InferCustomEventPayload<T>): void
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
declare const DEFAULT_REQUEST_STUBS:
|
|
114
|
-
'/@vite/client': {
|
|
115
|
-
injectQuery: (id: string) => string;
|
|
116
|
-
createHotContext(): {
|
|
117
|
-
accept: () => void;
|
|
118
|
-
prune: () => void;
|
|
119
|
-
dispose: () => void;
|
|
120
|
-
decline: () => void;
|
|
121
|
-
invalidate: () => void;
|
|
122
|
-
on: () => void;
|
|
123
|
-
};
|
|
124
|
-
updateStyle(id: string, css: string): void;
|
|
125
|
-
};
|
|
126
|
-
'@vite/client': {
|
|
127
|
-
injectQuery: (id: string) => string;
|
|
128
|
-
createHotContext(): {
|
|
129
|
-
accept: () => void;
|
|
130
|
-
prune: () => void;
|
|
131
|
-
dispose: () => void;
|
|
132
|
-
decline: () => void;
|
|
133
|
-
invalidate: () => void;
|
|
134
|
-
on: () => void;
|
|
135
|
-
};
|
|
136
|
-
updateStyle(id: string, css: string): void;
|
|
137
|
-
};
|
|
138
|
-
};
|
|
113
|
+
declare const DEFAULT_REQUEST_STUBS: Record<string, unknown>;
|
|
139
114
|
declare class ModuleCacheMap extends Map<string, ModuleCache> {
|
|
140
115
|
normalizePath(fsPath: string): string;
|
|
141
116
|
/**
|
package/dist/types.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
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-c39b64bb.js';
|
|
2
2
|
export { D as DecodedSourceMap, E as EncodedSourceMap } from './types.d-1e7e3fdf.js';
|
package/dist/utils.cjs
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var node_url = require('node:url');
|
|
6
|
+
var module$1 = require('module');
|
|
6
7
|
var fs = require('fs');
|
|
7
8
|
var pathe = require('pathe');
|
|
8
9
|
|
|
@@ -18,15 +19,17 @@ function normalizeRequestId(id, base) {
|
|
|
18
19
|
}
|
|
19
20
|
const queryRE = /\?.*$/s;
|
|
20
21
|
const hashRE = /#.*$/s;
|
|
21
|
-
|
|
22
|
+
function cleanUrl(url) {
|
|
23
|
+
return url.replace(hashRE, "").replace(queryRE, "");
|
|
24
|
+
}
|
|
22
25
|
const internalRequests = [
|
|
23
26
|
"@vite/client",
|
|
24
27
|
"@vite/env"
|
|
25
28
|
];
|
|
26
29
|
const internalRequestRegexp = new RegExp(`^/?(${internalRequests.join("|")})$`);
|
|
27
|
-
|
|
30
|
+
function isInternalRequest(id) {
|
|
28
31
|
return internalRequestRegexp.test(id);
|
|
29
|
-
}
|
|
32
|
+
}
|
|
30
33
|
function normalizeModuleId(id) {
|
|
31
34
|
return id.replace(/\\/g, "/").replace(/^\/@fs\//, isWindows ? "" : "/").replace(/^file:\//, "/").replace(/^node:/, "").replace(/^\/+/, "/");
|
|
32
35
|
}
|
|
@@ -53,6 +56,28 @@ function toFilePath(id, root) {
|
|
|
53
56
|
exists
|
|
54
57
|
};
|
|
55
58
|
}
|
|
59
|
+
const builtins = /* @__PURE__ */ new Set([
|
|
60
|
+
...module$1.builtinModules,
|
|
61
|
+
"assert/strict",
|
|
62
|
+
"diagnostics_channel",
|
|
63
|
+
"dns/promises",
|
|
64
|
+
"fs/promises",
|
|
65
|
+
"path/posix",
|
|
66
|
+
"path/win32",
|
|
67
|
+
"readline/promises",
|
|
68
|
+
"stream/consumers",
|
|
69
|
+
"stream/promises",
|
|
70
|
+
"stream/web",
|
|
71
|
+
"timers/promises",
|
|
72
|
+
"util/types",
|
|
73
|
+
"wasi"
|
|
74
|
+
]);
|
|
75
|
+
const NODE_BUILTIN_NAMESPACE = "node:";
|
|
76
|
+
function isNodeBuiltin(id) {
|
|
77
|
+
return builtins.has(
|
|
78
|
+
id.startsWith(NODE_BUILTIN_NAMESPACE) ? id.slice(NODE_BUILTIN_NAMESPACE.length) : id
|
|
79
|
+
);
|
|
80
|
+
}
|
|
56
81
|
function toArray(array) {
|
|
57
82
|
if (array === null || array === void 0)
|
|
58
83
|
array = [];
|
|
@@ -65,6 +90,7 @@ exports.VALID_ID_PREFIX = VALID_ID_PREFIX;
|
|
|
65
90
|
exports.cleanUrl = cleanUrl;
|
|
66
91
|
exports.hashRE = hashRE;
|
|
67
92
|
exports.isInternalRequest = isInternalRequest;
|
|
93
|
+
exports.isNodeBuiltin = isNodeBuiltin;
|
|
68
94
|
exports.isPrimitive = isPrimitive;
|
|
69
95
|
exports.isWindows = isWindows;
|
|
70
96
|
exports.normalizeModuleId = normalizeModuleId;
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { N as Nullable, A as Arrayable } from './types-
|
|
1
|
+
import { N as Nullable, A as Arrayable } from './types-c39b64bb.js';
|
|
2
2
|
import './types.d-1e7e3fdf.js';
|
|
3
3
|
|
|
4
4
|
declare const isWindows: boolean;
|
|
@@ -7,14 +7,15 @@ declare const VALID_ID_PREFIX = "/@id/";
|
|
|
7
7
|
declare function normalizeRequestId(id: string, base?: string): string;
|
|
8
8
|
declare const queryRE: RegExp;
|
|
9
9
|
declare const hashRE: RegExp;
|
|
10
|
-
declare
|
|
11
|
-
declare
|
|
10
|
+
declare function cleanUrl(url: string): string;
|
|
11
|
+
declare function isInternalRequest(id: string): boolean;
|
|
12
12
|
declare function normalizeModuleId(id: string): string;
|
|
13
13
|
declare function isPrimitive(v: any): boolean;
|
|
14
14
|
declare function toFilePath(id: string, root: string): {
|
|
15
15
|
path: string;
|
|
16
16
|
exists: boolean;
|
|
17
17
|
};
|
|
18
|
+
declare function isNodeBuiltin(id: string): boolean;
|
|
18
19
|
/**
|
|
19
20
|
* Convert `Arrayable<T>` to `Array<T>`
|
|
20
21
|
*
|
|
@@ -22,4 +23,4 @@ declare function toFilePath(id: string, root: string): {
|
|
|
22
23
|
*/
|
|
23
24
|
declare function toArray<T>(array?: Nullable<Arrayable<T>>): Array<T>;
|
|
24
25
|
|
|
25
|
-
export { VALID_ID_PREFIX, cleanUrl, hashRE, isInternalRequest, isPrimitive, isWindows, normalizeModuleId, normalizeRequestId, queryRE, slash, toArray, toFilePath };
|
|
26
|
+
export { VALID_ID_PREFIX, cleanUrl, hashRE, isInternalRequest, isNodeBuiltin, isPrimitive, isWindows, normalizeModuleId, normalizeRequestId, queryRE, slash, toArray, toFilePath };
|
package/dist/utils.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
2
|
+
import { builtinModules } from 'node:module';
|
|
2
3
|
import { existsSync } from 'node:fs';
|
|
3
4
|
import { resolve } from 'pathe';
|
|
4
5
|
|
|
@@ -14,15 +15,17 @@ function normalizeRequestId(id, base) {
|
|
|
14
15
|
}
|
|
15
16
|
const queryRE = /\?.*$/s;
|
|
16
17
|
const hashRE = /#.*$/s;
|
|
17
|
-
|
|
18
|
+
function cleanUrl(url) {
|
|
19
|
+
return url.replace(hashRE, "").replace(queryRE, "");
|
|
20
|
+
}
|
|
18
21
|
const internalRequests = [
|
|
19
22
|
"@vite/client",
|
|
20
23
|
"@vite/env"
|
|
21
24
|
];
|
|
22
25
|
const internalRequestRegexp = new RegExp(`^/?(${internalRequests.join("|")})$`);
|
|
23
|
-
|
|
26
|
+
function isInternalRequest(id) {
|
|
24
27
|
return internalRequestRegexp.test(id);
|
|
25
|
-
}
|
|
28
|
+
}
|
|
26
29
|
function normalizeModuleId(id) {
|
|
27
30
|
return id.replace(/\\/g, "/").replace(/^\/@fs\//, isWindows ? "" : "/").replace(/^file:\//, "/").replace(/^node:/, "").replace(/^\/+/, "/");
|
|
28
31
|
}
|
|
@@ -49,6 +52,28 @@ function toFilePath(id, root) {
|
|
|
49
52
|
exists
|
|
50
53
|
};
|
|
51
54
|
}
|
|
55
|
+
const builtins = /* @__PURE__ */ new Set([
|
|
56
|
+
...builtinModules,
|
|
57
|
+
"assert/strict",
|
|
58
|
+
"diagnostics_channel",
|
|
59
|
+
"dns/promises",
|
|
60
|
+
"fs/promises",
|
|
61
|
+
"path/posix",
|
|
62
|
+
"path/win32",
|
|
63
|
+
"readline/promises",
|
|
64
|
+
"stream/consumers",
|
|
65
|
+
"stream/promises",
|
|
66
|
+
"stream/web",
|
|
67
|
+
"timers/promises",
|
|
68
|
+
"util/types",
|
|
69
|
+
"wasi"
|
|
70
|
+
]);
|
|
71
|
+
const NODE_BUILTIN_NAMESPACE = "node:";
|
|
72
|
+
function isNodeBuiltin(id) {
|
|
73
|
+
return builtins.has(
|
|
74
|
+
id.startsWith(NODE_BUILTIN_NAMESPACE) ? id.slice(NODE_BUILTIN_NAMESPACE.length) : id
|
|
75
|
+
);
|
|
76
|
+
}
|
|
52
77
|
function toArray(array) {
|
|
53
78
|
if (array === null || array === void 0)
|
|
54
79
|
array = [];
|
|
@@ -57,4 +82,4 @@ function toArray(array) {
|
|
|
57
82
|
return [array];
|
|
58
83
|
}
|
|
59
84
|
|
|
60
|
-
export { VALID_ID_PREFIX, cleanUrl, hashRE, isInternalRequest, isPrimitive, isWindows, normalizeModuleId, normalizeRequestId, queryRE, slash, toArray, toFilePath };
|
|
85
|
+
export { VALID_ID_PREFIX, cleanUrl, hashRE, isInternalRequest, isNodeBuiltin, 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.30.0",
|
|
4
4
|
"description": "Vite as Node.js runtime",
|
|
5
5
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -67,12 +67,12 @@
|
|
|
67
67
|
"*.mjs"
|
|
68
68
|
],
|
|
69
69
|
"engines": {
|
|
70
|
-
"node": ">=v14.
|
|
70
|
+
"node": ">=v14.18.0"
|
|
71
71
|
},
|
|
72
72
|
"dependencies": {
|
|
73
73
|
"cac": "^6.7.14",
|
|
74
74
|
"debug": "^4.3.4",
|
|
75
|
-
"mlly": "^1.
|
|
75
|
+
"mlly": "^1.2.0",
|
|
76
76
|
"pathe": "^1.1.0",
|
|
77
77
|
"picocolors": "^1.0.0",
|
|
78
78
|
"vite": "^3.0.0 || ^4.0.0"
|