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.
(I'm lazy, so description just copied from commits)
Just like move (from where the main idea is copied), but keeps the original
chunks in place.
The implementation currently suffers from one drawback - the new chunks
aren't added into the byStart/byEnd indexes - since these index by original
location, the index would now have to lead to 2 locations. So if you copy
first, then overwrite/append/prepend, the changes are only written in the
original location, not on the copied snippet. However, if you do anything
before copying, the changes are carried over.
Regarding the added test and changes in package.json:
In test/dev builds, DEBUG is replaced with true, which runs additional
code marking the 'duplicate' chunks created by .copy() with chunk.isCopy.
This is detected in integrity checker in tests - these chunks are,
as described in previous commit, not included in the indexes, which
isn't easy to solve, so these chunks are just excluded from the check.
In production code (verified with npm run publish), DEBUG is replaced
with false and the code becomes unreachable and is tree-shaked.
Why I'm implementing this
For
svelte-check
- the type-checking (the svelte2tsx step) aroundsvelte:component this={x} bind:this={y}
is simplified (well, pretty much non-existent), and the copy feature is required for implementing it correctly. I hope this could help other projects as well.Does the resulting source map work
I believe so