Skip to content
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

feat: introduce offset #297

Merged
merged 5 commits into from
Dec 16, 2024
Merged

feat: introduce offset #297

merged 5 commits into from
Dec 16, 2024

Conversation

zhiyuanzmj
Copy link
Contributor

@zhiyuanzmj zhiyuanzmj commented Dec 12, 2024

close #296

Sets the offset property to adjust the incoming position for the following APIs: slice, update, overwrite, appendLeft, prependLeft, appendRight, prependRight, move, reset, and remove.

const s = new MagicString('hello world', { offset: 6 })
s.slice() === 'world'

const s1 = new MagicString('hello world', { offset: 6 })
s1.slice() === 'world'
s1.offset = 8
s1.slice() === 'rld'

Verified

This commit was signed with the committer’s verified signature.
Aaron1011 Aaron Hill
@antfu
Copy link
Collaborator

antfu commented Dec 13, 2024

This makes me wonder, if we should have the offset function directly in the MagicString class and make it immutable. But yeah it's also tricky as it's different from .clone this would write back to the original instance

@zhiyuanzmj zhiyuanzmj changed the title feat: introduce withOffset feat: introduce offset Dec 13, 2024

Verified

This commit was signed with the committer’s verified signature.
Aaron1011 Aaron Hill

Verified

This commit was signed with the committer’s verified signature.
Aaron1011 Aaron Hill

Verified

This commit was signed with the committer’s verified signature.
Aaron1011 Aaron Hill
@zhiyuanzmj zhiyuanzmj requested a review from antfu December 13, 2024 12:45
@antfu antfu merged commit 29f260e into Rich-Harris:master Dec 16, 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.

Feat: add offfset option to support Vue SFC
2 participants