@@ -17,7 +17,7 @@ const shouldTransform = (fileName: string) => !fileName.endsWith('.ngfactory.ts'
1717 *
1818 * Check `@Component` to do following things:
1919 * - Replace `templateUrl` path with `require` for `CommonJS` or a constant with `import` for `ESM`
20- * - Combine `styles` and `styleUrls` to become `styles` with empty array as value because we don't test css
20+ * - Remove `styles` and `styleUrls` because we don't test css
2121 *
2222 * @example
2323 *
@@ -33,7 +33,6 @@ const shouldTransform = (fileName: string) => !fileName.endsWith('.ngfactory.ts'
3333 * @Component ({
3434 * selector: 'foo',
3535 * templateUrl: require('./foo.component.html'),
36- * styles: [],
3736 * })
3837 *
3938 * or for `ESM`
@@ -42,7 +41,6 @@ const shouldTransform = (fileName: string) => !fileName.endsWith('.ngfactory.ts'
4241 * @Component ({
4342 * selector: 'foo',
4443 * templateUrl: __NG_CLI_RESOURCE__0,
45- * styles: [],
4644 * })
4745 */
4846export function replaceResources ( { program } : TsCompilerInstance ) : ts . TransformerFactory < ts . SourceFile > {
@@ -141,7 +139,7 @@ function visitDecorator(
141139 // visit all properties
142140 let properties = ts . visitNodes ( objectExpression . properties , ( node ) =>
143141 ts . isObjectLiteralElementLike ( node )
144- ? visitComponentMetadata ( nodeFactory , node , styleReplacements , resourceImportDeclarations , moduleKind )
142+ ? visitComponentMetadata ( nodeFactory , node , resourceImportDeclarations , moduleKind )
145143 : node ,
146144 ) ;
147145
@@ -180,7 +178,6 @@ function visitDecorator(
180178function visitComponentMetadata (
181179 nodeFactory : ts . NodeFactory ,
182180 node : ts . ObjectLiteralElementLike ,
183- styleReplacements : ts . Expression [ ] ,
184181 resourceImportDeclarations : ts . ImportDeclaration [ ] ,
185182 moduleKind ?: ts . ModuleKind ,
186183) : ts . ObjectLiteralElementLike | undefined {
@@ -208,38 +205,6 @@ function visitComponentMetadata(
208205 : ts . updatePropertyAssignment ( node , ts . createIdentifier ( TEMPLATE ) , importName ) ;
209206
210207 case STYLES :
211- if ( ! ts . isArrayLiteralExpression ( node . initializer ) ) {
212- return node ;
213- }
214- const isInlineStyles = name === STYLES ;
215- // @ts -expect-error should be fine
216- const styles = ts . visitNodes ( node . initializer . elements , ( node ) => {
217- if ( ! ts . isStringLiteral ( node ) && ! ts . isNoSubstitutionTemplateLiteral ( node ) ) {
218- return node ;
219- }
220-
221- let url ;
222- if ( isInlineStyles ) {
223- return useNodeFactory ? nodeFactory . createStringLiteral ( node . text ) : ts . createLiteral ( node . text ) ;
224- } else {
225- url = getResourceUrl ( node ) ;
226- }
227-
228- if ( ! url ) {
229- return node ;
230- }
231-
232- return createResourceImport ( nodeFactory , url , resourceImportDeclarations , moduleKind ) ;
233- } ) ;
234-
235- // Styles should be placed first
236- if ( isInlineStyles ) {
237- styleReplacements . unshift ( ...styles ) ;
238- } else {
239- styleReplacements . push ( ...styles ) ;
240- }
241-
242- return undefined ;
243208 case STYLE_URLS :
244209 if ( ! ts . isArrayLiteralExpression ( node . initializer ) ) {
245210 return node ;
@@ -251,7 +216,7 @@ function visitComponentMetadata(
251216 }
252217}
253218
254- export function getResourceUrl ( node : ts . Node ) : string | null {
219+ function getResourceUrl ( node : ts . Node ) : string | null {
255220 // only analyze strings
256221 if ( ! ts . isStringLiteral ( node ) && ! ts . isNoSubstitutionTemplateLiteral ( node ) ) {
257222 return null ;
0 commit comments