77 */
88
99import { type JsonObject , type JsonValue , isJsonObject } from '@angular-devkit/core' ;
10- import { type Rule , type SchematicContext , type Tree , chain } from '@angular-devkit/schematics' ;
10+ import {
11+ type Rule ,
12+ type SchematicContext ,
13+ SchematicsException ,
14+ type Tree ,
15+ chain ,
16+ } from '@angular-devkit/schematics' ;
1117import { dirname , join , normalize , relative } from 'node:path/posix' ;
1218import {
1319 DependencyType ,
@@ -100,7 +106,7 @@ function parseNgPackageFile(tree: Tree, filePath: string): NgPackageConfig | und
100106/**
101107 * Resolves the TypeScript entry file path for a library entry point directory.
102108 * Uses the explicitly configured `entryFile` when provided, or checks common
103- * default locations before falling back to `'src/public-api.ts'` .
109+ * default locations.
104110 *
105111 * @param tree The virtual file system tree.
106112 * @param dir The directory of the primary or secondary entry point.
@@ -127,7 +133,9 @@ function resolveEntryFile(tree: Tree, dir: string, configuredEntry?: string): st
127133 }
128134 }
129135
130- return 'src/public-api.ts' ;
136+ throw new SchematicsException (
137+ `Could not find an entry file for library entry point at "${ dir || '.' } ".` ,
138+ ) ;
131139}
132140
133141/**
@@ -150,12 +158,7 @@ function findSecondaryEntryPoints(
150158 const rootDir = tree . getDir ( normalizedRoot ) ;
151159 const directories = [ rootDir ] ;
152160
153- while ( directories . length > 0 ) {
154- const current = directories . shift ( ) ;
155- if ( ! current ) {
156- break ;
157- }
158-
161+ for ( const current of directories ) {
159162 const currentPath = normalizeRelativePath ( current . path ) ;
160163
161164 if ( currentPath !== normalizedRoot ) {
@@ -270,9 +273,16 @@ function migrateTargetOptions(
270273 : { } ;
271274
272275 if ( ngPackageConfig . lib . styleIncludePaths ?. length ) {
273- existingPreprocessorOptions [ 'includePaths' ] = ngPackageConfig . lib . styleIncludePaths . map ( ( p ) =>
276+ const existingIncludePaths = Array . isArray ( existingPreprocessorOptions [ 'includePaths' ] )
277+ ? ( existingPreprocessorOptions [ 'includePaths' ] as string [ ] )
278+ : [ ] ;
279+ const migratedIncludePaths = ngPackageConfig . lib . styleIncludePaths . map ( ( p ) =>
274280 join ( projectDir , p ) ,
275281 ) ;
282+ existingPreprocessorOptions [ 'includePaths' ] = [
283+ ...existingIncludePaths ,
284+ ...migratedIncludePaths ,
285+ ] ;
276286 }
277287 if ( ngPackageConfig . lib . sass ) {
278288 existingPreprocessorOptions [ 'sass' ] = ngPackageConfig . lib . sass ;
0 commit comments