Skip to content

fix(prerender): handle JSON imports during prerender bundling#1580

Merged
Tobbe merged 3 commits intocedarjs:mainfrom
lisa-assistant:lisa/fix-prerender-json-import
Apr 11, 2026
Merged

fix(prerender): handle JSON imports during prerender bundling#1580
Tobbe merged 3 commits intocedarjs:mainfrom
lisa-assistant:lisa/fix-prerender-json-import

Conversation

@lisa-assistant
Copy link
Copy Markdown
Contributor

Summary

  • Rollup's prerender build had no JSON transform plugin, so any page that transitively imported a .json file (e.g. .cedar/gqlorm-schema.json) would fail with RollupError: Expected ';', '}' or <eof>
  • Added a simple inline transform plugin that wraps .json file contents as a default export, matching the core behavior of @rollup/plugin-json

Reproduction

RollupError: .cedar/gqlorm-schema.json (2:15): Expected ';', '}' or <eof>
(Note that you need @rollup/plugin-json to import JSON files)

Test plan

  • Run yarn cedar prerender --dry-run on a project that imports .cedar/gqlorm-schema.json (directly or transitively) — should no longer throw
  • Confirm existing prerender tests still pass

🤖 Generated with Claude Code

Rollup's prerender build didn't have a JSON transform plugin, so any page
that transitively imported a .json file (e.g. .cedar/gqlorm-schema.json)
would fail with "Expected ';', '}' or <eof>". Add a simple inline transform
plugin that wraps JSON file contents as a default export.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@netlify
Copy link
Copy Markdown

netlify bot commented Apr 10, 2026

Deploy Preview for cedarjs canceled.

Name Link
🔨 Latest commit ecb4c69
🔍 Latest deploy log https://app.netlify.com/projects/cedarjs/deploys/69da9099991dc600081482d0

@nx-cloud
Copy link
Copy Markdown

nx-cloud bot commented Apr 10, 2026

🤖 Nx Cloud AI Fix

Ensure the fix-ci command is configured to always run in your CI pipeline to get automatic fixes in future runs. For more information, please see https://nx.dev/ci/features/self-healing-ci


View your CI Pipeline Execution ↗ for commit ecb4c69

Command Status Duration Result
nx run-many -t build:pack --exclude create-ceda... ✅ Succeeded 2s View ↗
nx run-many -t build ✅ Succeeded 8s View ↗
nx run-many -t test --minWorkers=1 --maxWorkers=4 ✅ Succeeded 1m 28s View ↗
nx run-many -t test:types ✅ Succeeded 10s View ↗

☁️ Nx Cloud last updated this comment at 2026-04-11 18:42:31 UTC

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Apr 10, 2026

Greptile Summary

This PR fixes prerender bundling failures caused by .json files (e.g. .cedar/gqlorm-schema.json) not being transformed into valid JS. A small inline Rollup transform plugin is added that round-trips file content through JSON.parse/JSON.stringify and emits export default {...}, matching the core behavior of @rollup/plugin-json without adding a new dependency. The docs in docs/implementation-docs/2026-03-26-cedarjs-project-overview.md remain factually accurate — the high-level prerender description and build pipeline descriptions are unaffected by this change.

Confidence Score: 5/5

Safe to merge — targeted fix with no regressions, correct JSON normalization via JSON.parse/JSON.stringify.

No P0 or P1 issues found. The implementation correctly normalizes JSON content (addressing the prior thread concern about raw byte pass-through). The inline plugin avoids a new dependency, plugin ordering is correct, and the fix is scoped entirely to the prerender bundling path.

No files require special attention.

Important Files Changed

Filename Overview
packages/prerender/src/build-and-import/buildAndImport.ts Adds an inline Rollup transform plugin that round-trips JSON through JSON.parse/JSON.stringify before emitting as a default-export ES module, fixing prerender failures on pages with .json transitive imports.

Reviews (3): Last reviewed commit: "Merge branch 'main' into lisa/fix-preren..." | Re-trigger Greptile

Comment thread packages/prerender/src/build-and-import/buildAndImport.ts
Tobbe and others added 2 commits April 10, 2026 19:52
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
@Tobbe Tobbe merged commit 872ff5e into cedarjs:main Apr 11, 2026
45 checks passed
@github-actions
Copy link
Copy Markdown

The changes in this PR are now available on npm.

Try them out by running yarn cedar upgrade -t 4.0.0-canary.13785

Or try it in a new app with yarn dlx create-cedar-app@4.0.0-canary.13785

Tobbe added a commit that referenced this pull request Apr 11, 2026
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: Tobbe Lundberg <tobbe@tlundberg.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
@Tobbe Tobbe modified the milestones: next-release-patch, v4.0.0 Apr 12, 2026
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