vite-node 0.12.0 → 0.12.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/cli.d.ts +8 -0
- package/client.d.ts +37 -0
- package/dist/cli.cjs +2 -2
- package/dist/cli.js +2 -2
- package/dist/{client-06b06913.js → client-def5e426.js} +1 -6
- package/dist/{client-da5aac97.js → client-e36231b1.js} +1 -6
- package/dist/client.cjs +1 -1
- package/dist/client.js +1 -1
- package/index.d.ts +1 -0
- package/package.json +1 -1
- 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
|
@@ -4,7 +4,7 @@ var events = require('events');
|
|
|
4
4
|
var kolorist = require('kolorist');
|
|
5
5
|
var vite = require('vite');
|
|
6
6
|
var server = require('./server-4791181c.js');
|
|
7
|
-
var client = require('./client-
|
|
7
|
+
var client = require('./client-def5e426.js');
|
|
8
8
|
require('pathe');
|
|
9
9
|
require('fs');
|
|
10
10
|
require('mlly');
|
|
@@ -626,7 +626,7 @@ class CAC extends events.EventEmitter {
|
|
|
626
626
|
|
|
627
627
|
const cac = (name = "") => new CAC(name);
|
|
628
628
|
|
|
629
|
-
var version = "0.12.
|
|
629
|
+
var version = "0.12.1";
|
|
630
630
|
|
|
631
631
|
const cli = cac("vite-node");
|
|
632
632
|
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();
|
package/dist/cli.js
CHANGED
|
@@ -2,7 +2,7 @@ import { EventEmitter } from 'events';
|
|
|
2
2
|
import { red, dim } from 'kolorist';
|
|
3
3
|
import { createServer } from 'vite';
|
|
4
4
|
import { V as ViteNodeServer } from './server-d9fc65e0.js';
|
|
5
|
-
import { V as ViteNodeRunner } from './client-
|
|
5
|
+
import { V as ViteNodeRunner } from './client-e36231b1.js';
|
|
6
6
|
import 'pathe';
|
|
7
7
|
import 'fs';
|
|
8
8
|
import 'mlly';
|
|
@@ -624,7 +624,7 @@ class CAC extends EventEmitter {
|
|
|
624
624
|
|
|
625
625
|
const cac = (name = "") => new CAC(name);
|
|
626
626
|
|
|
627
|
-
var version = "0.12.
|
|
627
|
+
var version = "0.12.1";
|
|
628
628
|
|
|
629
629
|
const cli = cac("vite-node");
|
|
630
630
|
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();
|
|
@@ -160,7 +160,6 @@ ${getStack()}`), 2e3);
|
|
|
160
160
|
return exports.default;
|
|
161
161
|
}
|
|
162
162
|
};
|
|
163
|
-
let require;
|
|
164
163
|
const context = this.prepareContext({
|
|
165
164
|
__vite_ssr_import__: request,
|
|
166
165
|
__vite_ssr_dynamic_import__: request,
|
|
@@ -168,11 +167,7 @@ ${getStack()}`), 2e3);
|
|
|
168
167
|
__vite_ssr_exportAll__: (obj) => exportAll(exports, obj),
|
|
169
168
|
__vite_ssr_import_meta__: { url: url$1 },
|
|
170
169
|
__vitest_resolve_id__: resolveId,
|
|
171
|
-
require: (
|
|
172
|
-
if (!require)
|
|
173
|
-
require = module$1.createRequire(url$1);
|
|
174
|
-
return require(path);
|
|
175
|
-
},
|
|
170
|
+
require: module$1.createRequire(url$1),
|
|
176
171
|
exports,
|
|
177
172
|
module: moduleProxy,
|
|
178
173
|
__filename,
|
|
@@ -136,7 +136,6 @@ ${getStack()}`), 2e3);
|
|
|
136
136
|
return exports.default;
|
|
137
137
|
}
|
|
138
138
|
};
|
|
139
|
-
let require;
|
|
140
139
|
const context = this.prepareContext({
|
|
141
140
|
__vite_ssr_import__: request,
|
|
142
141
|
__vite_ssr_dynamic_import__: request,
|
|
@@ -144,11 +143,7 @@ ${getStack()}`), 2e3);
|
|
|
144
143
|
__vite_ssr_exportAll__: (obj) => exportAll(exports, obj),
|
|
145
144
|
__vite_ssr_import_meta__: { url },
|
|
146
145
|
__vitest_resolve_id__: resolveId,
|
|
147
|
-
require: (
|
|
148
|
-
if (!require)
|
|
149
|
-
require = createRequire(url);
|
|
150
|
-
return require(path);
|
|
151
|
-
},
|
|
146
|
+
require: createRequire(url),
|
|
152
147
|
exports,
|
|
153
148
|
module: moduleProxy,
|
|
154
149
|
__filename,
|
package/dist/client.cjs
CHANGED
package/dist/client.js
CHANGED
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
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 };
|