-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
JS/JSX: Add support for recursive expressions #2163
base: master
Are you sure you want to change the base?
JS/JSX: Add support for recursive expressions #2163
Conversation
Another one worth refreshing for bundle size impacts. |
JS File Size Changes (gzipped)A total of 4 files have changed, with a combined diff of +261 B (+4.5%).
|
@RunDevelopment this looks really interesting, but I'm not sure how to help since a lot of it seems to be* out of date at this point. Do you think this is worth picking back up again? |
Not in its current form, no. This PR relies on a sorta hack to share regexes across languages. I'd rather wait for v2 where we can just directly import/export regexes via ESM. |
So after #2159 I wanted to add support for arbitrary JS spread expressions and kinda overdid it. I also added support for deeply nested expressions in JS template string interpolations.
Because I need very similar patterns in #2139, I decided that JS is going to share its patterns and added a way for languages to share internal patterns. It's done via a non-enumerable property
$
. Because the property is non-enumerable, it won't be cloned (e.g. forextend
) but it will be kept byinsertBefore
.Btw. I'm not very attached to this version by variable sharing, so better ideas are very welcome.
Edit: Maybe we could do a
Prism.patterns
for globally shared patterns (RegExp or string)?This PR is a 3 in 1: JS Template strings, JSX spread expressions, and the
$
property.