This repository has been archived by the owner on Jan 19, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: update to use loader api that webpack 2+ exposes
- Loading branch information
Matt Lewis
committed
Jul 9, 2017
1 parent
a680f32
commit 7e686b9
Showing
5 changed files
with
72 additions
and
21 deletions.
There are no files selected for viewing
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
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,21 +1,12 @@ | ||
import { createInstrumenter } from 'istanbul-lib-instrument'; | ||
import loaderUtils from 'loader-utils'; | ||
import convert from 'convert-source-map'; | ||
|
||
export default function (source, sourceMap) { | ||
let srcMap = sourceMap; | ||
// use inline source map, if any | ||
const inlineSourceMap = convert.fromSource(source); | ||
if (!srcMap && inlineSourceMap) { | ||
srcMap = inlineSourceMap.sourcemap; | ||
} | ||
export default function (source) { | ||
const userOptions = loaderUtils.getOptions(this) || {}; | ||
userOptions.produceSourceMap = typeof userOptions.produceSourceMap === 'undefined' ? true : userOptions.produceSourceMap; | ||
const instrumenter = createInstrumenter(userOptions); | ||
|
||
const userOptions = loaderUtils.getOptions(this); | ||
const instrumenter = createInstrumenter( | ||
Object.assign({ produceSourceMap: this.srcMap }, userOptions), | ||
); | ||
|
||
return instrumenter.instrument(source, this.resourcePath, (error, source) => { | ||
instrumenter.instrument(source, this.resourcePath, (error, source) => { | ||
this.callback(error, source, instrumenter.lastSourceMap()); | ||
}, srcMap); | ||
}); | ||
} |
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