1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-04 10:43:47 +00:00

Consolidate messaging-internal into messaging library

- Move SubjectMessageSender, helpers, and test files from messaging-internal to messaging
- Update imports to use relative paths instead of @bitwarden/messaging imports
- Remove messaging-internal library entirely to eliminate circular dependency
- Update external references to use @bitwarden/messaging instead of @bitwarden/messaging-internal
- Fix tsconfig.lib.json rootDir conflict by removing cross-library file includes

Resolves the first incomplete TODO in Fix Nx Library Paths memory:
'Import from messaging-internal directly in messaging'
This commit is contained in:
addisonbeck
2025-09-11 13:22:36 -04:00
parent 2503b37f2c
commit 51bf0baba9
21 changed files with 18 additions and 134 deletions

View File

@@ -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";

View File

@@ -1 +1 @@
export * from "@bitwarden/messaging-internal";
export { SubjectMessageSender, tagAsExternal, getCommand } from "@bitwarden/messaging";

View File

@@ -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.

View File

@@ -1,3 +0,0 @@
import baseConfig from "../../eslint.config.mjs";
export default [...baseConfig];

View File

@@ -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",
};

View File

@@ -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": "index.js",
"types": "index.d.ts",
"license": "GPL-3.0",
"author": "platform"
}

View File

@@ -1,34 +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"],
"rootDir": "libs/messaging-internal/src"
}
},
"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"
}
}
}
}

View File

@@ -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";

View File

@@ -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();
});
});

View File

@@ -1,6 +0,0 @@
{
"extends": "../../tsconfig.base.json",
"files": [],
"include": ["src/**/*.ts", "src/**/*.js"],
"exclude": ["**/build", "**/dist"]
}

View File

@@ -1,13 +0,0 @@
{
"extends": "../../tsconfig.base.json",
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.lib.json"
},
{
"path": "./tsconfig.spec.json"
}
]
}

View File

@@ -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"]
}

View File

@@ -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"]
}

View File

@@ -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", () => {

View File

@@ -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,

View File

@@ -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";

View File

@@ -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 }>>();

View File

@@ -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>>>) {}

View File

@@ -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"]
}

View File

@@ -4,8 +4,8 @@
"description": "<%= description %>",
"private": true,
"type": "commonjs",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"main": "index.js",
"types": "index.d.ts",
"license": "GPL-3.0",
"author": "<%= team %>"
}

View File

@@ -12,7 +12,8 @@
"outputPath": "dist/libs/<%= name %>",
"main": "libs/<%= name %>/src/index.ts",
"tsConfig": "libs/<%= name %>/tsconfig.lib.json",
"assets": ["libs/<%= name%>/*.md"]
"assets": ["libs/<%= name %>/*.md"],
"rootDir": "libs/<%= name %>/src"
}
},
"lint": {