vite-node 0.12.5 → 0.12.8
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/cli.d.ts +8 -0
- package/client.d.ts +37 -0
- package/dist/cli.cjs +6 -6
- package/dist/cli.js +7 -7
- package/dist/{client-aa28334b.js → client-3270fd45.js} +2 -2
- package/dist/{client-d42a1094.js → client-f221b9b5.js} +2 -2
- package/dist/client.cjs +2 -2
- package/dist/client.js +2 -2
- package/dist/{server-e4d25388.js → server-013a4491.js} +1 -1
- package/dist/{server-c98deede.js → server-f6511dc4.js} +1 -1
- package/dist/server.cjs +2 -2
- package/dist/server.js +2 -2
- package/dist/{utils-0290448b.js → utils-b4f03380.js} +4 -1
- package/dist/{utils-5d86aff6.js → utils-c2e3d5fd.js} +4 -0
- package/dist/utils.cjs +2 -1
- package/dist/utils.d.ts +2 -1
- package/dist/utils.js +1 -1
- package/index.d.ts +1 -0
- package/package.json +3 -3
- package/server.d.ts +26 -0
- package/types.d.ts +68 -0
- package/utils.d.ts +10 -0
package/cli.d.ts
ADDED
package/client.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { ViteNodeRunnerOptions, ModuleCache } from './types.js';
|
|
2
|
+
|
|
3
|
+
declare const DEFAULT_REQUEST_STUBS: {
|
|
4
|
+
'/@vite/client': {
|
|
5
|
+
injectQuery: (id: string) => string;
|
|
6
|
+
createHotContext(): {
|
|
7
|
+
accept: () => void;
|
|
8
|
+
prune: () => void;
|
|
9
|
+
};
|
|
10
|
+
updateStyle(): void;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
declare class ViteNodeRunner {
|
|
14
|
+
options: ViteNodeRunnerOptions;
|
|
15
|
+
root: string;
|
|
16
|
+
moduleCache: Map<string, ModuleCache>;
|
|
17
|
+
constructor(options: ViteNodeRunnerOptions);
|
|
18
|
+
executeFile(file: string): Promise<any>;
|
|
19
|
+
executeId(id: string): Promise<any>;
|
|
20
|
+
cachedRequest(rawId: string, callstack: string[]): Promise<any>;
|
|
21
|
+
directRequest(id: string, fsPath: string, callstack: string[]): Promise<any>;
|
|
22
|
+
prepareContext(context: Record<string, any>): Record<string, any>;
|
|
23
|
+
setCache(id: string, mod: Partial<ModuleCache>): void;
|
|
24
|
+
shouldResolveId(dep: string): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Define if a module should be interop-ed
|
|
27
|
+
* This function mostly for the ability to override by subclass
|
|
28
|
+
*/
|
|
29
|
+
shouldInterop(path: string, mod: any): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Import a module and interop it
|
|
32
|
+
*/
|
|
33
|
+
interopedImport(path: string): Promise<any>;
|
|
34
|
+
hasNestedDefault(target: any): any;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export { DEFAULT_REQUEST_STUBS, ViteNodeRunner };
|
package/dist/cli.cjs
CHANGED
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
var events = require('events');
|
|
4
4
|
var kolorist = require('kolorist');
|
|
5
5
|
var vite = require('vite');
|
|
6
|
-
var server = require('./server-
|
|
7
|
-
var client = require('./client-
|
|
6
|
+
var server = require('./server-f6511dc4.js');
|
|
7
|
+
var client = require('./client-f221b9b5.js');
|
|
8
8
|
require('pathe');
|
|
9
9
|
require('debug');
|
|
10
10
|
require('fs');
|
|
11
11
|
require('mlly');
|
|
12
|
-
require('./utils-
|
|
12
|
+
require('./utils-c2e3d5fd.js');
|
|
13
13
|
require('url');
|
|
14
14
|
require('module');
|
|
15
15
|
require('vm');
|
|
@@ -627,7 +627,7 @@ class CAC extends events.EventEmitter {
|
|
|
627
627
|
|
|
628
628
|
const cac = (name = "") => new CAC(name);
|
|
629
629
|
|
|
630
|
-
var version = "0.12.
|
|
630
|
+
var version = "0.12.8";
|
|
631
631
|
|
|
632
632
|
const cli = cac("vite-node");
|
|
633
633
|
cli.version(version).option("-r, --root <path>", "Use specified root directory").option("-c, --config <path>", "Use specified config file").option("-w, --watch", 'Restart on file changes, similar to "nodemon"').help();
|
|
@@ -662,8 +662,8 @@ async function run(files, options = {}) {
|
|
|
662
662
|
await runner.executeFile(file);
|
|
663
663
|
if (!options.watch)
|
|
664
664
|
await server$1.close();
|
|
665
|
-
server$1.watcher.on("change", async (
|
|
666
|
-
console.log(kolorist.
|
|
665
|
+
server$1.watcher.on("change", async (path) => {
|
|
666
|
+
console.log(`${kolorist.cyan("[vite-node]")} File change detected. ${kolorist.dim(path)}`);
|
|
667
667
|
Array.from(runner.moduleCache.keys()).forEach((i) => {
|
|
668
668
|
if (!i.includes("node_modules"))
|
|
669
669
|
runner.moduleCache.delete(i);
|
package/dist/cli.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { EventEmitter } from 'events';
|
|
2
|
-
import { red, dim } from 'kolorist';
|
|
2
|
+
import { red, cyan, dim } from 'kolorist';
|
|
3
3
|
import { createServer } from 'vite';
|
|
4
|
-
import { V as ViteNodeServer } from './server-
|
|
5
|
-
import { V as ViteNodeRunner } from './client-
|
|
4
|
+
import { V as ViteNodeServer } from './server-013a4491.js';
|
|
5
|
+
import { V as ViteNodeRunner } from './client-3270fd45.js';
|
|
6
6
|
import 'pathe';
|
|
7
7
|
import 'debug';
|
|
8
8
|
import 'fs';
|
|
9
9
|
import 'mlly';
|
|
10
|
-
import './utils-
|
|
10
|
+
import './utils-b4f03380.js';
|
|
11
11
|
import 'url';
|
|
12
12
|
import 'module';
|
|
13
13
|
import 'vm';
|
|
@@ -625,7 +625,7 @@ class CAC extends EventEmitter {
|
|
|
625
625
|
|
|
626
626
|
const cac = (name = "") => new CAC(name);
|
|
627
627
|
|
|
628
|
-
var version = "0.12.
|
|
628
|
+
var version = "0.12.8";
|
|
629
629
|
|
|
630
630
|
const cli = cac("vite-node");
|
|
631
631
|
cli.version(version).option("-r, --root <path>", "Use specified root directory").option("-c, --config <path>", "Use specified config file").option("-w, --watch", 'Restart on file changes, similar to "nodemon"').help();
|
|
@@ -660,8 +660,8 @@ async function run(files, options = {}) {
|
|
|
660
660
|
await runner.executeFile(file);
|
|
661
661
|
if (!options.watch)
|
|
662
662
|
await server.close();
|
|
663
|
-
server.watcher.on("change", async (
|
|
664
|
-
console.log(
|
|
663
|
+
server.watcher.on("change", async (path) => {
|
|
664
|
+
console.log(`${cyan("[vite-node]")} File change detected. ${dim(path)}`);
|
|
665
665
|
Array.from(runner.moduleCache.keys()).forEach((i) => {
|
|
666
666
|
if (!i.includes("node_modules"))
|
|
667
667
|
runner.moduleCache.delete(i);
|
|
@@ -4,7 +4,7 @@ import vm from 'vm';
|
|
|
4
4
|
import { resolve, dirname, isAbsolute, extname } from 'pathe';
|
|
5
5
|
import { isNodeBuiltin } from 'mlly';
|
|
6
6
|
import createDebug from 'debug';
|
|
7
|
-
import { n as normalizeModuleId, s as slash, a as normalizeRequestId, t as toFilePath, i as isPrimitive } from './utils-
|
|
7
|
+
import { n as normalizeModuleId, s as slash, a as normalizeRequestId, t as toFilePath, i as isPrimitive, m as mergeSlashes } from './utils-b4f03380.js';
|
|
8
8
|
|
|
9
9
|
const debugExecute = createDebug("vite-node:client:execute");
|
|
10
10
|
const debugNative = createDebug("vite-node:client:native");
|
|
@@ -109,7 +109,7 @@ ${getStack()}`), 2e3);
|
|
|
109
109
|
if (importer && importer.startsWith("mock:"))
|
|
110
110
|
importer = importer.slice(5);
|
|
111
111
|
const { id: id2 } = await this.options.resolveId(dep, importer) || {};
|
|
112
|
-
dep = id2 && isAbsolute(id2) ? `/@fs/${id2}` : id2 || dep;
|
|
112
|
+
dep = id2 && isAbsolute(id2) ? mergeSlashes(`/@fs/${id2}`) : id2 || dep;
|
|
113
113
|
}
|
|
114
114
|
return dep;
|
|
115
115
|
};
|
|
@@ -6,7 +6,7 @@ var vm = require('vm');
|
|
|
6
6
|
var pathe = require('pathe');
|
|
7
7
|
var mlly = require('mlly');
|
|
8
8
|
var createDebug = require('debug');
|
|
9
|
-
var utils = require('./utils-
|
|
9
|
+
var utils = require('./utils-c2e3d5fd.js');
|
|
10
10
|
|
|
11
11
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
12
12
|
|
|
@@ -134,7 +134,7 @@ ${getStack()}`), 2e3);
|
|
|
134
134
|
if (importer && importer.startsWith("mock:"))
|
|
135
135
|
importer = importer.slice(5);
|
|
136
136
|
const { id: id2 } = await this.options.resolveId(dep, importer) || {};
|
|
137
|
-
dep = id2 && pathe.isAbsolute(id2) ? `/@fs/${id2}` : id2 || dep;
|
|
137
|
+
dep = id2 && pathe.isAbsolute(id2) ? utils.mergeSlashes(`/@fs/${id2}`) : id2 || dep;
|
|
138
138
|
}
|
|
139
139
|
return dep;
|
|
140
140
|
};
|
package/dist/client.cjs
CHANGED
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var client = require('./client-
|
|
5
|
+
var client = require('./client-f221b9b5.js');
|
|
6
6
|
require('module');
|
|
7
7
|
require('url');
|
|
8
8
|
require('vm');
|
|
9
9
|
require('pathe');
|
|
10
10
|
require('mlly');
|
|
11
11
|
require('debug');
|
|
12
|
-
require('./utils-
|
|
12
|
+
require('./utils-c2e3d5fd.js');
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
|
package/dist/client.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { D as DEFAULT_REQUEST_STUBS, M as ModuleCacheMap, V as ViteNodeRunner } from './client-
|
|
1
|
+
export { D as DEFAULT_REQUEST_STUBS, M as ModuleCacheMap, V as ViteNodeRunner } from './client-3270fd45.js';
|
|
2
2
|
import 'module';
|
|
3
3
|
import 'url';
|
|
4
4
|
import 'vm';
|
|
5
5
|
import 'pathe';
|
|
6
6
|
import 'mlly';
|
|
7
7
|
import 'debug';
|
|
8
|
-
import './utils-
|
|
8
|
+
import './utils-b4f03380.js';
|
|
@@ -2,7 +2,7 @@ import { join } from 'pathe';
|
|
|
2
2
|
import createDebug from 'debug';
|
|
3
3
|
import { existsSync } from 'fs';
|
|
4
4
|
import { isNodeBuiltin, isValidNodeImport } from 'mlly';
|
|
5
|
-
import { s as slash, t as toFilePath, w as withInlineSourcemap } from './utils-
|
|
5
|
+
import { s as slash, t as toFilePath, w as withInlineSourcemap } from './utils-b4f03380.js';
|
|
6
6
|
|
|
7
7
|
const ESM_EXT_RE = /\.(es|esm|esm-browser|esm-bundler|es6|module)\.js$/;
|
|
8
8
|
const ESM_FOLDER_RE = /\/esm\/(.*\.js)$/;
|
|
@@ -4,7 +4,7 @@ var pathe = require('pathe');
|
|
|
4
4
|
var createDebug = require('debug');
|
|
5
5
|
var fs = require('fs');
|
|
6
6
|
var mlly = require('mlly');
|
|
7
|
-
var utils = require('./utils-
|
|
7
|
+
var utils = require('./utils-c2e3d5fd.js');
|
|
8
8
|
|
|
9
9
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
10
10
|
|
package/dist/server.cjs
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var server = require('./server-
|
|
5
|
+
var server = require('./server-f6511dc4.js');
|
|
6
6
|
require('pathe');
|
|
7
7
|
require('debug');
|
|
8
8
|
require('fs');
|
|
9
9
|
require('mlly');
|
|
10
|
-
require('./utils-
|
|
10
|
+
require('./utils-c2e3d5fd.js');
|
|
11
11
|
require('url');
|
|
12
12
|
|
|
13
13
|
|
package/dist/server.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { V as ViteNodeServer, g as guessCJSversion, s as shouldExternalize } from './server-
|
|
1
|
+
export { V as ViteNodeServer, g as guessCJSversion, s as shouldExternalize } from './server-013a4491.js';
|
|
2
2
|
import 'pathe';
|
|
3
3
|
import 'debug';
|
|
4
4
|
import 'fs';
|
|
5
5
|
import 'mlly';
|
|
6
|
-
import './utils-
|
|
6
|
+
import './utils-b4f03380.js';
|
|
7
7
|
import 'url';
|
|
@@ -5,6 +5,9 @@ const isWindows = process.platform === "win32";
|
|
|
5
5
|
function slash(str) {
|
|
6
6
|
return str.replace(/\\/g, "/");
|
|
7
7
|
}
|
|
8
|
+
function mergeSlashes(str) {
|
|
9
|
+
return str.replace(/\/\//g, "/");
|
|
10
|
+
}
|
|
8
11
|
function normalizeRequestId(id, base) {
|
|
9
12
|
if (base && id.startsWith(base))
|
|
10
13
|
id = `/${id.slice(base.length)}`;
|
|
@@ -36,4 +39,4 @@ async function withInlineSourcemap(result) {
|
|
|
36
39
|
return result;
|
|
37
40
|
}
|
|
38
41
|
|
|
39
|
-
export { normalizeRequestId as a, isWindows as b, isPrimitive as i, normalizeModuleId as n, slash as s, toFilePath as t, withInlineSourcemap as w };
|
|
42
|
+
export { normalizeRequestId as a, isWindows as b, isPrimitive as i, mergeSlashes as m, normalizeModuleId as n, slash as s, toFilePath as t, withInlineSourcemap as w };
|
|
@@ -7,6 +7,9 @@ const isWindows = process.platform === "win32";
|
|
|
7
7
|
function slash(str) {
|
|
8
8
|
return str.replace(/\\/g, "/");
|
|
9
9
|
}
|
|
10
|
+
function mergeSlashes(str) {
|
|
11
|
+
return str.replace(/\/\//g, "/");
|
|
12
|
+
}
|
|
10
13
|
function normalizeRequestId(id, base) {
|
|
11
14
|
if (base && id.startsWith(base))
|
|
12
15
|
id = `/${id.slice(base.length)}`;
|
|
@@ -40,6 +43,7 @@ async function withInlineSourcemap(result) {
|
|
|
40
43
|
|
|
41
44
|
exports.isPrimitive = isPrimitive;
|
|
42
45
|
exports.isWindows = isWindows;
|
|
46
|
+
exports.mergeSlashes = mergeSlashes;
|
|
43
47
|
exports.normalizeModuleId = normalizeModuleId;
|
|
44
48
|
exports.normalizeRequestId = normalizeRequestId;
|
|
45
49
|
exports.slash = slash;
|
package/dist/utils.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var utils = require('./utils-
|
|
5
|
+
var utils = require('./utils-c2e3d5fd.js');
|
|
6
6
|
require('url');
|
|
7
7
|
require('pathe');
|
|
8
8
|
|
|
@@ -10,6 +10,7 @@ require('pathe');
|
|
|
10
10
|
|
|
11
11
|
exports.isPrimitive = utils.isPrimitive;
|
|
12
12
|
exports.isWindows = utils.isWindows;
|
|
13
|
+
exports.mergeSlashes = utils.mergeSlashes;
|
|
13
14
|
exports.normalizeModuleId = utils.normalizeModuleId;
|
|
14
15
|
exports.normalizeRequestId = utils.normalizeRequestId;
|
|
15
16
|
exports.slash = utils.slash;
|
package/dist/utils.d.ts
CHANGED
|
@@ -2,10 +2,11 @@ import { TransformResult } from 'vite';
|
|
|
2
2
|
|
|
3
3
|
declare const isWindows: boolean;
|
|
4
4
|
declare function slash(str: string): string;
|
|
5
|
+
declare function mergeSlashes(str: string): string;
|
|
5
6
|
declare function normalizeRequestId(id: string, base?: string): string;
|
|
6
7
|
declare function normalizeModuleId(id: string): string;
|
|
7
8
|
declare function isPrimitive(v: any): boolean;
|
|
8
9
|
declare function toFilePath(id: string, root: string): string;
|
|
9
10
|
declare function withInlineSourcemap(result: TransformResult): Promise<TransformResult>;
|
|
10
11
|
|
|
11
|
-
export { isPrimitive, isWindows, normalizeModuleId, normalizeRequestId, slash, toFilePath, withInlineSourcemap };
|
|
12
|
+
export { isPrimitive, isWindows, mergeSlashes, normalizeModuleId, normalizeRequestId, slash, toFilePath, withInlineSourcemap };
|
package/dist/utils.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { i as isPrimitive, b as isWindows, n as normalizeModuleId, a as normalizeRequestId, s as slash, t as toFilePath, w as withInlineSourcemap } from './utils-
|
|
1
|
+
export { i as isPrimitive, b as isWindows, m as mergeSlashes, n as normalizeModuleId, a as normalizeRequestId, s as slash, t as toFilePath, w as withInlineSourcemap } from './utils-b4f03380.js';
|
|
2
2
|
import 'url';
|
|
3
3
|
import 'pathe';
|
package/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DepsHandlingOptions, FetchFunction, FetchResult, ModuleCache, RawSourceMap, ResolveIdFunction, StartOfSourceMap, ViteNodeResolveId, ViteNodeRunnerOptions, ViteNodeServerOptions } from './types.js';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-node",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.12.
|
|
4
|
+
"version": "0.12.8",
|
|
5
5
|
"description": "Vite as Node.js runtime",
|
|
6
6
|
"homepage": "https://github.com/vitest-dev/vitest/blob/main/packages/vite-node#readme",
|
|
7
7
|
"bugs": {
|
|
@@ -57,16 +57,16 @@
|
|
|
57
57
|
}
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
|
+
"debug": "^4.3.4",
|
|
60
61
|
"kolorist": "^1.5.1",
|
|
61
62
|
"mlly": "^0.5.2",
|
|
62
63
|
"pathe": "^0.2.0",
|
|
63
|
-
"debug": "^4.3.4",
|
|
64
64
|
"vite": "^2.9.8"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
67
|
"@types/debug": "^4.1.7",
|
|
68
68
|
"cac": "^6.7.12",
|
|
69
|
-
"rollup": "^2.
|
|
69
|
+
"rollup": "^2.73.0"
|
|
70
70
|
},
|
|
71
71
|
"engines": {
|
|
72
72
|
"node": ">=v14.16.0"
|
package/server.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ViteDevServer, TransformResult } from 'vite';
|
|
2
|
+
import { DepsHandlingOptions, ViteNodeServerOptions, FetchResult, ViteNodeResolveId } from './types.js';
|
|
3
|
+
|
|
4
|
+
declare function guessCJSversion(id: string): string | undefined;
|
|
5
|
+
declare function shouldExternalize(id: string, options?: DepsHandlingOptions, cache?: Map<string, Promise<string | false>>): Promise<string | false>;
|
|
6
|
+
|
|
7
|
+
declare class ViteNodeServer {
|
|
8
|
+
server: ViteDevServer;
|
|
9
|
+
options: ViteNodeServerOptions;
|
|
10
|
+
private fetchPromiseMap;
|
|
11
|
+
private transformPromiseMap;
|
|
12
|
+
fetchCache: Map<string, {
|
|
13
|
+
timestamp: number;
|
|
14
|
+
result: FetchResult;
|
|
15
|
+
}>;
|
|
16
|
+
constructor(server: ViteDevServer, options?: ViteNodeServerOptions);
|
|
17
|
+
shouldExternalize(id: string): Promise<string | false>;
|
|
18
|
+
resolveId(id: string, importer?: string): Promise<ViteNodeResolveId | null>;
|
|
19
|
+
fetchModule(id: string): Promise<FetchResult>;
|
|
20
|
+
transformRequest(id: string): Promise<TransformResult | null | undefined>;
|
|
21
|
+
getTransformMode(id: string): "web" | "ssr";
|
|
22
|
+
private _fetchModule;
|
|
23
|
+
private _transformRequest;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export { ViteNodeServer, guessCJSversion, shouldExternalize };
|
package/types.d.ts
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
interface DepsHandlingOptions {
|
|
2
|
+
external?: (string | RegExp)[];
|
|
3
|
+
inline?: (string | RegExp)[];
|
|
4
|
+
/**
|
|
5
|
+
* Try to guess the CJS version of a package when it's invalid ESM
|
|
6
|
+
* @default true
|
|
7
|
+
*/
|
|
8
|
+
fallbackCJS?: boolean;
|
|
9
|
+
}
|
|
10
|
+
interface StartOfSourceMap {
|
|
11
|
+
file?: string;
|
|
12
|
+
sourceRoot?: string;
|
|
13
|
+
}
|
|
14
|
+
interface RawSourceMap extends StartOfSourceMap {
|
|
15
|
+
version: string;
|
|
16
|
+
sources: string[];
|
|
17
|
+
names: string[];
|
|
18
|
+
sourcesContent?: string[];
|
|
19
|
+
mappings: string;
|
|
20
|
+
}
|
|
21
|
+
interface FetchResult {
|
|
22
|
+
code?: string;
|
|
23
|
+
externalize?: string;
|
|
24
|
+
map?: RawSourceMap;
|
|
25
|
+
}
|
|
26
|
+
declare type FetchFunction = (id: string) => Promise<FetchResult>;
|
|
27
|
+
declare type ResolveIdFunction = (id: string, importer?: string) => Promise<ViteNodeResolveId | null>;
|
|
28
|
+
interface ModuleCache {
|
|
29
|
+
promise?: Promise<any>;
|
|
30
|
+
exports?: any;
|
|
31
|
+
code?: string;
|
|
32
|
+
}
|
|
33
|
+
interface ViteNodeRunnerOptions {
|
|
34
|
+
fetchModule: FetchFunction;
|
|
35
|
+
resolveId: ResolveIdFunction;
|
|
36
|
+
root: string;
|
|
37
|
+
base?: string;
|
|
38
|
+
moduleCache?: Map<string, ModuleCache>;
|
|
39
|
+
interopDefault?: boolean;
|
|
40
|
+
requestStubs?: Record<string, any>;
|
|
41
|
+
}
|
|
42
|
+
interface ViteNodeResolveId {
|
|
43
|
+
external?: boolean | 'absolute' | 'relative';
|
|
44
|
+
id: string;
|
|
45
|
+
meta?: Record<string, any> | null;
|
|
46
|
+
moduleSideEffects?: boolean | 'no-treeshake' | null;
|
|
47
|
+
syntheticNamedExports?: boolean | string | null;
|
|
48
|
+
}
|
|
49
|
+
interface ViteNodeServerOptions {
|
|
50
|
+
/**
|
|
51
|
+
* Inject inline sourcemap to modules
|
|
52
|
+
* @default 'inline'
|
|
53
|
+
*/
|
|
54
|
+
sourcemap?: 'inline' | boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Deps handling
|
|
57
|
+
*/
|
|
58
|
+
deps?: DepsHandlingOptions;
|
|
59
|
+
/**
|
|
60
|
+
* Transform method for modules
|
|
61
|
+
*/
|
|
62
|
+
transformMode?: {
|
|
63
|
+
ssr?: RegExp[];
|
|
64
|
+
web?: RegExp[];
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export { DepsHandlingOptions, FetchFunction, FetchResult, ModuleCache, RawSourceMap, ResolveIdFunction, StartOfSourceMap, ViteNodeResolveId, ViteNodeRunnerOptions, ViteNodeServerOptions };
|
package/utils.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { TransformResult } from 'vite';
|
|
2
|
+
|
|
3
|
+
declare const isWindows: boolean;
|
|
4
|
+
declare function slash(str: string): string;
|
|
5
|
+
declare function normalizeId(id: string, base?: string): string;
|
|
6
|
+
declare function isPrimitive(v: any): boolean;
|
|
7
|
+
declare function toFilePath(id: string, root: string): string;
|
|
8
|
+
declare function withInlineSourcemap(result: TransformResult): Promise<TransformResult>;
|
|
9
|
+
|
|
10
|
+
export { isPrimitive, isWindows, normalizeId, slash, toFilePath, withInlineSourcemap };
|