-
-
Notifications
You must be signed in to change notification settings - Fork 73
chore: update esrap
#620
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: update esrap
#620
Conversation
|
commit: |
|
This is ready as soon as we merge sveltejs/esrap#79 and update the referenced package here away from pkg.pr.new |
|
sveltejs/esrap#90 was merged in lieu of sveltejs/esrap#79 and released as [email protected] But I'm guessing it's not a simple package change anymore. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR updates the esrap library from ^1.4.9 to ^2.2.0 and adapts the codebase to handle the breaking changes in how comments are managed during AST processing. The new version requires explicit comment state management instead of automatically attaching comments to AST nodes.
Key Changes:
- Introduces
CommentStateandCommentsclasses to manage comment associations with AST nodes - Updates
parseScriptto return bothastandcommentStateinstead of pre-attaching comments to nodes - Modifies
serializeScriptto acceptcommentStateparameter for proper comment serialization - Removes
guessQuoteStylefunction as esrap 2.x handles quote styles internally
Reviewed changes
Copilot reviewed 19 out of 20 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| pnpm-lock.yaml | Updates esrap dependency from 1.4.9 to 2.2.0 and adjusts snapshots |
| packages/core/package.json | Updates esrap version specification to ^2.2.0 |
| packages/core/tooling/index.ts | Implements new comment handling system with CommentState and Comments classes; removes guessQuoteStyle; updates parseScript and serializeScript signatures |
| packages/core/tooling/parsers.ts | Updates parseScript wrapper to expose comments and handle new API |
| packages/core/tooling/js/index.ts | Exports Comments type for external use |
| packages/core/tooling/js/common.ts | Updates comment manipulation functions to use Comments class methods instead of direct node property manipulation |
| packages/core/tests/utils.ts | Updates test utilities to use new API; removes guessQuoteStyle tests |
| packages/core/tests/js/index.ts | Updates test runner to pass comments parameter to test run functions |
| packages/core/tests/js/common/jsdoc-type-comment/run.ts | Updates to use new Comments API |
| packages/core/tests/js/common/jsdoc-comment/run.ts | Updates to use new Comments API |
| packages/core/tests/js/object/create/run.ts | Removes direct leadingComments manipulation |
| packages/core/tests/js/vite/with-satisfies/output.ts | Test snapshot update reflecting formatting changes from esrap 2.x |
| packages/core/tests/js/vite/add-plugin-mode/output.ts | Test snapshot update reflecting formatting changes from esrap 2.x |
| packages/core/tests/js/object/property-node/output.ts | Test snapshot update reflecting formatting changes from esrap 2.x |
| packages/core/tests/js/object/override-property/output.ts | Test snapshot update reflecting formatting changes from esrap 2.x |
| packages/core/tests/js/object/ensure-nested-property/output.ts | Test snapshot update reflecting formatting changes from esrap 2.x |
| packages/core/tests/js/object/create/output.ts | Test snapshot update reflecting formatting and removed prettier-ignore comment |
| packages/core/tests/js/common/jsdoc-type-comment/output.ts | Test snapshot update showing comment formatting change |
| packages/addons/sveltekit-adapter/index.ts | Updates to use new Comments API; implements comment filtering by modifying original array |
| packages/addons/eslint/index.ts | Updates to use new Comments API with addLeading method |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <[email protected]>
jycouet
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I need to pull it locally to see a bit more :)
Will do in coming days.
Thx 🎉
jycouet
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
I did a small test with the test snapshot branch to see a bit the diff for users...
39cfdf8
Quite small 👍
Some are better than before!
Some can be improve in esrap later
|
Thanks! That's really an elegant change to the snapshots, expect maybe for |
jycouet
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
|
This got way bigger than I initially expected. Glad we got it done. |
Figure out how to handle adding new comments during ast processing.