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

fix: use correct options object & set fallback context #20

Merged
merged 2 commits into from
Apr 11, 2018
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
14 changes: 5 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,10 @@ module.exports = function(source, map) {
// Pass on query parameters as an options object to the DtsCreator. This lets
// you change the default options of the DtsCreator and e.g. use a different
// output folder.
var queryOptions = loaderUtils.getOptions(this);
var options;
var emitFile = true;
if (queryOptions) {
options = Object.assign({}, queryOptions);
emitFile = !options.noEmit;
delete options.noEmit;
}
var options = loaderUtils.getOptions(this) || {};
var context = options.context || this.context || this.rootContext;
var emitFile = !options.noEmit;
delete options.noEmit;

var creator = new DtsCreator(options);

Expand All @@ -26,7 +22,7 @@ module.exports = function(source, map) {
creator.create(this.resourcePath, source).then(content => {
if (emitFile) {
// Emit the created content as well
this.emitFile(path.relative(this.options.context, content.outputFilePath), content.contents || [''], map);
this.emitFile(path.relative(context, content.outputFilePath), content.contents || [''], map);
}
content.writeFile().then(_ => {
callback(null, source, map);
Expand Down