fix: apply transform visitors to resolver-loaded tokens#730
Open
avasis-ai wants to merge 5 commits intoterrazzoapp:mainfrom
Open
fix: apply transform visitors to resolver-loaded tokens#730avasis-ai wants to merge 5 commits intoterrazzoapp:mainfrom
avasis-ai wants to merge 5 commits intoterrazzoapp:mainfrom
Conversation
…razzoapp#546) When a Buffer or other binary object is passed to the parser, it now throws a clear error instead of silently finding 0 tokens. Also updates JS API docs to use fs.readFile(filename, 'utf-8').
…pp#653) Thread the transform option through the resolver path so that transform visitors (group, token, type-specific) are applied to tokens loaded via resolver documents. Previously transforms were only applied in the non-resolver (direct token file) code path. - Extract applyTransformVisitors() from transformer() in parse/load.ts - Pass transform through loadResolver → createResolver → apply() - Apply transforms to the momoa AST in createResolver().apply() before processTokens is called - Add tests verifying visitors fire and can modify tokens via resolver
🦋 Changeset detectedLatest commit: de6eeb1 The changes in this PR will be included in the next version bump. This PR includes changesets to release 10 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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.
Fixes #653
Summary
When using
transformoption withresolvers, the transform visitors were only applied during the initial parse and not when resolvers expanded into sub-sources.Root Cause
transformwas applied inloadSources → bundle()but never threaded intoloadResolver → createResolver().apply(). Resolvers built a momoa AST from merged JS objects and skipped the transform step entirely.Changes
packages/parser/src/parse/index.ts: PasstransformtoloadResolver()packages/parser/src/parse/load.ts: ExtractapplyTransformVisitors()fromtransformer()for reusepackages/parser/src/resolver/load.ts: Threadtransformthrough the resolver pipeline; apply visitors to momoa AST beforeprocessTokens()packages/parser/test/resolver.test.ts: 2 new tests: visitors fire for resolver-loaded tokens; visitors can modify/delete tokensTest plan