vite-node 0.24.1 → 0.24.2
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 +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/server.cjs +72 -1
- package/dist/server.mjs +74 -3
- package/package.json +1 -1
- package/cli.d.ts +0 -8
- package/client.d.ts +0 -37
- package/dist/chunk-debug.cjs +0 -77
- package/dist/chunk-debug.mjs +0 -75
- package/index.d.ts +0 -1
- package/server.d.ts +0 -26
- package/types.d.ts +0 -68
- package/utils.d.ts +0 -10
package/dist/cli.cjs
CHANGED
|
@@ -630,7 +630,7 @@ class CAC extends events.EventEmitter {
|
|
|
630
630
|
|
|
631
631
|
const cac = (name = "") => new CAC(name);
|
|
632
632
|
|
|
633
|
-
var version = "0.24.
|
|
633
|
+
var version = "0.24.2";
|
|
634
634
|
|
|
635
635
|
const cli = cac("vite-node");
|
|
636
636
|
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"').option("--options <options>", "Use specified Vite server options").help();
|
package/dist/cli.mjs
CHANGED
|
@@ -628,7 +628,7 @@ class CAC extends EventEmitter {
|
|
|
628
628
|
|
|
629
629
|
const cac = (name = "") => new CAC(name);
|
|
630
630
|
|
|
631
|
-
var version = "0.24.
|
|
631
|
+
var version = "0.24.2";
|
|
632
632
|
|
|
633
633
|
const cli = cac("vite-node");
|
|
634
634
|
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"').option("--options <options>", "Use specified Vite server options").help();
|
package/dist/server.cjs
CHANGED
|
@@ -8,7 +8,9 @@ var createDebug = require('debug');
|
|
|
8
8
|
var fs = require('fs');
|
|
9
9
|
var mlly = require('mlly');
|
|
10
10
|
var utils = require('./utils.cjs');
|
|
11
|
+
var picocolors = require('./chunk-picocolors.cjs');
|
|
11
12
|
require('url');
|
|
13
|
+
require('tty');
|
|
12
14
|
|
|
13
15
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
14
16
|
|
|
@@ -101,6 +103,75 @@ function patchWindowsImportPath(path) {
|
|
|
101
103
|
return path;
|
|
102
104
|
}
|
|
103
105
|
|
|
106
|
+
function hashCode(s) {
|
|
107
|
+
return s.split("").reduce((a, b) => {
|
|
108
|
+
a = (a << 5) - a + b.charCodeAt(0);
|
|
109
|
+
return a & a;
|
|
110
|
+
}, 0);
|
|
111
|
+
}
|
|
112
|
+
class Debugger {
|
|
113
|
+
constructor(root, options) {
|
|
114
|
+
this.options = options;
|
|
115
|
+
this.externalizeMap = /* @__PURE__ */ new Map();
|
|
116
|
+
if (options.dumpModules)
|
|
117
|
+
this.dumpDir = pathe.resolve(root, options.dumpModules === true ? ".vite-node/dump" : options.dumpModules);
|
|
118
|
+
if (this.dumpDir) {
|
|
119
|
+
if (options.loadDumppedModules)
|
|
120
|
+
console.info(picocolors.picocolors.exports.gray(`[vite-node] [debug] load modules from ${this.dumpDir}`));
|
|
121
|
+
else
|
|
122
|
+
console.info(picocolors.picocolors.exports.gray(`[vite-node] [debug] dump modules to ${this.dumpDir}`));
|
|
123
|
+
}
|
|
124
|
+
this.initPromise = this.clearDump();
|
|
125
|
+
}
|
|
126
|
+
async clearDump() {
|
|
127
|
+
if (!this.dumpDir)
|
|
128
|
+
return;
|
|
129
|
+
if (!this.options.loadDumppedModules && fs.existsSync(this.dumpDir))
|
|
130
|
+
await fs.promises.rm(this.dumpDir, { recursive: true, force: true });
|
|
131
|
+
await fs.promises.mkdir(this.dumpDir, { recursive: true });
|
|
132
|
+
}
|
|
133
|
+
encodeId(id) {
|
|
134
|
+
return `${id.replace(/[^\w@_-]/g, "_").replace(/_+/g, "_")}-${hashCode(id)}.js`;
|
|
135
|
+
}
|
|
136
|
+
async recordExternalize(id, path) {
|
|
137
|
+
if (!this.dumpDir)
|
|
138
|
+
return;
|
|
139
|
+
this.externalizeMap.set(id, path);
|
|
140
|
+
await this.writeInfo();
|
|
141
|
+
}
|
|
142
|
+
async dumpFile(id, result) {
|
|
143
|
+
if (!result || !this.dumpDir)
|
|
144
|
+
return;
|
|
145
|
+
await this.initPromise;
|
|
146
|
+
const name = this.encodeId(id);
|
|
147
|
+
return await fs.promises.writeFile(pathe.join(this.dumpDir, name), `// ${id.replace(/\0/g, "\\0")}
|
|
148
|
+
${result.code}`, "utf-8");
|
|
149
|
+
}
|
|
150
|
+
async loadDump(id) {
|
|
151
|
+
if (!this.dumpDir)
|
|
152
|
+
return null;
|
|
153
|
+
await this.initPromise;
|
|
154
|
+
const name = this.encodeId(id);
|
|
155
|
+
const path = pathe.join(this.dumpDir, name);
|
|
156
|
+
if (!fs.existsSync(path))
|
|
157
|
+
return null;
|
|
158
|
+
const code = await fs.promises.readFile(path, "utf-8");
|
|
159
|
+
return {
|
|
160
|
+
code: code.replace(/^\/\/.*?\n/, ""),
|
|
161
|
+
map: void 0
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
async writeInfo() {
|
|
165
|
+
if (!this.dumpDir)
|
|
166
|
+
return;
|
|
167
|
+
const info = JSON.stringify({
|
|
168
|
+
time: new Date().toLocaleString(),
|
|
169
|
+
externalize: Object.fromEntries(this.externalizeMap.entries())
|
|
170
|
+
}, null, 2);
|
|
171
|
+
return fs.promises.writeFile(pathe.join(this.dumpDir, "info.json"), info, "utf-8");
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
104
175
|
const debugRequest = createDebug__default["default"]("vite-node:server:request");
|
|
105
176
|
const RealDate = Date;
|
|
106
177
|
class ViteNodeServer {
|
|
@@ -129,7 +200,7 @@ class ViteNodeServer {
|
|
|
129
200
|
}, options.debug ?? {});
|
|
130
201
|
}
|
|
131
202
|
if (options.debug)
|
|
132
|
-
|
|
203
|
+
this.debugger = new Debugger(server.config.root, options.debug);
|
|
133
204
|
}
|
|
134
205
|
shouldExternalize(id) {
|
|
135
206
|
return shouldExternalize(id, this.options.deps, this.externalizeCache);
|
package/dist/server.mjs
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { performance } from 'perf_hooks';
|
|
2
|
-
import { resolve } from 'pathe';
|
|
2
|
+
import { resolve, join } from 'pathe';
|
|
3
3
|
import createDebug from 'debug';
|
|
4
|
-
import { existsSync } from 'fs';
|
|
4
|
+
import { existsSync, promises } from 'fs';
|
|
5
5
|
import { isNodeBuiltin, isValidNodeImport } from 'mlly';
|
|
6
6
|
import { slash, toArray, toFilePath, withInlineSourcemap } from './utils.mjs';
|
|
7
|
+
import { p as picocolors } from './chunk-picocolors.mjs';
|
|
7
8
|
import 'url';
|
|
9
|
+
import 'tty';
|
|
8
10
|
|
|
9
11
|
const ESM_EXT_RE = /\.(es|esm|esm-browser|esm-bundler|es6|module)\.js$/;
|
|
10
12
|
const ESM_FOLDER_RE = /\/(es|esm)\/(.*\.js)$/;
|
|
@@ -93,6 +95,75 @@ function patchWindowsImportPath(path) {
|
|
|
93
95
|
return path;
|
|
94
96
|
}
|
|
95
97
|
|
|
98
|
+
function hashCode(s) {
|
|
99
|
+
return s.split("").reduce((a, b) => {
|
|
100
|
+
a = (a << 5) - a + b.charCodeAt(0);
|
|
101
|
+
return a & a;
|
|
102
|
+
}, 0);
|
|
103
|
+
}
|
|
104
|
+
class Debugger {
|
|
105
|
+
constructor(root, options) {
|
|
106
|
+
this.options = options;
|
|
107
|
+
this.externalizeMap = /* @__PURE__ */ new Map();
|
|
108
|
+
if (options.dumpModules)
|
|
109
|
+
this.dumpDir = resolve(root, options.dumpModules === true ? ".vite-node/dump" : options.dumpModules);
|
|
110
|
+
if (this.dumpDir) {
|
|
111
|
+
if (options.loadDumppedModules)
|
|
112
|
+
console.info(picocolors.exports.gray(`[vite-node] [debug] load modules from ${this.dumpDir}`));
|
|
113
|
+
else
|
|
114
|
+
console.info(picocolors.exports.gray(`[vite-node] [debug] dump modules to ${this.dumpDir}`));
|
|
115
|
+
}
|
|
116
|
+
this.initPromise = this.clearDump();
|
|
117
|
+
}
|
|
118
|
+
async clearDump() {
|
|
119
|
+
if (!this.dumpDir)
|
|
120
|
+
return;
|
|
121
|
+
if (!this.options.loadDumppedModules && existsSync(this.dumpDir))
|
|
122
|
+
await promises.rm(this.dumpDir, { recursive: true, force: true });
|
|
123
|
+
await promises.mkdir(this.dumpDir, { recursive: true });
|
|
124
|
+
}
|
|
125
|
+
encodeId(id) {
|
|
126
|
+
return `${id.replace(/[^\w@_-]/g, "_").replace(/_+/g, "_")}-${hashCode(id)}.js`;
|
|
127
|
+
}
|
|
128
|
+
async recordExternalize(id, path) {
|
|
129
|
+
if (!this.dumpDir)
|
|
130
|
+
return;
|
|
131
|
+
this.externalizeMap.set(id, path);
|
|
132
|
+
await this.writeInfo();
|
|
133
|
+
}
|
|
134
|
+
async dumpFile(id, result) {
|
|
135
|
+
if (!result || !this.dumpDir)
|
|
136
|
+
return;
|
|
137
|
+
await this.initPromise;
|
|
138
|
+
const name = this.encodeId(id);
|
|
139
|
+
return await promises.writeFile(join(this.dumpDir, name), `// ${id.replace(/\0/g, "\\0")}
|
|
140
|
+
${result.code}`, "utf-8");
|
|
141
|
+
}
|
|
142
|
+
async loadDump(id) {
|
|
143
|
+
if (!this.dumpDir)
|
|
144
|
+
return null;
|
|
145
|
+
await this.initPromise;
|
|
146
|
+
const name = this.encodeId(id);
|
|
147
|
+
const path = join(this.dumpDir, name);
|
|
148
|
+
if (!existsSync(path))
|
|
149
|
+
return null;
|
|
150
|
+
const code = await promises.readFile(path, "utf-8");
|
|
151
|
+
return {
|
|
152
|
+
code: code.replace(/^\/\/.*?\n/, ""),
|
|
153
|
+
map: void 0
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
async writeInfo() {
|
|
157
|
+
if (!this.dumpDir)
|
|
158
|
+
return;
|
|
159
|
+
const info = JSON.stringify({
|
|
160
|
+
time: new Date().toLocaleString(),
|
|
161
|
+
externalize: Object.fromEntries(this.externalizeMap.entries())
|
|
162
|
+
}, null, 2);
|
|
163
|
+
return promises.writeFile(join(this.dumpDir, "info.json"), info, "utf-8");
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
96
167
|
const debugRequest = createDebug("vite-node:server:request");
|
|
97
168
|
const RealDate = Date;
|
|
98
169
|
class ViteNodeServer {
|
|
@@ -121,7 +192,7 @@ class ViteNodeServer {
|
|
|
121
192
|
}, options.debug ?? {});
|
|
122
193
|
}
|
|
123
194
|
if (options.debug)
|
|
124
|
-
|
|
195
|
+
this.debugger = new Debugger(server.config.root, options.debug);
|
|
125
196
|
}
|
|
126
197
|
shouldExternalize(id) {
|
|
127
198
|
return shouldExternalize(id, this.options.deps, this.externalizeCache);
|
package/package.json
CHANGED
package/cli.d.ts
DELETED
package/client.d.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
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/chunk-debug.cjs
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var fs = require('fs');
|
|
4
|
-
var pathe = require('pathe');
|
|
5
|
-
var picocolors = require('./chunk-picocolors.cjs');
|
|
6
|
-
require('tty');
|
|
7
|
-
|
|
8
|
-
function hashCode(s) {
|
|
9
|
-
return s.split("").reduce((a, b) => {
|
|
10
|
-
a = (a << 5) - a + b.charCodeAt(0);
|
|
11
|
-
return a & a;
|
|
12
|
-
}, 0);
|
|
13
|
-
}
|
|
14
|
-
class Debugger {
|
|
15
|
-
constructor(root, options) {
|
|
16
|
-
this.options = options;
|
|
17
|
-
this.externalizeMap = /* @__PURE__ */ new Map();
|
|
18
|
-
if (options.dumpModules)
|
|
19
|
-
this.dumpDir = pathe.resolve(root, options.dumpModules === true ? ".vite-node/dump" : options.dumpModules);
|
|
20
|
-
if (this.dumpDir) {
|
|
21
|
-
if (options.loadDumppedModules)
|
|
22
|
-
console.info(picocolors.picocolors.exports.gray(`[vite-node] [debug] load modules from ${this.dumpDir}`));
|
|
23
|
-
else
|
|
24
|
-
console.info(picocolors.picocolors.exports.gray(`[vite-node] [debug] dump modules to ${this.dumpDir}`));
|
|
25
|
-
}
|
|
26
|
-
this.initPromise = this.clearDump();
|
|
27
|
-
}
|
|
28
|
-
async clearDump() {
|
|
29
|
-
if (!this.dumpDir)
|
|
30
|
-
return;
|
|
31
|
-
if (!this.options.loadDumppedModules && fs.existsSync(this.dumpDir))
|
|
32
|
-
await fs.promises.rm(this.dumpDir, { recursive: true, force: true });
|
|
33
|
-
await fs.promises.mkdir(this.dumpDir, { recursive: true });
|
|
34
|
-
}
|
|
35
|
-
encodeId(id) {
|
|
36
|
-
return `${id.replace(/[^\w@_-]/g, "_").replace(/_+/g, "_")}-${hashCode(id)}.js`;
|
|
37
|
-
}
|
|
38
|
-
async recordExternalize(id, path) {
|
|
39
|
-
if (!this.dumpDir)
|
|
40
|
-
return;
|
|
41
|
-
this.externalizeMap.set(id, path);
|
|
42
|
-
await this.writeInfo();
|
|
43
|
-
}
|
|
44
|
-
async dumpFile(id, result) {
|
|
45
|
-
if (!result || !this.dumpDir)
|
|
46
|
-
return;
|
|
47
|
-
await this.initPromise;
|
|
48
|
-
const name = this.encodeId(id);
|
|
49
|
-
return await fs.promises.writeFile(pathe.join(this.dumpDir, name), `// ${id.replace(/\0/g, "\\0")}
|
|
50
|
-
${result.code}`, "utf-8");
|
|
51
|
-
}
|
|
52
|
-
async loadDump(id) {
|
|
53
|
-
if (!this.dumpDir)
|
|
54
|
-
return null;
|
|
55
|
-
await this.initPromise;
|
|
56
|
-
const name = this.encodeId(id);
|
|
57
|
-
const path = pathe.join(this.dumpDir, name);
|
|
58
|
-
if (!fs.existsSync(path))
|
|
59
|
-
return null;
|
|
60
|
-
const code = await fs.promises.readFile(path, "utf-8");
|
|
61
|
-
return {
|
|
62
|
-
code: code.replace(/^\/\/.*?\n/, ""),
|
|
63
|
-
map: void 0
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
async writeInfo() {
|
|
67
|
-
if (!this.dumpDir)
|
|
68
|
-
return;
|
|
69
|
-
const info = JSON.stringify({
|
|
70
|
-
time: new Date().toLocaleString(),
|
|
71
|
-
externalize: Object.fromEntries(this.externalizeMap.entries())
|
|
72
|
-
}, null, 2);
|
|
73
|
-
return fs.promises.writeFile(pathe.join(this.dumpDir, "info.json"), info, "utf-8");
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
exports.Debugger = Debugger;
|
package/dist/chunk-debug.mjs
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { existsSync, promises } from 'fs';
|
|
2
|
-
import { resolve, join } from 'pathe';
|
|
3
|
-
import { p as picocolors } from './chunk-picocolors.mjs';
|
|
4
|
-
import 'tty';
|
|
5
|
-
|
|
6
|
-
function hashCode(s) {
|
|
7
|
-
return s.split("").reduce((a, b) => {
|
|
8
|
-
a = (a << 5) - a + b.charCodeAt(0);
|
|
9
|
-
return a & a;
|
|
10
|
-
}, 0);
|
|
11
|
-
}
|
|
12
|
-
class Debugger {
|
|
13
|
-
constructor(root, options) {
|
|
14
|
-
this.options = options;
|
|
15
|
-
this.externalizeMap = /* @__PURE__ */ new Map();
|
|
16
|
-
if (options.dumpModules)
|
|
17
|
-
this.dumpDir = resolve(root, options.dumpModules === true ? ".vite-node/dump" : options.dumpModules);
|
|
18
|
-
if (this.dumpDir) {
|
|
19
|
-
if (options.loadDumppedModules)
|
|
20
|
-
console.info(picocolors.exports.gray(`[vite-node] [debug] load modules from ${this.dumpDir}`));
|
|
21
|
-
else
|
|
22
|
-
console.info(picocolors.exports.gray(`[vite-node] [debug] dump modules to ${this.dumpDir}`));
|
|
23
|
-
}
|
|
24
|
-
this.initPromise = this.clearDump();
|
|
25
|
-
}
|
|
26
|
-
async clearDump() {
|
|
27
|
-
if (!this.dumpDir)
|
|
28
|
-
return;
|
|
29
|
-
if (!this.options.loadDumppedModules && existsSync(this.dumpDir))
|
|
30
|
-
await promises.rm(this.dumpDir, { recursive: true, force: true });
|
|
31
|
-
await promises.mkdir(this.dumpDir, { recursive: true });
|
|
32
|
-
}
|
|
33
|
-
encodeId(id) {
|
|
34
|
-
return `${id.replace(/[^\w@_-]/g, "_").replace(/_+/g, "_")}-${hashCode(id)}.js`;
|
|
35
|
-
}
|
|
36
|
-
async recordExternalize(id, path) {
|
|
37
|
-
if (!this.dumpDir)
|
|
38
|
-
return;
|
|
39
|
-
this.externalizeMap.set(id, path);
|
|
40
|
-
await this.writeInfo();
|
|
41
|
-
}
|
|
42
|
-
async dumpFile(id, result) {
|
|
43
|
-
if (!result || !this.dumpDir)
|
|
44
|
-
return;
|
|
45
|
-
await this.initPromise;
|
|
46
|
-
const name = this.encodeId(id);
|
|
47
|
-
return await promises.writeFile(join(this.dumpDir, name), `// ${id.replace(/\0/g, "\\0")}
|
|
48
|
-
${result.code}`, "utf-8");
|
|
49
|
-
}
|
|
50
|
-
async loadDump(id) {
|
|
51
|
-
if (!this.dumpDir)
|
|
52
|
-
return null;
|
|
53
|
-
await this.initPromise;
|
|
54
|
-
const name = this.encodeId(id);
|
|
55
|
-
const path = join(this.dumpDir, name);
|
|
56
|
-
if (!existsSync(path))
|
|
57
|
-
return null;
|
|
58
|
-
const code = await promises.readFile(path, "utf-8");
|
|
59
|
-
return {
|
|
60
|
-
code: code.replace(/^\/\/.*?\n/, ""),
|
|
61
|
-
map: void 0
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
async writeInfo() {
|
|
65
|
-
if (!this.dumpDir)
|
|
66
|
-
return;
|
|
67
|
-
const info = JSON.stringify({
|
|
68
|
-
time: new Date().toLocaleString(),
|
|
69
|
-
externalize: Object.fromEntries(this.externalizeMap.entries())
|
|
70
|
-
}, null, 2);
|
|
71
|
-
return promises.writeFile(join(this.dumpDir, "info.json"), info, "utf-8");
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export { Debugger };
|
package/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { DepsHandlingOptions, FetchFunction, FetchResult, ModuleCache, RawSourceMap, ResolveIdFunction, StartOfSourceMap, ViteNodeResolveId, ViteNodeRunnerOptions, ViteNodeServerOptions } from './types.js';
|
package/server.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
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 };
|