Skip to content

feat: new reset method (#218)#271

Merged
antfu merged 4 commits intoRich-Harris:masterfrom
kermanx:master
Feb 5, 2024
Merged

feat: new reset method (#218)#271
antfu merged 4 commits intoRich-Harris:masterfrom
kermanx:master

Conversation

@kermanx
Copy link
Copy Markdown
Contributor

@kermanx kermanx commented Feb 3, 2024

New methods

The MagicString.reset method resets chars in the specified range to its original version.

The Chunk.resetToOriginal method resets the chunk to its original version. (empty intro and outro, and set edited to false)

Usage

  1. Restore previously removed range ([Feature request] Add method to restore previously removed range #218)
  2. Discard unwanted changes

I don't know much about sourcemap, so I'm not 100% sure that the sourcemap produced by this method is correct.

@antfu antfu changed the title feat: new restore method (#218) feat: new reset method (#218) Feb 4, 2024
Copy link
Copy Markdown
Collaborator

@antfu antfu left a comment

Choose a reason for hiding this comment

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

Seems like a good feature to me 👍

@antfu antfu merged commit 3dc21e2 into Rich-Harris:master Feb 5, 2024
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.

2 participants