Skip to content

Commit 2a1b3d0

Browse files
committed
fix(build): use fileURLToPath for cross-platform path comparison in esbuild
The esbuild config was comparing import.meta.url directly with process.argv[1] to detect direct invocation. On Windows, this comparison always failed because: - import.meta.url: `file:///D:/path/to/file.mjs` (forward slashes, triple slash) - process.argv[1]: `D:\path\to\file.mjs` (backslashes) This caused the build() function to never run on Windows. The script would just export the config and exit with code 0, which is why the build reported success without creating any files. Fix: Use fileURLToPath(import.meta.url) to normalize the URL to a file path that matches process.argv[1] on all platforms. This was the root cause of all Windows CI failures - the build wasn't actually running, so no dist/cli.js was created, causing ~180 tests to fail.
1 parent 3f2b050 commit 2a1b3d0

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

packages/cli/.config/esbuild.cli.build.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,8 @@ const config = {
371371
}
372372

373373
// Run build if invoked directly.
374-
if (import.meta.url === `file://${process.argv[1]}`) {
374+
// Use fileURLToPath to handle Windows paths correctly.
375+
if (fileURLToPath(import.meta.url) === process.argv[1]) {
375376
build(config).catch(error => {
376377
console.error('Build failed:', error)
377378
process.exitCode = 1

0 commit comments

Comments
 (0)