Closed
Bug 1208421
Opened 9 years ago
Closed 8 years ago
Bower/npm: The webcompat runtime is written in ES2015 rather than ES5
Categories
(L20n :: JS Library, defect)
L20n
JS Library
Tracking
(Not tracked)
RESOLVED
FIXED
People
(Reporter: karl, Unassigned)
Details
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.99 Safari/537.36
Steps to reproduce:
I have tried to use L20n via the latest 3.0.6 release on both npm and Bower. I have also looked at the code for the previous 3.x releases, all of which exhibit the same behaviour.
Actual results:
The dist/webcompat/l20n.js file is written in ES2015 rather than ES5.
The documentation available at https://github.com/l20n/l20n.js/blob/master/docs/html.md states that "The dist/ directory contains subdirectories with different variations of L20n (called runtimes). The webcompat runtime is best suited for webpages and is written in ES5. The web runtime is written in ES2015." but that does not seem to be the case regarding the webcompat runtime.
The documentation also states "Please use v3.x if you can." followed by an instruction on how to install L20n via bower, so I believe I am using the correct setup according to the guidance.
Expected results:
The dist/webcompat/l20n.js file should be written in ES5. The file makes use of ES5-incompatible features such as Array.from and WeakSet and as such L20n does not currently seem to be very well supported by the latest stable browsers.
Perhaps the code should have been transpiled as part of the CI process with each release but somehow this step has been missed?
Comment 1•9 years ago
|
||
Thanks for filing the bug. We need to get better at maintaining the compatibility of the code. Bug 939994 is about documenting it.
There's https://github.com/l20n/l20n.js/pull/64 about supporting IE 11 and https://github.com/l20n/l20n.js/pull/44 about removing the WeakSet.
We could also replace Array.from with [...iterable] and let Babel transpile that.
Status: UNCONFIRMED → NEW
Ever confirmed: true
Thanks for your quick reply.
As the issues are disabled for the project on GitHub, I had somehow assumed that the pull requests would not be publicly visible either or I would have checked there for related issue.
Do you have any advice on which Polyfill to use for WeakSet please, as Babel's browser-polyfill.js does not seem to work in Safari 8.0.8 and es6-shim does not attempt to shim WeakMap.
Array.from seems to be less of an issue as working shims are available.
Comment 3•9 years ago
|
||
(In reply to karl from comment #2)
> Do you have any advice on which Polyfill to use for WeakSet please, as
> Babel's browser-polyfill.js does not seem to work in Safari 8.0.8 and
> es6-shim does not attempt to shim WeakMap.
That's bad. Unfortunately, I can't recommend anything else at the moment. I think the solution is to not use the WeakSet for now, actually.
Zibi, what do you think? I already updated rework https://github.com/l20n/l20n.js/pull/44 and replaced WeakSet with a regular Set. Since locals are GC'ed anyways it doesn't matter which set it is.
Flags: needinfo?(gandalf)
Comment 4•9 years ago
|
||
Hi,
I'm using latest (master) /dist/compat/web/l20n.js and getting
> 'WeakSet' is undefined
on Windows Phone 10 Silverlight XAML WebView (phone:WebBrowser). WeakSet doesn't seem to be supported by Windows Explorer at all: https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/WeakSet
Can I use this polyfill? -> https://github.com/dfcreative/weakset
Comment 5•9 years ago
|
||
(In reply to André Fiedler from comment #4)
> Can I use this polyfill? -> https://github.com/dfcreative/weakset
That should work, but I'm afraid of the number of polyfills that we require. In particular, this polyfill pollutes the objects that are added to the set with custom props, which I'm not sure I like. If there's a viable alternative in using regular Set, I think we should pursue it and remove WeakSet for now.
Zibi, do you agree?
Comment 6•8 years ago
|
||
Removing an old NI. We now have formal list of supported environments - https://github.com/l20n/l20n.js/blob/master/docs/compat.md
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Updated•8 years ago
|
Flags: needinfo?(gandalf)
You need to log in
before you can comment on or make changes to this bug.
Description
•