Skip to content
Closed
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
27 changes: 27 additions & 0 deletions src/WorkerPool.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,33 @@ class PoolWorker {
],
});
});

finalCallback();
break;
}
case 'importModule':
{
const {
request,
options,
questionId
} = message;
const {
data
} = this.jobs[id];
data.importModule(request, options)
.then(result => this.writeJson({
type: 'result',
id: questionId,
error: null,
result
}))
.catch(error => this.writeJson({
type: 'result',
id: questionId,
error
}));

finalCallback();
break;
}
Expand Down
2 changes: 2 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,14 @@ function pitch() {
this._compilation.options.devtool,
},
},
mode: this.mode,
resourcePath: this.resourcePath,
resource: this.resourcePath + (this.resourceQuery || ''),
sourceMap: this.sourceMap,
emitError: this.emitError,
emitWarning: this.emitWarning,
loadModule: this.loadModule,
importModule: this.importModule,
resolve: this.resolve,
getResolve: this.getResolve,
target: this.target,
Expand Down
21 changes: 21 additions & 0 deletions src/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,26 @@ const queue = asyncQueue(({ id, data }, taskCallback) => {
});
nextQuestionId += 1;
},
importModule: (request, options) => {
const promise = new Promise((resolve, reject) => {
callbackMap[nextQuestionId] = (error, result) => {
if (error) {
reject(error);
} else {
resolve(result);
}
};
});
writeJson({
type: 'importModule',
id,
questionId: nextQuestionId,
request,
options
});
nextQuestionId += 1;
return promise;
},
resolve: (context, request, callback) => {
resolveWithOptions(context, request, callback);
},
Expand Down Expand Up @@ -244,6 +264,7 @@ const queue = asyncQueue(({ id, data }, taskCallback) => {
sourceMap: data.sourceMap,
target: data.target,
minimize: data.minimize,
mode: data.mode,
resourceQuery: data.resourceQuery,
rootContext: data.rootContext,
// eslint-disable-next-line no-underscore-dangle
Expand Down