Skip to content

Commit 8168e3b

Browse files
authored
build: account for absolute paths in token extraction (#29848)
Fixes an error that is currently breaking the patch branch, because we didn't have a resolver for imports like `@use '@angular/cdk';`.
1 parent c73ab02 commit 8168e3b

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

tools/extract-tokens/extract-tokens.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,9 @@ function extractTokens(themePath: string): Token[] {
7474

7575
const startMarker = '/*! extract tokens start */';
7676
const endMarker = '/*! extract tokens end */';
77-
const absoluteThemePath = join(process.cwd(), themePath);
78-
const srcPath = join(process.cwd(), 'src');
77+
const root = process.cwd();
78+
const absoluteThemePath = join(root, themePath);
79+
const srcPath = join(root, 'src');
7980
const {prepend, append} = getTokenExtractionCode(
8081
srcPath,
8182
themePath,
@@ -93,6 +94,16 @@ function extractTokens(themePath: string): Token[] {
9394
compileString(toCompile, {
9495
loadPaths: [srcPath],
9596
url: pathToFileURL(absoluteThemePath),
97+
importers: [
98+
{
99+
findFileUrl: (url: string) => {
100+
const angularPrefix = '@angular/';
101+
return url.startsWith(angularPrefix)
102+
? pathToFileURL(join(srcPath, url.substring(angularPrefix.length)))
103+
: null;
104+
},
105+
},
106+
],
96107
sourceMap: false,
97108
logger: {
98109
debug: message => {

0 commit comments

Comments
 (0)