Skip to content

Commit e1ee636

Browse files
alan-agius4dgp1130
authored andcommitted
fix(@schematics/angular): don't add path mapping to old entrypoint definition file
With the APF changes in version 14, the dts entrypoint file has been changed to `index.d.ts`, this results in TypeScript being able to resolve the type definition file without the need of the additional path to the flat module file dts.
1 parent 32281c2 commit e1ee636

File tree

2 files changed

+4
-14
lines changed

2 files changed

+4
-14
lines changed

packages/schematics/angular/library/index.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,6 @@ export default function (options: LibraryOptions): Rule {
139139

140140
const projectRoot = join(normalize(newProjectRoot), folderName);
141141
const distRoot = `dist/${folderName}`;
142-
const pathImportLib = `${distRoot}/${folderName.replace('/', '-')}`;
143142
const sourceDir = `${projectRoot}/src/lib`;
144143

145144
const templateSource = apply(url('./files'), [
@@ -162,7 +161,7 @@ export default function (options: LibraryOptions): Rule {
162161
mergeWith(templateSource),
163162
addLibToWorkspaceFile(options, projectRoot, packageName),
164163
options.skipPackageJson ? noop() : addDependenciesToPackageJson(),
165-
options.skipTsConfig ? noop() : updateTsConfig(packageName, pathImportLib, distRoot),
164+
options.skipTsConfig ? noop() : updateTsConfig(packageName, distRoot),
166165
schematic('module', {
167166
name: options.name,
168167
commonModule: false,

packages/schematics/angular/library/index_spec.ts

+3-12
Original file line numberDiff line numberDiff line change
@@ -236,10 +236,7 @@ describe('Library Schematic', () => {
236236
.toPromise();
237237

238238
const tsConfigJson = getJsonFileContent(tree, 'tsconfig.json');
239-
expect(tsConfigJson.compilerOptions.paths.foo).toBeTruthy();
240-
expect(tsConfigJson.compilerOptions.paths.foo.length).toEqual(2);
241-
expect(tsConfigJson.compilerOptions.paths.foo[0]).toEqual('dist/foo/foo');
242-
expect(tsConfigJson.compilerOptions.paths.foo[1]).toEqual('dist/foo');
239+
expect(tsConfigJson.compilerOptions.paths['foo']).toEqual(['dist/foo']);
243240
});
244241

245242
it(`should append to existing paths mappings`, async () => {
@@ -259,10 +256,7 @@ describe('Library Schematic', () => {
259256
.toPromise();
260257

261258
const tsConfigJson = getJsonFileContent(tree, 'tsconfig.json');
262-
expect(tsConfigJson.compilerOptions.paths.foo).toBeTruthy();
263-
expect(tsConfigJson.compilerOptions.paths.foo.length).toEqual(3);
264-
expect(tsConfigJson.compilerOptions.paths.foo[1]).toEqual('dist/foo/foo');
265-
expect(tsConfigJson.compilerOptions.paths.foo[2]).toEqual('dist/foo');
259+
expect(tsConfigJson.compilerOptions.paths['foo']).toEqual(['libs/*', 'dist/foo']);
266260
});
267261

268262
it(`should not modify the file when --skipTsConfig`, async () => {
@@ -316,10 +310,7 @@ describe('Library Schematic', () => {
316310
expect(cfg.projects['@myscope/mylib']).toBeDefined();
317311

318312
const rootTsCfg = getJsonFileContent(tree, '/tsconfig.json');
319-
expect(rootTsCfg.compilerOptions.paths['@myscope/mylib']).toEqual([
320-
'dist/myscope/mylib/myscope-mylib',
321-
'dist/myscope/mylib',
322-
]);
313+
expect(rootTsCfg.compilerOptions.paths['@myscope/mylib']).toEqual(['dist/myscope/mylib']);
323314

324315
const karmaConf = getFileContent(tree, '/projects/myscope/mylib/karma.conf.js');
325316
expect(karmaConf).toContain(

0 commit comments

Comments
 (0)