Skip to content
This repository has been archived by the owner on Jan 19, 2021. It is now read-only.

fix: use latest API (loader-utils) #61

Merged
merged 1 commit into from
Jun 28, 2017
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
6 changes: 3 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import istanbulLibInstrument from 'istanbul-lib-instrument';
import { createInstrumenter } from 'istanbul-lib-instrument';
import loaderUtils from 'loader-utils';
import convert from 'convert-source-map';

Expand All @@ -10,8 +10,8 @@ export default function (source, sourceMap) {
srcMap = inlineSourceMap.sourcemap;
}

const userOptions = loaderUtils.parseQuery(this.query);
const instrumenter = istanbulLibInstrument.createInstrumenter(
const userOptions = loaderUtils.getOptions(this);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

- const userOptions = loaderUtils.getOptions(this);
+ const userOptions = loaderUtils.getOptions(this) || {};

loaderUtils.getOptions() returns null, if there aren't any options

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is safe as passing null as an arg to Object.assign just has it skip it without an error Object.assign({foo: 'bar'}, null) == {foo: 'bar'}

https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/assign

const instrumenter = createInstrumenter(
Object.assign({ produceSourceMap: this.srcMap }, userOptions),
);

Expand Down