MCPcopy Create free account
hub / github.com/Snapchat/Valdi / makeModule

Function makeModule

src/valdi_modules/src/valdi/valdi_core/src/CSSModule.ts:11–31  ·  view source on GitHub ↗
(compiledCSSPath: string, ruleMapping: StringMap<string>)

Source from the content-addressed store, hash-verified

9
10export 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
32export function getNativeModule(compiledCSSPath: string): CSSModuleNative {
33 const cssModule = getValdiRuntime().getCSSModule(compiledCSSPath);
34 setObjectId(cssModule);

Callers

nothing calls this directly

Calls 1

getNativeModuleFunction · 0.85

Tested by

no test coverage detected