@knighted/css 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -0
- package/dist/cjs/loaderBridge.cjs +10 -7
- package/dist/cjs/loaderBridge.cjs.map +1 -1
- package/dist/loaderBridge.js +10 -7
- package/dist/loaderBridge.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -137,6 +137,11 @@ selectors.card // hashed CSS Modules class name
|
|
|
137
137
|
> `--hashed` requires wiring `@knighted/css/loader-bridge` to handle `?knighted-css` queries so
|
|
138
138
|
> the generated proxies can read `knightedCss` and `knightedCssModules` at build time.
|
|
139
139
|
|
|
140
|
+
> [!NOTE]
|
|
141
|
+
> `--hashed` builds the selector list from compiled CSS. The generated sidecar can therefore
|
|
142
|
+
> include class names that are not exported by the module (e.g. sprinkles output), while the
|
|
143
|
+
> runtime `selectors` map only includes exported locals from the loader bridge.
|
|
144
|
+
|
|
140
145
|
Refer to [docs/type-generation.md](../../docs/type-generation.md) for CLI options and workflow tips.
|
|
141
146
|
|
|
142
147
|
### Combined + runtime selectors
|
|
@@ -291,17 +291,20 @@ function resolveCssModules(primary, module) {
|
|
|
291
291
|
continue;
|
|
292
292
|
return locals;
|
|
293
293
|
}
|
|
294
|
-
const
|
|
295
|
-
const entries = Object.entries(value);
|
|
294
|
+
const normalizeStringMapLocal = (value) => {
|
|
295
|
+
const entries = Object.entries(value).filter(([key]) => key !== 'default' && key !== '__esModule');
|
|
296
296
|
if (entries.length === 0)
|
|
297
|
-
return
|
|
298
|
-
|
|
297
|
+
return undefined;
|
|
298
|
+
if (!entries.every(([, entry]) => typeof entry === 'string'))
|
|
299
|
+
return undefined;
|
|
300
|
+
return Object.fromEntries(entries);
|
|
299
301
|
};
|
|
300
302
|
for (const candidate of candidates) {
|
|
301
303
|
if (!candidate || typeof candidate !== 'object')
|
|
302
304
|
continue;
|
|
303
|
-
|
|
304
|
-
|
|
305
|
+
const normalized = normalizeStringMapLocal(candidate);
|
|
306
|
+
if (normalized)
|
|
307
|
+
return normalized;
|
|
305
308
|
}
|
|
306
309
|
const collectNamedExportsLocal = (value) => {
|
|
307
310
|
if (!value || typeof value !== 'object')
|
|
@@ -341,7 +344,7 @@ function createBridgeModule(options) {
|
|
|
341
344
|
`const __knightedResolveCss = ${resolveCssText.toString()};`,
|
|
342
345
|
`const __knightedResolveCssModules = ${resolveCssModules.toString()};`,
|
|
343
346
|
`const __knightedUpstreamLocals =\n __knightedResolveCssModules(__knightedUpstream, __knightedUpstream);`,
|
|
344
|
-
`const __knightedLocalsExport =\n __knightedUpstreamLocals ??\n __knightedResolveCssModules(__knightedLocals, __knightedLocals)
|
|
347
|
+
`const __knightedLocalsExport =\n __knightedUpstreamLocals ??\n __knightedResolveCssModules(__knightedLocals, __knightedLocals);`,
|
|
345
348
|
`const __knightedBaseCss = __knightedResolveCss(__knightedDefault, __knightedUpstream);`,
|
|
346
349
|
`const __knightedCss = [__knightedBaseCss, ${cssValues.join(', ')}].filter(Boolean).join('\\n');`,
|
|
347
350
|
`export const ${DEFAULT_EXPORT_NAME} = __knightedCss;`,
|