-
Notifications
You must be signed in to change notification settings - Fork 229
chore: enhance npm start command to run compass sync and sandbox COMPASS-9851 #7338
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
base: main
Are you sure you want to change the base?
Conversation
const halfRamMb = Math.min( | ||
Math.floor(os.totalmem() / 2 / 1024 / 1024), | ||
16384 | ||
); | ||
// Merge with existing NODE_OPTIONS if present | ||
const existingNodeOptions = process.env.NODE_OPTIONS ?? ''; | ||
const mergedNodeOptions = [ | ||
`--max_old_space_size=${halfRamMb}`, | ||
existingNodeOptions, | ||
] | ||
.filter(Boolean) | ||
.join(' '); |
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.
When running sync, webpack OOMs after a while of use, this seems to make it last much longer. An alternative is we can reboot.
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.
I wonder if we can do something about this, I'm like 99% sure it's source map generation in mms build that causes this. Maybe we can try switching it off on mms side, compass-web will also have source maps and presumably if you're running this script, that's the main source maps you care about
for (const arg of args) { | ||
if (validTargets.includes(arg as keyof typeof targets)) { | ||
// Switch to new target |
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.
Possibly overboard, I support passing arguments to each target but I also don't know of any use cases for that, just figured there probably are some.
child_process.execFileSync('pnpm', ['install'], { | ||
cwd: process.env.MMS_HOME, | ||
stdio: 'inherit', | ||
}); |
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.
Can we either make this skippable or make it ignore strict engine requirement in mms? I usually keep nodejs version on the same version as electron for compass and it rarely matches what mms has
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.
I made it skippable, I have tried to run MMS on different Node's before, if its working for you then that's great I've hit so many silly failures related to the strictness before 🤷🏻
child_process.execFileSync('pnpm', ['run', 'init'], { | ||
cwd: process.env.MMS_HOME, | ||
stdio: 'inherit', | ||
}); |
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.
You don't need init, it's doing the same thing that start will do right after
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.
Yea I always thought the output looks similar but pressing enter on the command in my terminal history was easier than looking into why 🤦🏻 lol thank you!
desktop: { enabled: false, args: [] as string[] }, | ||
sandbox: { enabled: false, args: [] as string[] }, |
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.
desktop and sandbox currently have ports in common, so you can't run then in parallel, you might want to adjust that
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.
just made sandbox something you have to run alone because of the way things are shared, I think desktop & sync are more likely to be used in parallel? at least by our team. But happy to dig deeper if you have a better idea of what needs to be changed.
Like I changed the compass-web dev server port but then something else is using that config because I get a port reuse error 🤔
|
||
const paddedName = targetName.padEnd(8); | ||
console.log(`start | ${spawnArgs[0]} ${spawnArgs[1].join(' ')}`); | ||
const subProcess = child_process.spawn(...spawnArgs); |
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.
You need to pipe stdin also. Desktop command in particular has support for extra commands to restart the process / pass extra args:
desktop | <i> [webpack-plugin-start-electron] Starting electron application
desktop | <i> [webpack-plugin-start-electron] - Ctrl+R to restart the main process
desktop | <i> [webpack-plugin-start-electron] - Ctrl+A to restart the main process with extra arguments
And none of it is working at the moment
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.
should be working now 🎉
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.
Pull Request Overview
This PR adds a new npm start
command that allows launching multiple Compass environments (desktop, sandbox, sync) in parallel to streamline testing across different platforms.
- New multi-process launcher script that can start desktop, sandbox, and sync environments together
- Enhanced sync script converted from JS to MJS with improved MMS dev server management
- Updated package.json configurations to support the new start command
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
File | Description |
---|---|
scripts/start.mts | New multi-process launcher script handling argument parsing and subprocess management |
scripts/start.md | Help documentation for the new start command |
packages/compass-web/scripts/sync-dist-to-mms.mjs | Converted sync script from JS to MJS with enhanced MMS server handling |
packages/compass-web/scripts/sync-dist-to-mms.js | Removed old JS version of sync script |
packages/compass-web/package.json | Updated sync command to use new MJS script |
packages/compass-web/.eslintrc.js | Added ESLint configuration for MJS files |
package.json | Updated root start command to use new launcher script |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Description
npm start++
There is now a script responsible for multi-process launching to enable and encourage mulitplatform testing of compass and DE changes.
npm start
will still launch compass as per usual.New Commands:
npm start desktop sync sandbox
Provide each one of the subcommands optionally to combine launching each environment to start testing changes in parallel.
Note that the sync command still requires use of a redirector / redwood extension in your browser.
Checklist
Motivation and Context
In the effort of DE and Compass unification hopefully this change will make verifying in both environements easy and commonplace to squash inconsistency early on in development.
Open Questions
Dependents
Types of changes