From b07d0ae39bf570f06dfa1bbc7d4b63719d609d65 Mon Sep 17 00:00:00 2001 From: Derek Nance Date: Fri, 12 Dec 2025 17:06:02 -0600 Subject: [PATCH] WIP bit-desktop entrypoints Need to get preload and renderer set up in commercial webpack config, otherwise it fails when running webpack. --- apps/desktop/package.json | 1 + bitwarden_license/bit-desktop/src/entry.ts | 8 ++++++ bitwarden_license/bit-desktop/tsconfig.json | 4 +++ .../bit-desktop/webpack.config.js | 26 +++++++++++++++++++ tsconfig.base.json | 1 + 5 files changed, 40 insertions(+) create mode 100644 bitwarden_license/bit-desktop/src/entry.ts create mode 100644 bitwarden_license/bit-desktop/tsconfig.json create mode 100644 bitwarden_license/bit-desktop/webpack.config.js diff --git a/apps/desktop/package.json b/apps/desktop/package.json index ad20e7c0e69..732c3890901 100644 --- a/apps/desktop/package.json +++ b/apps/desktop/package.json @@ -34,6 +34,7 @@ "build:renderer": "cross-env NODE_ENV=production webpack --config webpack.config.js --config-name renderer", "build:renderer:dev": "cross-env NODE_ENV=development webpack --config webpack.config.js --config-name renderer", "build:renderer:watch": "cross-env NODE_ENV=development webpack --config webpack.config.js --config-name renderer --watch", + "build:bit:main": "cross-env NODE_ENV=production webpack --config ../../bitwarden_license/bit-desktop/webpack.config.js --config-name main", "electron": "node ./scripts/start.js", "electron:ignore": "node ./scripts/start.js --ignore-certificate-errors", "flatpak:dev": "npm run clean:dist && electron-builder --dir -p never && flatpak-builder --force-clean --install --user ../../.flatpak/ ./resources/com.bitwarden.desktop.devel.yaml && flatpak run com.bitwarden.desktop", diff --git a/bitwarden_license/bit-desktop/src/entry.ts b/bitwarden_license/bit-desktop/src/entry.ts new file mode 100644 index 00000000000..e8ad9ad1896 --- /dev/null +++ b/bitwarden_license/bit-desktop/src/entry.ts @@ -0,0 +1,8 @@ +// implicitly execute the OSS entrypoint +import "@bitwarden/desktop/entry"; + +// TODO coalesce +// import {Main as OssMain} from "@bitwarden/desktop/main"; + +// export class Main extends OssMain +// { } diff --git a/bitwarden_license/bit-desktop/tsconfig.json b/bitwarden_license/bit-desktop/tsconfig.json new file mode 100644 index 00000000000..cc177ec1c45 --- /dev/null +++ b/bitwarden_license/bit-desktop/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "../../apps/desktop/tsconfig", + "files": ["../../bitwarden_license/bit-common/src/platform/sdk/sdk-alias.d.ts", "src/entry.ts"] +} diff --git a/bitwarden_license/bit-desktop/webpack.config.js b/bitwarden_license/bit-desktop/webpack.config.js new file mode 100644 index 00000000000..4e4909bfce7 --- /dev/null +++ b/bitwarden_license/bit-desktop/webpack.config.js @@ -0,0 +1,26 @@ +const path = require("path"); +const { buildConfig } = require("../../apps/desktop/webpack.base"); + +module.exports = (webpackConfig, context) => { + // Detect if called by Nx (context parameter exists) + const isNxBuild = context && context.options; + + if (isNxBuild) { + return buildConfig({ + configName: "Commercial", + main: { + entry: path.resolve(__dirname, "src/entry.ts"), + tsConfig: path.resolve(context.context.root, "bitwarden_license/bit-desktop/tsconfig.json"), + }, + outputPath: path.resolve(context.context.root, context.options.outputPath), + }); + } else { + return buildConfig({ + configName: "Commercial", + main: { + entry: path.resolve(__dirname, "src/entry.ts"), + tsConfig: path.resolve(__dirname, "tsconfig.json"), + }, + }); + } +}; diff --git a/tsconfig.base.json b/tsconfig.base.json index 68498cfae01..881d7fbc0eb 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -34,6 +34,7 @@ "@bitwarden/common/*": ["./libs/common/src/*"], "@bitwarden/components": ["./libs/components/src"], "@bitwarden/core-test-utils": ["./libs/core-test-utils/src/index.ts"], + "@bitwarden/desktop/*": ["./apps/desktop/src/*"], "@bitwarden/dirt-card": ["./libs/dirt/card/src"], "@bitwarden/generator-components": ["./libs/tools/generator/components/src"], "@bitwarden/generator-core": ["./libs/tools/generator/core/src"],