vite-node 0.24.4 → 0.24.5

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.
@@ -146,9 +146,11 @@ async function handleMessage(runner, emitter, files, payload) {
146
146
  });
147
147
  break;
148
148
  case "full-reload":
149
+ notifyListeners(runner, "vite:beforeFullReload", payload);
149
150
  reload(runner, files);
150
151
  break;
151
152
  case "prune":
153
+ notifyListeners(runner, "vite:beforePrune", payload);
152
154
  payload.paths.forEach((path) => {
153
155
  const fn = maps.pruneMap.get(path);
154
156
  if (fn)
@@ -209,6 +211,7 @@ function createHotContext(runner, emitter, files, ownerPath) {
209
211
  maps.pruneMap.set(ownerPath, cb);
210
212
  },
211
213
  invalidate() {
214
+ notifyListeners(runner, "vite:invalidate", { path: ownerPath });
212
215
  return reload(runner, files);
213
216
  },
214
217
  on(event, cb) {
@@ -140,9 +140,11 @@ async function handleMessage(runner, emitter, files, payload) {
140
140
  });
141
141
  break;
142
142
  case "full-reload":
143
+ notifyListeners(runner, "vite:beforeFullReload", payload);
143
144
  reload(runner, files);
144
145
  break;
145
146
  case "prune":
147
+ notifyListeners(runner, "vite:beforePrune", payload);
146
148
  payload.paths.forEach((path) => {
147
149
  const fn = maps.pruneMap.get(path);
148
150
  if (fn)
@@ -203,6 +205,7 @@ function createHotContext(runner, emitter, files, ownerPath) {
203
205
  maps.pruneMap.set(ownerPath, cb);
204
206
  },
205
207
  invalidate() {
208
+ notifyListeners(runner, "vite:invalidate", { path: ownerPath });
206
209
  return reload(runner, files);
207
210
  },
208
211
  on(event, cb) {
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.4";
633
+ var version = "0.24.5";
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.4";
631
+ var version = "0.24.5";
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/utils.cjs CHANGED
@@ -32,15 +32,9 @@ function pathFromRoot(root, filename) {
32
32
  if (!filename.startsWith(root))
33
33
  return filename;
34
34
  const relativePath = pathe.relative(root, filename);
35
- if (!relativePath.startsWith("/") && !relativePath.startsWith("."))
36
- return `/${relativePath}`;
37
- let index = 0;
38
- for (const char of relativePath) {
39
- if (char !== "." && char !== "/")
40
- return relativePath.slice(index - 1);
41
- index++;
42
- }
43
- return relativePath;
35
+ const segments = relativePath.split("/");
36
+ const startIndex = segments.findIndex((segment) => segment !== ".." && segment !== ".");
37
+ return `/${segments.slice(startIndex).join("/")}`;
44
38
  }
45
39
  function toFilePath(id, root) {
46
40
  let absolute = (() => {
package/dist/utils.mjs CHANGED
@@ -28,15 +28,9 @@ function pathFromRoot(root, filename) {
28
28
  if (!filename.startsWith(root))
29
29
  return filename;
30
30
  const relativePath = relative(root, filename);
31
- if (!relativePath.startsWith("/") && !relativePath.startsWith("."))
32
- return `/${relativePath}`;
33
- let index = 0;
34
- for (const char of relativePath) {
35
- if (char !== "." && char !== "/")
36
- return relativePath.slice(index - 1);
37
- index++;
38
- }
39
- return relativePath;
31
+ const segments = relativePath.split("/");
32
+ const startIndex = segments.findIndex((segment) => segment !== ".." && segment !== ".");
33
+ return `/${segments.slice(startIndex).join("/")}`;
40
34
  }
41
35
  function toFilePath(id, root) {
42
36
  let absolute = (() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-node",
3
- "version": "0.24.4",
3
+ "version": "0.24.5",
4
4
  "description": "Vite as Node.js runtime",
5
5
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
6
6
  "license": "MIT",