Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions apps/web/webpack.base.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ const config = require(path.resolve(__dirname, "config.js"));
const pjson = require(path.resolve(__dirname, "package.json"));

module.exports.getEnv = function getEnv(params) {
const ENV = params.env || (process.env.ENV == null ? "development" : process.env.ENV);
const NODE_ENV = process.env.NODE_ENV == null ? "development" : process.env.NODE_ENV;
const LOGGING = process.env.LOGGING != "false";
const ENV = params.env?.ENV ?? process.env?.ENV ?? "development";
const NODE_ENV = params.env?.NODE_ENV ?? process.env?.NODE_ENV ?? "development";
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

โš ๏ธ Finding 1: Inconsistent LOGGING logic compared to ENV and NODE_ENV.

While ENV and NODE_ENV use nullish coalescing for boolean/truthy checks, LOGGING uses != "false" which means:

  • params.env.LOGGING undefined โ†’ falls through to process.env.LOGGING != "false"
  • If params.env.LOGGING is false (boolean), it becomes the value without the string check

This could lead to unexpected behavior if params.env.LOGGING is passed as a boolean false (it would be used directly) vs a string "false" (which would need the != check).

Consider making this consistent:

const LOGGING = params.env?.LOGGING ?? (process.env?.LOGGING != "false");

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was your code snippet the suggestion?

const LOGGING = params.env?.LOGGING ?? process.env?.LOGGING != "false";

return { ENV, NODE_ENV, LOGGING };
};
Expand All @@ -35,7 +35,11 @@ const DEFAULT_PARAMS = {
* tsConfig: string;
* outputPath?: string;
* mode?: string;
* env?: string;
* env?: {
* ENV?: string;
* NODE_ENV?: string;
* LOGGING?: boolean;
* };
* importAliases?: import("webpack").ResolveOptions["alias"];
* }} params
*/
Expand Down
1 change: 1 addition & 0 deletions apps/web/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module.exports = (webpackConfig, context) => {
},
tsConfig: "apps/web/tsconfig.build.json",
outputPath: path.resolve(context.context.root, context.options.outputPath),
env: context.options.env,
});
} else {
return buildConfig({
Expand Down
2 changes: 2 additions & 0 deletions bitwarden_license/bit-web/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const { buildConfig } = require(path.resolve(__dirname, "../../apps/web/webpack.

module.exports = (webpackConfig, context) => {
const isNxBuild = context && context.options;

if (isNxBuild) {
return buildConfig({
configName: "Commercial",
Expand All @@ -23,6 +24,7 @@ module.exports = (webpackConfig, context) => {
alias: "@bitwarden/commercial-sdk-internal",
},
],
env: context.options.env,
});
} else {
return buildConfig({
Expand Down
Loading