If babel doesn't implement it either, don't count against it#30
If babel doesn't implement it either, don't count against it#30
Conversation
| "firefox": 3, | ||
| "safari": 10, | ||
| "node": 6 | ||
| "chrome": -1, |
There was a problem hiding this comment.
This one is interesting since it seems as if the transform doesn't actually work or the compat-table is wrong for babel's data?
data/plugins.json
Outdated
| "firefox": 45, | ||
| "safari": 10, | ||
| "node": 6 | ||
| "node": 4 |
There was a problem hiding this comment.
The Function.name will be incorrect, and the function-name transform can only fix it for transformed arrow functions.
There was a problem hiding this comment.
Though I think that is the case with Node 6 too (but should be fixed in Node 7).
There was a problem hiding this comment.
var a = ()=>1
a.name // is '' in v4, 'a' in v6 & v7.
Object.defineProperty(a, 'name', { 'value': 'a', 'configurable': true });
a.name // is 'a' in v4In my arrow function use at least, name wasn't a stopper. @sindresorhus
There was a problem hiding this comment.
Yeah, it's definitely not a stopper, though it might make things more confusing when debugging, especially for functional React components.
There was a problem hiding this comment.
Interestingly out of Chrome, Edge, Firefox, and Safari, it's Firefox 49 (current stable) that still displays "" for a.name while the others display "a".
data/plugins.json
Outdated
| "firefox": 45, | ||
| "safari": 10, | ||
| "node": 5 | ||
| "node": 4 |
There was a problem hiding this comment.
Node 4 doesn't support spread, so non-transformed classes that have super(...args) will not run.
class X extends Y {
constructor (...args) {
super(...args)
}
}is invalid in node 4 regardless of the other transforms. That example constructor is useless as that is the default implementation, but when transform-class-properties runs, it has to generate a constructor with that content to attach the public property initializers:
class X extends Y {
z = null
}transforms to:
class X extends Y {
constructor (...args) {
super(...args)
this.z = null
}
}There was a problem hiding this comment.
Is it possible to change spread to account for this? Or do we need to check if a user is using spread.. or make another option
There was a problem hiding this comment.
Ok I guess we'll need to figure out a good way to override this or just not do this PR
There was a problem hiding this comment.
I wrote, a long time ago in phabricator (no idea on the bug number), that transform-rest-spread should, at least, detect if super with spread is being used, and bail if transform-es2015-classes is not also being used.
|
Closing for now, doing this may cause more issues |
|
Is there a way to opt-out of transforms? For example, say I don't want to transform arrow functions in Node 4 (I don't care about whatever edge case issue there is) but I still want the general Node 4 bar. |
|
there's the exclude option |
|
Something like "presets": [
["env", {
"exclude": ["transform-es2015-arrow-functions"],
"targets": { "node": 4 }
}]
] |
Following up on slevithan#108 (comment), this change adds [Babel] to the build process, with [babel-preset-env] to ensure browser compatibility. It defaults to supporting all ES5 browsers, but can be tweaked in the future. To reduce potential merge conflicts, this commit intentionally omits the resulting changes to `xregexp-all.js`, but they are only formatting changes anyway (you can use a tool like [prettier-diff] to see this). In particular, `'use strict';` is prepended to every module in the bundle. Of course, this shouldn't affect the API or browser compatibility. The [transform-es2015-literals] plugin is [excluded] to avoid changing unicode strings. See slevithan#174 (comment) After this commit, a separate "build" commit should be made that updates `xregexp-all.js`. [Babel]: https://babeljs.io/ [babel-preset-env]: https://github.com/babel/babel-preset-env [prettier-diff]: https://github.com/josephfrazier/prettier-diff [transform-es2015-literals]: https://www.npmjs.com/package/babel-plugin-transform-es2015-literals [excluded]: babel/babel-preset-env#30 (comment)
Following up on #108 (comment), this change adds [Babel] to the build process, with [babel-preset-env] to ensure browser compatibility. It defaults to supporting all ES5 browsers, but can be tweaked in the future. To reduce potential merge conflicts, this commit intentionally omits the resulting changes to `xregexp-all.js`, but they are only formatting changes anyway (you can use a tool like [prettier-diff] to see this). In particular, `'use strict';` is prepended to every module in the bundle. Of course, this shouldn't affect the API or browser compatibility. The [transform-es2015-literals] plugin is [excluded] to avoid changing unicode strings. See #174 (comment) After this commit, a separate "build" commit should be made that updates `xregexp-all.js`. [Babel]: https://babeljs.io/ [babel-preset-env]: https://github.com/babel/babel-preset-env [prettier-diff]: https://github.com/josephfrazier/prettier-diff [transform-es2015-literals]: https://www.npmjs.com/package/babel-plugin-transform-es2015-literals [excluded]: babel/babel-preset-env#30 (comment)
Didn't get to this at the time and the fix is actually pretty simple I think?
@jdalton mentioned in b80dfaa#commitcomment-19652847 that node 4 supports arrow-functions. It's a similar thing for other transforms which I noticed before but didn't look into. This seems to change a bunch to node 4.
the entries babel is failing at (or w/ non-spec option)
arrow functions/correct precedencearrow functions/no "prototype" property
arrow functions/lexical "super" binding in constructors
arrow functions/lexical "new.target" binding
class/computed names, temporal dead zone
class/extends null
class/new.target
super/statement in constructors
super/expression in constructors
super/constructor calls use correct "new.target" binding
super/super() invokes the correct constructor
destructuring, parameters/new Function() support
destructuring, parameters/defaults, separate scope
destructuring, parameters/defaults, new Function() support
function "name" property/new Function
function "name" property/bound functions
function "name" property/accessor properties
function "name" property/symbol-keyed methods
function "name" property/object methods (class)
function "name" property/isn't writable, is configurable
Unicode code point escapes/in identifiers
default function parameters/temporal dead zone
default function parameters/separate scope
default function parameters/new Function() support
rest parameters/can't be used in setters
rest parameters/new Function() support
spread (...) operator/with sparse arrays, in array literals
spread (...) operator/spreading non-iterables is a runtime error
RegExp "y" and "u" flags / "y" flag
RegExp "y" and "u" flags / "y" flag, lastIndex
template literals/toString conversion
generators/can't use "this" with new
generators/%GeneratorPrototype%.constructor
generators/yield * on non-iterables is a runtime error
Details