Skip to content
This repository was archived by the owner on May 29, 2019. It is now read-only.
Merged
Show file tree
Hide file tree
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
13 changes: 12 additions & 1 deletion loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ module.exports = function(source) {
module.exports.pitch = function(request) {
if(this.cacheable) this.cacheable();
var query = loaderUtils.parseQuery(this.query);
var loaders = this.loaders.slice(this.loaderIndex + 1);
this.addDependency(this.resourcePath);
// We already in child compiler, return empty bundle
if(this[NS] === undefined) {
Expand All @@ -33,6 +34,7 @@ module.exports.pitch = function(request) {
if(query.omit) {
this.loaderIndex += +query.omit + 1;
request = request.split("!").slice(+query.omit).join("!");
loaders = loaders.slice(+query.omit);
}
var resultSource;
if(query.remove) {
Expand Down Expand Up @@ -64,10 +66,19 @@ module.exports.pitch = function(request) {
// We set loaderContext[NS] = false to indicate we already in
// a child compiler so we don't spawn another child compilers from there.
childCompiler.plugin("this-compilation", function(compilation) {
compilation.plugin("normal-module-loader", function(loaderContext) {
compilation.plugin("normal-module-loader", function(loaderContext, module) {
loaderContext[NS] = false;
if (module.request === request) {
module.loaders = loaders.map(function(loader) {
return {
loader: loader.path,
options: loader.options
};
});
}
});
});

var source;
childCompiler.plugin("after-compile", function(compilation, callback) {
source = compilation.assets[childFilename] && compilation.assets[childFilename].source();
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"dependencies": {
"async": "^2.1.2",
"loader-utils": "^0.2.3",
"loader-utils": "^0.2.16",
"webpack-sources": "^0.1.0"
},
"devDependencies": {
Expand Down