Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supresses the IO Exception of convert-source-map #6

Merged
merged 1 commit into from
Jul 11, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Supresses the IO Exception of convert-source-map
The IO Exception occurs when in the webpack pipeline some files have
the .map counterpart but some dont.

If the user enables the stats of webpack, he/she would still see the
warnings.
  • Loading branch information
Pouja committed Apr 6, 2020
commit 3ccab96d554bb540a50db13bb312ee4e0310874a
23 changes: 16 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -20,14 +20,23 @@ export default function(this: loader.LoaderContext, source: string, sourceMap?:
options = Object.assign(defaultOptions, options);
validateOptions(optionsSchema, options, "Coverage Istanbul Loader");

if (!sourceMap) {
// Check for an inline source map
const inlineSourceMap = convert.fromSource(source)
|| convert.fromMapFileSource(source, path.dirname(this.resourcePath));
try {
if (!sourceMap) {
// Check for an inline source map
const inlineSourceMap = convert.fromSource(source)
|| convert.fromMapFileSource(source, path.dirname(this.resourcePath));

if (inlineSourceMap) {
// Use the inline source map
sourceMap = inlineSourceMap.sourcemap as RawSourceMap;
if (inlineSourceMap) {
// Use the inline source map
sourceMap = inlineSourceMap.sourcemap as RawSourceMap;
}
}
} catch (e) {
// Exception is thrown by fromMapFileSource when there is no source map file
if (e instanceof Error && e.message.includes("An error occurred while trying to read the map file at")) {
this.emitWarning(e);
} else {
throw e;
}
}