buble issueshttps://gitlab.com/Rich-Harris/buble/-/issues2018-07-26T18:50:51Zhttps://gitlab.com/Rich-Harris/buble/-/issues/229Support stage 0 ?2018-07-26T18:50:51ZMakio64Support stage 0 ?Hi,
Is there a way to make stage-x features work?
Examples :
class X {
foo = ()=>{ } //synthax error, support from stage-3
}
Thanks!Hi,
Is there a way to make stage-x features work?
Examples :
class X {
foo = ()=>{ } //synthax error, support from stage-3
}
Thanks!https://gitlab.com/Rich-Harris/buble/-/issues/228Error on parsing JSX with hard spaces in a new line and end of line2017-11-12T15:58:04ZUKABUERError on parsing JSX with hard spaces in a new line and end of lineFor example
``` jsx
<div>
<a>1</a>&nbsp;
&nbsp;
</div>
```
is compiled to
``` js
React.createElement( 'div', null,
React.createElement( 'a', null, "1" )&nbsp;
&nbsp;
)
```
here `&nbsp;` is an unexpected tokenFor example
``` jsx
<div>
<a>1</a>
</div>
```
is compiled to
``` js
React.createElement( 'div', null,
React.createElement( 'a', null, "1" )
)
```
here ` ` is an unexpected tokenhttps://gitlab.com/Rich-Harris/buble/-/issues/227missing chalk dependency?2017-11-07T18:53:38ZAdam Pearcemissing chalk dependency?```
➜ 2017-11-07-tax-table git:(master) ✗ yarn add buble
➜ 2017-11-07-tax-table git:(master) ✗ node_modules/.bin/buble public/_assets/build-es6.js
module.js:529
throw err;
^
Error: Cannot find module 'chalk'
at Function.Mo...```
➜ 2017-11-07-tax-table git:(master) ✗ yarn add buble
➜ 2017-11-07-tax-table git:(master) ✗ node_modules/.bin/buble public/_assets/build-es6.js
module.js:529
throw err;
^
Error: Cannot find module 'chalk'
at Function.Module._resolveFilename (module.js:527:15)
at Function.Module._load (module.js:476:23)
at Module.require (module.js:568:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/Users/207342/Desktop/2017-11-07-tax-table/node_modules/buble/bin/handleError.js:1:75)
at Module._compile (module.js:624:30)
at Object.Module._extensions..js (module.js:635:10)
at Module.load (module.js:545:32)
at tryModuleLoad (module.js:508:12)
at Function.Module._load (module.js:500:3)
➜ 2017-11-07-tax-table git:(master) ✗ yarn add chalk
➜ 2017-11-07-tax-table git:(master) ✗ node_modules/.bin/buble public/_assets/build-es6.js
// works now
```
This is with version `0.17.0`https://gitlab.com/Rich-Harris/buble/-/issues/226update acorn dependency to 5.x2017-10-27T15:29:31ZPraveen Arimbrathodiyilupdate acorn dependency to 5.xWe like to package buble for debian but we already have acorn@5.1.1. It would be good if buble can be updated to use acron@5We like to package buble for debian but we already have acorn@5.1.1. It would be good if buble can be updated to use acron@5https://gitlab.com/Rich-Harris/buble/-/issues/225Newline in code throwing an error2017-10-19T22:35:55ZJustin CoxNewline in code throwing an errorAny time I try compiling a file, I always get an error after the first newline in the file.
```
SyntaxError: Unexpected character ' ' (1:18) in <eval> at line number 7659 at column number 12
```
The line can be anything, from `"use stric...Any time I try compiling a file, I always get an error after the first newline in the file.
```
SyntaxError: Unexpected character ' ' (1:18) in <eval> at line number 7659 at column number 12
```
The line can be anything, from `"use strict"` to declaring a variable. I've tested it using single line functions via the JS API and then inserting `"\n"` at the end of it and can firmly say that the error is from the newline declaration.
I'm currently running it in Java 8 (Nashorn engine), though I doubt that has anything to do with the error as I'm executing the tests from a console that is compiling the input via Buble before it even touches the Java code.https://gitlab.com/Rich-Harris/buble/-/issues/223Support class properties ?2017-10-17T15:04:01ZFengying ZhaoSupport class properties ?Can bublé support class properties like [babel-plugin-transform-class-properties](https://babeljs.io/docs/plugins/transform-class-properties/) ?Can bublé support class properties like [babel-plugin-transform-class-properties](https://babeljs.io/docs/plugins/transform-class-properties/) ?https://gitlab.com/Rich-Harris/buble/-/issues/222compose() built with arrow functions seems unusual2017-10-14T15:38:43ZBrook Monroecompose() built with arrow functions seems unusual`const compose = (...fun) => fun.reduce((f, g) => (...args) => f(g(...args)));`
yields
```
1 var compose = function () {
2 var fun = [], len = arguments.length;
3 while ( len-- ) fun[ len ] = arguments[ len ];
4
5 r...`const compose = (...fun) => fun.reduce((f, g) => (...args) => f(g(...args)));`
yields
```
1 var compose = function () {
2 var fun = [], len = arguments.length;
3 while ( len-- ) fun[ len ] = arguments[ len ];
4
5 return fun.reduce(function (f, g) { return function () {
6 var args = [], len = arguments.length;
7 while ( len-- ) args[ len ] = arguments[ len ];
8
9 return f(g.apply(void 0, args));
10 ; } });
11 };
```
JSHint suggests that there are three issues:
* 10 Unreachable ';' after 'return'.
* 10 Unnecessary semicolon.
* 10 Missing semicolon.
It seems to run but it's a little non-intuitive--and probably shouldn't generate warnings. That wouldn't get past my build process.https://gitlab.com/Rich-Harris/buble/-/issues/221I want to transform let to var, but leave const alone2017-10-18T15:01:39ZChris Morganme@chrismorgan.infoI want to transform let to var, but leave const alone`const` is well-supported (choosing one key browser, it works back to Safari 5.1). It gives certain concrete benefits over `var`, such as UglifyJS being able to inline primitives (`const X = 42; …; x = X` → `…; x = 42`).
`let` support i...`const` is well-supported (choosing one key browser, it works back to Safari 5.1). It gives certain concrete benefits over `var`, such as UglifyJS being able to inline primitives (`const X = 42; …; x = X` → `…; x = 42`).
`let` support is much more recent; Safari didn’t implement it until 10.0, for example. And `let` doesn’t really get you much over `var`.
I’d like to be able to configure Bublé to leave `const` alone, and only transpile `let` to `var`: all the browsers I care about support `const`, but not all of them support `let`.
I imagine this would entail still processing `const` declarations in order to make identifiers appropriately unique, but then emitting `const` instead of `var`. Because of this and the interaction between `let` and `const`, I’m expecting it would be done as an option on the `letConst` transformation rather than just splitting it into two transformations, `let` and `const`.https://gitlab.com/Rich-Harris/buble/-/issues/220Support accessors with literal names2017-10-03T05:59:24ZChris Morganme@chrismorgan.infoSupport accessors with literal namesImplemented in https://gitlab.com/chris-morgan/buble_/tree/class-accessors-with-literal-names.
This is an issue instead of an MR because GitLab is broken (https://gitlab.com/gitlab-com/support-forum/issues/2547).
e.g. `class Foo { get ...Implemented in https://gitlab.com/chris-morgan/buble_/tree/class-accessors-with-literal-names.
This is an issue instead of an MR because GitLab is broken (https://gitlab.com/gitlab-com/support-forum/issues/2547).
e.g. `class Foo { get 'foo' () { } }`
*Computed* names are still unimplemented, but *literal* names now work.https://gitlab.com/Rich-Harris/buble/-/issues/219npm script build:browser is failing2017-10-18T11:23:58ZChris Morganme@chrismorgan.infonpm script build:browser is failingWith a fresh clone of the repository, the `build:browser` script is failing:
```
$ rollup -c --environment DEPS -f umd -o dist/buble.deps.js
Module C:\Users\me\AppData\Local\Temp\buble\node_modules\vlq\dist\vlq.js does not export encode...With a fresh clone of the repository, the `build:browser` script is failing:
```
$ rollup -c --environment DEPS -f umd -o dist/buble.deps.js
Module C:\Users\me\AppData\Local\Temp\buble\node_modules\vlq\dist\vlq.js does not export encode (imported by C:\Users\me\AppData\Local\Temp\buble\node_modules\magic-string\dist\magic-string.es6.js)
Error: Module C:\Users\me\AppData\Local\Temp\buble\node_modules\vlq\dist\vlq.js does not export encode (imported by C:\Users\me\AppData\Local\Temp\buble\node_modules\magic-string\dist\magic-string.es6.js)
at Module.trace (C:\Users\me\AppData\Local\Temp\buble\node_modules\rollup\src\Module.js:652:30)
at C:\Users\me\AppData\Local\Temp\buble\node_modules\rollup\src\Module.js:261:30
at Array.forEach (<anonymous>)
at C:\Users\me\AppData\Local\Temp\buble\node_modules\rollup\src\Module.js:259:25
at Array.forEach (<anonymous>)
at Module.bindReferences (C:\Users\me\AppData\Local\Temp\buble\node_modules\rollup\src\Module.js:252:19)
at C:\Users\me\AppData\Local\Temp\buble\node_modules\rollup\src\Bundle.js:96:44
at Array.forEach (<anonymous>)
at C:\Users\me\AppData\Local\Temp\buble\node_modules\rollup\src\Bundle.js:96:18
at tryCatch (C:\Users\me\AppData\Local\Temp\buble\node_modules\rollup\node_modules\es6-promise\lib\es6-promise\-internal.js:187:12)
```
https://github.com/mishoo/UglifyJS2/pull/2005 has the same issue cropping up.
I’m running Node v8.5.0 on Windows 10 64-bit, but I get the same error on the Linux side of WSL.
I don’t get quite what’s going on, as vlq.js *is* exporting encode, as far as I can tell.
https://gitlab.com/chris-morgan/buble_/-/jobs/34855752 is a demonstration of this failing.https://gitlab.com/Rich-Harris/buble/-/issues/218Unexpected token using arrow notation returning class with "extends"2017-09-25T10:38:40ZDiko ConsunjiUnexpected token using arrow notation returning class with "extends"Hi Buble team!
I found a bug where I am using arrow notation that returns a class having "extends" keyword extending a base class and got an "Unexpected token" error.
The source:
```javascript
// this produces "Unexpected token" error
...Hi Buble team!
I found a bug where I am using arrow notation that returns a class having "extends" keyword extending a base class and got an "Unexpected token" error.
The source:
```javascript
// this produces "Unexpected token" error
const mixin = (Base) =>
class Test extends Base {
}
```
Transpile result:
```javascript
// this produces "Unexpected token" error
var mixin = function (Base) (function (Base) {
{ return function Test () {
Base.apply(this, arguments);
}if ( Base ) Test.__proto__ = Base;
Test.prototype = Object.create( Base && Base.prototype );
Test.prototype.constructor = Test;
return Test;
}(; }Base))
```
As for now, enclosing the arrow notation with bracket "{ class Classname extends Base {} return Classname; }" temporarily resolves the issue.
I hope this helps. Thanks :-)
Diko
- Tech Slavehttps://gitlab.com/Rich-Harris/buble/-/issues/216Syntax trailing function commas2017-11-01T02:25:37ZCristian Pallaréscristian@pallares.ioSyntax trailing function commasHi there!
[Syntax trailing function commas](https://babeljs.io/docs/plugins/syntax-trailing-function-commas/) is not implemented in Bublé. Is there any plans to support it?
```js
console.log(
'hello',
'world', // This trailing ...Hi there!
[Syntax trailing function commas](https://babeljs.io/docs/plugins/syntax-trailing-function-commas/) is not implemented in Bublé. Is there any plans to support it?
```js
console.log(
'hello',
'world', // This trailing comma crashes buble and rollup.
);
```
I think it's awesome to be allowed to always end with commas for Git and line duplication and reordering purposes.
Thanks!https://gitlab.com/Rich-Harris/buble/-/issues/215[bug] If structure incorrectly transformed2017-08-14T01:55:50ZJames Yangjamesyang999@gmail.com[bug] If structure incorrectly transformedThe `IF` bug is below:
**ES6 Source**
```javascript
let x,a,b
if(!x) x=2
;[a,b]=[1,2]
console.log(x,a,b)
```
Transformed result:
```javascript
var x;
var a;
var b;
if(!x) { x=2
;var assign;
(assign = [1,2], a = assign[0], b = assign[...The `IF` bug is below:
**ES6 Source**
```javascript
let x,a,b
if(!x) x=2
;[a,b]=[1,2]
console.log(x,a,b)
```
Transformed result:
```javascript
var x;
var a;
var b;
if(!x) { x=2
;var assign;
(assign = [1,2], a = assign[0], b = assign[1]) };
console.log(x,a,b);
```
You can see the `if` structure **incorrectly** changed, generated code will broken.https://gitlab.com/Rich-Harris/buble/-/issues/214[Request] pass allowImportExportEverywhere into acorn2017-08-10T22:41:51ZMax Motovilov[Request] pass allowImportExportEverywhere into acornLooking at the code, I don't see a way to pass acorn options via Buble. Well, the Webpack's dynamic `import()` syntax does not parse unless acorn gets `allowImportExportEverywhere`...Looking at the code, I don't see a way to pass acorn options via Buble. Well, the Webpack's dynamic `import()` syntax does not parse unless acorn gets `allowImportExportEverywhere`...https://gitlab.com/Rich-Harris/buble/-/issues/213[bug] inherited accessors (getters/setters) don't work.2017-08-09T07:57:08ZJoseph Orbegoso Pea (Joe Pea)[bug] inherited accessors (getters/setters) don't work.Accessors with Buble only work without inheritance. But with inheritance, the context of an accessor is wrong (the `this`).
For [example](https://buble.surge.sh/#class%20Foo%20%7B%0A%20%20set%20foo(v)%20%7Bconsole.log('set%20foo')%7D%...Accessors with Buble only work without inheritance. But with inheritance, the context of an accessor is wrong (the `this`).
For [example](https://buble.surge.sh/#class%20Foo%20%7B%0A%20%20set%20foo(v)%20%7Bconsole.log('set%20foo')%7D%0A%20%20get%20foo()%20%7Breturn%20console.log('get%20foo')%7D%0A%7D%0A%0Aclass%20Bar%20extends%20Foo%20%7B%0A%20%20set%20foo(v)%20%7Bsuper.foo%20%3D%20v%7D%0A%20%20get%20foo()%20%7Breturn%20super.foo%7D%0A%7D), in
```js
class Foo {
set foo(v) {console.log('set foo')}
get foo() {return console.log('get foo')}
}
class Bar extends Foo {
set foo(v) {super.foo = v}
get foo() {return super.foo}
}
```
the Buble output will be something like
```js
var Foo = function Foo () {};
var prototypeAccessors = { foo: {} };
prototypeAccessors.foo.set = function (v) {console.log('set foo')};
prototypeAccessors.foo.get = function () {return console.log('get foo')};
Object.defineProperties( Foo.prototype, prototypeAccessors );
var Bar = (function (Foo) {
function Bar () {
Foo.apply(this, arguments);
}
if ( Foo ) Bar.__proto__ = Foo;
Bar.prototype = Object.create( Foo && Foo.prototype );
Bar.prototype.constructor = Bar;
var prototypeAccessors$1 = { foo: {} };
// --------------- ERROR -----------------------------------------------------
prototypeAccessors$1.foo.set = function (v) {Foo.prototype.foo = v};
prototypeAccessors$1.foo.get = function () {return Foo.prototype.foo};
Object.defineProperties( Bar.prototype, prototypeAccessors$1 );
return Bar;
}(Foo));
```
and as you can see it will attempt to run `Foo.prototype.foo = v` and `return Foo.prototype.foo` for the extending accessors.
This obviously won't work because `this` inside of the parent class accessors will be `Foo.prototype` rather than an instance of `Bar`.
To fix this problem, maybe Buble can output something like this instead:
```js
prototypeAccessors$1.foo.set = function (v) {Object.getOwnPropertyDescriptor(Foo.prototype, 'foo').set.call(this, v)};
prototypeAccessors$1.foo.get = function () {return Object.getOwnPropertyDescriptor(Foo.prototype, 'foo').get.call(this)};
```https://gitlab.com/Rich-Harris/buble/-/issues/212If using Rollup, does Buble operate on node_modules files?2017-10-18T11:16:34ZJoseph Orbegoso Pea (Joe Pea)If using Rollup, does Buble operate on node_modules files?If so, how do we prevent this?If so, how do we prevent this?https://gitlab.com/Rich-Harris/buble/-/issues/210[BUG] class accessors are not configurable2017-08-07T03:23:42ZJoseph Orbegoso Pea (Joe Pea)[BUG] class accessors are not configurableWhen defining a class in ES6, like
```js
class Foo {
get bar() {...}
set bar(value) {...}
}
```
the accessors are `configurable`.
However, Buble output uses [`Object.defineProperties`](https://developer.mozilla.org/en-US/docs/Web/...When defining a class in ES6, like
```js
class Foo {
get bar() {...}
set bar(value) {...}
}
```
the accessors are `configurable`.
However, Buble output uses [`Object.defineProperties`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperties) to create the accessors, and by default `Object.defineProperties` sets configurable to `false`.
This makes some code, like the following utility function that I use in non-Buble projects fail:
```js
function makeAccessorsEnumerable(object) {
const props = Object.getOwnPropertyNames(object)
for (let l=props.length, i=0; i<l; i+=1) {
const prop = props[i]
const descriptor = Object.getOwnPropertyDescriptor(object, prop)
console.log('descriptor for '+prop+':', descriptor)
if (descriptor && (descriptor.set || descriptor.get)) {
descriptor.enumerable = true
Object.defineProperty(object, prop, descriptor)
}
}
}
```
To reproduce the bug, you can paste and run the following in Chrome console:
```js
class Foo {
get bar() {return this.v}
set bar(v) {this.v = v}
}
makeAccessorsEnumerable(Foo.prototype) // it works, so far so good!
Object.defineProperties(Foo.prototype, {
lorem: {set: function(v) {this.l = v}, get: function() {return this.l}}
})
makeAccessorsEnumerable(Foo.prototype) // ERROR, because lorem is not configurable!
function makeAccessorsEnumerable(object) {
const props = Object.getOwnPropertyNames(object)
for (let l=props.length, i=0; i<l; i+=1) {
const prop = props[i]
const descriptor = Object.getOwnPropertyDescriptor(object, prop)
console.log('descriptor for '+prop+':', descriptor)
if (descriptor && (descriptor.set || descriptor.get)) {
descriptor.enumerable = true
Object.defineProperty(object, prop, descriptor)
}
}
}
```
The same applies to `static` accessors.https://gitlab.com/Rich-Harris/buble/-/issues/209Badly referenced object, Is this common?2017-08-05T00:42:28ZUpper.clBadly referenced object, Is this common?## Input
```javascript
let prop = 'sample',
value = [1,2,3];
value = {[prop]:value}
```
## Output
```javascript
var prop = 'sample',
value = [1,2,3];
value = {};
value[prop] = value
```
> This is an error in my...## Input
```javascript
let prop = 'sample',
value = [1,2,3];
value = {[prop]:value}
```
## Output
```javascript
var prop = 'sample',
value = [1,2,3];
value = {};
value[prop] = value
```
> This is an error in my code or a transpilation problem
[Link buble](https://buble.surge.sh/#let%20prop%20%20%3D%20'demo'%2C%0A%20%20%20%20value%20%3D%20%7B%7D%3B%0A%0A%09value%20%3D%20%7B%5Bprop%5D%3Avalue%7D%0A%09%0A%0A%09)
The result is a self-referential object and is not the right thinghttps://gitlab.com/Rich-Harris/buble/-/issues/208By not using semicolons the code does not transpile well2017-08-04T14:09:43ZMatias TrujilloBy not using semicolons the code does not transpile wellI usually write javascript with **semicolon** but I wanted to compile this code without the use of semicolons, which I can with **babel**, but **buble** generates an error when instantiating the transpilated function
```javascript
clas...I usually write javascript with **semicolon** but I wanted to compile this code without the use of semicolons, which I can with **babel**, but **buble** generates an error when instantiating the transpilated function
```javascript
class Dispatcher{
constructor(notify=[],mdd=[]){
this.notify = notify
this.middleware(...mdd)
}
subscribe(callback){
if( typeof callback === 'function' ){
this.notify.push(callback)
return ()=>this.unsubscribe(callback)
}else{
throw new Error('Expected the subscriber to be a function')
}
}
unsubscribe(callback){
this.notify.splice(
callback,
this.notify.indexOf(callback)>>>0,1
)
}
middleware(...mdd){
}
}
```
> Is not the complete code, but it is the perspiration that generated the error by not using a semicolon
```javascript
var Dispatcher = function Dispatcher(notify,mdd){
if ( notify === void 0 ) notify=[];
if ( mdd === void 0 ) mdd=[];
this.notify = notify
(ref = this).middleware.apply(ref, mdd)
var ref;
};
Dispatcher.prototype.subscribe = function subscribe (callback){
var this$1 = this;
if( typeof callback === 'function' ){
this.notify.push(callback)
return function (){ return this$1.unsubscribe(callback); }
}else{
throw new Error('Expected the subscriber to be a function')
}
};
Dispatcher.prototype.unsubscribe = function unsubscribe (callback){
this.notify.splice(
callback,
this.notify.indexOf(callback)>>>0,1
)
};
Dispatcher.prototype.middleware = function middleware (){
var mdd = [], len = arguments.length;
while ( len-- ) mdd[ len ] = arguments[ len ];
};
```
> You can run the lower script in the browser console to verify the transpilation error when instantiating the Dispatcher class
[Link buble online](https://buble.surge.sh/#%0A%0Aclass%20Dispatcher%7B%0A%20%20%20%20constructor(notify%3D%5B%5D%2Cmdd%3D%5B%5D)%7B%0A%20%20%20%20%20%20%20%20this.notify%20%3D%20notify%0A%20%20%20%20%20%20%20%20this.middleware(...mdd)%0A%20%20%20%20%7D%0A%20%20%20%20subscribe(callback)%7B%0A%20%20%20%20%20%20%20%20if(%20typeof%20callback%20%3D%3D%3D%20'function'%20)%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20this.notify.push(callback)%0A%20%20%20%20%20%20%20%20%20%20%20%20return%20()%3D%3Ethis.unsubscribe(callback)%0A%20%20%20%20%20%20%20%20%7Delse%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20throw%20new%20Error('Expected%20the%20subscriber%20to%20be%20a%20function')%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%20%20%20%20unsubscribe(callback)%7B%0A%20%20%20%20%20%20%20%20this.notify.splice(%0A%20%20%20%20%20%20%20%20%20%20%20%20callback%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20this.notify.indexOf(callback)%3E%3E%3E0%2C1%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20%7D%20%20%20%0A%20%20%20%20middleware(...mdd)%7B%0A%20%20%20%20%20%20%20%20%0A%20%20%20%20%7D%0A%7D)
> Made it clear that the code transpires well when using semicolonshttps://gitlab.com/Rich-Harris/buble/-/issues/207Cache property reads for performance?2017-08-02T07:24:16ZJoseph Orbegoso Pea (Joe Pea)Cache property reads for performance?I noticed this Buble output:
```js
for (var i = 0, list = childNodes; i < list.length; i += 1) {
```
but it could rather be
```js
for (var i = 0, length = childNodes.length; i < length; i += 1) {
```
which will perform faster...I noticed this Buble output:
```js
for (var i = 0, list = childNodes; i < list.length; i += 1) {
```
but it could rather be
```js
for (var i = 0, length = childNodes.length; i < length; i += 1) {
```
which will perform faster because the `.length` property won't be looked up every iteration.