Skip to content

fix: make build tooling paths portable#1479

Open
KirtiRamchandani wants to merge 1 commit into
google:mainfrom
KirtiRamchandani:fix/windows-tooling-paths
Open

fix: make build tooling paths portable#1479
KirtiRamchandani wants to merge 1 commit into
google:mainfrom
KirtiRamchandani:fix/windows-tooling-paths

Conversation

@KirtiRamchandani

Copy link
Copy Markdown

Problem

Some repo build and test tooling assumes POSIX shell/path behavior. On Windows, that can break before the intended command runs:

  • prebuild uses rm -rf build.
  • Several scripts convert import.meta.url with new URL(...).pathname, which produces invalid filesystem paths for Windows drive-letter paths.
  • test:circular relies on shell glob expansion for src/*.

Root cause

URL pathnames are not filesystem paths on all platforms, and npm scripts should not depend on shell-specific cleanup or glob expansion for these commands.

Solution

  • Use fileURLToPath(import.meta.url) before passing module paths to node:path.
  • Replace the prebuild cleanup with fs.rmSync(..., { recursive: true, force: true }) through Node.
  • Run Madge against the src directory with explicit TypeScript extensions.
  • Keep the architecture script reference in sync with package.json.

Tests

  • npm run build:versions
  • npm run test:license
  • npm run test:circular
  • npm run test:size
  • node --check on modified scripts/tests
  • npx prettier --check package.json docs\architecture.md scripts\build-js.mjs scripts\build-jsr.mjs scripts\build-pkgjson-lite.mjs scripts\build-pkgjson-main.mjs scripts\build-size-limit.mjs scripts\build-tests.mjs scripts\build-versions.mjs test\extra.test.js test\it\build-jsr.test.js
  • git diff --check

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant