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.
This adds a Regex Replace node based on Rust's regex crate. I will soon release a new version of chainner_ext with the classes used by this PR.
This node also comes with type support. I added a new builtin function
regexReplace
that does regex replacements in the type system. This function is implemented using rregex, which we already used. Unfortunately, rregex does not export Rust's capturing groups. This means that we cannot do replacements that reference capturing groups in the type system. This is a huge limitation and I already opened on issue about this (2fd/rregex#32).And now a little rant:
I hate NodeJS. I literally spend a day just getting rregex to work. While NodeJS support WASM just fine, its fucky module system ruined my day once again. You see, WASM files are, well, files, so the atrocious ESM support of NodeJS rears its ugly head again.
No joke, I spend a day on this. I first thought that rregex not working is a webpack thing, but no. In the end, I used
require
to import a different distribution of rregex depending on whether the main process (NodeJS) or the renderer (Chromium) is importing rregex. That works IF you also manually copy over the actual WASM file. Webpack has a heuristic (that just works™) for which files to include in the distribution since NodeJS packages like tofs.read
files. While this heuristic is supposed to be super conservative, so that everything just works™, it failed here. So why did the heuristic fail? NodeJS. It's very hard to statically evaluate thepath.join
s with__dirname
and so on, so I don't blame webpack at all. I do however blame NodeJS for not supporting ESM properly which trivially solves this problem withimport.meta.url
.