vite-node 0.30.0 → 0.30.1
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 +2 -2
- package/dist/cli.mjs +1 -1
- package/dist/server.cjs +8 -8
- package/dist/server.d.ts +2 -2
- package/dist/server.mjs +8 -8
- package/dist/source-map.cjs +4 -4
- package/dist/source-map.mjs +5 -5
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -6,8 +6,8 @@ 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 hmr = require('./chunk-hmr.cjs');
|
|
10
9
|
var sourceMap = require('./source-map.cjs');
|
|
10
|
+
var hmr = require('./chunk-hmr.cjs');
|
|
11
11
|
require('perf_hooks');
|
|
12
12
|
require('fs');
|
|
13
13
|
require('pathe');
|
|
@@ -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.30.
|
|
27
|
+
var version = "0.30.1";
|
|
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.mjs
CHANGED
|
@@ -17,7 +17,7 @@ import 'node:path';
|
|
|
17
17
|
import 'node:vm';
|
|
18
18
|
import 'node:events';
|
|
19
19
|
|
|
20
|
-
var version = "0.30.
|
|
20
|
+
var version = "0.30.1";
|
|
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/server.cjs
CHANGED
|
@@ -288,11 +288,11 @@ class ViteNodeServer {
|
|
|
288
288
|
}
|
|
289
289
|
return this.fetchPromiseMap.get(id);
|
|
290
290
|
}
|
|
291
|
-
async transformRequest(id) {
|
|
291
|
+
async transformRequest(id, filepath = id) {
|
|
292
292
|
if (!this.transformPromiseMap.has(id)) {
|
|
293
293
|
this.transformPromiseMap.set(
|
|
294
294
|
id,
|
|
295
|
-
this._transformRequest(id).finally(() => {
|
|
295
|
+
this._transformRequest(id, filepath).finally(() => {
|
|
296
296
|
this.transformPromiseMap.delete(id);
|
|
297
297
|
})
|
|
298
298
|
);
|
|
@@ -337,7 +337,7 @@ class ViteNodeServer {
|
|
|
337
337
|
(_b = this.debugger) == null ? void 0 : _b.recordExternalize(id, externalize);
|
|
338
338
|
} else {
|
|
339
339
|
const start = perf_hooks.performance.now();
|
|
340
|
-
const r = await this._transformRequest(id, transformMode);
|
|
340
|
+
const r = await this._transformRequest(id, filePath, transformMode);
|
|
341
341
|
duration = perf_hooks.performance.now() - start;
|
|
342
342
|
result = { code: r == null ? void 0 : r.code, map: r == null ? void 0 : r.map };
|
|
343
343
|
}
|
|
@@ -348,14 +348,14 @@ class ViteNodeServer {
|
|
|
348
348
|
});
|
|
349
349
|
return result;
|
|
350
350
|
}
|
|
351
|
-
async processTransformResult(
|
|
352
|
-
const mod = this.server.moduleGraph.getModuleById(
|
|
351
|
+
async processTransformResult(filepath, result) {
|
|
352
|
+
const mod = this.server.moduleGraph.getModuleById(filepath);
|
|
353
353
|
return sourceMap.withInlineSourcemap(result, {
|
|
354
|
-
filepath: (mod == null ? void 0 : mod.file) ||
|
|
354
|
+
filepath: (mod == null ? void 0 : mod.file) || filepath,
|
|
355
355
|
root: this.server.config.root
|
|
356
356
|
});
|
|
357
357
|
}
|
|
358
|
-
async _transformRequest(id, customTransformMode) {
|
|
358
|
+
async _transformRequest(id, filepath, customTransformMode) {
|
|
359
359
|
var _a, _b, _c, _d;
|
|
360
360
|
debugRequest(id);
|
|
361
361
|
let result = null;
|
|
@@ -374,7 +374,7 @@ class ViteNodeServer {
|
|
|
374
374
|
}
|
|
375
375
|
const sourcemap = this.options.sourcemap ?? "inline";
|
|
376
376
|
if (sourcemap === "inline" && result && !id.includes("node_modules"))
|
|
377
|
-
result = await this.processTransformResult(
|
|
377
|
+
result = await this.processTransformResult(filepath, result);
|
|
378
378
|
if ((_c = this.options.debug) == null ? void 0 : _c.dumpModules)
|
|
379
379
|
await ((_d = this.debugger) == null ? void 0 : _d.dumpFile(id, result));
|
|
380
380
|
return result;
|
package/dist/server.d.ts
CHANGED
|
@@ -38,10 +38,10 @@ declare class ViteNodeServer {
|
|
|
38
38
|
resolveId(id: string, importer?: string, transformMode?: 'web' | 'ssr'): Promise<ViteNodeResolveId | null>;
|
|
39
39
|
getSourceMap(source: string): EncodedSourceMap | null;
|
|
40
40
|
fetchModule(id: string, transformMode?: 'web' | 'ssr'): Promise<FetchResult>;
|
|
41
|
-
transformRequest(id: string): Promise<TransformResult | null | undefined>;
|
|
41
|
+
transformRequest(id: string, filepath?: string): Promise<TransformResult | null | undefined>;
|
|
42
42
|
getTransformMode(id: string): "web" | "ssr";
|
|
43
43
|
private _fetchModule;
|
|
44
|
-
protected processTransformResult(
|
|
44
|
+
protected processTransformResult(filepath: string, result: TransformResult): Promise<TransformResult>;
|
|
45
45
|
private _transformRequest;
|
|
46
46
|
}
|
|
47
47
|
|
package/dist/server.mjs
CHANGED
|
@@ -279,11 +279,11 @@ class ViteNodeServer {
|
|
|
279
279
|
}
|
|
280
280
|
return this.fetchPromiseMap.get(id);
|
|
281
281
|
}
|
|
282
|
-
async transformRequest(id) {
|
|
282
|
+
async transformRequest(id, filepath = id) {
|
|
283
283
|
if (!this.transformPromiseMap.has(id)) {
|
|
284
284
|
this.transformPromiseMap.set(
|
|
285
285
|
id,
|
|
286
|
-
this._transformRequest(id).finally(() => {
|
|
286
|
+
this._transformRequest(id, filepath).finally(() => {
|
|
287
287
|
this.transformPromiseMap.delete(id);
|
|
288
288
|
})
|
|
289
289
|
);
|
|
@@ -328,7 +328,7 @@ class ViteNodeServer {
|
|
|
328
328
|
(_b = this.debugger) == null ? void 0 : _b.recordExternalize(id, externalize);
|
|
329
329
|
} else {
|
|
330
330
|
const start = performance.now();
|
|
331
|
-
const r = await this._transformRequest(id, transformMode);
|
|
331
|
+
const r = await this._transformRequest(id, filePath, transformMode);
|
|
332
332
|
duration = performance.now() - start;
|
|
333
333
|
result = { code: r == null ? void 0 : r.code, map: r == null ? void 0 : r.map };
|
|
334
334
|
}
|
|
@@ -339,14 +339,14 @@ class ViteNodeServer {
|
|
|
339
339
|
});
|
|
340
340
|
return result;
|
|
341
341
|
}
|
|
342
|
-
async processTransformResult(
|
|
343
|
-
const mod = this.server.moduleGraph.getModuleById(
|
|
342
|
+
async processTransformResult(filepath, result) {
|
|
343
|
+
const mod = this.server.moduleGraph.getModuleById(filepath);
|
|
344
344
|
return withInlineSourcemap(result, {
|
|
345
|
-
filepath: (mod == null ? void 0 : mod.file) ||
|
|
345
|
+
filepath: (mod == null ? void 0 : mod.file) || filepath,
|
|
346
346
|
root: this.server.config.root
|
|
347
347
|
});
|
|
348
348
|
}
|
|
349
|
-
async _transformRequest(id, customTransformMode) {
|
|
349
|
+
async _transformRequest(id, filepath, customTransformMode) {
|
|
350
350
|
var _a, _b, _c, _d;
|
|
351
351
|
debugRequest(id);
|
|
352
352
|
let result = null;
|
|
@@ -365,7 +365,7 @@ class ViteNodeServer {
|
|
|
365
365
|
}
|
|
366
366
|
const sourcemap = this.options.sourcemap ?? "inline";
|
|
367
367
|
if (sourcemap === "inline" && result && !id.includes("node_modules"))
|
|
368
|
-
result = await this.processTransformResult(
|
|
368
|
+
result = await this.processTransformResult(filepath, result);
|
|
369
369
|
if ((_c = this.options.debug) == null ? void 0 : _c.dumpModules)
|
|
370
370
|
await ((_d = this.debugger) == null ? void 0 : _d.dumpFile(id, result));
|
|
371
371
|
return result;
|
package/dist/source-map.cjs
CHANGED
|
@@ -874,10 +874,10 @@ function withInlineSourcemap(result, options) {
|
|
|
874
874
|
map.sources = (_a = map.sources) == null ? void 0 : _a.map((source) => {
|
|
875
875
|
if (!source)
|
|
876
876
|
return source;
|
|
877
|
-
if (
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
877
|
+
if (pathe.isAbsolute(source)) {
|
|
878
|
+
const actualPath = !source.startsWith(options.root) && source.startsWith("/") ? pathe.resolve(options.root, source.slice(1)) : source;
|
|
879
|
+
return pathe.relative(pathe.dirname(options.filepath), actualPath);
|
|
880
|
+
}
|
|
881
881
|
return source;
|
|
882
882
|
});
|
|
883
883
|
const OTHER_SOURCE_MAP_REGEXP = new RegExp(`//# ${SOURCEMAPPING_URL}=data:application/json[^,]+base64,(.+)`, "g");
|
package/dist/source-map.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isAbsolute, resolve as resolve$2,
|
|
1
|
+
import { isAbsolute, resolve as resolve$2, relative, dirname } from 'pathe';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import fs from 'node:fs';
|
|
4
4
|
|
|
@@ -865,10 +865,10 @@ function withInlineSourcemap(result, options) {
|
|
|
865
865
|
map.sources = (_a = map.sources) == null ? void 0 : _a.map((source) => {
|
|
866
866
|
if (!source)
|
|
867
867
|
return source;
|
|
868
|
-
if (
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
868
|
+
if (isAbsolute(source)) {
|
|
869
|
+
const actualPath = !source.startsWith(options.root) && source.startsWith("/") ? resolve$2(options.root, source.slice(1)) : source;
|
|
870
|
+
return relative(dirname(options.filepath), actualPath);
|
|
871
|
+
}
|
|
872
872
|
return source;
|
|
873
873
|
});
|
|
874
874
|
const OTHER_SOURCE_MAP_REGEXP = new RegExp(`//# ${SOURCEMAPPING_URL}=data:application/json[^,]+base64,(.+)`, "g");
|