Repository navigation
runner: shim @a2ui/web_core's import attributes for the live preview - #420
Merged
Merged
Conversation
The /edit and /share preview runs on Sandpack's classic bundler, whose
babel 6 cannot parse import attributes. @a2ui/web_core 0.12 uses
`import x from './schemas/x.json' with { type: 'json' }` in its two version
entry points, so any demo built on @a2ui/react failed at setup with
"Support for the experimental syntax 'moduleAttributes' isn't currently
enabled", while the Vite build behind /d and /embed was fine.
Let a DEP_SHIMS entry name individual files to shadow in place (`files`)
instead of a single self-contained dist, and strip import attributes in
the dependency pre-transpile (import, export-from, and import() options).
Shim the two web_core files; the rest of the package stays the packager's
copy, including the package.json with its exports map.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
GreenFlux
marked this pull request as ready for review
October 7, 2026 16:29
pipeline/dep-shims.test.mjs proves a shim transpiles; it cannot prove the classic bundler then accepts the shadowed file and serves the JSON it imports. Boot the A2UI HotGrid project (the one that failed on production) through a stubbed ?payload= and assert the grid renders with no parse error. Opt-in via E2E_LIVE=1 like the other live-render checks. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Demos built on
@a2ui/reactpublish and embed fine (/d,/embedare Vite builds) but their live preview on/editand/sharefails at setup with:The classic Sandpack bundler's babel 6 cannot parse import attributes, and
@a2ui/web_core0.12 usesimport x from './schemas/x.json' with { type: 'json' }in exactly two of its ~140 files, the v0.9 and v0.8 entry points.This PR:
DEP_SHIMSentry name individual files to shadow in place ({ files: [...] }) instead of a single self-contained dist, the same per-file shadowingshimHandsontablealready does for prerelease builds. The package's ownpackage.jsonandexportsmap stay the packager's copy, so subpath imports and the shadowed files' relative imports keep resolving.import ... with {},export ... from ... with {}, and the options argument ofimport(). Babel 8 parses the clause by default; emptying the node leaves a plain JSON import for the bundler's own loader.@a2ui/web_corefiles. The shim cache key now includes the file path so multi-file entries do not collide.e2e/dep-shims-live.spec.ts, opt-in viaE2E_LIVE=1) that boots the failing project through a stubbed?payload=against the real hosted bundler and asserts the grid renders with no parse error. The project is a fixture, so no demo is created.Reproduces on https://demos.handsontable.com/edit/34326g6e4v (the A2UI recipe demo embedded by handsontable/handsontable#13734).
Test plan
pnpm testinrunner/: 2,726 passing, including newdep-shimscases for per-file shadowing, attribute stripping on import, export-from, andimport(), per-file cache keys, and an ES2017 parse of the shadowed output.pnpm typecheckclean.E2E_LIVE=1 npx playwright test e2e/dep-shims-live.spec.ts): passes in 9 s, grid rendered, JSON schema import served by the bundler.E2E_BASE_URL=https://demos.handsontable.com), which has no shim: fails, preview never renders. The test discriminates./edit/34326g6e4vpreviews.🤖 Generated with Claude Code
Note
Medium Risk
Touches the Sandpack dependency shim and transpile path used by all live previews; scope is narrow (new shim shape + attribute stripping) but incorrect shadowing could break other packages.
Overview
Fixes live Sandpack preview failures for
@a2ui/web_core0.12 demos where babel 6 rejects import attributes (with { type: "json" }) in the package’s v0.8/v0.9 entry files.Dependency shims now support a
{ files: [...] }mode that shadows only specific paths under/node_modules(like prerelease Handsontable), leaving the packager’spackage.json/exportsintact.@a2ui/web_coreis registered to shim those two entry files; shim cache keys include the file path.Pre-transpile adds a Babel plugin that strips import/export attributes and dynamic
import()options so the classic bundler can parse the shadowed sources and use its JSON loader.Tests: unit cases in
dep-shims.test.mjsfor per-file shadowing, attribute stripping, and caching; an opt-in live Playwright spec (E2E_LIVE=1) boots an a2ui-hotgrid fixture via stubbed?payload=and asserts the Handsontable grid renders without moduleAttributes parse errors.Reviewed by Cursor Bugbot for commit 523d259. Bugbot is set up for automated code reviews on this repo. Configure here.