I’m trying to generate the objet for the styleUrls
dynamically, but when doing so I’m getting the weirdest error.
Here is the interesting pieces of my code:
@Component({
tag: 'my-input',
styleUrls: getStylesForComponent('my-input'),
})
export const getStylesForComponent = (component: string): { [key: string]: string } => {
return {
style1: `themes/${component}.style1.scss`,
style2: `themes/${component}.style2.scss`,
}
}
If I do this I’m getting this error on the terminal when building:
[ ERROR ] Debug Failure. False expression: Negative numbers should be created in combination with
createPrefixUnaryExpression at Object.createNumericLiteral
(/Users/myuser/dev/myproject/node_modules/.pnpm/@stencil+core@4.20.0/node_modules/@stencil/core/compiler/stencil.js:28226:17)
at convertValueToLiteral
(/Users/myuser/dev/myproject/node_modules/.pnpm/@stencil+core@4.20.0/node_modules/@stencil/core/compiler/stencil.js:236688:47)
at
/Users/myuser/dev/myproject/node_modules/.pnpm/@stencil+core@4.20.0/node_modules/@stencil/core/compiler/stencil.js:236715:7
at Array.map (<anonymous>) at objectToObjectLiteral
(/Users/myuser/dev/myproject/node_modules/.pnpm/@stencil+core@4.20.0/node_modules/@stencil/core/compiler/stencil.js:236712:42)
at convertValueToLiteral
(/Users/myuser/dev/myproject/node_modules/.pnpm/@stencil+core@4.20.0/node_modules/@stencil/core/compiler/stencil.js:236685:12)
at
/Users/myuser/dev/myproject/node_modules/.pnpm/@stencil+core@4.20.0/node_modules/@stencil/core/compiler/stencil.js:236715:7
at Array.map (<anonymous>) at objectToObjectLiteral
(/Users/myuser/dev/myproject/node_modules/.pnpm/@stencil+core@4.20.0/node_modules/@stencil/core/compiler/stencil.js:236712:42)
at convertValueToLiteral
(/Users/myuser/dev/myproject/node_modules/.pnpm/@stencil+core@4.20.0/node_modules/@stencil/core/compiler/stencil.js:236685:12)
Currently I have the styleUrls
like this, which causes no errors:
@Component({
tag: 'my-input',
styleUrls: {
style1: `themes/my-input.style1.scss`,
style2: `themes/my-input.style2.scss`,
}
})
Is it possible to set the styleUrls
to a function/variable that returns the actual object? It doesn’t sound like something that can’t be done but somehow it fails, maybe I’m missing something?
Thank you!!