Skip to content

Commit

Permalink
[PM-16872] Update libs to use explicit dependencies (bitwarden#12770)
Browse files Browse the repository at this point in the history
Update all libs to use explicit dependencies rather than relying on tsconfig.libs.json. This allows us to more easily understand the dependencies between libs and prevent users from accidentally adding new dependencies.

We still use tsconfig.libs (now renamed tsconfig.spec) for tests.
  • Loading branch information
Hinton authored Jan 10, 2025
1 parent 138e07e commit 653b730
Show file tree
Hide file tree
Showing 43 changed files with 308 additions and 45 deletions.
2 changes: 1 addition & 1 deletion bitwarden_license/bit-common/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../libs/shared/tsconfig.libs",
"extends": "../../libs/shared/tsconfig",
"include": ["src", "spec"],
"exclude": ["node_modules", "dist"],
"compilerOptions": {
Expand Down
2 changes: 1 addition & 1 deletion libs/admin-console/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { pathsToModuleNameMapper } = require("ts-jest");

const { compilerOptions } = require("../shared/tsconfig.libs");
const { compilerOptions } = require("../shared/tsconfig.spec");

const sharedConfig = require("../../libs/shared/jest.config.angular");

Expand Down
10 changes: 9 additions & 1 deletion libs/admin-console/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
{
"extends": "../shared/tsconfig.libs",
"extends": "../shared/tsconfig",
"compilerOptions": {
"paths": {
"@bitwarden/admin-console/common": ["../admin-console/src/common"],
"@bitwarden/auth/common": ["../auth/src/common"],
"@bitwarden/common/*": ["../common/src/*"],
"@bitwarden/key-management": ["../key-management/src"]
}
},
"include": ["src", "spec"],
"exclude": ["node_modules", "dist"]
}
2 changes: 1 addition & 1 deletion libs/angular/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { pathsToModuleNameMapper } = require("ts-jest");

const { compilerOptions } = require("../shared/tsconfig.libs");
const { compilerOptions } = require("../shared/tsconfig.spec");

const sharedConfig = require("../../libs/shared/jest.config.angular");

Expand Down
22 changes: 21 additions & 1 deletion libs/angular/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
{
"extends": "../shared/tsconfig.libs",
"extends": "../shared/tsconfig",
"compilerOptions": {
"paths": {
"@bitwarden/admin-console/common": ["../admin-console/src/common"],
"@bitwarden/angular/*": ["../angular/src/*"],
"@bitwarden/auth/angular": ["../auth/src/angular"],
"@bitwarden/auth/common": ["../auth/src/common"],
"@bitwarden/common/*": ["../common/src/*"],
"@bitwarden/components": ["../components/src"],
"@bitwarden/generator-components": ["../tools/generator/components/src"],
"@bitwarden/generator-core": ["../tools/generator/core/src"],
"@bitwarden/generator-history": ["../tools/generator/extensions/history/src"],
"@bitwarden/generator-legacy": ["../tools/generator/extensions/legacy/src"],
"@bitwarden/generator-navigation": ["../tools/generator/extensions/navigation/src"],
"@bitwarden/importer/core": ["../importer/src"],
"@bitwarden/key-management": ["../key-management/src"],
"@bitwarden/platform": ["../platform/src"],
"@bitwarden/vault-export-core": ["../tools/export/vault-export/vault-export-core/src"],
"@bitwarden/vault": ["../vault/src"]
}
},
"include": ["src", "spec"],
"exclude": ["node_modules", "dist"]
}
2 changes: 1 addition & 1 deletion libs/auth/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { pathsToModuleNameMapper } = require("ts-jest");

const { compilerOptions } = require("../shared/tsconfig.libs");
const { compilerOptions } = require("../shared/tsconfig.spec");

const sharedConfig = require("../../libs/shared/jest.config.angular");

Expand Down
19 changes: 18 additions & 1 deletion libs/auth/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
{
"extends": "../shared/tsconfig.libs",
"extends": "../shared/tsconfig",
"compilerOptions": {
"resolveJsonModule": true,
"paths": {
"@bitwarden/admin-console/common": ["../admin-console/src/common"],
"@bitwarden/auth/common": ["../auth/src/common"],
"@bitwarden/auth/angular": ["../auth/src/angular"],
"@bitwarden/angular/*": ["../angular/src/*"],
"@bitwarden/common/*": ["../common/src/*"],
"@bitwarden/components": ["../components/src"],
"@bitwarden/key-management": ["../key-management/src"],
"@bitwarden/platform": ["../platform/src"],
"@bitwarden/generator-core": ["../tools/generator/core/src"],
"@bitwarden/generator-history": ["../tools/generator/extensions/history/src"],
"@bitwarden/generator-legacy": ["../tools/generator/extensions/legacy/src"],
"@bitwarden/generator-navigation": ["../tools/generator/extensions/navigation/src"]
}
},
"include": ["src", "spec"],
"exclude": ["node_modules", "dist"]
}
2 changes: 1 addition & 1 deletion libs/billing/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { pathsToModuleNameMapper } = require("ts-jest");

const { compilerOptions } = require("../shared/tsconfig.libs");
const { compilerOptions } = require("../shared/tsconfig.spec");

const sharedConfig = require("../../libs/shared/jest.config.angular");

Expand Down
3 changes: 2 additions & 1 deletion libs/billing/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"extends": "../shared/tsconfig.libs",
"extends": "../shared/tsconfig",
"compilerOptions": {},
"include": ["src", "spec"],
"exclude": ["node_modules", "dist"]
}
2 changes: 1 addition & 1 deletion libs/common/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { pathsToModuleNameMapper } = require("ts-jest");

const { compilerOptions } = require("../shared/tsconfig.libs");
const { compilerOptions } = require("../shared/tsconfig.spec");

const sharedConfig = require("../shared/jest.config.ts");

Expand Down
12 changes: 11 additions & 1 deletion libs/common/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
{
"extends": "../shared/tsconfig.libs",
"extends": "../shared/tsconfig",
"compilerOptions": {
"paths": {
"@bitwarden/admin-console/common": ["../admin-console/src/common"],
"@bitwarden/auth/common": ["../auth/src/common"],
"@bitwarden/common/*": ["../common/src/*"],
"@bitwarden/components": ["../components/src"],
"@bitwarden/key-management": ["../key-management/src"],
"@bitwarden/platform": ["../platform/src"]
}
},
"include": ["src", "spec", "./custom-matchers.d.ts", "../key-management/src/index.ts"],
"exclude": ["node_modules", "dist"]
}
39 changes: 38 additions & 1 deletion libs/components/src/form-field/form-field.stories.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore
import { TextFieldModule } from "@angular/cdk/text-field";
import { Directive, ElementRef, Input, OnInit, Renderer2 } from "@angular/core";
import {
AbstractControl,
UntypedFormBuilder,
Expand All @@ -10,7 +13,6 @@ import {
} from "@angular/forms";
import { Meta, StoryObj, moduleMetadata } from "@storybook/angular";

import { A11yTitleDirective } from "@bitwarden/angular/src/directives/a11y-title.directive";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";

import { AsyncActionsModule } from "../async-actions";
Expand All @@ -29,6 +31,41 @@ import { I18nMockService } from "../utils/i18n-mock.service";
import { BitFormFieldComponent } from "./form-field.component";
import { FormFieldModule } from "./form-field.module";

// TOOD: This solves a circular dependency between components and angular.
@Directive({
selector: "[appA11yTitle]",
})
export class A11yTitleDirective implements OnInit {
@Input() set appA11yTitle(title: string) {
this.title = title;
this.setAttributes();
}

private title: string;
private originalTitle: string | null;
private originalAriaLabel: string | null;

constructor(
private el: ElementRef,
private renderer: Renderer2,
) {}

ngOnInit() {
this.originalTitle = this.el.nativeElement.getAttribute("title");
this.originalAriaLabel = this.el.nativeElement.getAttribute("aria-label");
this.setAttributes();
}

private setAttributes() {
if (this.originalTitle === null) {
this.renderer.setAttribute(this.el.nativeElement, "title", this.title);
}
if (this.originalAriaLabel === null) {
this.renderer.setAttribute(this.el.nativeElement, "aria-label", this.title);
}
}
}

export default {
title: "Component Library/Form/Field",
component: BitFormFieldComponent,
Expand Down
1 change: 0 additions & 1 deletion libs/components/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
"lib": ["es2020", "dom"],
"paths": {
"@bitwarden/common/*": ["../common/src/*"],
"@bitwarden/angular/*": ["../angular/src/*"],
"@bitwarden/platform": ["../platform/src"]
},
"plugins": [
Expand Down
2 changes: 1 addition & 1 deletion libs/importer/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { pathsToModuleNameMapper } = require("ts-jest");

const { compilerOptions } = require("../shared/tsconfig.libs");
const { compilerOptions } = require("../shared/tsconfig.spec");

const sharedConfig = require("../shared/jest.config.ts");

Expand Down
18 changes: 17 additions & 1 deletion libs/importer/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
{
"extends": "../shared/tsconfig.libs",
"extends": "../shared/tsconfig",
"compilerOptions": {
"paths": {
"@bitwarden/admin-console/common": ["../admin-console/src/common"],
"@bitwarden/angular/*": ["../angular/src/*"],
"@bitwarden/auth/common": ["../auth/src/common"],
"@bitwarden/common/*": ["../common/src/*"],
"@bitwarden/components": ["../components/src"],
"@bitwarden/generator-core": ["../tools/generator/core/src"],
"@bitwarden/generator-history": ["../tools/generator/extensions/history/src"],
"@bitwarden/generator-legacy": ["../tools/generator/extensions/legacy/src"],
"@bitwarden/generator-navigation": ["../tools/generator/extensions/navigation/src"],
"@bitwarden/key-management": ["../key-management/src"],
"@bitwarden/platform": ["../platform/src"],
"@bitwarden/vault-export-core": ["../tools/export/vault-export/vault-export-core/src"]
}
},
"include": ["src", "spec"],
"exclude": ["node_modules", "dist"]
}
2 changes: 1 addition & 1 deletion libs/key-management/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { pathsToModuleNameMapper } = require("ts-jest");

const { compilerOptions } = require("../shared/tsconfig.libs");
const { compilerOptions } = require("../shared/tsconfig.spec");

const sharedConfig = require("../../libs/shared/jest.config.angular");

Expand Down
18 changes: 17 additions & 1 deletion libs/key-management/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
{
"extends": "../shared/tsconfig.libs",
"extends": "../shared/tsconfig",
"compilerOptions": {
"paths": {
"@bitwarden/admin-console/common": ["../admin-console/src/common"],
"@bitwarden/angular/*": ["../angular/src/*"],
"@bitwarden/auth/angular": ["../auth/src/angular"],
"@bitwarden/auth/common": ["../auth/src/common"],
"@bitwarden/common/*": ["../common/src/*"],
"@bitwarden/components": ["../components/src"],
"@bitwarden/key-management": ["../key-management/src"],
"@bitwarden/generator-core": ["../tools/generator/core/src"],
"@bitwarden/generator-history": ["../tools/generator/extensions/history/src"],
"@bitwarden/generator-legacy": ["../tools/generator/extensions/legacy/src"],
"@bitwarden/generator-navigation": ["../tools/generator/extensions/navigation/src"],
"@bitwarden/platform": ["../platform/src"]
}
},
"include": ["src", "spec"],
"exclude": ["node_modules", "dist"]
}
2 changes: 1 addition & 1 deletion libs/node/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { pathsToModuleNameMapper } = require("ts-jest");

const { compilerOptions } = require("../shared/tsconfig.libs");
const { compilerOptions } = require("../shared/tsconfig.spec");

const sharedConfig = require("../shared/jest.config.ts");

Expand Down
10 changes: 9 additions & 1 deletion libs/node/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
{
"extends": "../shared/tsconfig.libs",
"extends": "../shared/tsconfig",
"compilerOptions": {
"paths": {
"@bitwarden/admin-console/common": ["../admin-console/src/common"],
"@bitwarden/auth/common": ["../auth/src/common"],
"@bitwarden/common/*": ["../common/src/*"],
"@bitwarden/key-management": ["../key-management/src"]
}
},
"include": ["src", "spec"],
"exclude": ["node_modules", "dist"]
}
2 changes: 1 addition & 1 deletion libs/platform/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { pathsToModuleNameMapper } = require("ts-jest");

const { compilerOptions } = require("../shared/tsconfig.libs");
const { compilerOptions } = require("../shared/tsconfig.spec");

const sharedConfig = require("../../libs/shared/jest.config.angular");

Expand Down
5 changes: 4 additions & 1 deletion libs/platform/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"extends": "../shared/tsconfig.libs",
"extends": "../shared/tsconfig",
"compilerOptions": {
"paths": {}
},
"include": ["src", "spec"],
"exclude": ["node_modules", "dist"]
}
File renamed without changes.
2 changes: 1 addition & 1 deletion libs/tools/card/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { pathsToModuleNameMapper } = require("ts-jest");

const { compilerOptions } = require("../../../shared/tsconfig.libs");
const { compilerOptions } = require("../../../shared/tsconfig.spec");

/** @type {import('jest').Config} */
module.exports = {
Expand Down
13 changes: 12 additions & 1 deletion libs/tools/card/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
{
"extends": "../../shared/tsconfig.libs",
"extends": "../../shared/tsconfig",
"compilerOptions": {
"paths": {
"@bitwarden/admin-console/common": ["../../admin-console/src/common"],
"@bitwarden/angular/*": ["../../angular/src/*"],
"@bitwarden/auth/common": ["../../auth/src/common"],
"@bitwarden/common/*": ["../../common/src/*"],
"@bitwarden/components": ["../../components/src"],
"@bitwarden/key-management": ["../../key-management/src"],
"@bitwarden/platform": ["../../platform/src"]
}
},
"include": ["src"],
"exclude": ["node_modules", "dist"]
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { pathsToModuleNameMapper } = require("ts-jest");

const { compilerOptions } = require("../../../../shared/tsconfig.libs");
const { compilerOptions } = require("../../../../shared/tsconfig.spec");

/** @type {import('jest').Config} */
module.exports = {
Expand Down
10 changes: 9 additions & 1 deletion libs/tools/export/vault-export/vault-export-core/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
{
"extends": "../../../../shared/tsconfig.libs",
"extends": "../../../../shared/tsconfig",
"compilerOptions": {
"paths": {
"@bitwarden/admin-console/common": ["../../../../admin-console/src/common"],
"@bitwarden/auth/common": ["../../../../auth/src/common"],
"@bitwarden/common/*": ["../../../../common/src/*"],
"@bitwarden/key-management": ["../../../../key-management/src"]
}
},
"include": ["src"],
"exclude": ["node_modules", "dist"]
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { pathsToModuleNameMapper } = require("ts-jest");

const { compilerOptions } = require("../../../../shared/tsconfig.libs");
const { compilerOptions } = require("../../../../shared/tsconfig.spec");

/** @type {import('jest').Config} */
module.exports = {
Expand Down
21 changes: 20 additions & 1 deletion libs/tools/export/vault-export/vault-export-ui/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
{
"extends": "../../../../shared/tsconfig.libs",
"extends": "../../../../shared/tsconfig",
"compilerOptions": {
"paths": {
"@bitwarden/admin-console/common": ["../../../../admin-console/src/common"],
"@bitwarden/angular/*": ["../../../../angular/src/*"],
"@bitwarden/auth/angular": ["../../../../auth/src/angular"],
"@bitwarden/auth/common": ["../../../../auth/src/common"],
"@bitwarden/common/*": ["../../../../common/src/*"],
"@bitwarden/components": ["../../../../components/src"],
"@bitwarden/generator-core": ["../../../../tools/generator/core/src"],
"@bitwarden/generator-history": ["../../../../tools/generator/extensions/history/src"],
"@bitwarden/generator-legacy": ["../../../../tools/generator/extensions/legacy/src"],
"@bitwarden/generator-navigation": ["../../../../tools/generator/extensions/navigation/src"],
"@bitwarden/key-management": ["../../../../key-management/src"],
"@bitwarden/platform": ["../../../../platform/src"],
"@bitwarden/vault-export-core": [
"../../../../tools/export/vault-export/vault-export-core/src"
]
}
},
"include": ["src"],
"exclude": ["node_modules", "dist"]
}
2 changes: 1 addition & 1 deletion libs/tools/generator/components/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { pathsToModuleNameMapper } = require("ts-jest");

const { compilerOptions } = require("../../../shared/tsconfig.libs.json");
const { compilerOptions } = require("../../../shared/tsconfig.spec.json");

/** @type {import('jest').Config} */
module.exports = {
Expand Down
Loading

0 comments on commit 653b730

Please sign in to comment.