@@ -187,13 +187,35 @@ function getTokenExtractionCode(
187187
188188 // Goes through all the available namespaces looking for a `$prefix` variable. This allows us to
189189 // determine the prefixes that are used within the theme. Once we know the prefixes we can use
190- // them to extract only the tokens we care about from the full token set.
190+ // them to extract only the tokens we care about from the full token set. Note: `core-theme`
191+ // is a special case where not all of the imported tokens are supported in the `overrides`
192+ // mixin. Such cases will expose a `_get-supported-overrides-tokens` private function that
193+ // can be used to determine the exact set of prefixes that are used.
191194 // After the tokens are extracted, we log them out using `@debug` and then intercept the log
192195 // in order to get the raw data. We have to go through `@debug`, because there's no way to
193196 // output a Sass map to CSS.
194197 // The tokens are encoded as JSON so we don't have to implement parsing of Sass maps in TS.
195198 const append = `
196- $__namespaces: (${ useStatements . map ( stmt => `"${ extractNamespace ( stmt ) } "` ) . join ( ', ' ) } );
199+ $__prefixes: ();
200+
201+ @if ${ meta } .function-exists('_get-supported-overrides-tokens') {
202+ $__configs: _get-supported-overrides-tokens();
203+
204+ @each $config in $__configs {
205+ $__prefixes: ${ list } .append($__prefixes, ${ map } .get($config, prefix));
206+ }
207+ } @else {
208+ $__namespaces: (${ useStatements . map ( stmt => `"${ extractNamespace ( stmt ) } "` ) . join ( ', ' ) } );
209+
210+ @each $name in $__namespaces {
211+ $prefix: ${ map } .get(${ meta } .module-variables($name), prefix);
212+
213+ @if ($prefix) {
214+ $__prefixes: ${ list } .append($__prefixes, $prefix);
215+ }
216+ }
217+ }
218+
197219 $__all-color: ${ m3Tokens } .generate-color-tokens(light, ${ palettes } .$azure-palette,
198220 ${ palettes } .$azure-palette, ${ palettes } .$azure-palette, 'sys');
199221 $__all-typography: ${ m3Tokens } .generate-typography-tokens(font, 100, 100, 100, 100, 'sys');
@@ -204,15 +226,11 @@ function getTokenExtractionCode(
204226 $__density: ();
205227 $__base: ();
206228
207- @each $name in $__namespaces {
208- $prefix: map-get(${ meta } .module-variables($name), 'prefix');
209-
210- @if ($prefix) {
211- $__color: ${ map } .set($__color, $prefix, map-get($__all-color, $prefix));
212- $__typography: ${ map } .set($__typography, $prefix, map-get($__all-typography, $prefix));
213- $__density: ${ map } .set($__density, $prefix, map-get($__all-density, $prefix));
214- $__base: ${ map } .set($__base, $prefix, map-get($__all-base, $prefix));
215- }
229+ @each $prefix in $__prefixes {
230+ $__color: ${ map } .set($__color, $prefix, ${ map } .get($__all-color, $prefix));
231+ $__typography: ${ map } .set($__typography, $prefix, ${ map } .get($__all-typography, $prefix));
232+ $__density: ${ map } .set($__density, $prefix, ${ map } .get($__all-density, $prefix));
233+ $__base: ${ map } .set($__base, $prefix, ${ map } .get($__all-base, $prefix));
216234 }
217235
218236 // Define our JSON.stringify implementation so it can be used below.
0 commit comments