Fix legacy plugin JSON import validation#4690
Open
roboomp wants to merge 1 commit into
Open
Conversation
- Left JSON files imported with import attributes on Bun's native loader instead of registering them with the legacy source rewrite hook. - Added a regression test for loadLegacyPiModule loading a JSON import-attribute target. Fixes #4687
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
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.
Repro
A minimal legacy plugin entry that imports
./data.jsonwithwith { type: "json" }reproduced the failure throughloadLegacyPiModule()withbun /tmp/omp-json-import-repro.ts: before the fix, Bun raisedBuildMessage: Expected ";" but found ":"because the compat graph hook served the JSON file as JavaScript.Cause
packages/coding-agent/src/extensibility/plugins/legacy-pi-compat.tscollected every relativeBun.resolveSync()target into the extension rewrite graph. That included.jsonfiles, soinstallExtensionGraphHook()intercepted the JSON module andgetLoader()fell back to"js", forcing Bun's per-module parser to parse raw JSON instead of using the native JSON loader.Fix
hasSourceModuleExtension()before registering them with the rewrite hook.loadLegacyPiModule()regression test for a temp extension importing JSON withwith { type: "json" }.Verification
bun /tmp/omp-json-import-repro.tsnow prints{ "value": true };bun test packages/coding-agent/test/extensibility/legacy-pi-inplace-load.test.ts -t 'leaves JSON import-attribute targets on Bun'passed with 1 test;bun checkpassed;bun run fixreported no fixes needed before commit. Fixes #4687