-
Notifications
You must be signed in to change notification settings - Fork 30k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixup! src,lib: print source map error source on demand
- Loading branch information
1 parent
1ef283d
commit d3efe87
Showing
4 changed files
with
67 additions
and
0 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
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,34 @@ | ||
'use strict'; | ||
|
||
const common = require('../common.js'); | ||
const modPath = require.resolve('../fixtures/simple-error-stack.js'); | ||
|
||
const bench = common.createBenchmark(main, { | ||
method: ['without-sourcemap', 'sourcemap'], | ||
n: [1e5], | ||
}); | ||
|
||
function runN(n) { | ||
delete require.cache[modPath]; | ||
const mod = require(modPath); | ||
bench.start(); | ||
for (let i = 0; i < n; i++) { | ||
mod.simpleErrorStack(); | ||
} | ||
bench.end(n); | ||
} | ||
|
||
function main({ n, method }) { | ||
switch (method) { | ||
case 'without-sourcemap': | ||
process.setSourceMapsEnabled(false); | ||
runN(n); | ||
break; | ||
case 'sourcemap': | ||
process.setSourceMapsEnabled(true); | ||
runN(n); | ||
break; | ||
default: | ||
throw new Error(`Unexpected method "${method}"`); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,17 @@ | ||
'use strict'; | ||
|
||
// Compile with `tsc --inlineSourceMap benchmark/fixtures/simple-error-stack.ts`. | ||
|
||
const lorem = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.'; | ||
|
||
function simpleErrorStack() { | ||
try { | ||
(lorem as any).BANG(); | ||
} catch (e) { | ||
return e.stack; | ||
} | ||
} | ||
|
||
export { | ||
simpleErrorStack, | ||
}; |