Skip to content

fix(@schematics/angular): remove baseUrl from tsconfig.json #25934

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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