@@ -848,20 +848,23 @@ describeLibraryBuilder(executeLibraryBuilder, LIBRARY_BUILDER_INFO, (harness) =>
848848 ] ) ;
849849 } ) ;
850850
851- it ( 'should rebuild when an external Sass stylesheet or imported partial is modified' , async ( ) => {
851+ it ( 'should rebuild when an external Sass partial or template is modified and recover from template errors ' , async ( ) => {
852852 await harness . writeFiles ( {
853853 'projects/lib/src/lib/_vars.scss' : '$primary-color: rgb(10, 20, 30);' ,
854854 'projects/lib/src/lib/lib.component.scss' :
855- '@use "./vars"; :host { color: vars.$primary-color; padding: 4px; }' ,
855+ '@use "./vars"; :host { color: vars.$primary-color; }' ,
856+ 'projects/lib/src/lib/lib.component.html' : '<h1>{{ title }}</h1>' ,
856857 'projects/lib/src/lib/lib.component.ts' : `
857858 import { Component } from '@angular/core';
858859
859860 @Component({
860- selector: 'lib-external-sass ',
861- template : '<span>External Sass</span> ',
861+ selector: 'lib-external-resources ',
862+ templateUrl : './lib.component.html ',
862863 styleUrl: './lib.component.scss',
863864 })
864- export class LibComponent {}
865+ export class LibComponent {
866+ title = 'Hello';
867+ }
865868 ` ,
866869 } ) ;
867870
@@ -874,85 +877,21 @@ describeLibraryBuilder(executeLibraryBuilder, LIBRARY_BUILDER_INFO, (harness) =>
874877 async ( { result } ) => {
875878 expect ( result ?. success ) . toBeTrue ( ) ;
876879 const content = harness . readFile ( 'dist/lib/fesm2022/lib.mjs' ) ;
880+ expect ( content ) . toContain ( 'h1' ) ;
877881 expect ( content ) . toMatch ( / c o l o r : \s * (?: # 0 a 1 4 1 e | r g b \( 1 0 , \s * 2 0 , \s * 3 0 \) ) / ) ;
878- expect ( content ) . toMatch ( / p a d d i n g : \s * 4 p x / ) ;
879882 expect ( harness . readFile ( 'dist/lib/types/lib.d.ts' ) ) . toContain ( 'LibComponent' ) ;
880883
881- // Modify the external component stylesheet directly
882- await harness . writeFile (
883- 'projects/lib/src/lib/lib.component.scss' ,
884- '@use "./vars"; :host { color: vars.$primary-color; padding: 16px; }' ,
885- ) ;
886- } ,
887- async ( { result, logs } ) => {
888- expect ( result ?. success ) . toBeTrue ( ) ;
889- const content = harness . readFile ( 'dist/lib/fesm2022/lib.mjs' ) ;
890- expect ( content ) . toMatch ( / c o l o r : \s * (?: # 0 a 1 4 1 e | r g b \( 1 0 , \s * 2 0 , \s * 3 0 \) ) / ) ;
891- expect ( content ) . toMatch ( / p a d d i n g : \s * 1 6 p x / ) ;
892- expect ( harness . readFile ( 'dist/lib/types/lib.d.ts' ) ) . toContain ( 'LibComponent' ) ;
893- expect ( logs ) . toContain (
894- jasmine . objectContaining ( {
895- message : jasmine . stringContaining ( 'Compiling lib...' ) ,
896- } ) ,
897- ) ;
898-
899884 // Modify the imported Sass partial
900885 await harness . writeFile (
901886 'projects/lib/src/lib/_vars.scss' ,
902887 '$primary-color: rgb(200, 100, 50);' ,
903888 ) ;
904889 } ,
905- ( { result, logs } ) => {
906- expect ( result ?. success ) . toBeTrue ( ) ;
907- const content = harness . readFile ( 'dist/lib/fesm2022/lib.mjs' ) ;
908- expect ( content ) . toMatch ( / c o l o r : \s * (?: # c 8 6 4 3 2 | r g b \( 2 0 0 , \s * 1 0 0 , \s * 5 0 \) ) / ) ;
909- expect ( content ) . toMatch ( / p a d d i n g : \s * 1 6 p x / ) ;
910- expect ( harness . readFile ( 'dist/lib/types/lib.d.ts' ) ) . toContain ( 'LibComponent' ) ;
911- expect ( logs ) . toContain (
912- jasmine . objectContaining ( {
913- message : jasmine . stringContaining ( 'Compiling lib...' ) ,
914- } ) ,
915- ) ;
916- } ,
917- ] ) ;
918- } ) ;
919-
920- it ( 'should report template errors and recover when an external template is modified' , async ( ) => {
921- await harness . writeFiles ( {
922- 'projects/lib/src/lib/lib.component.html' : '<h1>{{ title }}</h1>' ,
923- 'projects/lib/src/lib/lib.component.ts' : `
924- import { Component } from '@angular/core';
925-
926- @Component({
927- selector: 'lib-external-template',
928- templateUrl: './lib.component.html',
929- })
930- export class LibComponent {
931- title = 'Hello';
932- }
933- ` ,
934- } ) ;
935-
936- harness . useTarget ( 'build' , {
937- ...BASE_OPTIONS ,
938- watch : true ,
939- } ) ;
940-
941- await harness . executeWithCases ( [
942890 async ( { result } ) => {
943891 expect ( result ?. success ) . toBeTrue ( ) ;
944- expect ( harness . readFile ( 'dist/lib/fesm2022/lib.mjs' ) ) . toContain ( 'h1' ) ;
945- expect ( harness . readFile ( 'dist/lib/types/lib.d.ts' ) ) . toContain ( 'LibComponent' ) ;
946-
947- // Modify external HTML template with valid markup
948- await harness . writeFile (
949- 'projects/lib/src/lib/lib.component.html' ,
950- '<section>{{ title }}</section>' ,
892+ expect ( harness . readFile ( 'dist/lib/fesm2022/lib.mjs' ) ) . toMatch (
893+ / c o l o r : \s * (?: # c 8 6 4 3 2 | r g b \( 2 0 0 , \s * 1 0 0 , \s * 5 0 \) ) / ,
951894 ) ;
952- } ,
953- async ( { result } ) => {
954- expect ( result ?. success ) . toBeTrue ( ) ;
955- expect ( harness . readFile ( 'dist/lib/fesm2022/lib.mjs' ) ) . toContain ( 'section' ) ;
956895 expect ( harness . readFile ( 'dist/lib/types/lib.d.ts' ) ) . toContain ( 'LibComponent' ) ;
957896
958897 // Introduce a template type-checking error in the external HTML template
0 commit comments