* Resolve the effective `@charset` by walking text imports. * @param {NormalModule} module the module * @param {ModuleGraph} moduleGraph module graph * @param {WeakSet<NormalModule>=} visited cycle guard * @returns {string | undefined} the effective charset
(module, moduleGraph, visited = new WeakSet())
| 747 | * @returns {string | undefined} the effective charset |
| 748 | */ |
| 749 | _getEffectiveCharset(module, moduleGraph, visited = new WeakSet()) { |
| 750 | if (!module || visited.has(module)) return undefined; |
| 751 | const exportType = /** @type {CssModule} */ (module).exportType; |
| 752 | if (exportType !== "text" && exportType !== "css-style-sheet") { |
| 753 | return undefined; |
| 754 | } |
| 755 | visited.add(module); |
| 756 | const own = |
| 757 | module.buildInfo && |
| 758 | /** @type {CssModuleBuildInfo} */ (module.buildInfo).charset; |
| 759 | if (own !== undefined) return own; |
| 760 | if (exportType !== "text") return undefined; |
| 761 | for (const dep of module.dependencies) { |
| 762 | if (dep instanceof CssImportDependency) { |
| 763 | const depModule = /** @type {NormalModule} */ ( |
| 764 | moduleGraph.getModule(dep) |
| 765 | ); |
| 766 | const inherited = this._getEffectiveCharset( |
| 767 | depModule, |
| 768 | moduleGraph, |
| 769 | visited |
| 770 | ); |
| 771 | if (inherited !== undefined) return inherited; |
| 772 | } |
| 773 | } |
| 774 | return undefined; |
| 775 | } |
| 776 | |
| 777 | /** |
| 778 | * Generate JS expressions for `@import` side effects (`style` exportType only). |
no test coverage detected