mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Extract message-bridge to separate NPM package to prevent dev dependencies being in the production bundle
Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
parent
cfb2bc8a5a
commit
5943a21671
21
package-lock.json
generated
21
package-lock.json
generated
@ -4725,6 +4725,10 @@
|
|||||||
"resolved": "packages/technical-features/messaging/agnostic",
|
"resolved": "packages/technical-features/messaging/agnostic",
|
||||||
"link": true
|
"link": true
|
||||||
},
|
},
|
||||||
|
"node_modules/@k8slens/messaging-fake-bridge": {
|
||||||
|
"resolved": "packages/technical-features/messaging/message-bridge-fake",
|
||||||
|
"link": true
|
||||||
|
},
|
||||||
"node_modules/@k8slens/messaging-for-main": {
|
"node_modules/@k8slens/messaging-for-main": {
|
||||||
"resolved": "packages/technical-features/messaging/main",
|
"resolved": "packages/technical-features/messaging/main",
|
||||||
"link": true
|
"link": true
|
||||||
@ -37245,6 +37249,23 @@
|
|||||||
"lodash": "^4.17.21"
|
"lodash": "^4.17.21"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"packages/technical-features/messaging/message-bridge-fake": {
|
||||||
|
"version": "1.0.0-alpha.1",
|
||||||
|
"license": "MIT",
|
||||||
|
"devDependencies": {
|
||||||
|
"@async-fn/jest": "^1.6.4",
|
||||||
|
"@k8slens/eslint-config": "^6.5.0-alpha.1",
|
||||||
|
"@k8slens/feature-core": "6.5.0-alpha.1",
|
||||||
|
"@ogre-tools/injectable-extension-for-mobx": "^15.1.2",
|
||||||
|
"mobx": "^6.7.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@k8slens/messaging": "^1.0.0-alpha.1",
|
||||||
|
"@ogre-tools/fp": "^15.1.2",
|
||||||
|
"@ogre-tools/injectable": "^15.1.2",
|
||||||
|
"lodash": "^4.17.21"
|
||||||
|
}
|
||||||
|
},
|
||||||
"packages/technical-features/messaging/renderer": {
|
"packages/technical-features/messaging/renderer": {
|
||||||
"name": "@k8slens/messaging-for-renderer",
|
"name": "@k8slens/messaging-for-renderer",
|
||||||
"version": "1.0.0-alpha.1",
|
"version": "1.0.0-alpha.1",
|
||||||
|
|||||||
@ -189,6 +189,7 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@async-fn/jest": "1.6.4",
|
"@async-fn/jest": "1.6.4",
|
||||||
|
"@k8slens/messaging-fake-bridge": "^1.0.0-alpha.1",
|
||||||
"@material-ui/core": "^4.12.3",
|
"@material-ui/core": "^4.12.3",
|
||||||
"@material-ui/icons": "^4.11.2",
|
"@material-ui/icons": "^4.11.2",
|
||||||
"@material-ui/lab": "^4.0.0-alpha.60",
|
"@material-ui/lab": "^4.0.0-alpha.60",
|
||||||
|
|||||||
@ -70,7 +70,8 @@ import { registerFeature } from "@k8slens/feature-core";
|
|||||||
import { applicationFeatureForElectronMain, testUtils as applicationForElectronTestUtils } from "@k8slens/application-for-electron-main";
|
import { applicationFeatureForElectronMain, testUtils as applicationForElectronTestUtils } from "@k8slens/application-for-electron-main";
|
||||||
import { applicationFeature, startApplicationInjectionToken } from "@k8slens/application";
|
import { applicationFeature, startApplicationInjectionToken } from "@k8slens/application";
|
||||||
import { testUsingFakeTime } from "../../../test-utils/use-fake-time";
|
import { testUsingFakeTime } from "../../../test-utils/use-fake-time";
|
||||||
import { sendMessageToChannelInjectionToken, testUtils as messagingTestUtils } from "@k8slens/messaging";
|
import { sendMessageToChannelInjectionToken } from "@k8slens/messaging";
|
||||||
|
import { getMessageBridgeFake } from "@k8slens/messaging-fake-bridge";
|
||||||
|
|
||||||
type MainDiCallback = (container: { mainDi: DiContainer }) => void | Promise<void>;
|
type MainDiCallback = (container: { mainDi: DiContainer }) => void | Promise<void>;
|
||||||
type WindowDiCallback = (container: { windowDi: DiContainer }) => void | Promise<void>;
|
type WindowDiCallback = (container: { windowDi: DiContainer }) => void | Promise<void>;
|
||||||
@ -179,7 +180,7 @@ export const getApplicationBuilder = () => {
|
|||||||
|
|
||||||
testUsingFakeTime();
|
testUsingFakeTime();
|
||||||
|
|
||||||
const messageBridgeFake = messagingTestUtils.getMessageBridgeFake();
|
const messageBridgeFake = getMessageBridgeFake();
|
||||||
|
|
||||||
messageBridgeFake.involve(mainDi);
|
messageBridgeFake.involve(mainDi);
|
||||||
|
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import { createContainer, DiContainer, getInjectable } from "@ogre-tools/injecta
|
|||||||
import {
|
import {
|
||||||
getMessageBridgeFake,
|
getMessageBridgeFake,
|
||||||
MessageBridgeFake,
|
MessageBridgeFake,
|
||||||
} from "../../unit-testing/get-message-bridge-fake/get-message-bridge-fake";
|
} from "@k8slens/messaging-fake-bridge";
|
||||||
import { startApplicationInjectionToken } from "@k8slens/application";
|
import { startApplicationInjectionToken } from "@k8slens/application";
|
||||||
import {
|
import {
|
||||||
computed,
|
computed,
|
||||||
|
|||||||
@ -27,6 +27,7 @@ export type { SendMessageToChannel } from "./message/message-to-channel-injectio
|
|||||||
export type {
|
export type {
|
||||||
GetMessageChannelListenerInfo,
|
GetMessageChannelListenerInfo,
|
||||||
MessageChannel,
|
MessageChannel,
|
||||||
|
MessageChannelHandler,
|
||||||
MessageChannelListener,
|
MessageChannelListener,
|
||||||
} from "./message/message-channel-listener-injection-token";
|
} from "./message/message-channel-listener-injection-token";
|
||||||
|
|
||||||
|
|||||||
@ -1,2 +1 @@
|
|||||||
export { messagingFeatureForUnitTesting } from "./feature";
|
export { messagingFeatureForUnitTesting } from "./feature";
|
||||||
export { getMessageBridgeFake } from "./get-message-bridge-fake/get-message-bridge-fake";
|
|
||||||
|
|||||||
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"extends": "@k8slens/eslint-config/eslint",
|
||||||
|
"parserOptions": {
|
||||||
|
"project": "./tsconfig.json"
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1 @@
|
|||||||
|
"@k8slens/eslint-config/prettier"
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
export type { MessageBridgeFake } from "./src/get-message-bridge-fake/get-message-bridge-fake";
|
||||||
|
|
||||||
|
export { getMessageBridgeFake } from "./src/get-message-bridge-fake/get-message-bridge-fake";
|
||||||
@ -0,0 +1 @@
|
|||||||
|
module.exports = require("@k8slens/jest").monorepoPackageConfig(__dirname).configForReact;
|
||||||
@ -0,0 +1,43 @@
|
|||||||
|
{
|
||||||
|
"name": "@k8slens/messaging-fake-bridge",
|
||||||
|
"private": false,
|
||||||
|
"version": "1.0.0-alpha.1",
|
||||||
|
"description": "Fake implementation to bridge multiple dependency injection containers.",
|
||||||
|
"type": "commonjs",
|
||||||
|
"files": [
|
||||||
|
"dist"
|
||||||
|
],
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/lensapp/lens.git"
|
||||||
|
},
|
||||||
|
"main": "dist/index.js",
|
||||||
|
"types": "dist/index.d.ts",
|
||||||
|
"author": {
|
||||||
|
"name": "OpenLens Authors",
|
||||||
|
"email": "info@k8slens.dev"
|
||||||
|
},
|
||||||
|
"license": "MIT",
|
||||||
|
"homepage": "https://github.com/lensapp/lens",
|
||||||
|
"scripts": {
|
||||||
|
"build": "webpack",
|
||||||
|
"dev": "webpack --mode=development --watch",
|
||||||
|
"test:unit": "jest --coverage --runInBand",
|
||||||
|
"lint:fix": "lens-lint --fix",
|
||||||
|
"lint": "lens-lint"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@k8slens/messaging": "^1.0.0-alpha.1",
|
||||||
|
"@ogre-tools/fp": "^15.1.2",
|
||||||
|
"@ogre-tools/injectable": "^15.1.2",
|
||||||
|
"lodash": "^4.17.21"
|
||||||
|
},
|
||||||
|
|
||||||
|
"devDependencies": {
|
||||||
|
"@async-fn/jest": "^1.6.4",
|
||||||
|
"@k8slens/feature-core": "6.5.0-alpha.1",
|
||||||
|
"@k8slens/eslint-config": "^6.5.0-alpha.1",
|
||||||
|
"@ogre-tools/injectable-extension-for-mobx": "^15.1.2",
|
||||||
|
"mobx": "^6.7.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,24 +1,23 @@
|
|||||||
import { createContainer, DiContainer, Injectable } from "@ogre-tools/injectable";
|
import { createContainer, DiContainer, Injectable } from "@ogre-tools/injectable";
|
||||||
import asyncFn, { AsyncFnMock } from "@async-fn/jest";
|
import asyncFn, { AsyncFnMock } from "@async-fn/jest";
|
||||||
import { registerFeature } from "@k8slens/feature-core/src/register-feature";
|
import { registerFeature } from "@k8slens/feature-core";
|
||||||
import {
|
import {
|
||||||
|
getMessageChannel,
|
||||||
getMessageChannelListenerInjectable,
|
getMessageChannelListenerInjectable,
|
||||||
|
getRequestChannel,
|
||||||
|
getRequestChannelListenerInjectable,
|
||||||
MessageChannel,
|
MessageChannel,
|
||||||
} from "../../actual/message/message-channel-listener-injection-token";
|
testUtils,
|
||||||
import { sendMessageToChannelInjectionToken } from "../../actual/message/message-to-channel-injection-token";
|
RequestChannel,
|
||||||
|
requestFromChannelInjectionToken,
|
||||||
|
sendMessageToChannelInjectionToken,
|
||||||
|
} from "@k8slens/messaging";
|
||||||
|
|
||||||
import { registerMobX } from "@ogre-tools/injectable-extension-for-mobx";
|
import { registerMobX } from "@ogre-tools/injectable-extension-for-mobx";
|
||||||
import { runInAction } from "mobx";
|
import { runInAction } from "mobx";
|
||||||
import {
|
|
||||||
getRequestChannelListenerInjectable,
|
|
||||||
RequestChannel,
|
|
||||||
} from "../../actual/request/request-channel-listener-injection-token";
|
|
||||||
import { requestFromChannelInjectionToken } from "../../actual/request/request-from-channel-injection-token";
|
|
||||||
import { getPromiseStatus } from "@k8slens/test-utils";
|
import { getPromiseStatus } from "@k8slens/test-utils";
|
||||||
import { getMessageBridgeFake } from "./get-message-bridge-fake";
|
import { getMessageBridgeFake } from "./get-message-bridge-fake";
|
||||||
import { getMessageChannel } from "../../actual/message/get-message-channel";
|
|
||||||
import { getRequestChannel } from "../../actual/request/get-request-channel";
|
|
||||||
import { startApplicationInjectionToken } from "@k8slens/application";
|
import { startApplicationInjectionToken } from "@k8slens/application";
|
||||||
import { messagingFeatureForUnitTesting } from "../feature";
|
|
||||||
|
|
||||||
type SomeMessageChannel = MessageChannel<string>;
|
type SomeMessageChannel = MessageChannel<string>;
|
||||||
type SomeRequestChannel = RequestChannel<string, number>;
|
type SomeRequestChannel = RequestChannel<string, number>;
|
||||||
@ -58,9 +57,11 @@ const someRequestChannelWithoutListeners: SomeRequestChannel = {
|
|||||||
registerMobX(someDiWithoutListeners);
|
registerMobX(someDiWithoutListeners);
|
||||||
|
|
||||||
runInAction(() => {
|
runInAction(() => {
|
||||||
registerFeature(someDi1, messagingFeatureForUnitTesting);
|
const feature = testUtils.messagingFeatureForUnitTesting;
|
||||||
registerFeature(someDi2, messagingFeatureForUnitTesting);
|
|
||||||
registerFeature(someDiWithoutListeners, messagingFeatureForUnitTesting);
|
registerFeature(someDi1, feature);
|
||||||
|
registerFeature(someDi2, feature);
|
||||||
|
registerFeature(someDiWithoutListeners, feature);
|
||||||
});
|
});
|
||||||
|
|
||||||
messageBridgeFake.involve(someDi1, someDi2, someDiWithoutListeners);
|
messageBridgeFake.involve(someDi1, someDi2, someDiWithoutListeners);
|
||||||
@ -1,16 +1,16 @@
|
|||||||
import type { DiContainer } from "@ogre-tools/injectable";
|
import type { DiContainer } from "@ogre-tools/injectable";
|
||||||
import type { Channel } from "../../actual/channel.no-coverage";
|
import type { Channel, MessageChannelHandler, RequestChannelHandler } from "@k8slens/messaging";
|
||||||
import type { MessageChannelHandler } from "../../actual/message/message-channel-listener-injection-token";
|
|
||||||
import type { RequestChannelHandler } from "../../actual/request/request-channel-listener-injection-token";
|
|
||||||
import { sendMessageToChannelInjectionToken } from "../../actual/message/message-to-channel-injection-token";
|
|
||||||
import { enlistMessageChannelListenerInjectionToken } from "../../actual/message/enlist-message-channel-listener-injection-token";
|
|
||||||
import { pipeline } from "@ogre-tools/fp";
|
|
||||||
import { filter, map } from "lodash/fp";
|
|
||||||
import {
|
import {
|
||||||
|
enlistMessageChannelListenerInjectionToken,
|
||||||
|
enlistRequestChannelListenerInjectionToken,
|
||||||
RequestFromChannel,
|
RequestFromChannel,
|
||||||
requestFromChannelInjectionToken,
|
requestFromChannelInjectionToken,
|
||||||
} from "../../actual/request/request-from-channel-injection-token";
|
sendMessageToChannelInjectionToken,
|
||||||
import { enlistRequestChannelListenerInjectionToken } from "../../actual/request/enlist-request-channel-listener-injection-token";
|
} from "@k8slens/messaging";
|
||||||
|
|
||||||
|
import { pipeline } from "@ogre-tools/fp";
|
||||||
|
import { filter, map } from "lodash/fp";
|
||||||
import asyncFn, { AsyncFnMock } from "@async-fn/jest";
|
import asyncFn, { AsyncFnMock } from "@async-fn/jest";
|
||||||
|
|
||||||
export type MessageBridgeFake = {
|
export type MessageBridgeFake = {
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"extends": "@k8slens/typescript/config/base.json",
|
||||||
|
"include": ["**/*.ts", "**/*.tsx"]
|
||||||
|
}
|
||||||
@ -0,0 +1 @@
|
|||||||
|
module.exports = require("@k8slens/webpack").configForNode;
|
||||||
Loading…
Reference in New Issue
Block a user