mirror of https://github.com/webpack/webpack.git
fix: crash with filesystem cache and unknown scheme
This commit is contained in:
parent
6a6d94c6d9
commit
9e190d738a
|
@ -202,14 +202,19 @@ class AssetModulesPlugin {
|
||||||
const data =
|
const data =
|
||||||
/** @type {NonNullable<CodeGenerationResult["data"]>} */
|
/** @type {NonNullable<CodeGenerationResult["data"]>} */
|
||||||
(codeGenResult.data);
|
(codeGenResult.data);
|
||||||
|
const errored = module.getNumberOfErrors() > 0;
|
||||||
result.push({
|
result.push({
|
||||||
render: () =>
|
render: () =>
|
||||||
/** @type {Source} */ (codeGenResult.sources.get(type)),
|
/** @type {Source} */ (codeGenResult.sources.get(type)),
|
||||||
filename: buildInfo.filename || data.get("filename"),
|
filename: errored
|
||||||
|
? module.nameForCondition()
|
||||||
|
: buildInfo.filename || data.get("filename"),
|
||||||
info: buildInfo.assetInfo || data.get("assetInfo"),
|
info: buildInfo.assetInfo || data.get("assetInfo"),
|
||||||
auxiliary: true,
|
auxiliary: true,
|
||||||
identifier: `assetModule${chunkGraph.getModuleId(module)}`,
|
identifier: `assetModule${chunkGraph.getModuleId(module)}`,
|
||||||
hash: buildInfo.fullContentHash || data.get("fullContentHash")
|
hash: errored
|
||||||
|
? chunkGraph.getModuleHash(module, chunk.runtime)
|
||||||
|
: buildInfo.fullContentHash || data.get("fullContentHash")
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
/** @type {Error} */ (err).message +=
|
/** @type {Error} */ (err).message +=
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
module.exports = [
|
||||||
|
/You may need an additional plugin to handle "unknown:" URIs./
|
||||||
|
];
|
|
@ -0,0 +1,14 @@
|
||||||
|
it("should not crash", () => {
|
||||||
|
let errored;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const url = new URL(
|
||||||
|
"unknown:test",
|
||||||
|
import.meta.url
|
||||||
|
);
|
||||||
|
} catch (err) {
|
||||||
|
errored = err;
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(/Module build failed/.test(errored.message)).toBe(true);
|
||||||
|
});
|
|
@ -0,0 +1,30 @@
|
||||||
|
/** @type {import("../../../../").Configuration} */
|
||||||
|
module.exports = {
|
||||||
|
mode: "development",
|
||||||
|
module: {
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
test: /\.(png|svg)$/,
|
||||||
|
type: "asset/inline"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
mimetype: "image/svg+xml",
|
||||||
|
type: "asset/inline"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /\.jpg$/,
|
||||||
|
type: "asset",
|
||||||
|
parser: {
|
||||||
|
dataUrlCondition: {
|
||||||
|
maxSize: Infinity
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
mimetype: "text/plain",
|
||||||
|
type: "asset/inline",
|
||||||
|
loader: "./loader"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
};
|
Loading…
Reference in New Issue