-
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: ignore all Types from TypeScript and not executable lines
- Loading branch information
1 parent
521dee7
commit 2fccc75
Showing
8 changed files
with
648 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
const V8ToIstanbul = require('./lib/v8-to-istanbul') | ||
|
||
module.exports = function (path, wrapperLength, sources, excludePath) { | ||
return new V8ToIstanbul(path, wrapperLength, sources, excludePath) | ||
module.exports = function (path, wrapperLength, sources, excludePath, plugin) { | ||
return new V8ToIstanbul(path, wrapperLength, sources, excludePath, plugin) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
const esbuild = require('esbuild') | ||
const vlq = require('vlq') | ||
|
||
module.exports = function (source, path) { | ||
let result | ||
try { | ||
const loader = path.endsWith('.tsx') || path.endsWith('.jsx') ? { loader: 'tsx', jsx: 'preserve' } : {} | ||
result = esbuild.transformSync(source.sourceRaw, { | ||
sourcemap: 'external', | ||
loader: 'ts', | ||
minify: false, | ||
minifyWhitespace: false, | ||
minifySyntax: false, | ||
legalComments: 'none', | ||
...loader | ||
}) | ||
} catch (err) { | ||
console.error(`${path} parsed with error ${err.message}`) | ||
return | ||
} | ||
const mappings = JSON.parse(result.map).mappings | ||
if (mappings) { | ||
let start = 0 | ||
const executableLines = mappings.split(';').reduce((set, str) => { | ||
start = str.split(',').reduce((number, seg) => { | ||
const [, , line] = vlq.decode(seg) | ||
set.add(number + line) | ||
return number + line | ||
}, start) | ||
return set | ||
}, new Set()) | ||
source.lines.forEach((line, index) => { | ||
line.ignore = line.ignore || !executableLines.has(index) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.