Skip to content

chore: added nx and updated scripts to use nx - #10274

Open
lizschwab wants to merge 2 commits into
RaspberryPiFoundation:mainfrom
lizschwab:10233
Open

chore: added nx and updated scripts to use nx#10274
lizschwab wants to merge 2 commits into
RaspberryPiFoundation:mainfrom
lizschwab:10233

Conversation

@lizschwab

Copy link
Copy Markdown
Contributor

The basics

The details

Resolves

Fixes 10233

Proposed Changes

  • Adds Nx to the monorepo
  • updates build and test scripts at the root to use nx to allow for paralell build and test
  • adds a clean script to the root
  • splits build out into 3 separate scripts, defaulting to building everything but docs (we do not need to build docs for publish)
  • leverages Nx to automate the steps needed to build/start/test in blockly and dev-tools
  • adds a newbuild:advanced script to blockly that launches the advanced playground from dev-tools while watching for changes to blockly (in the future we plan to move this back into the playground as a link the way it used to be)

Reason for Changes

  • allows for paralell test and build runs
  • removes unneeded docs build from publish workflow
  • makes starting and building packages easier

@lizschwab
lizschwab requested a review from a team as a code owner August 14, 2026 23:55
@lizschwab
lizschwab requested a review from maribethb August 14, 2026 23:55
@github-actions github-actions Bot added the PR: chore General chores (dependencies, typos, etc) label Aug 14, 2026
const json = JSON.parse(JSON.stringify(getPackageJson()));
// Remove unwanted entries.
delete json['scripts'];
delete json['nx'];

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Probably not necessary, but I figured if we're removing scripts from the /dist copy, we should remove nx, too.

"directory": "dist"
},
"nx": {
"implicitDependencies": ["!@blockly/block-test"],

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This prevents the circular dependency with block-test from preventing nx from determining build order. We don't need it for build, just test.

"package": "gulp pack",
"prepareDemos": "gulp prepareDemos",
"start": "npm run build && concurrently -n tsc,server \"tsc --watch --preserveWatchOutput --outDir \"build/src\" --declarationDir \"build/declarations\"\" \"http-server ./ -s -o /tests/playground.html -c-1\"",
"start:advanced": "npm run package && npx nx run @blockly/dev-tools:build && npm run start --workspace=@blockly/dev-tools && npx nx watch --projects=@blockly/dev-tools --includeDependencies -- nx run-many -t build -p \\$NX_PROJECT_NAME --exclude=@blockly/dev-tools",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We'll revisit adding this back in as a link on the regular playground later.

Comment thread package.json
},
"scripts": {
"test": "npm run test --ws --if-present",
"test": "npx nx run-many -t test --exclude=blockly && npx nx run blockly:test",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

If we run blockly tests in paralell with other tests, they fail to find targets. I'm guessing this has to do with the gulp tasks as it's when it's running the gulp tasks prior to launching the browser that these errors happen. For now, we can run everything else in paralell and run blockly tests by themselves. In the future we can look at how to run these all in paralell.

Default for nx is to run 3 processes in paralell. We can adjust that if we want but I figure start with the default and see how CI runners handle that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: chore General chores (dependencies, typos, etc)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Configure Nx

2 participants