(compiledCSSPath: string, ruleMapping: StringMap<string>)
| 9 | |
| 10 | export function makeModule(compiledCSSPath: string, ruleMapping: StringMap<string>): CSSModule { |
| 11 | const cssModule = getNativeModule(compiledCSSPath); |
| 12 | |
| 13 | const target = {} as any; |
| 14 | return new Proxy(target, { |
| 15 | get(target, key) { |
| 16 | let rule = target[key]; |
| 17 | if (typeof rule === 'undefined') { |
| 18 | const ruleName = ruleMapping[key as string]; |
| 19 | rule = ruleName && cssModule.getRule(ruleName); |
| 20 | if (typeof rule === 'undefined') { |
| 21 | // 'null' means already fetched and not found |
| 22 | rule = null; |
| 23 | } |
| 24 | target[key] = rule; |
| 25 | setObjectId(rule); |
| 26 | } |
| 27 | return rule; |
| 28 | }, |
| 29 | }); |
| 30 | } |
| 31 | |
| 32 | export function getNativeModule(compiledCSSPath: string): CSSModuleNative { |
| 33 | const cssModule = getValdiRuntime().getCSSModule(compiledCSSPath); |
| 34 | setObjectId(cssModule); |
nothing calls this directly
no test coverage detected