|
1 | 1 | /* eslint global-require: 0, import/no-dynamic-require: 0, object-curly-newline: 0, class-methods-use-this: 0, max-len: 0 */ |
2 | | -const path = require('path'); |
3 | 2 | const fs = require('fs'); |
4 | 3 | const { isSourceMap, isTypescript, ensureFilePath } = require('@after-work.js/utils'); |
5 | 4 | const FileCache = require('./file-cache'); |
6 | 5 |
|
7 | 6 | const fileCache = new FileCache(); |
8 | 7 |
|
9 | 8 | function getBabelOpts(filename, argv) { |
10 | | - const { options, babelPluginIstanbul } = argv.babel; |
11 | | - const sourceRoot = (options && options.sourceRoot) || argv.coverage ? path.dirname(filename) : undefined;// eslint-disable-line |
| 9 | + const { options: { sourceRoot, only, ignore }, babelPluginIstanbul } = argv.babel; |
12 | 10 | const addCoverage = argv.instrument.testExclude.shouldInstrument(filename); |
13 | 11 | const plugins = addCoverage ? |
14 | 12 | [[babelPluginIstanbul, {}]] : |
15 | 13 | []; |
16 | 14 | const sourceMaps = 'both'; |
17 | 15 | const retainLines = true; |
18 | | - const { only, ignore } = argv.babelOptions || {}; |
19 | 16 | return { filename, sourceRoot, plugins, only, ignore, sourceMaps, retainLines }; |
20 | 17 | } |
21 | 18 |
|
22 | 19 | function transformTypescript(filePath, sourceRoot, tsContent, argv) { |
23 | 20 | const { babel: { typescript } } = argv; |
24 | 21 | const { transform: { typescript: { compilerOptions, babelOptions } } } = argv; |
25 | | - const fileName = argv.coverage ? path.basename(filePath) : filePath; |
26 | | - compilerOptions.sourceRoot = argv.coverage ? path.resolve(path.dirname(filePath)) : sourceRoot; |
| 22 | + const fileName = filePath; |
| 23 | + compilerOptions.sourceRoot = sourceRoot; |
27 | 24 | compilerOptions.inlineSources = true; |
28 | 25 | if (!compilerOptions.sourceMap && !compilerOptions.inlineSourceMap) { |
29 | 26 | compilerOptions.inlineSourceMap = true; |
|
0 commit comments