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

Improve context code with MagicString #1

Open
jaredgorski opened this issue Mar 27, 2021 · 1 comment
Open

Improve context code with MagicString #1

jaredgorski opened this issue Mar 27, 2021 · 1 comment
Labels
enhancement New feature or request

Comments

@jaredgorski
Copy link
Collaborator

jaredgorski commented Mar 27, 2021

This library will outsource the complex link replacement code: https://github.com/rich-harris/magic-string

OR, I can just implement the right algorithm: walk the content backward so that I don't mess up "future" index values when replacing the links

@jaredgorski jaredgorski added the enhancement New feature or request label Mar 27, 2021
@jaredgorski jaredgorski changed the title Improve link replacement code with MagicString Improve context code with MagicString Mar 27, 2021
@jaredgorski
Copy link
Collaborator Author

MagicString's overwrite method would be used for this. Currently, I'm replacing by regex. Instead, I would need to get start and end indices for each match of regex.links.all and feed those to the overwrite method on a loop. Then, I could use toString on each call to getWordsFromIndex.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant