Named capture groups not supported (latest Firefox and < Node 10) #366
Comments
Somewhat related (we recently had to remove the dot all regex syntax from MDX core to ensure it works inside FF as well): mdx-js/mdx#532 |
@johno Would it be preferable to destructure the match instead of use a (ES2018) capture group for now? At least until Firefox catches up and builders start using Node 10+... In Current: const [matches] = className.match(/language-(?<lang>.*)/);
return {
codeString: codeString.trim(),
className,
language:
matches && matches.groups && matches.groups.lang
? matches.groups.lang
: "",
...props
}; New (works well for me): const [,match] = className.match(/language-(.*)/);
return {
codeString: codeString.trim(),
className,
language:
match ? match : "",
...props
}; |
Yeah, AFAICT this would work well since there will never be more than one language from a code block. Though I think we'll want to use the more verbose regex here as well ( |
Would |
We have to scoop everything up until the next whitespace afaik |
@ChristopherBiscardi That's very true. const [,match] = className.match(/language-([\0-\uFFFF]*)/);
return {
codeString: codeString.trim(),
className,
language:
match ? match : "",
...props
}; |
lgtm, would accept a PR |
Describe the bug
A syntax of named capture groups is being used in
mdx-utils
that is not widely supported. Babel isn't doing much for me using their plugin for named capture groups either π€·ββοΈSpecifically in
mdx-utils
-index.js
:Any way we could run babel on this file and publish to fix firefox and builders using node?
Materials
Notes
I could be a total
derp
trying to get babel working with Gatsby because I've never had to worry about it. I have a.babelrc
file with these settings:Still no luck.
The text was updated successfully, but these errors were encountered: