Skip to content

fix(cli): use pathToFileURL for dynamic imports in oxfmt/oxlint bin wrappers#867

Merged
fengmk2 merged 2 commits intomainfrom
fix-oxfmt-import-on-windows
Mar 14, 2026
Merged

fix(cli): use pathToFileURL for dynamic imports in oxfmt/oxlint bin wrappers#867
fengmk2 merged 2 commits intomainfrom
fix-oxfmt-import-on-windows

Conversation

@fengmk2
Copy link
Copy Markdown
Member

@fengmk2 fengmk2 commented Mar 14, 2026

On Windows, Node.js ESM loader rejects absolute paths like c:\Users\...
because it interprets the drive letter as a URL scheme. Convert resolved
paths to file:// URLs via pathToFileURL() which works on all platforms.

Also enable win32 snap tests for both wrappers since the non-LSP error
path doesn't involve dynamic imports.

Closes #865

@netlify
Copy link
Copy Markdown

netlify Bot commented Mar 14, 2026

Deploy Preview for viteplus-preview canceled.

Name Link
🔨 Latest commit 0b713b8
🔍 Latest deploy log https://app.netlify.com/projects/viteplus-preview/deploys/69b57c88fdd229000927d1d7

Copy link
Copy Markdown
Member Author

fengmk2 commented Mar 14, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

@fengmk2 fengmk2 requested a review from leaysgur March 14, 2026 14:09
@fengmk2 fengmk2 self-assigned this Mar 14, 2026
@fengmk2 fengmk2 marked this pull request as ready for review March 14, 2026 14:09
@fengmk2 fengmk2 added the bug Something isn't working label Mar 14, 2026
@fengmk2 fengmk2 force-pushed the fix-oxfmt-import-on-windows branch from e82a828 to 313d94d Compare March 14, 2026 15:02
Copy link
Copy Markdown
Contributor

@leaysgur leaysgur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you~!

Seeing snap, we may need wrapper restrictions to be more strict? (Allow only single —-lsp)

@fengmk2
Copy link
Copy Markdown
Member Author

fengmk2 commented Mar 14, 2026

Thank you~!

Seeing snap, we may need wrapper restrictions to be more strict? (Allow only single —-lsp)

I intentionally added an extra --help parameter so that it only tests the correctness of the import. The LSP correctness of oxfmt itself is not verified here.

fengmk2 added 2 commits March 14, 2026 23:08
…rappers

On Windows, Node.js ESM loader rejects absolute paths like `c:\Users\...`
because it interprets the drive letter as a URL scheme. Convert resolved
paths to file:// URLs via pathToFileURL() which works on all platforms.

Also enable win32 snap tests for both wrappers since the non-LSP error
path doesn't involve dynamic imports.

Closes oxc-project/oxc-vscode#149
Invoke bin scripts via `node` with relative path instead of relying on
PATH resolution, which fails on Windows because extensionless files are
invisible to PATHEXT-based command lookup.

Add `--lsp --help` test cases to exercise the dynamic import code path
(the pathToFileURL fix) in both wrappers.
@fengmk2 fengmk2 force-pushed the fix-oxfmt-import-on-windows branch from 313d94d to 0b713b8 Compare March 14, 2026 15:19
@fengmk2 fengmk2 merged commit d8e268d into main Mar 14, 2026
22 checks passed
Copy link
Copy Markdown
Member Author

fengmk2 commented Mar 14, 2026

Merge activity

@fengmk2 fengmk2 deleted the fix-oxfmt-import-on-windows branch March 14, 2026 15:27
@bd-dxg
Copy link
Copy Markdown

bd-dxg commented Mar 15, 2026

Merge activity

May I ask if this merger has solved the problem?

2026-03-15_08-54-26

➜ vp env current 
VITE+ - The Unified Toolchain for the Web

Environment:
  Version      25.8.0
  Source       default
  Source Path  C:\Users\bddxg\.vite-plus\config.json

Tool Paths:
  node  C:\Users\bddxg\.vite-plus\js_runtime\node\25.8.0\node.exe
  npm   C:\Users\bddxg\.vite-plus\js_runtime\node\25.8.0\npm.cmd
  npx   C:\Users\bddxg\.vite-plus\js_runtime\node\25.8.0\npx.cmd

➜ vp --version  
VITE+ - The Unified Toolchain for the Web

vp v0.1.11

Local vite-plus:
  vite-plus  v0.1.11

Tools:
  vite             v8.0.0
  rolldown         v1.0.0-rc.9
  vitest           v4.1.0
  oxfmt            v0.40.0
  oxlint           v1.55.0
  oxlint-tsgolint  v0.16.0
  tsdown           v0.21.2

@fengmk2
Copy link
Copy Markdown
Member Author

fengmk2 commented Mar 19, 2026

@bd-dxg should update vite-plus to 0.1.12

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Vite+ deleted the oxfmtrc.json file, which prevented my vscode from saving auto-formatting.

3 participants