| | |
| | | /** @typedef {import("./RequestShortener")} RequestShortener */ |
| | | /** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */ |
| | | /** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */ |
| | | /** @typedef {import("../declarations/WebpackOptions").CssParserExportType} CssParserExportType */ |
| | | |
| | | /** @typedef {string | undefined} CssLayer */ |
| | | /** @typedef {string | undefined} Supports */ |
| | |
| | | /** @typedef {[CssLayer, Supports, Media]} InheritanceItem */ |
| | | /** @typedef {InheritanceItem[]} Inheritance */ |
| | | |
| | | /** @typedef {NormalModuleCreateData & { cssLayer: CssLayer, supports: Supports, media: Media, inheritance?: Inheritance }} CSSModuleCreateData */ |
| | | /** @typedef {NormalModuleCreateData & { cssLayer: CssLayer, supports: Supports, media: Media, inheritance?: Inheritance, exportType?: CssParserExportType }} CSSModuleCreateData */ |
| | | |
| | | class CssModule extends NormalModule { |
| | | /** |
| | | * Creates an instance of CssModule. |
| | | * @param {CSSModuleCreateData} options options object |
| | | */ |
| | | constructor(options) { |
| | |
| | | this.media = options.media; |
| | | /** @type {CSSModuleCreateData['inheritance']} */ |
| | | this.inheritance = options.inheritance; |
| | | /** @type {CSSModuleCreateData['exportType']} */ |
| | | this.exportType = options.exportType; |
| | | } |
| | | |
| | | /** |
| | | * Returns the unique identifier used to reference this module. |
| | | * @returns {string} a unique identifier of the module |
| | | */ |
| | | identifier() { |
| | |
| | | identifier += `|${inheritance.join("|")}`; |
| | | } |
| | | |
| | | if (this.exportType) { |
| | | identifier += `|${this.exportType}`; |
| | | } |
| | | |
| | | // We generate extra code for HMR, so we need to invalidate the module |
| | | if (this.hot) { |
| | | identifier += `|${this.hot}`; |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns a human-readable identifier for this module. |
| | | * @param {RequestShortener} requestShortener the request shortener |
| | | * @returns {string} a user readable identifier of the module |
| | | */ |
| | |
| | | identifier += ` (media: ${this.media})`; |
| | | } |
| | | |
| | | if (this.exportType) { |
| | | identifier += ` (exportType: ${this.exportType})`; |
| | | } |
| | | |
| | | return identifier; |
| | | } |
| | | |
| | |
| | | this.supports = m.supports; |
| | | this.media = m.media; |
| | | this.inheritance = m.inheritance; |
| | | this.exportType = m.exportType; |
| | | } |
| | | |
| | | /** |
| | | * Serializes this instance into the provided serializer context. |
| | | * @param {ObjectSerializerContext} context context |
| | | */ |
| | | serialize(context) { |
| | |
| | | write(this.supports); |
| | | write(this.media); |
| | | write(this.inheritance); |
| | | write(this.exportType); |
| | | super.serialize(context); |
| | | } |
| | | |
| | | /** |
| | | * Restores this instance from the provided deserializer context. |
| | | * @param {ObjectDeserializerContext} context context |
| | | * @returns {CssModule} the deserialized object |
| | | */ |
| | |
| | | supports: /** @type {EXPECTED_ANY} */ (null), |
| | | media: /** @type {EXPECTED_ANY} */ (null), |
| | | inheritance: /** @type {EXPECTED_ANY} */ (null), |
| | | extractSourceMap: /** @type {EXPECTED_ANY} */ (null) |
| | | extractSourceMap: /** @type {EXPECTED_ANY} */ (null), |
| | | exportType: /** @type {EXPECTED_ANY} */ (null) |
| | | }); |
| | | obj.deserialize(context); |
| | | return obj; |
| | | } |
| | | |
| | | /** |
| | | * Restores this instance from the provided deserializer context. |
| | | * @param {ObjectDeserializerContext} context context |
| | | */ |
| | | deserialize(context) { |
| | |
| | | this.supports = read(); |
| | | this.media = read(); |
| | | this.inheritance = read(); |
| | | this.exportType = read(); |
| | | super.deserialize(context); |
| | | } |
| | | } |