Skip to content

Commit

Permalink
fix(worker-lodaer): correctly return errors from loader (#151)
Browse files Browse the repository at this point in the history
  • Loading branch information
ValeraS authored Jul 18, 2024
1 parent 275d943 commit 0042132
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/common/webpack/worker/worker-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,18 @@ export const pitch: webpack.PitchLoaderDefinitionFunction = function (request) {

const cb = this.async();
workerCompiler.compile((err, compilation) => {
if (!compilation) {
return undefined;
if (compilation) {
workerCompiler.parentCompilation?.children.push(compilation);
}

workerCompiler.parentCompilation?.children.push(compilation);

if (err) {
return cb(err);
}

if (!compilation) {
return cb(new Error('Child compilation failed'));
}

if (compilation.errors && compilation.errors.length) {
const errorDetails = compilation.errors
.map((error) => {
Expand All @@ -98,7 +100,7 @@ export const pitch: webpack.PitchLoaderDefinitionFunction = function (request) {
const cacheIdent = request;
const objectToHash = compilation.assets[filename];
if (!objectToHash) {
throw new Error(`Asset ${filename} not found in compilation`);
return cb(new Error(`Asset ${filename} not found in compilation`));
}
const cacheETag = cache.getLazyHashedEtag(objectToHash);

Expand Down

0 comments on commit 0042132

Please sign in to comment.