-
Notifications
You must be signed in to change notification settings - Fork 1.5k
build(cli): integrate nx #16648
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
build(cli): integrate nx #16648
Conversation
e7bb362
to
3bd5339
Compare
Great job! No new security vulnerabilities introduced in this pull request |
232c72a
to
e7ea2f7
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #16648 +/- ##
==========================================
- Coverage 38.75% 38.75% -0.01%
==========================================
Files 3406 3407 +1
Lines 96688 96713 +25
Branches 14533 14541 +8
==========================================
+ Hits 37473 37482 +9
- Misses 57577 57592 +15
- Partials 1638 1639 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
0103f77
to
8a4fcf3
Compare
463794f
to
10b7298
Compare
Pull request was converted to draft
6a2b37b
to
38be8b1
Compare
38be8b1
to
c61d4a8
Compare
return buildConfig({ | ||
configName: "OSS", | ||
entry: "./src/bw.ts", | ||
tsConfig: "./tsconfig.json", | ||
outputPath: path.resolve(__dirname, "build"), | ||
mode: mode, | ||
env: ENV, | ||
modulesPath: [path.resolve("../../node_modules")], | ||
localesPath: "./src/locales", | ||
externalsModulesDir: "../../node_modules", | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A lot of these are the default values in webpack.base, but they won't be for long so I was verbose with these args.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: instead of putting the default values interspersed in the code
patterns: [{ from: params.localesPath || "./src/locales", to: "locales" }],
could we move it all to one place?
const DEFAULT_PARAMS = {
outputPath: "...",
mode: "...",
env: "...",
modulesPath: [],
localesPath: "...",
externalsModulesDir: "...",
watch: "...",
};
module.exports.buildConfig = function buildConfig(params) {
params = { ...DEFAULT_PARAMS, params };
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea. Really cleans this up a lot. Implemented as suggested on a72cd0e.
apps/cli/project.json
Outdated
"mode": "development", | ||
"outputPath": "dist/apps/cli/oss-dev" | ||
}, | ||
"bit": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question/suggestion: should we take this as an opportunity to stop using bit
?
"bit": { | |
"commercial": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
implemented as suggested on 537d6d7
I'm going to get a task in Jira for the next Nx focused epic to rename the folders themselves whenever we remove the old npm scripts. No ticket for that right this second but I'm talking to Todd about it.
Screenshot of a "commercial" build passing:

d2e05a9
to
a72cd0e
Compare
|
🎟️ Tracking
https://bitwarden.atlassian.net/browse/PM-24802
All other clients are dependent on this PR for the new nx webpack plugin
📔 Objective
Enable Nx builds in the cli. For example:
Most complexity here is that we need to support the pre-nx build pipelines for a while, so we have to juggle both configurations. The recent refactor of our webpack config to a webpack config factory was pretty helpful here. I added a bunch of optional parameters that come from Nx in Nx builds.
Once we update CI to use Nx builds exclusively, and the Nx builds have had time to get battle tested, we'll remove the old npm builds and this configuration will get a bit simpler since we can start just depending on values from params.
Otherwise, this is a fairly straightforward port of the build commands from cli's
package.json
into a functioningproject.json
. It uses the standard executors and follows Nx conventions for this kind of build without much else that is special.I've included some docs on using Nx in a root level
docs
folder. I got architecture's blessing to create this folder here.📸 Screenshots
Here are some screenshots of various local nx builds. These aren't comprehensive, and the project.json should be reviewed to see what is available. I think I've verified that they all work locally. In CI you can reference the "Experimental Nx CI" job to see what is passing and what isn't. Please note this job will pass even if there are errors, so it should be reviewed even if it's green. For convenience I've included a screenshot of the last CI run showing
⏰ Reminders before review
🦮 Reviewer guidelines
:+1:
) or similar for great changes:memo:
) or ℹ️ (:information_source:
) for notes or general info:question:
) for questions:thinking:
) or 💭 (:thought_balloon:
) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion:art:
) for suggestions / improvements:x:
) or:warning:
) for more significant problems or concerns needing attention:seedling:
) or ♻️ (:recycle:
) for future improvements or indications of technical debt:pick:
) for minor or nitpick changes