vite-node 0.2.5 → 0.3.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/client.d.ts CHANGED
@@ -1,9 +1,20 @@
1
+ interface StartOfSourceMap {
2
+ file?: string;
3
+ sourceRoot?: string;
4
+ }
5
+ interface RawSourceMap extends StartOfSourceMap {
6
+ version: string;
7
+ sources: string[];
8
+ names: string[];
9
+ sourcesContent?: string[];
10
+ mappings: string;
11
+ }
1
12
  interface FetchResult {
2
13
  code?: string;
3
14
  externalize?: string;
15
+ map?: RawSourceMap;
4
16
  }
5
17
  declare type FetchFunction = (id: string) => Promise<FetchResult>;
6
- declare type ResolveIdFunction = (id: string, importer?: string) => Promise<ViteNodeResolveId | null>;
7
18
  interface ModuleCache {
8
19
  promise?: Promise<any>;
9
20
  exports?: any;
@@ -11,20 +22,12 @@ interface ModuleCache {
11
22
  }
12
23
  interface ViteNodeRunnerOptions {
13
24
  fetchModule: FetchFunction;
14
- resolveId: ResolveIdFunction;
15
25
  root: string;
16
26
  base?: string;
17
27
  moduleCache?: Map<string, ModuleCache>;
18
28
  interopDefault?: boolean;
19
29
  requestStubs?: Record<string, any>;
20
30
  }
21
- interface ViteNodeResolveId {
22
- external?: boolean | 'absolute' | 'relative';
23
- id: string;
24
- meta?: Record<string, any> | null;
25
- moduleSideEffects?: boolean | 'no-treeshake' | null;
26
- syntheticNamedExports?: boolean | string | null;
27
- }
28
31
 
29
32
  declare const DEFAULT_REQUEST_STUBS: {
30
33
  '/@vite/client': {
package/dist/cli.cjs CHANGED
@@ -68,15 +68,13 @@ async function withInlineSourcemap(result) {
68
68
  const ESM_EXT_RE = /\.(es|esm|esm-browser|esm-bundler|es6|module)\.js$/;
69
69
  const ESM_FOLDER_RE = /\/esm\/(.*\.js)$/;
70
70
  const defaultInline = [
71
- /\/vitest\/dist\//,
72
- /vitest-virtual-\w+\/dist/,
73
71
  /virtual:/,
74
72
  /\.ts$/,
75
73
  ESM_EXT_RE,
76
74
  ESM_FOLDER_RE
77
75
  ];
78
76
  const depsExternal = [
79
- /\.cjs.js$/,
77
+ /\.cjs\.js$/,
80
78
  /\.mjs$/
81
79
  ];
82
80
  function guessCJSversion(id) {
@@ -148,6 +146,25 @@ function patchWindowsImportPath(path) {
148
146
  return path;
149
147
  }
150
148
 
149
+ var __defProp = Object.defineProperty;
150
+ var __defProps = Object.defineProperties;
151
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
152
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
153
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
154
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
155
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
156
+ var __spreadValues = (a, b) => {
157
+ for (var prop in b || (b = {}))
158
+ if (__hasOwnProp.call(b, prop))
159
+ __defNormalProp(a, prop, b[prop]);
160
+ if (__getOwnPropSymbols)
161
+ for (var prop of __getOwnPropSymbols(b)) {
162
+ if (__propIsEnum.call(b, prop))
163
+ __defNormalProp(a, prop, b[prop]);
164
+ }
165
+ return a;
166
+ };
167
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
151
168
  class ViteNodeServer {
152
169
  constructor(server, options = {}) {
153
170
  this.server = server;
@@ -164,7 +181,9 @@ class ViteNodeServer {
164
181
  }
165
182
  async fetchModule(id) {
166
183
  if (!this.fetchPromiseMap.has(id)) {
167
- this.fetchPromiseMap.set(id, this._fetchModule(id).finally(() => {
184
+ this.fetchPromiseMap.set(id, this._fetchModule(id).then((r) => {
185
+ return this.options.sourcemap !== true ? __spreadProps(__spreadValues({}, r), { map: void 0 }) : r;
186
+ }).finally(() => {
168
187
  this.fetchPromiseMap.delete(id);
169
188
  }));
170
189
  }
@@ -190,25 +209,24 @@ class ViteNodeServer {
190
209
  return "web";
191
210
  }
192
211
  async _fetchModule(id) {
193
- var _a;
194
212
  let result;
195
- const timestamp = (_a = this.server.moduleGraph.getModuleById(id)) == null ? void 0 : _a.lastHMRTimestamp;
196
- const cache = this.fetchCache.get(id);
213
+ const filePath = toFilePath(id, this.server.config.root);
214
+ const module = this.server.moduleGraph.getModuleById(id);
215
+ const timestamp = (module == null ? void 0 : module.lastHMRTimestamp) || Date.now();
216
+ const cache = this.fetchCache.get(filePath);
197
217
  if (timestamp && cache && cache.timestamp >= timestamp)
198
218
  return cache.result;
199
- const externalize = await this.shouldExternalize(toFilePath(id, this.server.config.root));
219
+ const externalize = await this.shouldExternalize(filePath);
200
220
  if (externalize) {
201
221
  result = { externalize };
202
222
  } else {
203
223
  const r = await this._transformRequest(id);
204
- result = { code: r == null ? void 0 : r.code };
205
- }
206
- if (timestamp) {
207
- this.fetchCache.set(id, {
208
- timestamp,
209
- result
210
- });
224
+ result = { code: r == null ? void 0 : r.code, map: r == null ? void 0 : r.map };
211
225
  }
226
+ this.fetchCache.set(filePath, {
227
+ timestamp,
228
+ result
229
+ });
212
230
  return result;
213
231
  }
214
232
  async _transformRequest(id) {
@@ -220,7 +238,8 @@ class ViteNodeServer {
220
238
  } else {
221
239
  result = await this.server.transformRequest(id, { ssr: true });
222
240
  }
223
- if (this.options.sourcemap !== false && result && !id.includes("node_modules"))
241
+ const sourcemap = this.options.sourcemap ?? "inline";
242
+ if (sourcemap === "inline" && result && !id.includes("node_modules"))
224
243
  withInlineSourcemap(result);
225
244
  return result;
226
245
  }
@@ -437,9 +456,6 @@ async function run(options = {}) {
437
456
  base: server.config.base,
438
457
  fetchModule(id) {
439
458
  return node.fetchModule(id);
440
- },
441
- resolveId(id, importer) {
442
- return node.resolveId(id, importer);
443
459
  }
444
460
  });
445
461
  for (const file of files)
package/dist/cli.js CHANGED
@@ -43,15 +43,13 @@ async function withInlineSourcemap(result) {
43
43
  const ESM_EXT_RE = /\.(es|esm|esm-browser|esm-bundler|es6|module)\.js$/;
44
44
  const ESM_FOLDER_RE = /\/esm\/(.*\.js)$/;
45
45
  const defaultInline = [
46
- /\/vitest\/dist\//,
47
- /vitest-virtual-\w+\/dist/,
48
46
  /virtual:/,
49
47
  /\.ts$/,
50
48
  ESM_EXT_RE,
51
49
  ESM_FOLDER_RE
52
50
  ];
53
51
  const depsExternal = [
54
- /\.cjs.js$/,
52
+ /\.cjs\.js$/,
55
53
  /\.mjs$/
56
54
  ];
57
55
  function guessCJSversion(id) {
@@ -123,6 +121,25 @@ function patchWindowsImportPath(path) {
123
121
  return path;
124
122
  }
125
123
 
124
+ var __defProp = Object.defineProperty;
125
+ var __defProps = Object.defineProperties;
126
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
127
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
128
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
129
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
130
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
131
+ var __spreadValues = (a, b) => {
132
+ for (var prop in b || (b = {}))
133
+ if (__hasOwnProp.call(b, prop))
134
+ __defNormalProp(a, prop, b[prop]);
135
+ if (__getOwnPropSymbols)
136
+ for (var prop of __getOwnPropSymbols(b)) {
137
+ if (__propIsEnum.call(b, prop))
138
+ __defNormalProp(a, prop, b[prop]);
139
+ }
140
+ return a;
141
+ };
142
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
126
143
  class ViteNodeServer {
127
144
  constructor(server, options = {}) {
128
145
  this.server = server;
@@ -139,7 +156,9 @@ class ViteNodeServer {
139
156
  }
140
157
  async fetchModule(id) {
141
158
  if (!this.fetchPromiseMap.has(id)) {
142
- this.fetchPromiseMap.set(id, this._fetchModule(id).finally(() => {
159
+ this.fetchPromiseMap.set(id, this._fetchModule(id).then((r) => {
160
+ return this.options.sourcemap !== true ? __spreadProps(__spreadValues({}, r), { map: void 0 }) : r;
161
+ }).finally(() => {
143
162
  this.fetchPromiseMap.delete(id);
144
163
  }));
145
164
  }
@@ -165,25 +184,24 @@ class ViteNodeServer {
165
184
  return "web";
166
185
  }
167
186
  async _fetchModule(id) {
168
- var _a;
169
187
  let result;
170
- const timestamp = (_a = this.server.moduleGraph.getModuleById(id)) == null ? void 0 : _a.lastHMRTimestamp;
171
- const cache = this.fetchCache.get(id);
188
+ const filePath = toFilePath(id, this.server.config.root);
189
+ const module = this.server.moduleGraph.getModuleById(id);
190
+ const timestamp = (module == null ? void 0 : module.lastHMRTimestamp) || Date.now();
191
+ const cache = this.fetchCache.get(filePath);
172
192
  if (timestamp && cache && cache.timestamp >= timestamp)
173
193
  return cache.result;
174
- const externalize = await this.shouldExternalize(toFilePath(id, this.server.config.root));
194
+ const externalize = await this.shouldExternalize(filePath);
175
195
  if (externalize) {
176
196
  result = { externalize };
177
197
  } else {
178
198
  const r = await this._transformRequest(id);
179
- result = { code: r == null ? void 0 : r.code };
180
- }
181
- if (timestamp) {
182
- this.fetchCache.set(id, {
183
- timestamp,
184
- result
185
- });
199
+ result = { code: r == null ? void 0 : r.code, map: r == null ? void 0 : r.map };
186
200
  }
201
+ this.fetchCache.set(filePath, {
202
+ timestamp,
203
+ result
204
+ });
187
205
  return result;
188
206
  }
189
207
  async _transformRequest(id) {
@@ -195,7 +213,8 @@ class ViteNodeServer {
195
213
  } else {
196
214
  result = await this.server.transformRequest(id, { ssr: true });
197
215
  }
198
- if (this.options.sourcemap !== false && result && !id.includes("node_modules"))
216
+ const sourcemap = this.options.sourcemap ?? "inline";
217
+ if (sourcemap === "inline" && result && !id.includes("node_modules"))
199
218
  withInlineSourcemap(result);
200
219
  return result;
201
220
  }
@@ -412,9 +431,6 @@ async function run(options = {}) {
412
431
  base: server.config.base,
413
432
  fetchModule(id) {
414
433
  return node.fetchModule(id);
415
- },
416
- resolveId(id, importer) {
417
- return node.resolveId(id, importer);
418
434
  }
419
435
  });
420
436
  for (const file of files)
package/dist/server.cjs CHANGED
@@ -34,15 +34,13 @@ async function withInlineSourcemap(result) {
34
34
  const ESM_EXT_RE = /\.(es|esm|esm-browser|esm-bundler|es6|module)\.js$/;
35
35
  const ESM_FOLDER_RE = /\/esm\/(.*\.js)$/;
36
36
  const defaultInline = [
37
- /\/vitest\/dist\//,
38
- /vitest-virtual-\w+\/dist/,
39
37
  /virtual:/,
40
38
  /\.ts$/,
41
39
  ESM_EXT_RE,
42
40
  ESM_FOLDER_RE
43
41
  ];
44
42
  const depsExternal = [
45
- /\.cjs.js$/,
43
+ /\.cjs\.js$/,
46
44
  /\.mjs$/
47
45
  ];
48
46
  function guessCJSversion(id) {
@@ -114,6 +112,25 @@ function patchWindowsImportPath(path) {
114
112
  return path;
115
113
  }
116
114
 
115
+ var __defProp = Object.defineProperty;
116
+ var __defProps = Object.defineProperties;
117
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
118
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
119
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
120
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
121
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
122
+ var __spreadValues = (a, b) => {
123
+ for (var prop in b || (b = {}))
124
+ if (__hasOwnProp.call(b, prop))
125
+ __defNormalProp(a, prop, b[prop]);
126
+ if (__getOwnPropSymbols)
127
+ for (var prop of __getOwnPropSymbols(b)) {
128
+ if (__propIsEnum.call(b, prop))
129
+ __defNormalProp(a, prop, b[prop]);
130
+ }
131
+ return a;
132
+ };
133
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
117
134
  class ViteNodeServer {
118
135
  constructor(server, options = {}) {
119
136
  this.server = server;
@@ -130,7 +147,9 @@ class ViteNodeServer {
130
147
  }
131
148
  async fetchModule(id) {
132
149
  if (!this.fetchPromiseMap.has(id)) {
133
- this.fetchPromiseMap.set(id, this._fetchModule(id).finally(() => {
150
+ this.fetchPromiseMap.set(id, this._fetchModule(id).then((r) => {
151
+ return this.options.sourcemap !== true ? __spreadProps(__spreadValues({}, r), { map: void 0 }) : r;
152
+ }).finally(() => {
134
153
  this.fetchPromiseMap.delete(id);
135
154
  }));
136
155
  }
@@ -156,25 +175,24 @@ class ViteNodeServer {
156
175
  return "web";
157
176
  }
158
177
  async _fetchModule(id) {
159
- var _a;
160
178
  let result;
161
- const timestamp = (_a = this.server.moduleGraph.getModuleById(id)) == null ? void 0 : _a.lastHMRTimestamp;
162
- const cache = this.fetchCache.get(id);
179
+ const filePath = toFilePath(id, this.server.config.root);
180
+ const module = this.server.moduleGraph.getModuleById(id);
181
+ const timestamp = (module == null ? void 0 : module.lastHMRTimestamp) || Date.now();
182
+ const cache = this.fetchCache.get(filePath);
163
183
  if (timestamp && cache && cache.timestamp >= timestamp)
164
184
  return cache.result;
165
- const externalize = await this.shouldExternalize(toFilePath(id, this.server.config.root));
185
+ const externalize = await this.shouldExternalize(filePath);
166
186
  if (externalize) {
167
187
  result = { externalize };
168
188
  } else {
169
189
  const r = await this._transformRequest(id);
170
- result = { code: r == null ? void 0 : r.code };
171
- }
172
- if (timestamp) {
173
- this.fetchCache.set(id, {
174
- timestamp,
175
- result
176
- });
190
+ result = { code: r == null ? void 0 : r.code, map: r == null ? void 0 : r.map };
177
191
  }
192
+ this.fetchCache.set(filePath, {
193
+ timestamp,
194
+ result
195
+ });
178
196
  return result;
179
197
  }
180
198
  async _transformRequest(id) {
@@ -186,7 +204,8 @@ class ViteNodeServer {
186
204
  } else {
187
205
  result = await this.server.transformRequest(id, { ssr: true });
188
206
  }
189
- if (this.options.sourcemap !== false && result && !id.includes("node_modules"))
207
+ const sourcemap = this.options.sourcemap ?? "inline";
208
+ if (sourcemap === "inline" && result && !id.includes("node_modules"))
190
209
  withInlineSourcemap(result);
191
210
  return result;
192
211
  }
package/dist/server.js CHANGED
@@ -30,15 +30,13 @@ async function withInlineSourcemap(result) {
30
30
  const ESM_EXT_RE = /\.(es|esm|esm-browser|esm-bundler|es6|module)\.js$/;
31
31
  const ESM_FOLDER_RE = /\/esm\/(.*\.js)$/;
32
32
  const defaultInline = [
33
- /\/vitest\/dist\//,
34
- /vitest-virtual-\w+\/dist/,
35
33
  /virtual:/,
36
34
  /\.ts$/,
37
35
  ESM_EXT_RE,
38
36
  ESM_FOLDER_RE
39
37
  ];
40
38
  const depsExternal = [
41
- /\.cjs.js$/,
39
+ /\.cjs\.js$/,
42
40
  /\.mjs$/
43
41
  ];
44
42
  function guessCJSversion(id) {
@@ -110,6 +108,25 @@ function patchWindowsImportPath(path) {
110
108
  return path;
111
109
  }
112
110
 
111
+ var __defProp = Object.defineProperty;
112
+ var __defProps = Object.defineProperties;
113
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
114
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
115
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
116
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
117
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
118
+ var __spreadValues = (a, b) => {
119
+ for (var prop in b || (b = {}))
120
+ if (__hasOwnProp.call(b, prop))
121
+ __defNormalProp(a, prop, b[prop]);
122
+ if (__getOwnPropSymbols)
123
+ for (var prop of __getOwnPropSymbols(b)) {
124
+ if (__propIsEnum.call(b, prop))
125
+ __defNormalProp(a, prop, b[prop]);
126
+ }
127
+ return a;
128
+ };
129
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
113
130
  class ViteNodeServer {
114
131
  constructor(server, options = {}) {
115
132
  this.server = server;
@@ -126,7 +143,9 @@ class ViteNodeServer {
126
143
  }
127
144
  async fetchModule(id) {
128
145
  if (!this.fetchPromiseMap.has(id)) {
129
- this.fetchPromiseMap.set(id, this._fetchModule(id).finally(() => {
146
+ this.fetchPromiseMap.set(id, this._fetchModule(id).then((r) => {
147
+ return this.options.sourcemap !== true ? __spreadProps(__spreadValues({}, r), { map: void 0 }) : r;
148
+ }).finally(() => {
130
149
  this.fetchPromiseMap.delete(id);
131
150
  }));
132
151
  }
@@ -152,25 +171,24 @@ class ViteNodeServer {
152
171
  return "web";
153
172
  }
154
173
  async _fetchModule(id) {
155
- var _a;
156
174
  let result;
157
- const timestamp = (_a = this.server.moduleGraph.getModuleById(id)) == null ? void 0 : _a.lastHMRTimestamp;
158
- const cache = this.fetchCache.get(id);
175
+ const filePath = toFilePath(id, this.server.config.root);
176
+ const module = this.server.moduleGraph.getModuleById(id);
177
+ const timestamp = (module == null ? void 0 : module.lastHMRTimestamp) || Date.now();
178
+ const cache = this.fetchCache.get(filePath);
159
179
  if (timestamp && cache && cache.timestamp >= timestamp)
160
180
  return cache.result;
161
- const externalize = await this.shouldExternalize(toFilePath(id, this.server.config.root));
181
+ const externalize = await this.shouldExternalize(filePath);
162
182
  if (externalize) {
163
183
  result = { externalize };
164
184
  } else {
165
185
  const r = await this._transformRequest(id);
166
- result = { code: r == null ? void 0 : r.code };
167
- }
168
- if (timestamp) {
169
- this.fetchCache.set(id, {
170
- timestamp,
171
- result
172
- });
186
+ result = { code: r == null ? void 0 : r.code, map: r == null ? void 0 : r.map };
173
187
  }
188
+ this.fetchCache.set(filePath, {
189
+ timestamp,
190
+ result
191
+ });
174
192
  return result;
175
193
  }
176
194
  async _transformRequest(id) {
@@ -182,7 +200,8 @@ class ViteNodeServer {
182
200
  } else {
183
201
  result = await this.server.transformRequest(id, { ssr: true });
184
202
  }
185
- if (this.options.sourcemap !== false && result && !id.includes("node_modules"))
203
+ const sourcemap = this.options.sourcemap ?? "inline";
204
+ if (sourcemap === "inline" && result && !id.includes("node_modules"))
186
205
  withInlineSourcemap(result);
187
206
  return result;
188
207
  }
package/index.d.ts CHANGED
@@ -7,12 +7,23 @@ interface DepsHandlingOptions {
7
7
  */
8
8
  fallbackCJS?: boolean;
9
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
+ }
10
21
  interface FetchResult {
11
22
  code?: string;
12
23
  externalize?: string;
24
+ map?: RawSourceMap;
13
25
  }
14
26
  declare type FetchFunction = (id: string) => Promise<FetchResult>;
15
- declare type ResolveIdFunction = (id: string, importer?: string) => Promise<ViteNodeResolveId | null>;
16
27
  interface ModuleCache {
17
28
  promise?: Promise<any>;
18
29
  exports?: any;
@@ -20,7 +31,6 @@ interface ModuleCache {
20
31
  }
21
32
  interface ViteNodeRunnerOptions {
22
33
  fetchModule: FetchFunction;
23
- resolveId: ResolveIdFunction;
24
34
  root: string;
25
35
  base?: string;
26
36
  moduleCache?: Map<string, ModuleCache>;
@@ -37,9 +47,9 @@ interface ViteNodeResolveId {
37
47
  interface ViteNodeServerOptions {
38
48
  /**
39
49
  * Inject inline sourcemap to modules
40
- * @default true
50
+ * @default 'inline'
41
51
  */
42
- sourcemap?: boolean;
52
+ sourcemap?: 'inline' | boolean;
43
53
  /**
44
54
  * Deps handling
45
55
  */
@@ -53,4 +63,4 @@ interface ViteNodeServerOptions {
53
63
  };
54
64
  }
55
65
 
56
- export { DepsHandlingOptions, FetchFunction, FetchResult, ModuleCache, ResolveIdFunction, ViteNodeResolveId, ViteNodeRunnerOptions, ViteNodeServerOptions };
66
+ export { DepsHandlingOptions, FetchFunction, FetchResult, ModuleCache, RawSourceMap, StartOfSourceMap, ViteNodeResolveId, ViteNodeRunnerOptions, ViteNodeServerOptions };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-node",
3
- "version": "0.2.5",
3
+ "version": "0.3.0",
4
4
  "description": "Vite as Node.js runtime",
5
5
  "homepage": "https://github.com/vitest-dev/vitest#readme",
6
6
  "bugs": {
@@ -51,13 +51,13 @@
51
51
  "dependencies": {
52
52
  "kolorist": "^1.5.1",
53
53
  "minimist": "^1.2.5",
54
- "mlly": "^0.4.1",
54
+ "mlly": "^0.4.2",
55
55
  "pathe": "^0.2.0",
56
56
  "vite": "^2.7.13"
57
57
  },
58
58
  "devDependencies": {
59
59
  "@types/minimist": "^1.2.2",
60
- "rollup": "^2.66.1"
60
+ "rollup": "^2.67.1"
61
61
  },
62
62
  "engines": {
63
63
  "node": ">=14.14.0"
package/server.d.ts CHANGED
@@ -1,10 +1,5 @@
1
1
  import { ViteDevServer, TransformResult } from 'vite';
2
2
 
3
- interface FetchResult {
4
- code?: string;
5
- externalize?: string;
6
- }
7
-
8
3
  interface DepsHandlingOptions {
9
4
  external?: (string | RegExp)[];
10
5
  inline?: (string | RegExp)[];
@@ -14,6 +9,22 @@ interface DepsHandlingOptions {
14
9
  */
15
10
  fallbackCJS?: boolean;
16
11
  }
12
+ interface StartOfSourceMap {
13
+ file?: string;
14
+ sourceRoot?: string;
15
+ }
16
+ interface RawSourceMap extends StartOfSourceMap {
17
+ version: string;
18
+ sources: string[];
19
+ names: string[];
20
+ sourcesContent?: string[];
21
+ mappings: string;
22
+ }
23
+ interface FetchResult {
24
+ code?: string;
25
+ externalize?: string;
26
+ map?: RawSourceMap;
27
+ }
17
28
  interface ViteNodeResolveId {
18
29
  external?: boolean | 'absolute' | 'relative';
19
30
  id: string;
@@ -24,9 +35,9 @@ interface ViteNodeResolveId {
24
35
  interface ViteNodeServerOptions {
25
36
  /**
26
37
  * Inject inline sourcemap to modules
27
- * @default true
38
+ * @default 'inline'
28
39
  */
29
- sourcemap?: boolean;
40
+ sourcemap?: 'inline' | boolean;
30
41
  /**
31
42
  * Deps handling
32
43
  */
@@ -48,7 +59,10 @@ declare class ViteNodeServer {
48
59
  options: ViteNodeServerOptions;
49
60
  private fetchPromiseMap;
50
61
  private transformPromiseMap;
51
- private fetchCache;
62
+ fetchCache: Map<string, {
63
+ timestamp: number;
64
+ result: FetchResult;
65
+ }>;
52
66
  constructor(server: ViteDevServer, options?: ViteNodeServerOptions);
53
67
  shouldExternalize(id: string): Promise<string | false>;
54
68
  resolveId(id: string, importer?: string): Promise<ViteNodeResolveId | null>;