Browse Source

use .js.map extension for cached source maps

This is the more commonly used extension for source map files.

Fix the test which erroneously looked for `.js` files where it meant `.map`.
browser-support
Mark Wubben 9 years ago
parent
commit
934d57fa75
  1. 2
      lib/caching-precompiler.js
  2. 2
      lib/test-worker.js
  3. 4
      test/caching-precompiler.js

2
lib/caching-precompiler.js

@ -59,7 +59,7 @@ CachingPrecompiler.prototype._factory = function (babelConfig, cacheDir) {
code = code.toString();
var options = buildOptions(filename, code);
var result = babel.transform(code, options);
var mapFile = path.join(cacheDir, hash + '.map');
var mapFile = path.join(cacheDir, hash + '.js.map');
fs.writeFileSync(mapFile, JSON.stringify(result.map));
return result.code;
};

2
lib/test-worker.js

@ -72,7 +72,7 @@ installPrecompiler(function (filename) {
var precompiled = opts.precompiled[filename];
if (precompiled) {
sourceMapCache[filename] = path.join(cacheDir, precompiled + '.map');
sourceMapCache[filename] = path.join(cacheDir, precompiled + '.js.map');
return fs.readFileSync(path.join(cacheDir, precompiled + '.js'), 'utf8');
}

4
test/caching-precompiler.js

@ -18,7 +18,7 @@ function endsWithJs(filename) {
}
function endsWithMap(filename) {
return /\.js$/.test(filename);
return /\.js\.map$/.test(filename);
}
sinon.spy(babel, 'transform');
@ -50,7 +50,7 @@ test('adds files and source maps to the cache directory as needed', function (t)
var files = fs.readdirSync(tempDir);
t.is(files.length, 2);
t.is(files.filter(endsWithJs).length, 1, 'one .js file is saved to the cache');
t.is(files.filter(endsWithMap).length, 1, 'one .map file is saved to the cache');
t.is(files.filter(endsWithMap).length, 1, 'one .js.map file is saved to the cache');
t.end();
});

Loading…
Cancel
Save