Skip to content

Commit

Permalink
build: account for absolute paths in token extraction (#29848)
Browse files Browse the repository at this point in the history
Fixes an error that is currently breaking the patch branch, because we didn't have a resolver for imports like `@use '@angular/cdk';`.

(cherry picked from commit 8168e3b)
  • Loading branch information
crisbeto committed Oct 9, 2024
1 parent 4b9348b commit 966bd68
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions tools/extract-tokens/extract-tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,9 @@ function extractTokens(themePath: string): Token[] {

const startMarker = '/*! extract tokens start */';
const endMarker = '/*! extract tokens end */';
const absoluteThemePath = join(process.cwd(), themePath);
const srcPath = join(process.cwd(), 'src');
const root = process.cwd();
const absoluteThemePath = join(root, themePath);
const srcPath = join(root, 'src');
const {prepend, append} = getTokenExtractionCode(
srcPath,
themePath,
Expand All @@ -93,6 +94,16 @@ function extractTokens(themePath: string): Token[] {
compileString(toCompile, {
loadPaths: [srcPath],
url: pathToFileURL(absoluteThemePath),
importers: [
{
findFileUrl: (url: string) => {
const angularPrefix = '@angular/';
return url.startsWith(angularPrefix)
? pathToFileURL(join(srcPath, url.substring(angularPrefix.length)))
: null;
},
},
],
sourceMap: false,
logger: {
debug: message => {
Expand Down

0 comments on commit 966bd68

Please sign in to comment.