Skip to content

fix(website): Strip multiline imports in playground transformCode#4031

Merged
ntucker merged 3 commits into
masterfrom
fix/playground-multiline-import-transform
Jul 12, 2026
Merged

fix(website): Strip multiline imports in playground transformCode#4031
ntucker merged 3 commits into
masterfrom
fix/playground-multiline-import-transform

Conversation

@ntucker

@ntucker ntucker commented Jul 12, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Teach transformCode to remove complete static imports (including Prettier multiline / import type) and export-list/re-export declarations before stripping export prefixes
  • Fixes GraphQL homepage demos that SyntaxError’d on leftover } from '@data-client/graphql'
  • Wire website/src/components/Playground into the ReactDOM Jest roots so these regressions are covered in CI

Test plan

  • yarn test --selectProjects ReactDOM --testPathPatterns 'transformCode|codeModel'
  • Homepage: switch Reactive Mutations to GraphQL — live preview renders (no SyntaxError)
  • REST / polling demos still preview correctly

Note

Low Risk
Scoped to website playground string preprocessing and CI/Jest wiring; no auth, data, or package runtime changes.

Overview
Fixes GraphQL (and other) homepage playground previews that SyntaxError’d when Prettier-style multiline imports were only partially stripped, leaving orphan } from '…' fragments.

transformCode no longer uses a single-line regex on import/export. It now removes full static import declarations (including multiline and import type), export lists/re-exports, then strips remaining export prefixes—while preserving bodies like GraphQL resource classes and import.meta.

CI: CircleCI persists website/src/components/Playground into the workspace; Jest’s ReactDOM project adds that root only when the folder exists, and new transformCode unit tests lock in the behavior.

Reviewed by Cursor Bugbot for commit 05737e0. Bugbot is set up for automated code reviews on this repo. Configure here.

Prettier-wrapped import { … } from blocks were only partially removed,
leaving orphan } from '…' syntax that broke GraphQL live previews.
Also include Playground tests in the ReactDOM Jest project.

Co-authored-by: Cursor <cursoragent@cursor.com>
@changeset-bot

changeset-bot Bot commented Jul 12, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 05737e0

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel

vercel Bot commented Jul 12, 2026

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs-site Ignored Ignored Preview Jul 12, 2026 7:52pm

Request Review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 95aef71. Configure here.

Comment thread website/src/components/Playground/transformCode.ts Outdated
Require whitespace or a from-clause before the module string so
import './setup' is stripped like other static imports.

Co-authored-by: Cursor <cursoragent@cursor.com>
CircleCI attach_workspace omits website/, so a hard-coded Jest root
failed validation. Only add the Playground root when present, and
persist that path so ReactDOM CI still runs transformCode/codeModel.

Co-authored-by: Cursor <cursoragent@cursor.com>
@codecov

codecov Bot commented Jul 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.84%. Comparing base (93555f8) to head (05737e0).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4031      +/-   ##
==========================================
- Coverage   98.21%   97.84%   -0.38%     
==========================================
  Files         154      156       +2     
  Lines        3024     3057      +33     
  Branches      601      612      +11     
==========================================
+ Hits         2970     2991      +21     
- Misses         11       18       +7     
- Partials       43       48       +5     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ntucker
ntucker merged commit 8845a31 into master Jul 12, 2026
24 checks passed
@ntucker
ntucker deleted the fix/playground-multiline-import-transform branch July 12, 2026 20:07
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.

1 participant