vite-node 0.22.1 → 0.23.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/README.md +1 -1
- package/dist/chunk-hmr.cjs +16 -12
- package/dist/chunk-hmr.mjs +16 -12
- package/dist/cli.cjs +1 -1
- package/dist/cli.d.ts +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/client.cjs +48 -11
- package/dist/client.d.ts +1 -1
- package/dist/client.mjs +48 -11
- package/dist/hmr.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/server.cjs +14 -8
- package/dist/server.d.ts +1 -1
- package/dist/server.mjs +14 -8
- package/dist/{types-735b75af.d.ts → types-dca976ee.d.ts} +4 -0
- package/dist/types.d.ts +1 -1
- package/dist/utils.cjs +19 -0
- package/dist/utils.d.ts +3 -2
- package/dist/utils.mjs +20 -2
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/vite-node)
|
|
4
4
|
|
|
5
|
-
Vite as Node runtime. The engine powers [Vitest](https://github.com/vitest-dev/vitest).
|
|
5
|
+
Vite as Node runtime. The engine powers [Vitest](https://github.com/vitest-dev/vitest) and [Nuxt 3 Dev SSR](https://github.com/nuxt/framework).
|
|
6
6
|
|
|
7
7
|
## Features
|
|
8
8
|
|
package/dist/chunk-hmr.cjs
CHANGED
|
@@ -98,17 +98,19 @@ async function fetchUpdate(runner, { path, acceptedPath }) {
|
|
|
98
98
|
const qualifiedCallbacks = mod.callbacks.filter(({ deps }) => {
|
|
99
99
|
return deps.some((dep) => modulesToUpdate.has(dep));
|
|
100
100
|
});
|
|
101
|
-
await Promise.all(
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
101
|
+
await Promise.all(
|
|
102
|
+
Array.from(modulesToUpdate).map(async (dep) => {
|
|
103
|
+
const disposer = maps.disposeMap.get(dep);
|
|
104
|
+
if (disposer)
|
|
105
|
+
await disposer(maps.dataMap.get(dep));
|
|
106
|
+
try {
|
|
107
|
+
const newMod = await reload(runner, [dep]);
|
|
108
|
+
moduleMap.set(dep, newMod);
|
|
109
|
+
} catch (e) {
|
|
110
|
+
warnFailedFetch(e, dep);
|
|
111
|
+
}
|
|
112
|
+
})
|
|
113
|
+
);
|
|
112
114
|
return () => {
|
|
113
115
|
for (const { deps, fn } of qualifiedCallbacks)
|
|
114
116
|
fn(deps.map((dep) => moduleMap.get(dep)));
|
|
@@ -119,7 +121,9 @@ async function fetchUpdate(runner, { path, acceptedPath }) {
|
|
|
119
121
|
function warnFailedFetch(err, path) {
|
|
120
122
|
if (!err.message.match("fetch"))
|
|
121
123
|
console.error(err);
|
|
122
|
-
console.error(
|
|
124
|
+
console.error(
|
|
125
|
+
`[hmr] Failed to reload ${path}. This could be due to syntax errors or importing non-existent modules. (see errors above)`
|
|
126
|
+
);
|
|
123
127
|
}
|
|
124
128
|
async function handleMessage(runner, emitter, files, payload) {
|
|
125
129
|
const maps = getCache(runner);
|
package/dist/chunk-hmr.mjs
CHANGED
|
@@ -92,17 +92,19 @@ async function fetchUpdate(runner, { path, acceptedPath }) {
|
|
|
92
92
|
const qualifiedCallbacks = mod.callbacks.filter(({ deps }) => {
|
|
93
93
|
return deps.some((dep) => modulesToUpdate.has(dep));
|
|
94
94
|
});
|
|
95
|
-
await Promise.all(
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
95
|
+
await Promise.all(
|
|
96
|
+
Array.from(modulesToUpdate).map(async (dep) => {
|
|
97
|
+
const disposer = maps.disposeMap.get(dep);
|
|
98
|
+
if (disposer)
|
|
99
|
+
await disposer(maps.dataMap.get(dep));
|
|
100
|
+
try {
|
|
101
|
+
const newMod = await reload(runner, [dep]);
|
|
102
|
+
moduleMap.set(dep, newMod);
|
|
103
|
+
} catch (e) {
|
|
104
|
+
warnFailedFetch(e, dep);
|
|
105
|
+
}
|
|
106
|
+
})
|
|
107
|
+
);
|
|
106
108
|
return () => {
|
|
107
109
|
for (const { deps, fn } of qualifiedCallbacks)
|
|
108
110
|
fn(deps.map((dep) => moduleMap.get(dep)));
|
|
@@ -113,7 +115,9 @@ async function fetchUpdate(runner, { path, acceptedPath }) {
|
|
|
113
115
|
function warnFailedFetch(err, path) {
|
|
114
116
|
if (!err.message.match("fetch"))
|
|
115
117
|
console.error(err);
|
|
116
|
-
console.error(
|
|
118
|
+
console.error(
|
|
119
|
+
`[hmr] Failed to reload ${path}. This could be due to syntax errors or importing non-existent modules. (see errors above)`
|
|
120
|
+
);
|
|
117
121
|
}
|
|
118
122
|
async function handleMessage(runner, emitter, files, payload) {
|
|
119
123
|
const maps = getCache(runner);
|
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.
|
|
633
|
+
var version = "0.23.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.d.ts
CHANGED
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.
|
|
631
|
+
var version = "0.23.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/client.cjs
CHANGED
|
@@ -108,6 +108,21 @@ class ModuleCacheMap extends Map {
|
|
|
108
108
|
}
|
|
109
109
|
return invalidated;
|
|
110
110
|
}
|
|
111
|
+
invalidateSubDepTree(ids, invalidated = /* @__PURE__ */ new Set()) {
|
|
112
|
+
for (const _id of ids) {
|
|
113
|
+
const id = this.normalizePath(_id);
|
|
114
|
+
if (invalidated.has(id))
|
|
115
|
+
continue;
|
|
116
|
+
invalidated.add(id);
|
|
117
|
+
const subIds = Array.from(super.entries()).filter(([, mod]) => {
|
|
118
|
+
var _a;
|
|
119
|
+
return (_a = mod.importers) == null ? void 0 : _a.has(id);
|
|
120
|
+
}).map(([key]) => key);
|
|
121
|
+
subIds.length && this.invalidateSubDepTree(subIds, invalidated);
|
|
122
|
+
super.delete(id);
|
|
123
|
+
}
|
|
124
|
+
return invalidated;
|
|
125
|
+
}
|
|
111
126
|
}
|
|
112
127
|
class ViteNodeRunner {
|
|
113
128
|
constructor(options) {
|
|
@@ -198,15 +213,34 @@ ${getStack()}`), 2e3);
|
|
|
198
213
|
enumerable: false,
|
|
199
214
|
configurable: false
|
|
200
215
|
});
|
|
216
|
+
const cjsExports = new Proxy(exports, {
|
|
217
|
+
get(_, p, receiver) {
|
|
218
|
+
return Reflect.get(exports, p, receiver);
|
|
219
|
+
},
|
|
220
|
+
set(_, p, value) {
|
|
221
|
+
if (p !== "default") {
|
|
222
|
+
if (!Reflect.has(exports, "default"))
|
|
223
|
+
exports.default = {};
|
|
224
|
+
if (exports.default === null || typeof exports.default !== "object") {
|
|
225
|
+
defineExport(exports, p, () => void 0);
|
|
226
|
+
return true;
|
|
227
|
+
}
|
|
228
|
+
exports.default[p] = value;
|
|
229
|
+
defineExport(exports, p, () => value);
|
|
230
|
+
return true;
|
|
231
|
+
}
|
|
232
|
+
return Reflect.set(exports, p, value);
|
|
233
|
+
}
|
|
234
|
+
});
|
|
201
235
|
Object.assign(mod, { code: transformed, exports });
|
|
202
236
|
const __filename = url.fileURLToPath(url$1);
|
|
203
237
|
const moduleProxy = {
|
|
204
238
|
set exports(value) {
|
|
205
|
-
exportAll(
|
|
206
|
-
|
|
239
|
+
exportAll(cjsExports, value);
|
|
240
|
+
cjsExports.default = value;
|
|
207
241
|
},
|
|
208
242
|
get exports() {
|
|
209
|
-
return
|
|
243
|
+
return cjsExports;
|
|
210
244
|
}
|
|
211
245
|
};
|
|
212
246
|
let hotContext;
|
|
@@ -228,7 +262,7 @@ ${getStack()}`), 2e3);
|
|
|
228
262
|
__vite_ssr_import_meta__: meta,
|
|
229
263
|
__vitest_resolve_id__: resolveId,
|
|
230
264
|
require: module$1.createRequire(url$1),
|
|
231
|
-
exports,
|
|
265
|
+
exports: cjsExports,
|
|
232
266
|
module: moduleProxy,
|
|
233
267
|
__filename,
|
|
234
268
|
__dirname: pathe.dirname(__filename)
|
|
@@ -284,19 +318,22 @@ function proxyMethod(name, tryDefault) {
|
|
|
284
318
|
return result;
|
|
285
319
|
};
|
|
286
320
|
}
|
|
321
|
+
function defineExport(exports, key, value) {
|
|
322
|
+
Object.defineProperty(exports, key, {
|
|
323
|
+
enumerable: true,
|
|
324
|
+
configurable: true,
|
|
325
|
+
get: value
|
|
326
|
+
});
|
|
327
|
+
}
|
|
287
328
|
function exportAll(exports, sourceModule) {
|
|
288
329
|
if (exports === sourceModule)
|
|
289
330
|
return;
|
|
331
|
+
if (typeof sourceModule !== "object" || Array.isArray(sourceModule) || !sourceModule)
|
|
332
|
+
return;
|
|
290
333
|
for (const key in sourceModule) {
|
|
291
334
|
if (key !== "default") {
|
|
292
335
|
try {
|
|
293
|
-
|
|
294
|
-
enumerable: true,
|
|
295
|
-
configurable: true,
|
|
296
|
-
get() {
|
|
297
|
-
return sourceModule[key];
|
|
298
|
-
}
|
|
299
|
-
});
|
|
336
|
+
defineExport(exports, key, () => sourceModule[key]);
|
|
300
337
|
} catch (_err) {
|
|
301
338
|
}
|
|
302
339
|
}
|
package/dist/client.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { j as DEFAULT_REQUEST_STUBS, M as ModuleCacheMap, h as ViteNodeRunner } from './types-
|
|
1
|
+
export { j as DEFAULT_REQUEST_STUBS, M as ModuleCacheMap, h as ViteNodeRunner } from './types-dca976ee.js';
|
package/dist/client.mjs
CHANGED
|
@@ -81,6 +81,21 @@ class ModuleCacheMap extends Map {
|
|
|
81
81
|
}
|
|
82
82
|
return invalidated;
|
|
83
83
|
}
|
|
84
|
+
invalidateSubDepTree(ids, invalidated = /* @__PURE__ */ new Set()) {
|
|
85
|
+
for (const _id of ids) {
|
|
86
|
+
const id = this.normalizePath(_id);
|
|
87
|
+
if (invalidated.has(id))
|
|
88
|
+
continue;
|
|
89
|
+
invalidated.add(id);
|
|
90
|
+
const subIds = Array.from(super.entries()).filter(([, mod]) => {
|
|
91
|
+
var _a;
|
|
92
|
+
return (_a = mod.importers) == null ? void 0 : _a.has(id);
|
|
93
|
+
}).map(([key]) => key);
|
|
94
|
+
subIds.length && this.invalidateSubDepTree(subIds, invalidated);
|
|
95
|
+
super.delete(id);
|
|
96
|
+
}
|
|
97
|
+
return invalidated;
|
|
98
|
+
}
|
|
84
99
|
}
|
|
85
100
|
class ViteNodeRunner {
|
|
86
101
|
constructor(options) {
|
|
@@ -171,15 +186,34 @@ ${getStack()}`), 2e3);
|
|
|
171
186
|
enumerable: false,
|
|
172
187
|
configurable: false
|
|
173
188
|
});
|
|
189
|
+
const cjsExports = new Proxy(exports, {
|
|
190
|
+
get(_, p, receiver) {
|
|
191
|
+
return Reflect.get(exports, p, receiver);
|
|
192
|
+
},
|
|
193
|
+
set(_, p, value) {
|
|
194
|
+
if (p !== "default") {
|
|
195
|
+
if (!Reflect.has(exports, "default"))
|
|
196
|
+
exports.default = {};
|
|
197
|
+
if (exports.default === null || typeof exports.default !== "object") {
|
|
198
|
+
defineExport(exports, p, () => void 0);
|
|
199
|
+
return true;
|
|
200
|
+
}
|
|
201
|
+
exports.default[p] = value;
|
|
202
|
+
defineExport(exports, p, () => value);
|
|
203
|
+
return true;
|
|
204
|
+
}
|
|
205
|
+
return Reflect.set(exports, p, value);
|
|
206
|
+
}
|
|
207
|
+
});
|
|
174
208
|
Object.assign(mod, { code: transformed, exports });
|
|
175
209
|
const __filename = fileURLToPath(url);
|
|
176
210
|
const moduleProxy = {
|
|
177
211
|
set exports(value) {
|
|
178
|
-
exportAll(
|
|
179
|
-
|
|
212
|
+
exportAll(cjsExports, value);
|
|
213
|
+
cjsExports.default = value;
|
|
180
214
|
},
|
|
181
215
|
get exports() {
|
|
182
|
-
return
|
|
216
|
+
return cjsExports;
|
|
183
217
|
}
|
|
184
218
|
};
|
|
185
219
|
let hotContext;
|
|
@@ -201,7 +235,7 @@ ${getStack()}`), 2e3);
|
|
|
201
235
|
__vite_ssr_import_meta__: meta,
|
|
202
236
|
__vitest_resolve_id__: resolveId,
|
|
203
237
|
require: createRequire(url),
|
|
204
|
-
exports,
|
|
238
|
+
exports: cjsExports,
|
|
205
239
|
module: moduleProxy,
|
|
206
240
|
__filename,
|
|
207
241
|
__dirname: dirname(__filename)
|
|
@@ -257,19 +291,22 @@ function proxyMethod(name, tryDefault) {
|
|
|
257
291
|
return result;
|
|
258
292
|
};
|
|
259
293
|
}
|
|
294
|
+
function defineExport(exports, key, value) {
|
|
295
|
+
Object.defineProperty(exports, key, {
|
|
296
|
+
enumerable: true,
|
|
297
|
+
configurable: true,
|
|
298
|
+
get: value
|
|
299
|
+
});
|
|
300
|
+
}
|
|
260
301
|
function exportAll(exports, sourceModule) {
|
|
261
302
|
if (exports === sourceModule)
|
|
262
303
|
return;
|
|
304
|
+
if (typeof sourceModule !== "object" || Array.isArray(sourceModule) || !sourceModule)
|
|
305
|
+
return;
|
|
263
306
|
for (const key in sourceModule) {
|
|
264
307
|
if (key !== "default") {
|
|
265
308
|
try {
|
|
266
|
-
|
|
267
|
-
enumerable: true,
|
|
268
|
-
configurable: true,
|
|
269
|
-
get() {
|
|
270
|
-
return sourceModule[key];
|
|
271
|
-
}
|
|
272
|
-
});
|
|
309
|
+
defineExport(exports, key, () => sourceModule[key]);
|
|
273
310
|
} catch (_err) {
|
|
274
311
|
}
|
|
275
312
|
}
|
package/dist/hmr.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EventEmitter } from 'events';
|
|
2
2
|
import { HMRPayload, Plugin } from 'vite';
|
|
3
|
-
import { U as UpdatePayload, P as PrunePayload, g as FullReloadPayload, E as ErrorPayload, h as ViteNodeRunner, i as HMRPayload$1, H as HotContext } from './types-
|
|
3
|
+
import { U as UpdatePayload, P as PrunePayload, g as FullReloadPayload, E as ErrorPayload, h as ViteNodeRunner, i as HMRPayload$1, H as HotContext } from './types-dca976ee.js';
|
|
4
4
|
|
|
5
5
|
declare type EventType = string | symbol;
|
|
6
6
|
declare type Handler<T = unknown> = (event: T) => void;
|
package/dist/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { A as Arrayable, C as CreateHotContextFunction, f as DebuggerOptions, D as DepsHandlingOptions, a as FetchFunction, F as FetchResult, H as HotContext, c as ModuleCache, M as ModuleCacheMap, N as Nullable, R as RawSourceMap, b as ResolveIdFunction, S as StartOfSourceMap, d as ViteNodeResolveId, V as ViteNodeRunnerOptions, e as ViteNodeServerOptions } from './types-
|
|
1
|
+
export { A as Arrayable, C as CreateHotContextFunction, f as DebuggerOptions, D as DepsHandlingOptions, a as FetchFunction, F as FetchResult, H as HotContext, c as ModuleCache, M as ModuleCacheMap, N as Nullable, R as RawSourceMap, b as ResolveIdFunction, S as StartOfSourceMap, d as ViteNodeResolveId, V as ViteNodeRunnerOptions, e as ViteNodeServerOptions } from './types-dca976ee.js';
|
package/dist/server.cjs
CHANGED
|
@@ -142,19 +142,25 @@ class ViteNodeServer {
|
|
|
142
142
|
}
|
|
143
143
|
async fetchModule(id) {
|
|
144
144
|
if (!this.fetchPromiseMap.has(id)) {
|
|
145
|
-
this.fetchPromiseMap.set(
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
145
|
+
this.fetchPromiseMap.set(
|
|
146
|
+
id,
|
|
147
|
+
this._fetchModule(id).then((r) => {
|
|
148
|
+
return this.options.sourcemap !== true ? { ...r, map: void 0 } : r;
|
|
149
|
+
}).finally(() => {
|
|
150
|
+
this.fetchPromiseMap.delete(id);
|
|
151
|
+
})
|
|
152
|
+
);
|
|
150
153
|
}
|
|
151
154
|
return this.fetchPromiseMap.get(id);
|
|
152
155
|
}
|
|
153
156
|
async transformRequest(id) {
|
|
154
157
|
if (!this.transformPromiseMap.has(id)) {
|
|
155
|
-
this.transformPromiseMap.set(
|
|
156
|
-
|
|
157
|
-
|
|
158
|
+
this.transformPromiseMap.set(
|
|
159
|
+
id,
|
|
160
|
+
this._transformRequest(id).finally(() => {
|
|
161
|
+
this.transformPromiseMap.delete(id);
|
|
162
|
+
})
|
|
163
|
+
);
|
|
158
164
|
}
|
|
159
165
|
return this.transformPromiseMap.get(id);
|
|
160
166
|
}
|
package/dist/server.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TransformResult, ViteDevServer } from 'vite';
|
|
2
|
-
import { f as DebuggerOptions, D as DepsHandlingOptions, e as ViteNodeServerOptions, F as FetchResult, d as ViteNodeResolveId } from './types-
|
|
2
|
+
import { f as DebuggerOptions, D as DepsHandlingOptions, e as ViteNodeServerOptions, F as FetchResult, d as ViteNodeResolveId } from './types-dca976ee.js';
|
|
3
3
|
|
|
4
4
|
declare class Debugger {
|
|
5
5
|
options: DebuggerOptions;
|
package/dist/server.mjs
CHANGED
|
@@ -134,19 +134,25 @@ class ViteNodeServer {
|
|
|
134
134
|
}
|
|
135
135
|
async fetchModule(id) {
|
|
136
136
|
if (!this.fetchPromiseMap.has(id)) {
|
|
137
|
-
this.fetchPromiseMap.set(
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
137
|
+
this.fetchPromiseMap.set(
|
|
138
|
+
id,
|
|
139
|
+
this._fetchModule(id).then((r) => {
|
|
140
|
+
return this.options.sourcemap !== true ? { ...r, map: void 0 } : r;
|
|
141
|
+
}).finally(() => {
|
|
142
|
+
this.fetchPromiseMap.delete(id);
|
|
143
|
+
})
|
|
144
|
+
);
|
|
142
145
|
}
|
|
143
146
|
return this.fetchPromiseMap.get(id);
|
|
144
147
|
}
|
|
145
148
|
async transformRequest(id) {
|
|
146
149
|
if (!this.transformPromiseMap.has(id)) {
|
|
147
|
-
this.transformPromiseMap.set(
|
|
148
|
-
|
|
149
|
-
|
|
150
|
+
this.transformPromiseMap.set(
|
|
151
|
+
id,
|
|
152
|
+
this._transformRequest(id).finally(() => {
|
|
153
|
+
this.transformPromiseMap.delete(id);
|
|
154
|
+
})
|
|
155
|
+
);
|
|
150
156
|
}
|
|
151
157
|
return this.transformPromiseMap.get(id);
|
|
152
158
|
}
|
|
@@ -125,6 +125,10 @@ declare class ModuleCacheMap extends Map<string, ModuleCache> {
|
|
|
125
125
|
* Invalidate modules that dependent on the given modules, up to the main entry
|
|
126
126
|
*/
|
|
127
127
|
invalidateDepTree(ids: string[] | Set<string>, invalidated?: Set<string>): Set<string>;
|
|
128
|
+
/**
|
|
129
|
+
* Invalidate dependency modules of the given modules, down to the bottom-level dependencies
|
|
130
|
+
*/
|
|
131
|
+
invalidateSubDepTree(ids: string[] | Set<string>, invalidated?: Set<string>): Set<string>;
|
|
128
132
|
}
|
|
129
133
|
declare class ViteNodeRunner {
|
|
130
134
|
options: ViteNodeRunnerOptions;
|
package/dist/types.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { A as Arrayable, C as CreateHotContextFunction, f as DebuggerOptions, D as DepsHandlingOptions, a as FetchFunction, F as FetchResult, H as HotContext, c as ModuleCache, M as ModuleCacheMap, N as Nullable, R as RawSourceMap, b as ResolveIdFunction, S as StartOfSourceMap, d as ViteNodeResolveId, V as ViteNodeRunnerOptions, e as ViteNodeServerOptions } from './types-
|
|
1
|
+
export { A as Arrayable, C as CreateHotContextFunction, f as DebuggerOptions, D as DepsHandlingOptions, a as FetchFunction, F as FetchResult, H as HotContext, c as ModuleCache, M as ModuleCacheMap, N as Nullable, R as RawSourceMap, b as ResolveIdFunction, S as StartOfSourceMap, d as ViteNodeResolveId, V as ViteNodeRunnerOptions, e as ViteNodeServerOptions } from './types-dca976ee.js';
|
package/dist/utils.cjs
CHANGED
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var url = require('url');
|
|
6
6
|
var pathe = require('pathe');
|
|
7
|
+
var mlly = require('mlly');
|
|
7
8
|
|
|
8
9
|
const isWindows = process.platform === "win32";
|
|
9
10
|
function slash(str) {
|
|
@@ -23,6 +24,23 @@ function normalizeModuleId(id) {
|
|
|
23
24
|
function isPrimitive(v) {
|
|
24
25
|
return v !== Object(v);
|
|
25
26
|
}
|
|
27
|
+
function pathFromRoot(root, filename) {
|
|
28
|
+
if (mlly.isNodeBuiltin(filename))
|
|
29
|
+
return filename;
|
|
30
|
+
filename = filename.replace(/^\/@fs\//, isWindows ? "" : "/");
|
|
31
|
+
if (!filename.startsWith(root))
|
|
32
|
+
return filename;
|
|
33
|
+
const relativePath = pathe.relative(root, filename);
|
|
34
|
+
if (!relativePath.startsWith("/") && !relativePath.startsWith("."))
|
|
35
|
+
return `/${relativePath}`;
|
|
36
|
+
let index = 0;
|
|
37
|
+
for (const char of relativePath) {
|
|
38
|
+
if (char !== "." && char !== "/")
|
|
39
|
+
return relativePath.slice(index - 1);
|
|
40
|
+
index++;
|
|
41
|
+
}
|
|
42
|
+
return relativePath;
|
|
43
|
+
}
|
|
26
44
|
function toFilePath(id, root) {
|
|
27
45
|
let absolute = id.startsWith("/@fs/") ? id.slice(4) : id.startsWith(root) ? id : id.startsWith("/") ? pathe.resolve(root, id.slice(1)) : id;
|
|
28
46
|
if (absolute.startsWith("//"))
|
|
@@ -55,6 +73,7 @@ exports.isWindows = isWindows;
|
|
|
55
73
|
exports.mergeSlashes = mergeSlashes;
|
|
56
74
|
exports.normalizeModuleId = normalizeModuleId;
|
|
57
75
|
exports.normalizeRequestId = normalizeRequestId;
|
|
76
|
+
exports.pathFromRoot = pathFromRoot;
|
|
58
77
|
exports.slash = slash;
|
|
59
78
|
exports.toArray = toArray;
|
|
60
79
|
exports.toFilePath = toFilePath;
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TransformResult } from 'vite';
|
|
2
|
-
import { N as Nullable, A as Arrayable } from './types-
|
|
2
|
+
import { N as Nullable, A as Arrayable } from './types-dca976ee.js';
|
|
3
3
|
|
|
4
4
|
declare const isWindows: boolean;
|
|
5
5
|
declare function slash(str: string): string;
|
|
@@ -7,6 +7,7 @@ declare function mergeSlashes(str: string): string;
|
|
|
7
7
|
declare function normalizeRequestId(id: string, base?: string): string;
|
|
8
8
|
declare function normalizeModuleId(id: string): string;
|
|
9
9
|
declare function isPrimitive(v: any): boolean;
|
|
10
|
+
declare function pathFromRoot(root: string, filename: string): string;
|
|
10
11
|
declare function toFilePath(id: string, root: string): string;
|
|
11
12
|
declare function withInlineSourcemap(result: TransformResult): Promise<TransformResult>;
|
|
12
13
|
/**
|
|
@@ -16,4 +17,4 @@ declare function withInlineSourcemap(result: TransformResult): Promise<Transform
|
|
|
16
17
|
*/
|
|
17
18
|
declare function toArray<T>(array?: Nullable<Arrayable<T>>): Array<T>;
|
|
18
19
|
|
|
19
|
-
export { isPrimitive, isWindows, mergeSlashes, normalizeModuleId, normalizeRequestId, slash, toArray, toFilePath, withInlineSourcemap };
|
|
20
|
+
export { isPrimitive, isWindows, mergeSlashes, normalizeModuleId, normalizeRequestId, pathFromRoot, slash, toArray, toFilePath, withInlineSourcemap };
|
package/dist/utils.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { fileURLToPath, pathToFileURL } from 'url';
|
|
2
|
-
import { resolve } from 'pathe';
|
|
2
|
+
import { relative, resolve } from 'pathe';
|
|
3
|
+
import { isNodeBuiltin } from 'mlly';
|
|
3
4
|
|
|
4
5
|
const isWindows = process.platform === "win32";
|
|
5
6
|
function slash(str) {
|
|
@@ -19,6 +20,23 @@ function normalizeModuleId(id) {
|
|
|
19
20
|
function isPrimitive(v) {
|
|
20
21
|
return v !== Object(v);
|
|
21
22
|
}
|
|
23
|
+
function pathFromRoot(root, filename) {
|
|
24
|
+
if (isNodeBuiltin(filename))
|
|
25
|
+
return filename;
|
|
26
|
+
filename = filename.replace(/^\/@fs\//, isWindows ? "" : "/");
|
|
27
|
+
if (!filename.startsWith(root))
|
|
28
|
+
return filename;
|
|
29
|
+
const relativePath = relative(root, filename);
|
|
30
|
+
if (!relativePath.startsWith("/") && !relativePath.startsWith("."))
|
|
31
|
+
return `/${relativePath}`;
|
|
32
|
+
let index = 0;
|
|
33
|
+
for (const char of relativePath) {
|
|
34
|
+
if (char !== "." && char !== "/")
|
|
35
|
+
return relativePath.slice(index - 1);
|
|
36
|
+
index++;
|
|
37
|
+
}
|
|
38
|
+
return relativePath;
|
|
39
|
+
}
|
|
22
40
|
function toFilePath(id, root) {
|
|
23
41
|
let absolute = id.startsWith("/@fs/") ? id.slice(4) : id.startsWith(root) ? id : id.startsWith("/") ? resolve(root, id.slice(1)) : id;
|
|
24
42
|
if (absolute.startsWith("//"))
|
|
@@ -46,4 +64,4 @@ function toArray(array) {
|
|
|
46
64
|
return [array];
|
|
47
65
|
}
|
|
48
66
|
|
|
49
|
-
export { isPrimitive, isWindows, mergeSlashes, normalizeModuleId, normalizeRequestId, slash, toArray, toFilePath, withInlineSourcemap };
|
|
67
|
+
export { isPrimitive, isWindows, mergeSlashes, normalizeModuleId, normalizeRequestId, pathFromRoot, slash, toArray, toFilePath, withInlineSourcemap };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-node",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.23.2",
|
|
4
4
|
"description": "Vite as Node.js runtime",
|
|
5
5
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -65,15 +65,15 @@
|
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
67
|
"debug": "^4.3.4",
|
|
68
|
-
"mlly": "^0.5.
|
|
68
|
+
"mlly": "^0.5.14",
|
|
69
69
|
"pathe": "^0.2.0",
|
|
70
70
|
"vite": "^2.9.12 || ^3.0.0-0"
|
|
71
71
|
},
|
|
72
72
|
"devDependencies": {
|
|
73
73
|
"@types/debug": "^4.1.7",
|
|
74
|
-
"cac": "^6.7.
|
|
74
|
+
"cac": "^6.7.14",
|
|
75
75
|
"picocolors": "^1.0.0",
|
|
76
|
-
"rollup": "^2.
|
|
76
|
+
"rollup": "^2.79.0"
|
|
77
77
|
},
|
|
78
78
|
"scripts": {
|
|
79
79
|
"build": "rimraf dist && rollup -c",
|