@knighted/css 1.1.0-rc.2 → 1.1.0-rc.4

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 CHANGED
@@ -113,6 +113,8 @@ Run `knighted-css-generate-types` so every specifier that ends with `.knighted-c
113
113
  import stableSelectors from './button.module.scss.knighted-css.js'
114
114
  ```
115
115
 
116
+ Need bespoke resolution? Pass `--resolver` to load a module exporting a `CssResolver` and apply it during type generation.
117
+
116
118
  When the `.knighted-css` import targets a JavaScript/TypeScript module, the generated proxy also re-exports the module’s exports and `knightedCss`, so a single import can provide component exports, typed selectors, and the compiled stylesheet string:
117
119
 
118
120
  ```ts
package/dist/cjs/css.cjs CHANGED
@@ -184,7 +184,8 @@ async function compileStyleModule(file, { cwd, peerResolver, resolver, }) {
184
184
  async function compileSass(filePath, indented, { cwd, peerResolver, resolver, }) {
185
185
  const sassModule = await optionalPeer('sass', 'Sass', peerResolver);
186
186
  const sass = resolveSassNamespace(sassModule);
187
- const importer = (0, sassInternals_js_1.createSassImporter)({ cwd, resolver });
187
+ const importer = (0, sassInternals_js_1.createSassImporter)({ cwd, resolver, entryPath: filePath });
188
+ const legacyImporter = (0, sassInternals_js_1.createLegacySassImporter)({ cwd, resolver, entryPath: filePath });
188
189
  const loadPaths = buildSassLoadPaths(filePath);
189
190
  if (typeof sass.compileAsync === 'function') {
190
191
  const result = await sass.compileAsync(filePath, {
@@ -195,17 +196,18 @@ async function compileSass(filePath, indented, { cwd, peerResolver, resolver, })
195
196
  return result.css;
196
197
  }
197
198
  if (typeof sass.render === 'function') {
198
- return renderLegacySass(sass, filePath, indented, loadPaths);
199
+ return renderLegacySass(sass, filePath, indented, loadPaths, legacyImporter);
199
200
  }
200
201
  throw new Error('@knighted/css: Installed "sass" package does not expose compileAsync or render APIs. Please update "sass" to a supported version.');
201
202
  }
202
- function renderLegacySass(sass, filePath, indented, loadPaths) {
203
+ function renderLegacySass(sass, filePath, indented, loadPaths, importer) {
203
204
  return new Promise((resolve, reject) => {
204
205
  sass.render({
205
206
  file: filePath,
206
207
  indentedSyntax: indented,
207
208
  outputStyle: 'expanded',
208
209
  includePaths: loadPaths,
210
+ importer: importer ? [importer] : undefined,
209
211
  }, (error, result) => {
210
212
  if (error) {
211
213
  reject(error);