Skip to content

Commit

Permalink
fix(@schematics/angular): remove baseUrl from tsconfig.json
Browse files Browse the repository at this point in the history
The `baseUrl` is no longer needed since NGCC has been removed. This also enables better auto-import suggestions.

Closes #18834
  • Loading branch information
alan-agius4 committed Oct 2, 2023
1 parent dc6b6ea commit 419b5c1
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion packages/schematics/angular/library/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ export default function (options: LibraryOptions): Rule {
mergeWith(templateSource),
addLibToWorkspaceFile(options, libDir, packageName),
options.skipPackageJson ? noop() : addDependenciesToPackageJson(),
options.skipTsConfig ? noop() : updateTsConfig(packageName, distRoot),
options.skipTsConfig ? noop() : updateTsConfig(packageName, './' + distRoot),
options.standalone
? noop()
: schematic('module', {
Expand Down
6 changes: 3 additions & 3 deletions packages/schematics/angular/library/index_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ describe('Library Schematic', () => {
const tree = await schematicRunner.runSchematic('library', defaultOptions, workspaceTree);

const tsConfigJson = getJsonFileContent(tree, 'tsconfig.json');
expect(tsConfigJson.compilerOptions.paths['foo']).toEqual(['dist/foo']);
expect(tsConfigJson.compilerOptions.paths['foo']).toEqual(['./dist/foo']);
});

it(`should append to existing paths mappings`, async () => {
Expand All @@ -284,7 +284,7 @@ describe('Library Schematic', () => {
const tree = await schematicRunner.runSchematic('library', defaultOptions, workspaceTree);

const tsConfigJson = getJsonFileContent(tree, 'tsconfig.json');
expect(tsConfigJson.compilerOptions.paths['foo']).toEqual(['libs/*', 'dist/foo']);
expect(tsConfigJson.compilerOptions.paths['foo']).toEqual(['libs/*', './dist/foo']);
});

it(`should not modify the file when --skipTsConfig`, async () => {
Expand Down Expand Up @@ -333,7 +333,7 @@ describe('Library Schematic', () => {
expect(cfg.projects['@myscope/mylib']).toBeDefined();

const rootTsCfg = getJsonFileContent(tree, '/tsconfig.json');
expect(rootTsCfg.compilerOptions.paths['@myscope/mylib']).toEqual(['dist/myscope/mylib']);
expect(rootTsCfg.compilerOptions.paths['@myscope/mylib']).toEqual(['./dist/myscope/mylib']);
});

it(`should dasherize scoped libraries`, async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",<% if (strict) { %>
"forceConsistentCasingInFileNames": true,
"strict": true,
Expand Down
8 changes: 4 additions & 4 deletions tests/legacy-cli/e2e/tests/build/library-with-demo-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default async function () {

// Scenario #1 where we use wildcard path mappings for secondary entry-points.
await updateJsonFile('tsconfig.json', (json) => {
json.compilerOptions.paths = { 'mylib': ['dist/mylib'], 'mylib/*': ['dist/mylib/*'] };
json.compilerOptions.paths = { 'mylib': ['./dist/mylib'], 'mylib/*': ['./dist/mylib/*'] };
});

await appendToFile(
Expand All @@ -39,9 +39,9 @@ export default async function () {
// Scenario #2 where we don't use wildcard path mappings.
await updateJsonFile('tsconfig.json', (json) => {
json.compilerOptions.paths = {
'mylib': ['dist/mylib'],
'mylib/secondary': ['dist/mylib/secondary'],
'mylib/another': ['dist/mylib/another'],
'mylib': ['./dist/mylib'],
'mylib/secondary': ['./dist/mylib/secondary'],
'mylib/another': ['./dist/mylib/another'],
};
});

Expand Down

0 comments on commit 419b5c1

Please sign in to comment.