fix: run frontend npm steps with cwd instead of --prefix in scaffolded build.zig#94
Open
mvanhorn wants to merge 1 commit into
Open
fix: run frontend npm steps with cwd instead of --prefix in scaffolded build.zig#94mvanhorn wants to merge 1 commit into
mvanhorn wants to merge 1 commit into
Conversation
|
@mvanhorn is attempting to deploy a commit to the Vercel Labs Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
In src/tooling/templates.zig, change the generated build.zig's frontend steps (
npm install --prefix frontendat ~line 935 andnpm --prefix frontend run buildat ~line 939) to plainnpm install/npm run buildwithfrontend_install.setCwd(b.path("frontend"))/frontend_build.setCwd(b.path("frontend")), and update the templated README snippet (~line 2746) plus the dev-command template (~line 2007) tocd frontend-style or cwd-based invocations consistent with how the runner executes them. Mirror the same change in the four checked-in example apps (examples/next, react, svelte, vue build.zig), which are copies of the template output. Update the inline std.testing assertions in templates.zig (~line 2872) that currently pin the exact"npm", "install", "--prefix", "frontend"argv.Why this matters
A macOS user hit "No binary found for darwin-x64" from the old zero-native postinstall-download dispatcher, and its suggested remedy (
npm run build:native) failed outside the repo. A Windows user reproduced the follow-on failure: the scaffolded app'szig build runexecutesnpm install --prefix frontend, and npm 10.9.3 dies with ENOENT trying to read the app root's nonexistent package.json; upgrading to npm 11 made it work. The original darwin-x64 half is already obsolete: the package is now@native-sdk/cliwith per-platform optionalDependencies (@native-sdk/cli-darwin-x64exists under packages/native-sdk/npm/) and bin/native.js no longer suggests build:native. The remaining reproducible bug in current code is the npm--prefixinvocation baked into the scaffold and examples, which breaks on npm < 11 (notably on Windows).See #56.
Testing
zig build test(or the templates.zig inline tests) passes with the updated argv assertions; generated build.zig contains cwd-scoped npm steps and no--prefix. - Edge case: scaffold an app withnative init --frontend nextand confirmzig build runinstalls frontend deps with npm 10.x semantics (no read of app-root package.json). - Edge case: examples/*/build.zig stay in sync with the template (check-framework-sync/CI template checks still pass). - Error path: npm missing from PATH still surfaces the run-step failure for the frontend-install step with a clear failed-command message.Fixes #56