-
Notifications
You must be signed in to change notification settings - Fork 71
[CDTOOL-691] Better error reporting when JavaScript tools are missing #1640
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Validate JavaScript toolchains before attempting a build, catching common setup issues early and providing accurate error messages instead of build failures. As Bun becomes increasingly popular, it’s not ideal to ask users to install Node when they already have Bun. So, this PR also adds proper support for Bun as an alternative runtime. The verification detects whether a project uses Node.js or Bun by checking for lockfiles, with support for Bun workspaces where the lockfile lives at the workspace root rather than in the subpackage. When something is missing, the error message now explains exactly what's wrong and how to fix it, whether that's installing a runtime, running npm install, or adding the @fastly/js-compute package.
kpfleming
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only some comments for now, overall this looks like a nice improvement. I'll ask @harmony7 to also review this since he's our JavaScript runtime expert.
|
|
||
| usesWebpack, err := j.checkForWebpack() | ||
| if err != nil { | ||
| // Only verify toolchain when using default build (no custom [scripts.build]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be an issue, since most (possibly all) of our JavaScript starter kits include a scripts.build property, and that means users using those starter kits won't benefit from any of this verification logic.
It may be possible to do the verification even if scripts.build is set, as long as its value is exactly npm run build which is what we have in the starter kits.
|
|
||
| Verify: npm --version | ||
|
|
||
| Then retry: fastly compute build`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In each case where a 'retry' suggestion is provided we may need to do something more complicated, because the user may not have run fastly compute build - they may have run fastly compute publish or fastly compute serve, both of which internally run fastly compute build.
| - feat(service/ratelimit): moved the `rate-limit` commands under the `service` command, with an unlisted and deprecated alias of `rate-limit` ([#1632](https://github.com/fastly/cli/pull/1632)) | ||
| - feat(compute/build): Remove Rust version restriction, allowing 1.93.0 and later versions to be used. ([#1633](https://github.com/fastly/cli/pull/1633)) | ||
| - feat(service/resourcelink): moved the `resource-link` commands under the `service` command, with an unlisted and deprecated alias of `resource-link` ([#1635](https://github.com/fastly/cli/pull/1635)) | ||
| - feat(compute/build): improved error messaging for JavaScript builds with pre-flight toolchain verification including Bun runtime support |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add the PR link to this line, following the example of the other CHANGELOG lines.
Change summary
Validate JavaScript toolchains before attempting a build, catching common setup issues early and providing accurate error messages instead of build failures.
As Bun becomes increasingly popular, it’s not ideal to ask users to install Node when they already have Bun. So, this PR also adds proper support for Bun as an alternative runtime.
The verification detects whether a project uses Node.js or Bun by checking for lockfiles, with support for Bun workspaces where the lockfile lives at the workspace root rather than in the subpackage.
When something is missing, the error message now explains exactly what's wrong and how to fix it, whether that's installing a runtime, running npm install, or adding the @fastly/js-compute package.
All Submissions:
New Feature Submissions:
Changes to Core Features:
User Impact
Use get better guidance and can use Bun as an alternative Runtime.
Are there any considerations that need to be addressed for release?
No breaking changes.