Skip to content

fix(sandbox): read package.json with fs instead of ESM import#119

Merged
Schniz merged 3 commits intomainfrom
fix/inject-version-json-import
Apr 1, 2026
Merged

fix(sandbox): read package.json with fs instead of ESM import#119
Schniz merged 3 commits intomainfrom
fix/inject-version-json-import

Conversation

@pranaygp
Copy link
Copy Markdown
Contributor

Summary

  • Fixes the failing Release CI job
  • The inject-version.ts script imported package.json via ESM import, which newer Node.js rejects with ERR_IMPORT_ATTRIBUTE_MISSING unless with { type: "json" } is specified
  • Replaced with fs.readFile + JSON.parse to avoid the issue entirely

Test plan

  • Release CI workflow passes on this branch

🤖 Generated with Claude Code

The CI release job fails on newer Node.js because ESM JSON imports
require `with { type: "json" }`. Use fs.readFile instead to avoid the
ERR_IMPORT_ATTRIBUTE_MISSING error.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings March 27, 2026 23:14
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Mar 27, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
sandbox Ready Ready Preview, Comment, Open in v0 Apr 1, 2026 0:05am
sandbox-cli Ready Ready Preview, Comment Apr 1, 2026 0:05am
sandbox-sdk Ready Ready Preview, Comment Apr 1, 2026 0:05am
sandbox-sdk-ai-example Ready Ready Preview, Comment Apr 1, 2026 0:05am
workflow-code-runner Ready Ready Preview, Comment Apr 1, 2026 0:05am

Request Review

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the inject-version.ts script to avoid Node.js ESM JSON import attribute errors in Release CI by reading package.json via the filesystem instead of importing it.

Changes:

  • Replace import { version } from "../package.json" with readFile + JSON.parse.
  • Compute paths to package.json and generated src/version.ts at runtime.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/vercel-sandbox/scripts/inject-version.ts Outdated
Comment thread packages/vercel-sandbox/scripts/inject-version.ts Outdated
Address review feedback:
- Derive __dirname from import.meta.url since package is type: module
- Validate that parsed version is a string before interpolating

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Member

@TooTallNate TooTallNate left a comment

Choose a reason for hiding this comment

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

I simplified it a bit for ya

@Schniz Schniz merged commit cc74dbf into main Apr 1, 2026
14 checks passed
@Schniz Schniz deleted the fix/inject-version-json-import branch April 1, 2026 00:21
marc-vercel added a commit that referenced this pull request Apr 8, 2026
Rebasing `named-sandboxes`. Commits that I am moving:

1. cf13a34 — refactor(sdk): build @vercel/sandbox with tsdown dual
outputs (#84)
2. 772989c — Support "use workflow" serialization for Sandbox and
Command (#72)
3. cc74dbf — fix(sandbox): read package.json with fs instead of ESM
import (#119)
4. a6b8ce9 — feat(skill): update beta documentation for default snapshot
expiration (#125)
5. 184cd42 — patch(vercel-sandbox): count length by bytes and not ASCII
for binaries (#127)
6. 451c42e — feat(sandbox): accept string and Uint8Array in writeFiles
content (#128)
7. ad52dec — Version Packages (#122)
8. b91b9e4 — fix(sandbox): initialize API client in Command before
reading output (#130)
9. 28237b8 — refactor(workflow-code-runner): inline Sandbox calls in
workflow function (#129)
10. 0786e18 — Version Packages (#131)
11. 9555162 — fix(sandbox): handle abort signal and early stream close
in runCommand (#135)
12. db4e5f3 — Version Packages (#137)

I had to resolve multiple merge conflicts, specially with the commits 1
and 2. I've also added some tests for them because they were touching
`sandbox.ts` for serializing and deserializing, and in this branch we
moved most of the logic to `session.ts`.

---------

Co-authored-by: Gal Schlezinger <gal@spitfire.co.il>
Co-authored-by: Luke Phillips-Sheard <luke.phillips-sheard@vercel.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: Luke PS <LukeSheard@users.noreply.github.com>
Co-authored-by: Malte Ubl <cramforce@users.noreply.github.com>
Co-authored-by: Pranay Prakash <pranay.gp@gmail.com>
Co-authored-by: Nathan Rajlich <n@n8.io>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Phil Z <pbzona@users.noreply.github.com>
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.

4 participants