babel / babel Goto Github PK
View Code? Open in Web Editor NEWπ Babel is a compiler for writing next generation JavaScript.
Home Page: https://babel.dev
License: MIT License
π Babel is a compiler for writing next generation JavaScript.
Home Page: https://babel.dev
License: MIT License
Could you explain what functionality is lost when not including a runtime? In other words, what operations can be performed with Traceurβs ~75KB runtime?
(Sorry for my ignorance.)
Error: no templates directory - this is most likely the result of a broken `npm publish`. Please report to https://github.com/sebmck/6to5/issues
Is this a user error or a package error?
I know you're going for ease of use here, but it would be best if users get a clear consensus on modules between projects, otherwise interop suffers.
Here's the corrections I would make. No pressure at all - it is your project.
import "foo"; // var foo = require("foo");
import "foo-bar"; // var fooBar = require("foo-bar");
import "./directory/foo-bar"; // var fooBar = require("./directory/foo-bar");
import foo from "foo"; // var foo = require("foo");
import * as foo from "foo"; // var foo = require("foo");
import { bar } from "foo"; // var bar = require("foo").bar;
import foo as bar from "foo"; // var bar = require("foo").foo;
export { test }; // exports.test = test;
export var test = 5; // var test = 5; exports.test = test;
export default test; // module.exports = exports = test;
Should be
import "foo"; // require("foo");
import "foo-bar"; // require("foo-bar");
import "./directory/foo-bar"; // require("./directory/foo-bar");
import foo from "foo"; // var foo = require("foo").default;
import * as foo from "foo"; // var foo = require("foo");
import {bar} from "foo"; // var bar = require("foo").bar;
import {foo as bar} from "foo"; // var bar = require("foo").foo;
export {test}; // exports.test = test;
export var test = 5; // var test = 5; exports.test = test;
export default test; // exports.default = test;
Happy to continue the discussion. There are also variations to allow better interop with existing CommonJS if you want to dive into that topic, which I'm always happy to.
I'm preparing a gulpfile using, among others, the gulp-6to5 plugin. I'm not sure this is an issue with transpiling ... somehow it looks more of an issue with gulp streams, anyway I'm posting it here as suggested in plugin page.
When running the following gulp task (sixToFive is 'gulp-6to5'):
gulp.task('build', ['setup', 'clean', 'compile']);
[...]
gulp.task('compile', function () {
var compress = lazypipe()
.pipe(concat, 'all.js')
.pipe(uglify);
return gulp.src('src/lib/**/*.js')
.pipe(sourcemaps.init())
.pipe(sixToFive())
.pipe(gulpif(config.production, compress))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest(paths.dist));
});
I got the following error:
[03:47:06] 'compile' errored after 13 ms
[03:47:06] TypeError: Object function () {
validateSteps(steps);
return combine.apply(null, steps.map(function(t) {
return t.task.apply(null, t.args);
}));
} has no method 'on'
at DestroyableTransform.Readable.pipe (..rootDir..\node_modules\gulp-6to5\node_modules\through2\node_modules\read
able-stream\lib\_stream_readable.js:516:8)
at Gulp.gulp.task.mochaOptions.ui (..rootDir..\gulpfile.js:54:6)
at module.exports (..rootDir..\node_modules\gulp\node_modules\orchestrator\lib\runTask.js:34:7)
at Gulp.Orchestrator._runTask (..rootDir..\node_modules\gulp\node_modules\orchestrator\index.js:273:3)
at Gulp.Orchestrator._runStep (..rootDir..\node_modules\gulp\node_modules\orchestrator\index.js:214:10)
at ..rootDir..\node_modules\gulp\node_modules\orchestrator\index.js:279:18
at finish (..rootDir..\node_modules\gulp\node_modules\orchestrator\lib\runTask.js:21:8)
at cb (..rootDir..\node_modules\gulp\node_modules\orchestrator\lib\runTask.js:29:3)
at Gulp.<anonymous> (..rootDir..\gulpfile.js:43:3)
at module.exports (..rootDir..\node_modules\gulp\node_modules\orchestrator\lib\runTask.js:34:7)
(..rootDir..
is just not to show long paths here in the post)
http://github.com/esnext/es6-module-transpiler
Maybe i mis-understood the chart.
See https://mathiasbynens.be/notes/es6-unicode-regex for more info on this feature.
Hereβs a module you can use for the transpilation: https://github.com/mathiasbynens/regexpu Traceur depends on regexpu as well.
I'm new to ES6 so I'm not sure if this is a bug or a feature.
I have this little piece of code:
function student () {
let isStudent = true;
return Object.freeze({
isStudent
});
}
6to5 transpiles it into:
function student() {
(function () {
var isStudent = true;
return Object.freeze({ isStudent: isStudent });
}());
}
whereas the Traceur and es6-transpiler output looks like:
function student () {
var isStudent = true;
return Object.freeze({
isStudent: isStudent
});
}
My problem here is that the code transpiled by 6to5 returns an undefined while the others return the desired freezed object. Now I'm curious if this is a brain or a software bug.
class Blah extends Foo {
constructor() {
super(...arguments);
}
}
Generates a super call that looks like this.
Foo.call.apply(null, [this].concat(Array.prototype.slice.call(arguments)));
Currently getting around this by doing gross workarounds like this.
var s = super;
s.apply(this, arguments);
If I make a file such as:
require('6to5/register')
require('6to5/polyfill')
class A {
constructor() {
console.log('A')
}
}
var a = new A()
I will get the following error:
class A {
^^^^^
SyntaxError: Unexpected reserved word
at Module._compile (module.js:439:25)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:906:3
but if I put class A
in it's own file and require it, everything work as expected.
Not sure if we are missing something very obvious here, but each time we run a build from npm
(in turn invoking gulp.js
) we see this warning.
We read that this is due to the README.md
not present in downloaded module, and as a matter of fact that could not be found in node_modules\6to5
, but still that exists here on github repo.
Nothing serious, just a little annoying. Thanks and keep up the good work!
~/code/es6test β uname -rvps
Linux 3.13.0-36-generic #63-Ubuntu SMP Wed Sep 3 21:30:07 UTC 2014 x86_64
~/code/es6test β node -v
v0.10.30
~/code/es6test β npm -v
1.4.21
~/code/es6test β 6to5 -V
0.2.0
~/code/es6test β npm install -g sebmck/6to5
/usr/local/bin/6to5 -> /usr/local/lib/node_modules/6to5/bin/6to5
/usr/local/bin/6to5-node -> /usr/local/lib/node_modules/6to5/bin/6to5-node
[email protected] /usr/local/lib/node_modules/6to5
βββ [email protected]
βββ [email protected]
βββ [email protected]
βββ [email protected]
βββ [email protected] ([email protected])
βββ [email protected]
βββ [email protected] ([email protected])
βββ [email protected]
βββ [email protected] ([email protected], [email protected], [email protected], [email protected])
~/code/es6test β echo "[1, 2, 3].map(x => x * x)" > test.js
~/code/es6test β 6to5 test.js
[
1,
2,
3
].map(function (x) {
return x * x;
});
~/code/es6test β 6to5 test.js --out-file compiled-test.js
fs.js:432
return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
^
TypeError: path must be a string
at Object.fs.openSync (fs.js:432:18)
at Object.fs.writeFileSync (fs.js:971:15)
at Object.<anonymous> (/usr/local/lib/node_modules/6to5/bin/6to5:139:8)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:906:3
var to5 = require('6to5');
var result = to5.transform('let foo = {bar: "baz"};\n var {bar} = foo;', {filename:'foo.js',sourceMap: true});
var sourceMap = result.split('\n').splice(-2, 1)[0].slice(50);
console.log((new Buffer(sourceMap, 'base64')).toString());
// {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
class A { toString() { return 'a'; } }
class B extends A { toString() { return 'b(' + super() + ')'; } }
console.log(new B().toString());
This should print b(a)
, but right now it prints b(undefined)
because super()
turns into A.call(this)
when this would be closer: A.prototype.toString.call(this)
.
Probably a noob question since I'm a novice with source maps. When I pass in a path+file to options.filename
, (ex: /app/script/test.js
) while generating source maps, the source map has sources[0]
set to test.js
and sourceRoot
is not defined, meaning that information on the path is nowhere. Shouldn't it appear or able to be inferred somehow? (full path on sources[0]
or directory in sourceRoot
) I haven't seen this problem with other source maps.
Could be just one option.
Instead of:
// Append source map and comment to bottom of returned output.
sourceMap: false,
// Returns an object `{ code: "", map: {} }` instead of an appended string.
sourceMapObject: false,
You could have:
sourceMap: 'inline',
sourceMap: 'external', // or a better word?
sourceMap: false
Is this a bug or semantically not allowed?
let some = (count = "30") => {
console.log('count', count);
}
some();
// foo.js
var obj = {
["x" + foo]: "heh",
["y" + bar]: "noo",
foo: "foo",
bar: "bar"
};
$ 6to5 foo.js
var obj = function (obj) {
obj['x' + foo] = 'heh';
obj['y' + bar] = 'noo';
return obj;
}({
foo: 'foo',
bar: 'bar'
});
That would result in: ReferenceError: foo is not defined
It should have been:
var obj = function (obj) {
obj['x' + obj.foo] = 'heh';
obj['y' + obj.bar] = 'noo';
return obj;
}({
foo: 'foo',
bar: 'bar'
});
I get the following error:
TypeError: Cannot read property 'prototype' of undefined
when I make a file with the following:
require('6to5/register')
require('6to5/polyfill')
var Collection = require('./lib/collection')
var collection = new Collection()
and in ./lib/collection
:
var Backbone = require('backbone')
class Collection extends Backbone.Collection {
initialize() {
super()
}
}
module.exports = Collection
If I don't call super
, there's no error.
If I rename the class I'm extending to BackboneCollection
like so:
var Backbone = require('backbone'),
BackboneCollection = Backbone.Collection
class Collection extends BackboneCollection {
initialize() {
super()
}
}
module.exports = Collection
it works fine.
Assuming this is related to the error I ran into the other day? #22
npm install sebmck/6to5
Ξ» node
> to5 = require('6to5')
Error: ENOENT, no such file or directory '/Code/6to5test/node_modules/6to5/lib/6to5/templates'
at Object.fs.readdirSync (fs.js:654:18)
at Object.<anonymous> (/Code/6to5test/node_modules/6to5/lib/6to5/util.js:201:13)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/Code/6to5test/node_modules/6to5/lib/6to5/transform.js:4:16)
at Module._compile (module.js:456:26)
https://github.com/sebmck/6to5/blob/master/.npmignore#L5
Seems as if your intention is to only include them for dev/test, but util
needs to be fixed to not puke when they're absent.
6to5 (awesome project btw) cannot process the following snippets:
function unpackObject({title: title, author: author}) {
return title + ' ' + author;
}
console.log(unpackObject({title: 'title', author: 'author'});
function unpackArray([a, b, c]) {
return a+b+c;
}
console.log(unpackArray(['hello', ', ', 'world']));
Any idea if it's possible to support that?
Even though I specified filename
in options.
_file: undefined,
Reproduce: Run npm test
in the gulp-6to5 repo. https://github.com/sindresorhus/gulp-6to5/blob/e7bd9167c7ba3d98f521fa675b026511965f7af6/index.js#L30
Full map:
{ _file: undefined,
_sourceRoot: null,
_sources: { _array: [ 'fixture.js' ], _set: { '$fixture.js': 0 } },
_names: { _array: [ 'map', 'v' ], _set: { '$map': 0, '$v': 1 } },
_mappings:
[ { generatedLine: 1,
generatedColumn: 0,
originalLine: 1,
originalColumn: 0,
source: 'fixture.js',
name: null },
{ generatedLine: 1,
generatedColumn: 3,
originalLine: 1,
originalColumn: 3,
source: 'fixture.js',
name: 'map' },
{ generatedLine: 1,
generatedColumn: 6,
originalLine: 1,
originalColumn: 0,
source: 'fixture.js',
name: null },
{ generatedLine: 1,
generatedColumn: 7,
originalLine: 1,
originalColumn: 7,
source: 'fixture.js',
name: null },
{ generatedLine: 1,
generatedColumn: 17,
originalLine: 1,
originalColumn: 7,
source: 'fixture.js',
name: 'v' },
{ generatedLine: 1,
generatedColumn: 18,
originalLine: 1,
originalColumn: 7,
source: 'fixture.js',
name: null },
{ generatedLine: 1,
generatedColumn: 20,
originalLine: false,
originalColumn: false,
source: null,
name: null },
{ generatedLine: 2,
generatedColumn: 9,
originalLine: 1,
originalColumn: 12,
source: 'fixture.js',
name: 'v' },
{ generatedLine: 2,
generatedColumn: 10,
originalLine: 1,
originalColumn: 12,
source: 'fixture.js',
name: null },
{ generatedLine: 2,
generatedColumn: 13,
originalLine: 1,
originalColumn: 16,
source: 'fixture.js',
name: null },
{ generatedLine: 2,
generatedColumn: 14,
originalLine: false,
originalColumn: false,
source: null,
name: null },
{ generatedLine: 3,
generatedColumn: 1,
originalLine: 1,
originalColumn: 0,
source: 'fixture.js',
name: null } ],
_sourcesContents: { '$fixture.js': '[].map(v => v + 1)' } }
It's weird that the output type can change based on an option.
// Returns an object `{ code: "", map: {} }` instead of an appended string.
sourceMapObject: false,
I think you should always return an object. Just make the .map
prop null when sourceMapObject: false
.
compilation of the following code
(function() {
if(true){
let a = arguments[0];
console.log(a);
}
})(1);
will turn into:
(function() {
if(true){
(function() {
var a = arguments[0];
console.log(a);
})();
}
})(1);
which is incorrect.
PR https://github.com/ariya/esprima/pull/287 adds support for the correct and final ES6 module syntax to Esprima. It would be ideal to peg this packages esprima
dependency to a commit after that PR was merged.
Also, Facebook's Esprima fork has already been released to npm with these changes: [email protected]
/cc @caridy
I've loaded es6-shim
first, but I'm still getting this error. It's when it hits class
. Is there a setting that needs to be turned on?
How should I assign properties on a class?
I tried this:
class Blah {
foo: 'bar'
constructor() {
console.log(this.foo)
}
}
but got an error about Unexpected string
on foo: 'bar'
.
I assumed assigning class properties would be the same as CoffeeScript, where foo
is placed on the prototype
of Blah
.
I can do either of the following, but neither are as much fun:
class Blah {
constructor() {
this.foo = 'bar'
console.log(this.foo)
}
}
The problem with this approach is that I cannot use Blah.prototype.foo
to override the default value.
class Blah {
constructor() {
console.log(this.foo)
}
}
Blah.prototype.foo = 'bar'
The "problem" with this approach is that it requires assigning default values outside the class declaration.
function outer() {
var inner = () => arguments;
return [].slice.call(inner());
}
console.log(outer(1, 2));
This should print [ 1, 2 ]
but it currently prints []
.
When saying
class BaseController extends Chaplin.Controller
I get the following error:
{ '0':
{ [Error: Parsing file /Projects/app/controllers/base/controller.js: Line 2: Unexpected token .]
stream:
{ _readableState: [Object],
readable: true,
domain: null,
_events: [Object],
_maxListeners: 10,
_writableState: [Object],
writable: true,
allowHalfOpen: true,
_options: [Object],
_wrapOptions: [Object],
_streams: [Object],
length: 1,
label: 'deps' } } }
This does not work either:
class BaseController extends Chaplin['Controller']
This is, admittedly, a use case that is rare in the CommonJS world. However it is a valid ES6 modules use case. In this example there is a cycle between evens.js and odds.js that should nevertheless work. This example is taken from the es6-module-transpiler test suite.
// odds.js
import { isEven } from './evens';
export function nextOdd(n) {
return isEven(n) ? n + 1 : n + 2;
}
/**
* We go through these gymnastics to eager-bind to isEven. This is done to
* ensure that both this module and the 'evens' module eagerly use something
* from the other.
*/
export var isOdd = (function(isEven) {
return function(n) {
return !isEven(n);
};
})(isEven);
// evens.js
import { nextOdd } from './odds';
/**
* We go through these gymnastics to eager-bind to nextOdd. This is done to
* ensure that both this module and the 'odds' module eagerly use something
* from the other.
*/
export var nextEven = (function() {
return function(n) {
var no = nextOdd(n);
return (no === n + 2) ?
no - 1 : no;
};
})(nextOdd);
export function isEven(n) {
return n % 2 === 0;
}
// main.js
/**
* The 'evens' and 'odds' modules are configured in such a way that they both
* have two exported functions: isEven, nextEven, isOdd, and nextOdd. Normally
* these four functions could be in any order regardless of which depends on
* which because of JavaScript function hoisting.
*
* For the purposes of our test we need to prevent function hoisting, so it has
* been arranged that two of them will be function expressions assigned to
* variables. Specifically, isOdd and nextEven both eagerly evaluate their
* dependencies (i.e. isEven and nextOdd). This allows us to test that exported
* function declarations are available before what would be a module's
* "execute" step, per the spec.
*/
import { nextEven, isEven } from './evens';
import { nextOdd, isOdd } from './odds';
assert.equal(nextEven(1), 2);
assert.equal(nextOdd(1), 3);
assert.ok(isOdd(1));
assert.ok(!isOdd(0));
assert.ok(isEven(0));
assert.ok(!isEven(1));
The way we handle this in the es6-module-transpiler is to export function declarations at the top of the module scope before any requires. So where right now this project converts odds.js to this:
var isEven = require('./evens').isEven;
function nextOdd(n) {
return isEven(n) ? n + 1 : n + 2;
}
exports.nextOdd = nextOdd;
var isOdd = (function(isEven) {
return function(n) {
return !isEven(n);
};
})(isEven);
exports.isOdd = isOdd;
It should convert it to this:
exports.nextOdd = nextOdd;
var isEven = require('./evens').isEven;
function nextOdd(n) {
return isEven(n) ? n + 1 : n + 2;
}
var isOdd = (function(isEven) {
return function(n) {
return !isEven(n);
};
})(isEven);
exports.isOdd = isOdd;
Case:
module.exports = {
init() {
return new Promise((resolve, reject) => {
MongoClient.connect(config.mongodb, (err, db) => {
if (err) {
return reject(err);
}
this.db = db;
resolve(this);
});
});
}
}
Compiles to:
module.exports = {
init: function() {
return new Promise(function(resolve, reject) {
var _this = this;
MongoClient.connect(config.mongodb, function(err, db) {
if (err) {
return reject(err);
}
_this.db = db;
resolve(_this);
});
});
}
}
var _this = this;
should be on the line after init: function() {
?
I were using traceur that support the module thing from "stuff"
syntax that we can found here.
http://wiki.ecmascript.org/doku.php?id=harmony:modules
I've tried to replace that by import * as thing from "stuff"
but my prior transformation (reactify (jsx)) is now broken (probably unable to parse).
Why don't your handle this syntax too ?
For example, running 6to5 on the following code currently raises an exception:
#!/usr/bin/env node
console.log(3);
I ran this example command:
$ 6to5 script.js --out-file script-compiled.js
script.js
included the following:
var BaseView = class BaseView {
constructor() {
this.autoRender = true;
}
}
module.exports = BaseView
but script-compiled.js
ended up being the exact same thing. There was no compilation.
When running the 6to5-node script using forever.js (to keep node instances running), the filenames provided by forever (commander.args) have their paths resolved, so doing a path.join(process.cwd(),filename) should only be done if filename.charAt(0) != '/', or node will be unable to find the desired file (the path will have been resolved twice).
To fix, I replace the require() line with:
require(require.resolve(filename.charAt(0) == '/' ? filename : path.join(process.cwd(),filename)));
class A {
static foo() {
return 'A#foo';
}
}
class B extends A {
static foo() {
return 'B#foo, ' + super();
}
}
console.log(B.foo());
This should print B#foo, A#foo
but it currently throws an exception trying to access A.prototype.foo.call
.
In certain circumstances, the transformed code looks like this:
return function () {
/* code goes here */
}();
This causes an 'Illegal return statement' syntax error. It appears to be caused by some combination of let
and functions. These all work...
let _message = 'hello';
console.log( _message );
console.log( message() );
function message () {
return 'hello';
}
var _message = message();
console.log( _message );
function message () {
return 'hello';
}
...but this doesn't:
let _message = message();
console.log( _message );
function message () {
return 'hello';
}
It transforms to this:
return function() {
var _message = message();
console.log( _message );
function message () {
return 'hello';
}
}();
Source map from 1.6.0:
{"version":3,"sources":["fixture.js"],"names":["Test"],"mappings":"IAAMA,I;WAAAA,I;;SAAAA,I","file":"fixture.js","sourcesContent":["class Test {}\n"]}
Source map from 1.7.0:
{"version":3,"file":"fixture.js","sources":["fixture.js"],"names":[],"mappings":"IAAM,CAAC,CAAC,CAAC;WAAH,CAAC,CAAC,CAAC;SAAH,CAAC,CAAC,CAAC","sourcesContent":["class Test {}\n"]}
Appears to be a side effect from the switch to recast. Might not be important, but I figured I'd report it.
$ npm install -g 6to5
$ 6to5-node
module.js:340
throw err;
^
Error: Cannot find module 'es6-symbol/implement'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/Users/azu/.nodebrew/node/v0.10.28/lib/node_modules/6to5/lib/6to5/polyfill.js:1:63)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
Env:
$ node -v
v0.10.28
$ npm -v
2.1.2
Workaround :
npm install -g es6-symbol
It may be as well to add es6-symbol
to dependencies of package.json.
http://git-scm.com/book/en/Git-Basics-Tagging
You may find this helpful:
https://github.com/visionmedia/git-extras/blob/master/bin/git-release
Or this version which does the npm publish
step for you also:
https://github.com/paulmillr/dotfiles/blob/master/git-extras/git-release.sh
it would be amazing to be able to run this in the browser. Is the only thing preventing that from happening the node 'fs' calls?
If that's all it is, I could pull request a browser version if you'd like.
Right now, if you try to create a tagged template string, you get a parse error.
A tagged string looks like:
tag`a${ 42 }b`
// ^ Parse error occurs here
This probably is more about Esprima gaining support than anything else.
> class A { constructor(...args) { console.log(args) } }
undefined
> new A(1, 2, 3)
ReferenceError: args is not defined
at new A (repl:2:30)
at repl:1:5
at REPLServer.replEval [as eval] (6to5/bin/6to5-node:63:17)
at Interface.<anonymous> (repl.js:239:12)
at Interface.emit (events.js:95:17)
at Interface._onLine (readline.js:202:10)
at Interface._line (readline.js:531:8)
at Interface._ttyWrite (readline.js:760:14)
at ReadStream.onkeypress (readline.js:99:10)
at ReadStream.emit (events.js:98:17)
This should result in a function A
that immediately logs the arguments given to it as an array.
This is not that big a deal as most code probably will not depend on this, but file this away somewhere under "spec compliance".
class A {
foo() {}
}
for (var key in new A()) {
console.log(key);
}
This should print nothing, but it currently prints foo
.
When I write
const X = 1;
var X = 2;
It gives me an error that X is read-only.
If I define X as a class, it changes X.
const X = 1;
class X {
constructor() {}
}
It changes the X instead of throwing X is read-only error.
Are there grunt and gulp plugins available for this?
class A {
constructor(name) {
this.name = name;
}
}
class B extends A {
hello() {
return 'Hello ' + this.name;
}
}
var b = new B('John');
require('assert').equal('Hello John', b.hello());
The output is :
var A = function() {
function A(name) {
this.name = name;
}
return A;
}();
var B = function(A) {
function B() {
A.call(this, arguments);
}
B.prototype = Object.create(A.prototype, {
constructor: {
value: B,
enumerable: false,
writable: true,
configurable: true
}
});
B.__proto__ = A;
B.prototype.hello = function() {
return 'Hello ' + this.name;
};
return B;
}(A);
var b = new B('John');
require('assert').equal('Hello John', b.hello());
A.call(this, arguments);
should be A.apply(this, arguments);
?
Just tried this out in the command line and get the following error from lib/6to5/transform.js
with 1.7.6:
$ npm install 6to5
...
$ node
> require('6to5')
Error: Cannot find module 'source-map'
class A {}
A.foo = 1;
class B extends A {}
console.log(B.foo);
This should print 1
when run via 6to5-node
, but it actually prints undefined
.
class A { static a(){}; static get b(){}; static set b(b){} }
This should result in a function A
with properties set on it, but instead they are set on its prototype.
Can we have a comparison with jstransform?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.