register.js cache algorithm fails to account for buble version and options
Buble's caching algorithm only hashes the source and not the buble version and corresponding transpile options:
So in the event that buble is upgraded or the transpile options change, the cached compiled file would be incorrect. This might be fixed by something like the following untested patch:
--- a/register.js
+++ b/register.js
@@ -48,6 +48,8 @@ require.extensions[ '.js' ] = function ( m, filename ) {
var source = fs.readFileSync( filename, 'utf-8' );
var hash = crypto.createHash( 'sha256' );
+ hash.update( buble.VERSION );
+ hash.update( JSON.stringify( options ) );
hash.update( source );
var key = hash.digest( 'hex' ) + '.json';
var cachepath = path.join( cachedir, key );
Was also surprised to learn that the local ./register.js
is not run for npm test
- see #153 (closed).