mirror of
https://github.com/bitwarden/browser.git
synced 2025-12-05 09:14:28 +01:00
refactor(libs): consolidate messaging-internal into messaging library (#16386)
This change eliminates the circular dependency between messaging and messaging-internal libraries by merging them into a single messaging library. Previously, messaging-internal imported from @bitwarden/messaging while messaging tried to import from @bitwarden/messaging-internal, creating an unresolvable circular dependency. This also violated Nx best practices by using cross-library file includes in tsconfig.lib.json. Changes made: - Moved all messaging-internal code (SubjectMessageSender, helpers, tests) into libs/messaging/src/ - Updated all imports to use relative paths instead of @bitwarden/messaging imports - Removed the entire messaging-internal library and its configuration files - Updated external references in apps/browser to import from @bitwarden/messaging - Fixed libs/messaging/tsconfig.lib.json to use standard src/**/*.ts pattern - Updated libs/common internal.ts to re-export from messaging instead of messaging-internal The messaging library now exports both public APIs and internal implementations, which is a cleaner architecture than maintaining two separate libraries with circular dependencies. Fixes rootDir configuration issues identified in the Nx library systematic fix project.
This commit is contained in:
parent
24c8b2dc5d
commit
7ac75a6c52
1
.github/CODEOWNERS
vendored
1
.github/CODEOWNERS
vendored
@ -96,7 +96,6 @@ libs/storage-core @bitwarden/team-platform-dev
|
||||
libs/logging @bitwarden/team-platform-dev
|
||||
libs/storage-test-utils @bitwarden/team-platform-dev
|
||||
libs/messaging @bitwarden/team-platform-dev
|
||||
libs/messaging-internal @bitwarden/team-platform-dev
|
||||
libs/serialization @bitwarden/team-platform-dev
|
||||
libs/guid @bitwarden/team-platform-dev
|
||||
libs/client-type @bitwarden/team-platform-dev
|
||||
|
||||
@ -4,7 +4,7 @@ import { Subject, firstValueFrom } from "rxjs";
|
||||
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
|
||||
import { MessageListener, MessageSender } from "@bitwarden/common/platform/messaging";
|
||||
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
|
||||
import { tagAsExternal } from "@bitwarden/messaging-internal";
|
||||
import { tagAsExternal } from "@bitwarden/messaging";
|
||||
|
||||
import { FullSyncMessage } from "./foreground-sync.service";
|
||||
import { FULL_SYNC_FINISHED, SyncServiceListener } from "./sync-service.listener";
|
||||
|
||||
@ -41,7 +41,6 @@ module.exports = {
|
||||
"<rootDir>/libs/key-management/jest.config.js",
|
||||
"<rootDir>/libs/key-management-ui/jest.config.js",
|
||||
"<rootDir>/libs/logging/jest.config.js",
|
||||
"<rootDir>/libs/messaging-internal/jest.config.js",
|
||||
"<rootDir>/libs/messaging/jest.config.js",
|
||||
"<rootDir>/libs/node/jest.config.js",
|
||||
"<rootDir>/libs/platform/jest.config.js",
|
||||
|
||||
@ -1 +1 @@
|
||||
export * from "@bitwarden/messaging-internal";
|
||||
export { SubjectMessageSender, tagAsExternal, getCommand } from "@bitwarden/messaging";
|
||||
|
||||
@ -1,5 +0,0 @@
|
||||
# messaging-internal
|
||||
|
||||
Owned by: platform
|
||||
|
||||
Internal details to accompany @bitwarden/messaging this library should not be consumed in non-platform code.
|
||||
@ -1,3 +0,0 @@
|
||||
import baseConfig from "../../eslint.config.mjs";
|
||||
|
||||
export default [...baseConfig];
|
||||
@ -1,10 +0,0 @@
|
||||
module.exports = {
|
||||
displayName: "messaging-internal",
|
||||
preset: "../../jest.preset.js",
|
||||
testEnvironment: "node",
|
||||
transform: {
|
||||
"^.+\\.[tj]s$": ["ts-jest", { tsconfig: "<rootDir>/tsconfig.spec.json" }],
|
||||
},
|
||||
moduleFileExtensions: ["ts", "js", "html"],
|
||||
coverageDirectory: "../../coverage/libs/messaging-internal",
|
||||
};
|
||||
@ -1,11 +0,0 @@
|
||||
{
|
||||
"name": "@bitwarden/messaging-internal",
|
||||
"version": "0.0.1",
|
||||
"description": "Internal details to accompany @bitwarden/messaging this library should not be consumed in non-platform code.",
|
||||
"private": true,
|
||||
"type": "commonjs",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
"license": "GPL-3.0",
|
||||
"author": "platform"
|
||||
}
|
||||
@ -1,33 +0,0 @@
|
||||
{
|
||||
"name": "messaging-internal",
|
||||
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
||||
"sourceRoot": "libs/messaging-internal/src",
|
||||
"projectType": "library",
|
||||
"tags": [],
|
||||
"targets": {
|
||||
"build": {
|
||||
"executor": "@nx/js:tsc",
|
||||
"outputs": ["{options.outputPath}"],
|
||||
"options": {
|
||||
"outputPath": "dist/libs/messaging-internal",
|
||||
"main": "libs/messaging-internal/src/index.ts",
|
||||
"tsConfig": "libs/messaging-internal/tsconfig.lib.json",
|
||||
"assets": ["libs/messaging-internal/*.md"]
|
||||
}
|
||||
},
|
||||
"lint": {
|
||||
"executor": "@nx/eslint:lint",
|
||||
"outputs": ["{options.outputFile}"],
|
||||
"options": {
|
||||
"lintFilePatterns": ["libs/messaging-internal/**/*.ts"]
|
||||
}
|
||||
},
|
||||
"test": {
|
||||
"executor": "@nx/jest:jest",
|
||||
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
|
||||
"options": {
|
||||
"jestConfig": "libs/messaging-internal/jest.config.js"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,5 +0,0 @@
|
||||
// Built in implementations
|
||||
export { SubjectMessageSender } from "./subject-message.sender";
|
||||
|
||||
// Helpers meant to be used only by other implementations
|
||||
export { tagAsExternal, getCommand } from "./helpers";
|
||||
@ -1,8 +0,0 @@
|
||||
import * as lib from "./index";
|
||||
|
||||
describe("messaging-internal", () => {
|
||||
// This test will fail until something is exported from index.ts
|
||||
it("should work", () => {
|
||||
expect(lib).toBeDefined();
|
||||
});
|
||||
});
|
||||
@ -1,6 +0,0 @@
|
||||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"files": [],
|
||||
"include": ["src/**/*.ts", "src/**/*.js"],
|
||||
"exclude": ["**/build", "**/dist"]
|
||||
}
|
||||
@ -1,13 +0,0 @@
|
||||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"files": [],
|
||||
"include": [],
|
||||
"references": [
|
||||
{
|
||||
"path": "./tsconfig.lib.json"
|
||||
},
|
||||
{
|
||||
"path": "./tsconfig.spec.json"
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -1,10 +0,0 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "../../dist/out-tsc",
|
||||
"declaration": true,
|
||||
"types": ["node"]
|
||||
},
|
||||
"include": ["src/**/*.ts"],
|
||||
"exclude": ["jest.config.js", "src/**/*.spec.ts"]
|
||||
}
|
||||
@ -1,10 +0,0 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "../../dist/out-tsc",
|
||||
"module": "commonjs",
|
||||
"moduleResolution": "node10",
|
||||
"types": ["jest", "node"]
|
||||
},
|
||||
"include": ["jest.config.ts", "src/**/*.test.ts", "src/**/*.spec.ts", "src/**/*.d.ts"]
|
||||
}
|
||||
@ -1,8 +1,8 @@
|
||||
import { Subject, firstValueFrom } from "rxjs";
|
||||
|
||||
import { CommandDefinition, isExternalMessage, Message } from "@bitwarden/messaging";
|
||||
|
||||
import { getCommand, tagAsExternal } from "./helpers";
|
||||
import { isExternalMessage } from "./is-external-message";
|
||||
import { CommandDefinition, Message } from "./types";
|
||||
|
||||
describe("helpers", () => {
|
||||
describe("getCommand", () => {
|
||||
@ -1,6 +1,7 @@
|
||||
import { map } from "rxjs";
|
||||
|
||||
import { CommandDefinition, EXTERNAL_SOURCE_TAG } from "@bitwarden/messaging";
|
||||
import { EXTERNAL_SOURCE_TAG } from "./is-external-message";
|
||||
import { CommandDefinition } from "./types";
|
||||
|
||||
export const getCommand = (
|
||||
commandDefinition: CommandDefinition<Record<string, unknown>> | string,
|
||||
@ -2,3 +2,7 @@ export { MessageListener } from "./message.listener";
|
||||
export { MessageSender } from "./message.sender";
|
||||
export { Message, CommandDefinition } from "./types";
|
||||
export { isExternalMessage, EXTERNAL_SOURCE_TAG } from "./is-external-message";
|
||||
|
||||
// Internal implementations
|
||||
export { SubjectMessageSender } from "./subject-message.sender";
|
||||
export { tagAsExternal, getCommand } from "./helpers";
|
||||
|
||||
@ -1,8 +1,7 @@
|
||||
import { bufferCount, firstValueFrom, Subject } from "rxjs";
|
||||
|
||||
import { CommandDefinition, Message } from "@bitwarden/messaging";
|
||||
|
||||
import { SubjectMessageSender } from "./subject-message.sender";
|
||||
import { CommandDefinition, Message } from "./types";
|
||||
|
||||
describe("SubjectMessageSender", () => {
|
||||
const subject = new Subject<Message<{ test: number }>>();
|
||||
@ -1,8 +1,8 @@
|
||||
import { Subject } from "rxjs";
|
||||
|
||||
import { CommandDefinition, Message, MessageSender } from "@bitwarden/messaging";
|
||||
|
||||
import { getCommand } from "./helpers";
|
||||
import { MessageSender } from "./message.sender";
|
||||
import { CommandDefinition, Message } from "./types";
|
||||
|
||||
export class SubjectMessageSender implements MessageSender {
|
||||
constructor(private readonly messagesSubject: Subject<Message<Record<string, unknown>>>) {}
|
||||
@ -5,12 +5,6 @@
|
||||
"declaration": true,
|
||||
"types": ["node"]
|
||||
},
|
||||
"include": [
|
||||
"src/**/*.ts",
|
||||
"../messaging-internal/src/subject-message.sender.spec.ts",
|
||||
"../messaging-internal/src/subject-message.sender.ts",
|
||||
"../messaging-internal/src/helpers.spec.ts",
|
||||
"../messaging-internal/src/helpers.ts"
|
||||
],
|
||||
"include": ["src/**/*.ts"],
|
||||
"exclude": ["jest.config.js", "src/**/*.spec.ts"]
|
||||
}
|
||||
|
||||
@ -45,7 +45,6 @@
|
||||
"@bitwarden/key-management-ui": ["./libs/key-management-ui/src"],
|
||||
"@bitwarden/logging": ["libs/logging/src"],
|
||||
"@bitwarden/messaging": ["libs/messaging/src/index.ts"],
|
||||
"@bitwarden/messaging-internal": ["libs/messaging-internal/src/index.ts"],
|
||||
"@bitwarden/node/*": ["./libs/node/src/*"],
|
||||
"@bitwarden/nx-plugin": ["libs/nx-plugin/src/index.ts"],
|
||||
"@bitwarden/platform": ["./libs/platform/src"],
|
||||
|
||||
Loading…
Reference in New Issue
Block a user