Browse Source
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.pull/16402/head
22 changed files with 14 additions and 133 deletions
@ -1 +1 @@
@@ -1 +1 @@
|
||||
export * from "@bitwarden/messaging-internal"; |
||||
export { SubjectMessageSender, tagAsExternal, getCommand } from "@bitwarden/messaging"; |
||||
|
||||
@ -1,5 +0,0 @@
@@ -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 @@
@@ -1,3 +0,0 @@
|
||||
import baseConfig from "../../eslint.config.mjs"; |
||||
|
||||
export default [...baseConfig]; |
||||
@ -1,10 +0,0 @@
@@ -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 @@
@@ -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 @@
@@ -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 @@
@@ -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 @@
@@ -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 @@
@@ -1,6 +0,0 @@
|
||||
{ |
||||
"extends": "../../tsconfig.base.json", |
||||
"files": [], |
||||
"include": ["src/**/*.ts", "src/**/*.js"], |
||||
"exclude": ["**/build", "**/dist"] |
||||
} |
||||
@ -1,13 +0,0 @@
@@ -1,13 +0,0 @@
|
||||
{ |
||||
"extends": "../../tsconfig.base.json", |
||||
"files": [], |
||||
"include": [], |
||||
"references": [ |
||||
{ |
||||
"path": "./tsconfig.lib.json" |
||||
}, |
||||
{ |
||||
"path": "./tsconfig.spec.json" |
||||
} |
||||
] |
||||
} |
||||
@ -1,10 +0,0 @@
@@ -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 @@
@@ -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 @@
@@ -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 @@
@@ -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, |
||||
@ -1,8 +1,7 @@
@@ -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 @@
@@ -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>>>) {} |
||||
Loading…
Reference in new issue