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

Use RegExp constructor instead of using literal expression #444

Open
mukiienko opened this issue Jan 7, 2020 · 2 comments
Open

Use RegExp constructor instead of using literal expression #444

mukiienko opened this issue Jan 7, 2020 · 2 comments

Comments

@mukiienko
Copy link

Hi guys, I have an issue with IE11 because it doesn't support sticky 'y' RegExp flag.
The last release of core-js polyfilled sticky flag, but it works if we use the constructor for creating RegExp expression. For instance:

//worked example in IE11
new RegExp(/\d/, 'y')

//not worked example in IE11
/\d/y

We don't use wepback, so we can't use babel in our stack, thus we can't use any babel transpiler.
Tell me please is it possible to migrate fluent.js from literal RegExp expression to constructor?
I can create PR for this change if you don't mind.
Thanks!

P.S. I know fluent.js officially doesn't support IE11

@stasm
Copy link
Contributor

stasm commented Jan 16, 2020

Thanks for opening this issue, @mukiienko. Lately, there has been some interest in getting Fluent to work in IE11, which might be of interest to you: https://discourse.mozilla.org/t/working-with-the-team-to-support-ie11/48273/8

I'm torn on the issue itself. From my experience there's no such thing as partially supporting a browser; it's either we support it, or we explicitly don't support it. It's true the in this particular case we could replace all regex literals with constructors, and the code could work in IE11. But without a change in the browser support matrix and the official fluent.js-wide policy, the risk of using another incompatible JS feature in the future would be significant. That's why I'm leaning against making this particular change to our codebase at this time. @Pike, do you have more thoughts on this?

I think that the proper solution to use-cases like yours is to document a build setup which allows users of fluent.js to produce their custom compat builds. I'd be more than willing to help kick start such documentation.

In any case, it would be best to wait a couple of weeks before moving forward. I'm almost done with porting @fluent/bundle to TypeScript (#436); I expect to land it early next week. I also filed #435 about a larger attempt to redefine our compatibility strategy.

@Pike
Copy link
Contributor

Pike commented Jan 17, 2020

I think it makes sense to look at our options in a post-TS world again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants