bevry / base

Base files for new projects
Other
30 stars 14 forks source link

Achieve Node 0.10 and IE8 compatibility somehow #20

Closed balupton closed 8 years ago

balupton commented 8 years ago

See https://github.com/bevry/cson/issues/68 and https://phabricator.babeljs.io/T6987 as to why

One option is to use babel's loose mode. Loose mode can be opted-in selectively:

{
    "presets": ["es2015"],
    "plugins": [
        ["transform-es2015-for-of", {
            "loose": true
        }]
    ]
}

All all-in:

Would need to go through already published modules and be more intelligent on how we've done loops now.

balupton commented 8 years ago

Let's go all in with loose mode, as apparently it is faster due to inherent V8 optimisations... if it causes problems we'll switch to selective opt-in. Any objections?

balupton commented 8 years ago

Turns out there are many issues with going all in.

Discussion on slack arose: https://babeljs.slack.com/archives/plugins/p1453108840000636

Example issue:

Essentially:

Yeah. It is all really confusing. As essentially the differences between the modes (loose and no loose), both take the same input code, but can actually produce different output results, which may or may not go detected. Saying it just about performance, or about how the code is done, is misleading, as unfortunately, the situation seems to be - use loose mode for performant ES5 output for browsers like IE8 however ES6 features and input may fail secretly on you - or use ESNext features like for-of without loose mode, and have things fail secretly for you in ES5 environments like IE8 - either way there seems to be dragons in cross-browser use cases. https://babeljs.slack.com/archives/plugins/p1453169847000667

To just continue on from my last paragraph… It is quite a dilemma for me, as my libraries are used in all sorts of environments, modern and old, for instance, mostly node v5 environments, however Meteor users (who still run node 0.10) encounter the “missing Symbol” error of non-loose babel compilation of for-of loops on arrays - and it seems that with the current options, I either need to compile to code that will work fine for Meteor users on node 0.10 and then have secret failures with integration with ESNext code, or to compile to ESNext code and tell Meteor and older-browser users, tough luck https://babeljs.slack.com/archives/plugins/p1453170370000679

The solution could be to:

  1. Publish esnext version with esnextguardian fallback to normal es2015 babel code (no loose mode)
  2. Inform developers coding for older environments (e.g. node 0.10 and IE8 users) that they will need to include the babel polyfill or the babel runtime
balupton commented 8 years ago

@johnthepink can I get your opinion on whether or not including the babel polyfill or the babel runtime for your meteor app is good enough a solution? /cc https://github.com/bevry/cson/pull/69

johnthepink commented 8 years ago

@balupton We are currently good with our fork. We don't want to stand in the way of the project moving forward. Meteor is hopefully going to upgrade node versions soon, and until then we will just use our fork.

That being said, if you get babel in there somehow, we should be able to use it. Thanks!

balupton commented 8 years ago

Will drop 0.10 support. It will be up to the user to include the babel polyfill for environments less than node 0.12.