vite-node 0.27.1 → 0.27.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 +2 -2
- package/dist/cli.mjs +1 -1
- package/dist/client.cjs +4 -3
- package/dist/client.mjs +4 -3
- package/dist/server.cjs +1 -1
- package/dist/server.mjs +1 -1
- package/dist/utils.cjs +11 -6
- package/dist/utils.d.ts +4 -1
- package/dist/utils.mjs +11 -6
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -6,8 +6,8 @@ var vite = require('vite');
|
|
|
6
6
|
var server = require('./server.cjs');
|
|
7
7
|
var client = require('./client.cjs');
|
|
8
8
|
var utils = require('./utils.cjs');
|
|
9
|
-
var hmr = require('./chunk-hmr.cjs');
|
|
10
9
|
var sourceMap = require('./source-map.cjs');
|
|
10
|
+
var hmr = require('./chunk-hmr.cjs');
|
|
11
11
|
require('perf_hooks');
|
|
12
12
|
require('pathe');
|
|
13
13
|
require('debug');
|
|
@@ -25,7 +25,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
25
25
|
var cac__default = /*#__PURE__*/_interopDefaultLegacy(cac);
|
|
26
26
|
var c__default = /*#__PURE__*/_interopDefaultLegacy(c);
|
|
27
27
|
|
|
28
|
-
var version = "0.27.
|
|
28
|
+
var version = "0.27.2";
|
|
29
29
|
|
|
30
30
|
const cli = cac__default["default"]("vite-node");
|
|
31
31
|
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
|
@@ -18,7 +18,7 @@ import 'node:path';
|
|
|
18
18
|
import 'node:vm';
|
|
19
19
|
import 'node:events';
|
|
20
20
|
|
|
21
|
-
var version = "0.27.
|
|
21
|
+
var version = "0.27.2";
|
|
22
22
|
|
|
23
23
|
const cli = cac("vite-node");
|
|
24
24
|
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
|
@@ -193,11 +193,12 @@ class ViteNodeRunner {
|
|
|
193
193
|
if (importee && id.startsWith(utils.VALID_ID_PREFIX))
|
|
194
194
|
importee = void 0;
|
|
195
195
|
id = utils.normalizeRequestId(id, this.options.base);
|
|
196
|
-
|
|
197
|
-
|
|
196
|
+
const { path, exists } = utils.toFilePath(id, this.root);
|
|
197
|
+
if (!this.options.resolveId || exists)
|
|
198
|
+
return [id, path];
|
|
198
199
|
const resolved = await this.options.resolveId(id, importee);
|
|
199
200
|
const resolvedId = resolved ? utils.normalizeRequestId(resolved.id, this.options.base) : id;
|
|
200
|
-
const fsPath = resolved ? resolvedId :
|
|
201
|
+
const fsPath = resolved ? resolvedId : path;
|
|
201
202
|
return [resolvedId, fsPath];
|
|
202
203
|
}
|
|
203
204
|
async resolveUrl(id, importee) {
|
package/dist/client.mjs
CHANGED
|
@@ -166,11 +166,12 @@ class ViteNodeRunner {
|
|
|
166
166
|
if (importee && id.startsWith(VALID_ID_PREFIX))
|
|
167
167
|
importee = void 0;
|
|
168
168
|
id = normalizeRequestId(id, this.options.base);
|
|
169
|
-
|
|
170
|
-
|
|
169
|
+
const { path, exists } = toFilePath(id, this.root);
|
|
170
|
+
if (!this.options.resolveId || exists)
|
|
171
|
+
return [id, path];
|
|
171
172
|
const resolved = await this.options.resolveId(id, importee);
|
|
172
173
|
const resolvedId = resolved ? normalizeRequestId(resolved.id, this.options.base) : id;
|
|
173
|
-
const fsPath = resolved ? resolvedId :
|
|
174
|
+
const fsPath = resolved ? resolvedId : path;
|
|
174
175
|
return [resolvedId, fsPath];
|
|
175
176
|
}
|
|
176
177
|
async resolveUrl(id, importee) {
|
package/dist/server.cjs
CHANGED
|
@@ -287,7 +287,7 @@ class ViteNodeServer {
|
|
|
287
287
|
async _fetchModule(id) {
|
|
288
288
|
var _a;
|
|
289
289
|
let result;
|
|
290
|
-
const filePath = utils.toFilePath(id, this.server.config.root);
|
|
290
|
+
const { path: filePath } = utils.toFilePath(id, this.server.config.root);
|
|
291
291
|
const module = this.server.moduleGraph.getModuleById(id);
|
|
292
292
|
const timestamp = module ? module.lastHMRTimestamp : null;
|
|
293
293
|
const cache = this.fetchCache.get(filePath);
|
package/dist/server.mjs
CHANGED
|
@@ -278,7 +278,7 @@ class ViteNodeServer {
|
|
|
278
278
|
async _fetchModule(id) {
|
|
279
279
|
var _a;
|
|
280
280
|
let result;
|
|
281
|
-
const filePath = toFilePath(id, this.server.config.root);
|
|
281
|
+
const { path: filePath } = toFilePath(id, this.server.config.root);
|
|
282
282
|
const module = this.server.moduleGraph.getModuleById(id);
|
|
283
283
|
const timestamp = module ? module.lastHMRTimestamp : null;
|
|
284
284
|
const cache = this.fetchCache.get(filePath);
|
package/dist/utils.cjs
CHANGED
|
@@ -34,19 +34,24 @@ function isPrimitive(v) {
|
|
|
34
34
|
return v !== Object(v);
|
|
35
35
|
}
|
|
36
36
|
function toFilePath(id, root) {
|
|
37
|
-
let absolute = (() => {
|
|
37
|
+
let { absolute, exists } = (() => {
|
|
38
38
|
if (id.startsWith("/@fs/"))
|
|
39
|
-
return id.slice(4);
|
|
39
|
+
return { absolute: id.slice(4), exists: true };
|
|
40
40
|
if (!id.startsWith(root) && id.startsWith("/")) {
|
|
41
41
|
const resolved = pathe.resolve(root, id.slice(1));
|
|
42
|
-
if (fs.existsSync(resolved
|
|
43
|
-
return resolved;
|
|
42
|
+
if (fs.existsSync(cleanUrl(resolved)))
|
|
43
|
+
return { absolute: resolved, exists: true };
|
|
44
|
+
} else if (id.startsWith(root) && fs.existsSync(cleanUrl(id))) {
|
|
45
|
+
return { absolute: id, exists: true };
|
|
44
46
|
}
|
|
45
|
-
return id;
|
|
47
|
+
return { absolute: id, exists: false };
|
|
46
48
|
})();
|
|
47
49
|
if (absolute.startsWith("//"))
|
|
48
50
|
absolute = absolute.slice(1);
|
|
49
|
-
return
|
|
51
|
+
return {
|
|
52
|
+
path: isWindows && absolute.startsWith("/") ? slash(node_url.fileURLToPath(node_url.pathToFileURL(absolute.slice(1)).href)) : absolute,
|
|
53
|
+
exists
|
|
54
|
+
};
|
|
50
55
|
}
|
|
51
56
|
function toArray(array) {
|
|
52
57
|
if (array === null || array === void 0)
|
package/dist/utils.d.ts
CHANGED
|
@@ -10,7 +10,10 @@ declare const cleanUrl: (url: string) => string;
|
|
|
10
10
|
declare const isInternalRequest: (id: string) => boolean;
|
|
11
11
|
declare function normalizeModuleId(id: string): string;
|
|
12
12
|
declare function isPrimitive(v: any): boolean;
|
|
13
|
-
declare function toFilePath(id: string, root: string):
|
|
13
|
+
declare function toFilePath(id: string, root: string): {
|
|
14
|
+
path: string;
|
|
15
|
+
exists: boolean;
|
|
16
|
+
};
|
|
14
17
|
/**
|
|
15
18
|
* Convert `Arrayable<T>` to `Array<T>`
|
|
16
19
|
*
|
package/dist/utils.mjs
CHANGED
|
@@ -30,19 +30,24 @@ function isPrimitive(v) {
|
|
|
30
30
|
return v !== Object(v);
|
|
31
31
|
}
|
|
32
32
|
function toFilePath(id, root) {
|
|
33
|
-
let absolute = (() => {
|
|
33
|
+
let { absolute, exists } = (() => {
|
|
34
34
|
if (id.startsWith("/@fs/"))
|
|
35
|
-
return id.slice(4);
|
|
35
|
+
return { absolute: id.slice(4), exists: true };
|
|
36
36
|
if (!id.startsWith(root) && id.startsWith("/")) {
|
|
37
37
|
const resolved = resolve(root, id.slice(1));
|
|
38
|
-
if (existsSync(resolved
|
|
39
|
-
return resolved;
|
|
38
|
+
if (existsSync(cleanUrl(resolved)))
|
|
39
|
+
return { absolute: resolved, exists: true };
|
|
40
|
+
} else if (id.startsWith(root) && existsSync(cleanUrl(id))) {
|
|
41
|
+
return { absolute: id, exists: true };
|
|
40
42
|
}
|
|
41
|
-
return id;
|
|
43
|
+
return { absolute: id, exists: false };
|
|
42
44
|
})();
|
|
43
45
|
if (absolute.startsWith("//"))
|
|
44
46
|
absolute = absolute.slice(1);
|
|
45
|
-
return
|
|
47
|
+
return {
|
|
48
|
+
path: isWindows && absolute.startsWith("/") ? slash(fileURLToPath(pathToFileURL(absolute.slice(1)).href)) : absolute,
|
|
49
|
+
exists
|
|
50
|
+
};
|
|
46
51
|
}
|
|
47
52
|
function toArray(array) {
|
|
48
53
|
if (array === null || array === void 0)
|