Commit 7952751
authored
fix(cli): import local versions module via file URL (#2749)
## Summary
Fix loading tool versions from the locally installed `vite-plus` package
by converting the generated `dist/versions.js` filesystem path to a
`file://` URL before passing it to dynamic `import()`.
## Why
Dynamic `import()` expects a valid module specifier. Passing an absolute
filesystem path directly is not portable, especially for Windows
drive-letter paths such as `C:\...`, which may be interpreted
incorrectly by Node's ESM loader.
Using `pathToFileURL()` produces a valid file URL and allows the
generated versions module to be imported consistently across platforms.
## Changes
* Build the path to `dist/versions.js` with `path.join()`
* Convert the filesystem path with `pathToFileURL()`
* Import the generated versions module using the resulting `file://` URL
🤖 Generated with Codex1 parent ed9cdb1 commit 7952751
4 files changed
Lines changed: 38 additions & 1 deletion
File tree
- crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_version_local_tools
- snapshots
- packages/cli/src
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
Lines changed: 23 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| |||
66 | 67 | | |
67 | 68 | | |
68 | 69 | | |
69 | | - | |
| 70 | + | |
| 71 | + | |
70 | 72 | | |
71 | 73 | | |
72 | 74 | | |
| |||
0 commit comments