Socket
Socket
Sign inDemoInstall

buble

Package Overview
Dependencies
Maintainers
3
Versions
109
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

buble - npm Package Compare versions

Comparing version 0.19.4 to 0.19.5

11

CHANGELOG.md
# buble changelog
## 0.19.5 (2018-10-16)
* Transpile U+2028 and U+2029 according to stage 4 proposal json-superset
* Add `/*@__PURE__*/` annotations to transpiled classes
* Update support data
* Allow disabling spread properties transpiling
* Fix specific edge case with spread and computed properties ([#139](https://github.com/Rich-Harris/buble/issues/139))
* Allow global `return` statements
* Don't create unnecessary `this` aliases with loops ([#120](https://github.com/Rich-Harris/buble/issues/120))
* Don't allow getters and setters if IE8 is transpile target ([#20](https://github.com/Rich-Harris/buble/issues/20))
## 0.19.4 (2018-10-06)

@@ -4,0 +15,0 @@

36

package.json
{
"name": "buble",
"version": "0.19.4",
"version": "0.19.5",
"description": "The blazing fast, batteries-included ES2015 compiler",

@@ -23,4 +23,6 @@ "main": "dist/buble.cjs.js",

"pretest": "npm run build",
"test:register": "echo '\"use strict\";' | cat - src/program/Node.js | sed 's/export default/module.exports =/' | node -r ./register.js",
"test:full": "npm run test && npm run test:register && npm run lint",
"prepublish": "npm test",
"lint": "eslint bin/ src/ test/test.js"
"lint": "eslint bin/ src/ test/test.js test/utils/ register.js rollup.*.js"
},

@@ -52,25 +54,25 @@ "bin": {

"console-group": "^0.3.3",
"eslint": "^4.17.0",
"glob": "^7.0.3",
"mocha": "^5.0.0",
"eslint": "^4.19.1",
"glob": "^7.1.3",
"mocha": "^5.2.0",
"rimraf": "^2.5.2",
"rollup": "^0.55.5",
"rollup-plugin-buble": "^0.19.1",
"rollup-plugin-commonjs": "^8.3.0",
"rollup-plugin-json": "^2.3.0",
"rollup-plugin-node-resolve": "^3.0.2",
"rollup": "0.66.0",
"rollup-plugin-buble": "^0.19.2",
"rollup-plugin-commonjs": "=9.1.8",
"rollup-plugin-json": "^3.1.0",
"rollup-plugin-node-resolve": "^3.4.0",
"source-map": "^0.6.1",
"source-map-support": "^0.5.3"
"source-map-support": "^0.5.9"
},
"dependencies": {
"acorn": "^5.4.1",
"acorn-dynamic-import": "^3.0.0",
"acorn-jsx": "^4.1.1",
"chalk": "^2.3.1",
"magic-string": "^0.22.4",
"acorn": "^6.0.2",
"acorn-dynamic-import": "^4.0.0",
"acorn-jsx": "^5.0.0",
"chalk": "^2.4.1",
"magic-string": "^0.25.1",
"minimist": "^1.2.0",
"os-homedir": "^1.0.1",
"regexpu-core": "^4.1.3",
"regexpu-core": "^4.2.0",
"vlq": "^1.0.0"
}
}

@@ -81,3 +81,3 @@ var fs = require( 'fs' );

console.log( err.message );
console.log( '' )
console.log( '' );
process.exit( 1 );

@@ -84,0 +84,0 @@ }

@@ -1,4 +0,4 @@

import * as acorn from 'acorn';
import acornJsx from 'acorn-jsx/inject';
import acornDynamicImport from 'acorn-dynamic-import/lib/inject';
import { Parser } from 'acorn';
import acornJsx from 'acorn-jsx';
import acornDynamicImport from 'acorn-dynamic-import';
import Program from './program/Program.js';

@@ -8,6 +8,3 @@ import { features, matrix } from './support.js';

const { parse } = [acornJsx, acornDynamicImport].reduce(
(final, plugin) => plugin(final),
acorn
);
const parser = Parser.extend(acornDynamicImport, acornJsx());

@@ -19,4 +16,4 @@ const dangerousTransforms = ['dangerousTaggedTemplateString', 'dangerousForOf'];

let bitmask = targets.length
? 0b11111111111111111111
: 0b01000000000000000000;
? 0b11111111111111111111111
: 0b00010000000000000000001;

@@ -61,6 +58,7 @@ Object.keys(target).forEach(environment => {

try {
ast = parse(source, {
ecmaVersion: 9,
ast = parser.parse(source, {
ecmaVersion: 10,
preserveParens: true,
sourceType: 'module',
allowReturnOutsideFunction: true,
onComment: (block, text) => {

@@ -71,6 +69,2 @@ if (!jsx) {

}
},
plugins: {
jsx: true,
dynamicImport: true
}

@@ -77,0 +71,0 @@ });

@@ -33,3 +33,3 @@ import Node from '../Node.js';

} else if (/Pattern/.test(this.left.type) && transforms.destructuring) {
this.transpileDestructuring(code, transforms);
this.transpileDestructuring(code);
}

@@ -36,0 +36,0 @@

@@ -0,1 +1,2 @@

import CompileError from '../../utils/CompileError.js';
import Node from '../Node.js';

@@ -94,2 +95,8 @@ import { findIndex } from '../../utils/array.js';

this.body.forEach((method, i) => {
if ((method.kind === 'get' || method.kind === 'set') && transforms.getterSetter) {
throw new CompileError(
"getters and setters are not supported. Use `transforms: { getterSetter: false }` to skip transformation and disable this error",
method);
}
if (method.kind === 'constructor') {

@@ -96,0 +103,0 @@ let constructorName = namedConstructor ? ' ' + name : '';

@@ -45,3 +45,3 @@ import Node from '../Node.js';

code.remove(c, this.superClass.start);
code.appendLeft(c, ` = (function (${superName}) {\n${i1}`);
code.appendLeft(c, ` = /*@__PURE__*/(function (${superName}) {\n${i1}`);
} else {

@@ -52,3 +52,3 @@ code.overwrite(c, this.superClass.start, ' = ');

this.body.start,
`(function (${superName}) {\n${i1}`
`/*@__PURE__*/(function (${superName}) {\n${i1}`
);

@@ -55,0 +55,0 @@ }

@@ -31,5 +31,5 @@ import Node from '../Node.js';

code.remove(this.superClass.end, this.body.start);
code.appendLeft(this.start, `(function (${superName}) {\n${i1}`);
code.appendLeft(this.start, `/*@__PURE__*/(function (${superName}) {\n${i1}`);
} else {
code.overwrite(this.start, this.body.start, `(function () {\n${i1}`);
code.overwrite(this.start, this.body.start, `/*@__PURE__*/(function () {\n${i1}`);
}

@@ -36,0 +36,0 @@

@@ -39,3 +39,2 @@ import ArrayExpression from './ArrayExpression.js';

import ReturnStatement from './ReturnStatement.js';
import SpreadElement from './SpreadElement.js';
import Super from './Super.js';

@@ -89,3 +88,2 @@ import TaggedTemplateExpression from './TaggedTemplateExpression.js';

ReturnStatement,
SpreadElement,
Super,

@@ -92,0 +90,0 @@ TaggedTemplateExpression,

@@ -31,3 +31,3 @@ import Node from '../Node.js';

if (children.length) {
let c = this.openingElement.end;
let c = (this.openingElement || this.openingFragment).end;

@@ -34,0 +34,0 @@ let i;

@@ -5,2 +5,4 @@ import Node from '../Node.js';

const nonAsciiLsOrPs = /[\u2028-\u2029]/g;
export default class Literal extends Node {

@@ -41,4 +43,13 @@ initialise() {

}
} else if (typeof this.value === "string" && this.value.match(nonAsciiLsOrPs)) {
code.overwrite(
this.start,
this.end,
this.raw.replace(nonAsciiLsOrPs, m => m == '\u2028' ? '\\u2028' : '\\u2029'),
{
contentOnly: true
}
);
}
}
}

@@ -9,3 +9,2 @@ import Node from '../Node.js';

let firstPropertyStart = this.start + 1;
let regularPropertyCount = 0;
let spreadPropertyCount = 0;

@@ -21,11 +20,12 @@ let computedPropertyCount = 0;

if (firstSpreadProperty === null) firstSpreadProperty = i;
} else if (prop.computed) {
} else if (prop.computed && transforms.computedProperty) {
computedPropertyCount += 1;
if (firstComputedProperty === null) firstComputedProperty = i;
} else if (prop.type === 'Property') {
regularPropertyCount += 1;
}
}
if (spreadPropertyCount) {
if (spreadPropertyCount && !transforms.objectRestSpread && !(computedPropertyCount && transforms.computedProperty)) {
spreadPropertyCount = 0;
firstSpreadProperty = null;
} else if (spreadPropertyCount) {
if (!this.program.options.objectAssign) {

@@ -37,29 +37,25 @@ throw new CompileError(

}
// enclose run of non-spread properties in curlies
let i = this.properties.length;
if (regularPropertyCount && !computedPropertyCount) {
while (i--) {
const prop = this.properties[i];
while (i--) {
const prop = this.properties[i];
if (prop.type === 'Property' && !prop.computed) {
const lastProp = this.properties[i - 1];
const nextProp = this.properties[i + 1];
// enclose run of non-spread properties in curlies
if (prop.type === 'Property' && !computedPropertyCount) {
const lastProp = this.properties[i - 1];
const nextProp = this.properties[i + 1];
if (
!lastProp ||
lastProp.type !== 'Property' ||
lastProp.computed
) {
code.prependRight(prop.start, '{');
}
if (!lastProp || lastProp.type !== 'Property') {
code.prependRight(prop.start, '{');
}
if (
!nextProp ||
nextProp.type !== 'Property' ||
nextProp.computed
) {
code.appendLeft(prop.end, '}');
}
if (!nextProp || nextProp.type !== 'Property') {
code.appendLeft(prop.end, '}');
}
}
// Remove ellipsis on spread property
if (prop.type === 'SpreadElement') {
code.remove(prop.start, prop.argument.start);
code.remove(prop.argument.end, prop.end);
}
}

@@ -240,10 +236,5 @@

} else if (i == len - 1) c = this.end;
code.remove(prop.end, c);
if (prop.end != c) code.overwrite(prop.end, c, '', {contentOnly: true});
}
// special case
if (computedPropertyCount === len) {
code.remove(this.properties[len - 1].end, this.end - 1);
}
if (!isSimpleAssignment && name) {

@@ -250,0 +241,0 @@ code.appendLeft(lastComputedProp.end, `, ${name} )`);

@@ -0,1 +1,2 @@

import CompileError from '../../utils/CompileError.js';
import Node from '../Node.js';

@@ -5,2 +6,11 @@ import reserved from '../../utils/reserved.js';

export default class Property extends Node {
initialise(transforms) {
if ((this.kind === 'get' || this.kind === 'set') && transforms.getterSetter) {
throw new CompileError(
"getters and setters are not supported. Use `transforms: { getterSetter: false }` to skip transformation and disable this error",
this);
}
super.initialise(transforms);
}
transpile(code, transforms) {

@@ -7,0 +17,0 @@ super.transpile(code, transforms);

@@ -18,2 +18,4 @@ import Node from '../../Node.js';

this.thisRefs = [];
super.initialise(transforms);

@@ -41,2 +43,5 @@

this.shouldRewriteAsFunction = true;
for (const node of this.thisRefs) {
node.alias = node.alias || node.findLexicalBoundary().getThisAlias();
}
break;

@@ -43,0 +48,0 @@ }

@@ -6,14 +6,18 @@ import Node from '../Node.js';

initialise(transforms) {
const lexicalBoundary = this.findLexicalBoundary();
if (transforms.letConst) {
// save all loops up to the lexical boundary in case we need
// to alias them later for block-scoped declarations
let node = this.findNearest(loopStatement);
while (node && node.depth > lexicalBoundary.depth) {
node.thisRefs.push(this);
node = node.parent.findNearest(loopStatement);
}
}
if (transforms.arrow) {
const lexicalBoundary = this.findLexicalBoundary();
const arrowFunction = this.findNearest('ArrowFunctionExpression');
const loop = this.findNearest(loopStatement);
if (
(arrowFunction && arrowFunction.depth > lexicalBoundary.depth) ||
(loop &&
loop.body.contains(this) &&
loop.depth > lexicalBoundary.depth) ||
(loop && loop.right && loop.right.contains(this))
) {
if (arrowFunction && arrowFunction.depth > lexicalBoundary.depth) {
this.alias = lexicalBoundary.getThisAlias();

@@ -20,0 +24,0 @@ }

export const matrix = {
chrome: {
48: 0b01001010100011001111,
49: 0b01001111100111111111,
50: 0b01011111100111111111,
51: 0b01011111100111111111,
52: 0b01111111100111111111,
53: 0b01111111100111111111,
54: 0b01111111100111111111,
55: 0b01111111100111111111,
56: 0b01111111100111111111,
57: 0b01111111100111111111,
58: 0b11111111100111111111,
59: 0b11111111100111111111,
60: 0b11111111100111111111,
61: 0b11111111100111111111,
62: 0b11111111100111111111,
63: 0b11111111100111111111
48: 0b00010010101000110011111,
49: 0b00010011111001111111111,
50: 0b00010111111001111111111,
51: 0b00010111111001111111111,
52: 0b00011111111001111111111,
53: 0b00011111111001111111111,
54: 0b00011111111001111111111,
55: 0b01011111111001111111111,
56: 0b01011111111001111111111,
57: 0b01011111111001111111111,
58: 0b01111111111001111111111,
59: 0b01111111111001111111111,
60: 0b11111111111001111111111,
61: 0b11111111111001111111111,
62: 0b11111111111001111111111,
63: 0b11111111111001111111111,
64: 0b11111111111001111111111,
65: 0b11111111111001111111111,
66: 0b11111111111001111111111,
67: 0b11111111111001111111111,
68: 0b11111111111001111111111,
69: 0b11111111111001111111111,
70: 0b11111111111001111111111,
71: 0b11111111111001111111111
},
firefox: {
43: 0b01001110100011011101,
44: 0b01001110100111011101,
45: 0b01001110100111011111,
46: 0b01011110100111011111,
47: 0b01011110100111111111,
48: 0b01011110100111111111,
49: 0b01011110100111111111,
50: 0b01011110100111111111,
51: 0b01011110100111111111,
52: 0b11111111100111111111,
53: 0b11111111100111111111,
54: 0b11111111100111111111,
55: 0b11111111100111111111,
56: 0b11111111100111111111,
57: 0b11111111100111111111,
58: 0b11111111100111111111
43: 0b00010011101000110111011,
44: 0b00010011101000110111011,
45: 0b00010011101000110111111,
46: 0b00010111101000110111111,
47: 0b00010111101000111111111,
48: 0b00010111101000111111111,
49: 0b00010111101000111111111,
50: 0b00010111101000111111111,
51: 0b00010111101001111111111,
52: 0b01111111111001111111111,
53: 0b01111111111001111111111,
54: 0b01111111111001111111111,
55: 0b11111111111001111111111,
56: 0b11111111111001111111111,
57: 0b11111111111001111111111,
58: 0b11111111111001111111111,
59: 0b11111111111001111111111,
60: 0b11111111111001111111111,
61: 0b11111111111001111111111,
62: 0b11111111111001111111111,
63: 0b11111111111001111111111,
64: 0b11111111111001111111111
},
safari: {
8: 0b01000000000000000100,
9: 0b01001001100001101110,
10: 0b11011111100111111111,
'10.1': 0b11111111100111111111,
11: 0b11111111100111111111
8: 0b00010000000000000001001,
9: 0b00010010001000011011101,
10: 0b00110111111001111111111,
'10.1': 0b01111111111001111111111,
11: 0b01111111111001111111111,
'11.1': 0b11111111111001111111111,
12: 0b11111111111001111111111
},
ie: {
8: 0b00000000000000000000,
9: 0b01000000000000000000,
10: 0b01000000000000000000,
11: 0b01000000000100000000
8: 0b00000000000000000000000,
9: 0b00010000000000000000001,
10: 0b00010000000000000000001,
11: 0b00010000000000000000001 // no let/const in for loops
},
edge: {
12: 0b01001010100101001101,
13: 0b01011110100111001111,
14: 0b11111110100111111111,
15: 0b11111110100111111111,
16: 0b11111110100111111111
12: 0b00010010101000010011011,
13: 0b00010111101000110011111,
14: 0b00111111101001111111111,
15: 0b01111111101001111111111,
16: 0b01111111101001111111111,
17: 0b01111111101001111111111,
18: 0b01111111101001111111111,
19: 0b01111111101001111111111
},
node: {
'0.10': 0b01000000000000000000,
'0.12': 0b01000000000001000000,
4: 0b01001000100011001111,
5: 0b01001000100011001111,
6: 0b01011111100111111111,
8: 0b11111111100111111111,
'8.3': 0b11111111100111111111,
'8.7': 0b11111111100111111111
'0.10': 0b00010000000000000000001,
'0.12': 0b00010000000000010000001,
4: 0b00010010001000110011111,
5: 0b00010010001000110011111,
6: 0b00010111111001111111111,
8: 0b01111111111001111111111,
'8.3': 0b11111111111001111111111,
'8.7': 0b11111111111001111111111,
'8.10': 0b11111111111001111111111
}

@@ -71,2 +91,3 @@ };

export const features = [
'getterSetter',
'arrow',

@@ -97,3 +118,5 @@ 'classes',

'trailingFunctionCommas'
'trailingFunctionCommas',
'asyncAwait',
'objectRestSpread'
];

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc