mirror of https://github.com/webpack/webpack.git
fix: avoid extra inheritance
This commit is contained in:
parent
e5e86206f8
commit
14a9ea55e1
|
|
@ -14,7 +14,13 @@ const makeSerializable = require("./util/makeSerializable");
|
|||
/** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
||||
/** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
||||
|
||||
/** @typedef {NormalModuleCreateData & { cssLayer: string|undefined|null, supports: string|undefined|null, media: string|undefined|null, inheritance: Array<[string|undefined, string|undefined, string|undefined]>|null }} CSSModuleCreateData */
|
||||
/** @typedef {string|undefined} CssLayer */
|
||||
/** @typedef {string|undefined} Supports */
|
||||
/** @typedef {string|undefined} Media */
|
||||
/** @typedef {[CssLayer?, Supports?, Media?]} InheritanceItem */
|
||||
/** @typedef {Array<InheritanceItem>} Inheritance */
|
||||
|
||||
/** @typedef {NormalModuleCreateData & { cssLayer: CssLayer|null, supports: Supports|null, media: Media|null, inheritance: Inheritance|null }} CSSModuleCreateData */
|
||||
|
||||
class CssModule extends NormalModule {
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -187,11 +187,31 @@ class CssModulesPlugin {
|
|||
(compilation.moduleGraph.getParentModule(dependency));
|
||||
|
||||
if (parent instanceof CssModule) {
|
||||
let inheritance = [
|
||||
[parent.cssLayer, parent.supports, parent.media]
|
||||
];
|
||||
/** @type {import("../CssModule").Inheritance | undefined} */
|
||||
let inheritance;
|
||||
|
||||
if (
|
||||
(parent.cssLayer !== null &&
|
||||
parent.cssLayer !== undefined) ||
|
||||
parent.supports ||
|
||||
parent.media
|
||||
) {
|
||||
if (!inheritance) {
|
||||
inheritance = [];
|
||||
}
|
||||
|
||||
inheritance.push([
|
||||
parent.cssLayer,
|
||||
parent.supports,
|
||||
parent.media
|
||||
]);
|
||||
}
|
||||
|
||||
if (parent.inheritance) {
|
||||
if (!inheritance) {
|
||||
inheritance = [];
|
||||
}
|
||||
|
||||
inheritance.push(...parent.inheritance);
|
||||
}
|
||||
|
||||
|
|
@ -480,7 +500,7 @@ class CssModulesPlugin {
|
|||
inheritance.push(...module.inheritance);
|
||||
}
|
||||
|
||||
for (let i = 0; i < inheritance.length - 1; i++) {
|
||||
for (let i = 0; i < inheritance.length; i++) {
|
||||
const layer = inheritance[i][0];
|
||||
const supports = inheritance[i][1];
|
||||
const media = inheritance[i][2];
|
||||
|
|
|
|||
Loading…
Reference in New Issue