catch errors thrown during parser/generation creation

This commit is contained in:
Tobias Koppers 2021-04-29 16:18:10 +02:00
parent e9de77aae4
commit eea0aee1a7
5 changed files with 49 additions and 23 deletions

View File

@ -520,6 +520,7 @@ class NormalModuleFactory extends ModuleFactory {
)
);
}
try {
Object.assign(data.createData, {
layer:
layer === undefined ? contextInfo.issuerLayer || null : layer,
@ -543,6 +544,9 @@ class NormalModuleFactory extends ModuleFactory {
generatorOptions: settings.generator,
resolveOptions
});
} catch (e) {
return callback(e);
}
callback();
});
this.resolveRequestArray(

View File

@ -0,0 +1,6 @@
module.exports = [
[
/Invalid generator object\. Asset Modules Plugin has been initialized using a generator object that does not match the API schema/,
/generator has an unknown property 'filename'/
]
];

View File

@ -0,0 +1 @@
import url from "./text.txt";

View File

@ -0,0 +1 @@
Hello World

View File

@ -0,0 +1,14 @@
/** @type {import("../../../../").Configuration} */
module.exports = {
module: {
rules: [
{
test: /\.txt$/,
type: "asset/inline",
generator: {
filename: "[name].txt"
}
}
]
}
};