From 2d3afb431c54466d18f7b7b59a8910456d8ca36c Mon Sep 17 00:00:00 2001 From: Michelle Tilley Date: Mon, 31 Oct 2016 23:21:13 -0700 Subject: [PATCH] Include package name as part of cache key --- spec/package-transpilation-registry-spec.js | 2 +- src/compile-cache.js | 4 ++-- src/package-transpilation-registry.js | 9 +++++---- src/package.coffee | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/spec/package-transpilation-registry-spec.js b/spec/package-transpilation-registry-spec.js index 6efd2e72b..7a13d3396 100644 --- a/spec/package-transpilation-registry-spec.js +++ b/spec/package-transpilation-registry-spec.js @@ -98,7 +98,7 @@ describe("PackageTranspilationRegistry", () => { throw new Error('bad transpiler path ' + spec.transpiler) }) - registry.addTranspilerConfigForPath('/path/to', [ + registry.addTranspilerConfigForPath('/path/to', 'my-package', [ jsSpec, coffeeSpec, omgSpec ]) }) diff --git a/src/compile-cache.js b/src/compile-cache.js index 6101626bb..fed890d5c 100644 --- a/src/compile-cache.js +++ b/src/compile-cache.js @@ -19,9 +19,9 @@ var COMPILERS = { '.coffee': packageTranspilationRegistry.wrapTranspiler(require('./coffee-script')) } -exports.addTranspilerConfigForPath = function (packagePath, config) { +exports.addTranspilerConfigForPath = function (packagePath, packageName, config) { packagePath = fs.realpathSync(packagePath) - packageTranspilationRegistry.addTranspilerConfigForPath(packagePath, config) + packageTranspilationRegistry.addTranspilerConfigForPath(packagePath, packageName, config) } exports.removeTranspilerConfigForPath = function (packagePath) { diff --git a/src/package-transpilation-registry.js b/src/package-transpilation-registry.js index e51eebea6..80e2469c1 100644 --- a/src/package-transpilation-registry.js +++ b/src/package-transpilation-registry.js @@ -13,10 +13,11 @@ function PackageTranspilationRegistry () { } Object.assign(PackageTranspilationRegistry.prototype, { - addTranspilerConfigForPath: function (packagePath, config) { + addTranspilerConfigForPath: function (packagePath, packageName, config) { this.configByPackagePath[packagePath] = { - specs: config, - path: packagePath + name: packageName, + path: packagePath, + specs: config } }, @@ -116,7 +117,7 @@ Object.assign(PackageTranspilationRegistry.prototype, { hash.update(additionalCacheData, 'utf8') } - return path.join('package-transpile', hash.digest('hex')) + return path.join('package-transpile', spec._config.name, hash.digest('hex')) }, transpileWithPackageTranspiler: function (sourceCode, filePath, spec) { diff --git a/src/package.coffee b/src/package.coffee index 1874a6916..6029c99ae 100644 --- a/src/package.coffee +++ b/src/package.coffee @@ -254,7 +254,7 @@ class Package registerTranspilerConfig: -> if @metadata.atomTranspilers - CompileCache.addTranspilerConfigForPath(@path, @metadata.atomTranspilers) + CompileCache.addTranspilerConfigForPath(@path, @name, @metadata.atomTranspilers) unregisterTranspilerConfig: -> if @metadata.atomTranspilers