Skip to content

[CDTOOL-691] Better error reporting when JavaScript tools are missing#1640

Draft
jedisct1 wants to merge 6 commits intofastly:mainfrom
dip-proto:jsruntimes
Draft

[CDTOOL-691] Better error reporting when JavaScript tools are missing#1640
jedisct1 wants to merge 6 commits intofastly:mainfrom
dip-proto:jsruntimes

Conversation

@jedisct1
Copy link
Contributor

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:

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?

New Feature Submissions:

  • Does your submission pass tests?

Changes to Core Features:

  • Have you written new tests for your core changes, as applicable?
  • Have you successfully run tests with your changes locally?

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.

@jedisct1 jedisct1 requested a review from a team as a code owner January 27, 2026 09:51
@jedisct1 jedisct1 requested a review from kpfleming January 27, 2026 09:51
Copy link
Contributor

@kpfleming kpfleming left a 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])
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Users of the starter kits should now benefit from it!


Verify: npm --version

Then retry: fastly compute build`,
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed! The help messages have been updated to be more generic.

@kpfleming kpfleming requested a review from harmony7 January 27, 2026 14:05
@jedisct1 jedisct1 marked this pull request as draft January 28, 2026 16:21
@jedisct1 jedisct1 force-pushed the jsruntimes branch 2 times, most recently from 3bf04e9 to 456d77b Compare March 10, 2026 16:16
jedisct1 and others added 4 commits March 10, 2026 17:21
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.
As noted by @kpfleming:

Most starter kits set scripts.build to "npm run build", which
previously skipped all toolchain verification.

Now we also verify when the build script matches known defaults like
"npm run build" or "bun run build".
Build verification can also be triggered by "publish" or "serve",
so telling the user to retry with "fastly compute build" is
misleading.

Suggested by @kpfleming, thanks!
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.

2 participants