Skip to content

Commit

Permalink
Set source file name relative to options.sourceRoot
Browse files Browse the repository at this point in the history
  • Loading branch information
eur00t committed Nov 9, 2015
1 parent 71158f5 commit b8e5432
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ var cache = require('./lib/fs-cache.js');
var resolveRc = require('./lib/resolve-rc.js');
var pkg = require('./package.json');
var babelrc = resolveRc(process.cwd());
var path = require('path');

var transpile = function(source, options) {
var result = babel.transform(source, options);
Expand All @@ -28,6 +29,7 @@ module.exports = function(source, inputSourceMap) {
// Handle options
var defaultOptions = {
inputSourceMap: inputSourceMap,
sourceRoot: process.cwd(),
filename: loaderUtils.getRemainingRequest(this),
cacheIdentifier: JSON.stringify({
'babel-loader': pkg.version,
Expand All @@ -43,6 +45,13 @@ module.exports = function(source, inputSourceMap) {
options.sourceMap = this.sourceMap;
}

if (options.sourceFileName === undefined) {
options.sourceFileName = path.relative(
options.sourceRoot,
options.filename
);
}

var cacheDirectory = options.cacheDirectory;
var cacheIdentifier = options.cacheIdentifier;

Expand Down

0 comments on commit b8e5432

Please sign in to comment.