Comparing version 0.11.6 to 0.12.0
# buble changelog | ||
## 0.12.0 | ||
* Support `u` flag in regular expression literals ([!62](https://gitlab.com/Rich-Harris/buble/merge_requests/62)) | ||
* Save `buble/register` transformations to `$HOME/.buble-cache` ([!63](https://gitlab.com/Rich-Harris/buble/merge_requests/63)) | ||
## 0.11.6 | ||
@@ -4,0 +9,0 @@ |
{ | ||
"name": "buble", | ||
"version": "0.11.6", | ||
"version": "0.12.0", | ||
"description": "The blazing fast, batteries-included ES2015 compiler", | ||
@@ -52,2 +52,3 @@ "main": "dist/buble.umd.js", | ||
"mocha": "^2.4.5", | ||
"regexpu-core": "^2.0.0", | ||
"rimraf": "^2.5.2", | ||
@@ -68,4 +69,5 @@ "rollup": "^0.26.3", | ||
"magic-string": "^0.14.0", | ||
"minimist": "^1.2.0" | ||
"minimist": "^1.2.0", | ||
"os-homedir": "^1.0.1" | ||
} | ||
} |
var fs = require( 'fs' ); | ||
var path = require( 'path' ); | ||
var crypto = require( 'crypto' ); | ||
var homedir = require( 'os-homedir' ); | ||
var buble = require( './' ); | ||
@@ -9,7 +11,7 @@ | ||
var nodeVersion = /(?:0\.)?\d+/.exec( process.version )[0]; | ||
var versions = [ '0.10', '0.12', '4', '5' ]; | ||
var versions = [ '0.10', '0.12', '4', '5', '6' ]; | ||
if ( !~versions.indexOf( nodeVersion ) ) { | ||
if ( +nodeVersion > 5 ) { | ||
nodeVersion = 5; | ||
if ( +nodeVersion > 6 ) { | ||
nodeVersion = 6; | ||
} else { | ||
@@ -26,2 +28,21 @@ throw new Error( 'Unsupported version (' + nodeVersion + '). Please raise an issue at https://gitlab.com/Rich-Harris/buble/issues' ); | ||
function mkdirp ( dir ) { | ||
var parent = path.dirname( dir ); | ||
if ( dir === parent ) return; | ||
mkdirp( parent ); | ||
try { | ||
fs.mkdirSync( dir ); | ||
} catch ( err ) { | ||
if ( err.code !== 'EEXIST' ) throw err; | ||
} | ||
} | ||
var home = homedir(); | ||
if ( home ) { | ||
var cachedir = path.join( home, '.buble-cache', nodeVersion ); | ||
mkdirp( cachedir ); | ||
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.' ); | ||
} | ||
require.extensions[ '.js' ] = function ( m, filename ) { | ||
@@ -31,15 +52,35 @@ if ( nodeModulesPattern.test( filename ) ) return original( m, filename ); | ||
var source = fs.readFileSync( filename, 'utf-8' ); | ||
var hash = crypto.createHash( 'sha256' ); | ||
hash.update( source ); | ||
var key = hash.digest( 'hex' ) + '.json'; | ||
var cachepath = path.join( cachedir, key ); | ||
try { | ||
var compiled = buble.transform( source, options ); | ||
} catch ( err ) { | ||
if ( err.snippet ) { | ||
console.log( 'Error compiling ' + filename + ':\n---' ); | ||
console.log( err.snippet ); | ||
console.log( err.message ); | ||
console.log( '' ) | ||
process.exit( 1 ); | ||
var compiled; | ||
if ( cachedir ) { | ||
try { | ||
compiled = JSON.parse( fs.readFileSync( cachepath, 'utf-8' ) ); | ||
} catch ( err ) { | ||
// noop | ||
} | ||
} | ||
throw err; | ||
if ( !compiled ) { | ||
try { | ||
compiled = buble.transform( source, options ); | ||
if ( cachedir ) { | ||
fs.writeFileSync( cachepath, JSON.stringify( compiled ) ); | ||
} | ||
} catch ( err ) { | ||
if ( err.snippet ) { | ||
console.log( 'Error compiling ' + filename + ':\n---' ); | ||
console.log( err.snippet ); | ||
console.log( err.message ); | ||
console.log( '' ) | ||
process.exit( 1 ); | ||
} | ||
throw err; | ||
} | ||
} | ||
@@ -46,0 +87,0 @@ |
import Node from '../Node.js'; | ||
import CompileError from '../../utils/CompileError.js'; | ||
import rewritePattern from 'regexpu-core'; | ||
@@ -14,6 +15,10 @@ export default class Literal extends Node { | ||
if ( this.regex ) { | ||
if ( transforms.unicodeRegExp && /u/.test( this.regex.flags ) ) throw new CompileError( this, 'Regular expression unicode flag is not supported' ); | ||
if ( transforms.stickyRegExp && /y/.test( this.regex.flags ) ) throw new CompileError( this, 'Regular expression sticky flag is not supported' ); | ||
const { pattern, flags } = this.regex; | ||
if ( transforms.stickyRegExp && /y/.test( flags ) ) throw new CompileError( this, 'Regular expression sticky flag is not supported' ); | ||
if ( transforms.unicodeRegExp && /u/.test( flags ) ) { | ||
code.overwrite( this.start, this.end, `/${rewritePattern( pattern, flags )}/${flags.replace( 'u', '' )}` ); | ||
} | ||
} | ||
} | ||
} |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
High entropy strings
Supply chain riskContains high entropy strings. This could be a sign of encrypted data, leaked secrets or obfuscated code.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2679354
78
25275
7
14
2
17
+ Addedos-homedir@^1.0.1
+ Addedos-homedir@1.0.2(transitive)