Comparing version
# buble changelog | ||
## 0.16.0 | ||
* Allow truthy dash-cased props ([#2](https://github.com/Rich-Harris/buble/pull/2)) | ||
* Make class accessors configurable ([#3](https://github.com/Rich-Harris/buble/pull/3)) | ||
* Support JSX pragma comments ([#5](https://github.com/Rich-Harris/buble/pull/5)) | ||
* Handle JSX with no spaces between attributes ([#6](https://github.com/Rich-Harris/buble/pull/6)) | ||
## 0.15.2 | ||
@@ -4,0 +11,0 @@ |
{ | ||
"name": "buble", | ||
"version": "0.15.2", | ||
"version": "0.16.0", | ||
"description": "The blazing fast, batteries-included ES2015 compiler", | ||
"main": "dist/buble.umd.js", | ||
"jsnext:main": "dist/buble.es.js", | ||
"module": "dist/buble.es.js", | ||
"browser": "dist/buble.deps.js", | ||
"files": [ | ||
@@ -15,11 +16,6 @@ "bin", | ||
"scripts": { | ||
"build": "npm run build:umd && npm run build:es && npm run build:browser", | ||
"build:umd": "rollup -c -f umd -o dist/buble.umd.js", | ||
"build:browser": "rollup -c --environment DEPS -f umd -o dist/buble.deps.js", | ||
"build:es": "rollup -c -f es6 -o dist/buble.es.js", | ||
"test": "mocha test/test.js --compilers js:./register", | ||
"pretest": "npm run build:umd && npm run build:browser", | ||
"test:node": "mocha test/test.js --compilers js:./register", | ||
"pretest:node": "npm run build:umd", | ||
"prepublish": "npm test && npm run build:es", | ||
"build": "rollup -c", | ||
"test": "mocha test/test.js", | ||
"pretest": "npm run build", | ||
"prepublish": "npm test", | ||
"lint": "eslint src" | ||
@@ -58,3 +54,3 @@ }, | ||
"rimraf": "^2.5.2", | ||
"rollup": "^0.26.3", | ||
"rollup": "^0.50.0", | ||
"rollup-plugin-buble": "^0.8.0", | ||
@@ -72,6 +68,8 @@ "rollup-plugin-commonjs": "^2.2.1", | ||
"chalk": "^1.1.3", | ||
"vlq": "0.2.1", | ||
"magic-string": "^0.14.0", | ||
"minimist": "^1.2.0", | ||
"os-homedir": "^1.0.1" | ||
"os-homedir": "^1.0.1", | ||
"vlq": "^0.2.2" | ||
} | ||
} |
@@ -41,3 +41,3 @@ var fs = require( 'fs' ); | ||
if ( home ) { | ||
var cachedir = path.join( home, '.buble-cache', nodeVersion ); | ||
var cachedir = path.join( home, '.buble-cache', String(nodeVersion) ); | ||
mkdirp( cachedir ); | ||
@@ -44,0 +44,0 @@ fs.writeFileSync( path.join( home, '.buble-cache/README.txt' ), 'These files enable a faster startup when using buble/register. You can safely delete this folder at any time. See https://buble.surge.sh/guide/ for more information.' ); |
@@ -49,2 +49,3 @@ import acorn from 'acorn/dist/acorn.js'; | ||
let ast; | ||
let jsx = null; | ||
@@ -56,2 +57,8 @@ try { | ||
sourceType: 'module', | ||
onComment: (block, text) => { | ||
if ( !jsx ) { | ||
let match = /@jsx\s+([^\s]+)/.exec( text ); | ||
if ( match ) jsx = match[1]; | ||
} | ||
}, | ||
plugins: { | ||
@@ -62,2 +69,3 @@ jsx: true, | ||
}); | ||
options.jsx = jsx || options.jsx; | ||
} catch ( err ) { | ||
@@ -64,0 +72,0 @@ err.snippet = getSnippet( source, err.loc ); |
@@ -159,3 +159,3 @@ import Node from '../Node.js'; | ||
if ( prototypeGettersAndSetters.length ) { | ||
intro.push( `var ${prototypeAccessors} = { ${prototypeGettersAndSetters.map( name => `${name}: {}` ).join( ',' )} };` ); | ||
intro.push( `var ${prototypeAccessors} = { ${prototypeGettersAndSetters.map( name => `${name}: { configurable: true }` ).join( ',' )} };` ); | ||
outro.push( `Object.defineProperties( ${name}.prototype, ${prototypeAccessors} );` ); | ||
@@ -165,3 +165,3 @@ } | ||
if ( staticGettersAndSetters.length ) { | ||
intro.push( `var ${staticAccessors} = { ${staticGettersAndSetters.map( name => `${name}: {}` ).join( ',' )} };` ); | ||
intro.push( `var ${staticAccessors} = { ${staticGettersAndSetters.map( name => `${name}: { configurable: true }` ).join( ',' )} };` ); | ||
outro.push( `Object.defineProperties( ${name}, ${staticAccessors} );` ); | ||
@@ -168,0 +168,0 @@ } |
import Node from '../Node.js'; | ||
const IS_DATA_ATTRIBUTE = /-/; | ||
const hasDashes = val => /-/.test(val); | ||
const formatKey = key => hasDashes(key) ? `'${key}'` : key; | ||
const formatVal = val => val ? '' : 'true'; | ||
export default class JSXAttribute extends Node { | ||
transpile ( code, transforms ) { | ||
if ( this.value ) { | ||
code.overwrite( this.name.end, this.value.start, ': ' ); | ||
} else { | ||
// tag without value | ||
code.overwrite( this.name.start, this.name.end, `${this.name.name}: true` ); | ||
} | ||
const { start, name } = this.name; | ||
if ( IS_DATA_ATTRIBUTE.test( this.name.name ) ) { | ||
code.overwrite( this.name.start, this.name.end, `'${this.name.name}'` ); | ||
} | ||
// Overwrite equals sign if value is present. | ||
const end = this.value ? this.value.start : this.name.end; | ||
code.overwrite( start, end, `${formatKey(name)}: ${formatVal(this.value)}` ); | ||
super.transpile( code, transforms ); | ||
} | ||
} |
@@ -31,3 +31,6 @@ import Node from '../Node.js'; | ||
if ( i > 0 ) { | ||
code.overwrite( c, attr.start, ', ' ); | ||
if ( attr.start === c ) | ||
code.insertRight( c, ', ' ); | ||
else | ||
code.overwrite( c, attr.start, ', ' ); | ||
} | ||
@@ -34,0 +37,0 @@ |
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
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
26388
0.12%2558279
-2.52%8
14.29%+ Added