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 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Matt Lewis
committed
Jul 10, 2017
1 parent
cec1986
commit a6f974b
Showing
8 changed files
with
70 additions
and
16 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,11 +1,21 @@ | ||
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 | ||
if (!srcMap) { | ||
const inlineSourceMap = convert.fromSource(source); | ||
if (inlineSourceMap) { | ||
srcMap = inlineSourceMap.sourcemap; | ||
} | ||
} | ||
|
||
export default function (source) { | ||
const options = Object.assign({ produceSourceMap: true }, loaderUtils.getOptions(this)); | ||
const instrumenter = createInstrumenter(options); | ||
|
||
instrumenter.instrument(source, this.resourcePath, (error, instrumentedSource) => { | ||
this.callback(error, instrumentedSource, instrumenter.lastSourceMap()); | ||
}); | ||
}, srcMap); | ||
} |
Large diffs are not rendered by default.
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 |
---|---|---|
|
@@ -4,8 +4,4 @@ module.exports = class Foo { | |
return !!this; | ||
} | ||
|
||
baz() { | ||
return !this.bar(); | ||
} | ||
|
||
}; |
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,11 +1,15 @@ | ||
import path from 'path'; | ||
import loader from '../../src/cjs'; | ||
|
||
module.exports = function (...args) { | ||
module.exports = function (source, map, ...args) { | ||
// hack the resourcePath to be consistent across systems so that tests always work | ||
this.resourcePath = this.resourcePath | ||
.replace(path.resolve(__dirname, '..'), '') | ||
// make windows paths appear like unix | ||
.replace(/\\/g, '/'); | ||
return loader.call(this, ...args); | ||
const sourceMap = map; | ||
if (sourceMap) { | ||
sourceMap.sourceRoot = ''; | ||
} | ||
return loader.call(this, source, sourceMap, ...args); | ||
}; |
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