Fea: get message under src when has error

This commit is contained in:
lichengyin 2016-03-16 20:02:14 +08:00
parent 3e5e04a243
commit 38f188611d
2 changed files with 9 additions and 3 deletions

View File

@ -9,7 +9,7 @@
"scripts": {
"test": "npm run eslint && npm run test-cov",
"test-cov": "istanbul cover ./node_modules/mocha/bin/_mocha -- -t 20000 --recursive -R spec test/",
"compile": "babel --presets es2015-loose,stage-1 --plugins transform-runtime src/ --out-dir lib/",
"compile": "babel --presets es2015-loose,stage-1 --plugins transform-runtime src/ --out-dir lib/ --source-maps",
"watch-compile": "npm run compile -- --watch",
"watch": "npm run watch-compile",
"prepublish": "npm run compile",

View File

@ -126,13 +126,19 @@ export default class {
filename: file,
retainLines: retainLines,
presets: ['es2015-loose', 'stage-1'].concat(this.options.presets || []),
plugins: ['transform-runtime'].concat(this.options.plugins || [])
plugins: ['transform-runtime'].concat(this.options.plugins || []),
sourceMaps: true
});
if(!logged && this.options.log){
think.log(`Compile file ${file}`, 'Babel', startTime);
}
think.mkdir(path.dirname(`${this.outPath}${think.sep}${file}`));
fs.writeFileSync(`${this.outPath}${think.sep}${file}`, data.code);
let basename = path.basename(file);
let outputContent = data.code + '\n//# sourceMappingURL=' + basename + '.map';
fs.writeFileSync(`${this.outPath}${think.sep}${file}`, outputContent);
let relativePath = path.relative(this.outPath + think.sep + file, this.srcPath + think.sep + file);
data.map.sources[0] = relativePath;
fs.writeFileSync(`${this.outPath}${think.sep}${file}.map`, JSON.stringify(data.map));
}
/**
* src file is deleted, but app file also exist