Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@manuel3108
Copy link
Member

Figure out how to handle adding new comments during ast processing.

@changeset-bot
Copy link

changeset-bot bot commented Jun 28, 2025

⚠️ No Changeset found

Latest commit: 3afb161

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

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jun 28, 2025

Open in StackBlitz

npx https://pkg.pr.new/sveltejs/cli/sv@620
npx https://pkg.pr.new/sveltejs/cli/svelte-migrate@620

commit: 3afb161

@svelte-docs-bot
Copy link

@manuel3108
Copy link
Member Author

This is ready as soon as we merge sveltejs/esrap#79 and update the referenced package here away from pkg.pr.new

@sacrosanctic
Copy link
Contributor

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.

Copy link
Contributor

Copilot AI left a 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 CommentState and Comments classes to manage comment associations with AST nodes
  • Updates parseScript to return both ast and commentState instead of pre-attaching comments to nodes
  • Modifies serializeScript to accept commentState parameter for proper comment serialization
  • Removes guessQuoteStyle function 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.

Copy link
Contributor

@jycouet jycouet left a 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 🎉

Copy link
Contributor

@jycouet jycouet left a 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

@manuel3108
Copy link
Member Author

Thanks! That's really an elegant change to the snapshots, expect maybe for packages/cli/tests/snapshots/create-with-all-addons/vite.config.ts. But that needs to be fixed inside esrap as you said.

@jycouet jycouet self-requested a review December 2, 2025 22:58
Copy link
Contributor

@jycouet jycouet left a comment

Choose a reason for hiding this comment

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

👍

@manuel3108
Copy link
Member Author

This got way bigger than I initially expected. Glad we got it done.

@manuel3108 manuel3108 merged commit 16166b1 into main Dec 5, 2025
8 checks passed
@manuel3108 manuel3108 deleted the chore/esrap-2 branch December 5, 2025 14:02
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.

4 participants