Skip to content

build(pnpm): migrate to pnpm#1933

Draft
spliffone wants to merge 2 commits into
mainfrom
build/migrate-to-pnpm
Draft

build(pnpm): migrate to pnpm#1933
spliffone wants to merge 2 commits into
mainfrom
build/migrate-to-pnpm

Conversation

@spliffone

@spliffone spliffone commented Apr 22, 2026

Copy link
Copy Markdown
Member

See #1900

PNPM NPM
node_modules structure Non-flat by default — only direct dependencies appear in the root of node_modules. Transitive deps are stored under .pnpm/ and symlinked. Flat/hoisted — all packages (including transitive deps) are hoisted to the root of node_modules.
Storage model Uses a global content-addressable store. Files are hard-linked into node_modules — only one physical copy per version across all projects. Only changed files are added when upgrading a dependency. Copies every package into each project's node_modules.
Isolated node_modules Yes (default) Yes (install linked)
Ships with Node.js No Yes
Workspace support Yes Yes
Managing Node.js versions Yes (pnpm env) No
Catalogs (shared dep versions) Yes (catalogs) No
Auto-install before script run Yes (ensure node_modules are in sync with lock file) No
Supported JSR registry Yes (npm-compatibility) No
Postinstall allow list Yes (Config dependencies) No
Lock file stability Stable between feature version Unstable
Branch specific log file Yes (Git branch lockfiles) No
Installation hooks Yes (.pnpmfile.mjs) No
  • PNPM is consistently faster than NPM (see PNPM Benchmark results)
  • ng serve (vite) require a flat node_modules to run the dev server which require adjustments in the PNPM configuration to hoist dependencies
  • The generated tarballUrl in the lock file are incorrectly for code.siemens.com

Challenges:

  • Installation of code.siemens packages require the tarBallUrl

Documentation.
Examples.
Dashboards Demo.
Playwright report.

Coverage Reports:

Code Coverage

@spliffone spliffone requested review from a team as code owners April 22, 2026 13:51

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request migrates the project from npm to pnpm as the primary package manager. The changes include updating the release configuration, documentation, and all package scripts to use pnpm commands. Additionally, a new pnpm-workspace.yaml file has been introduced, and the package.json has been updated with pnpm-specific engine requirements and dependency overrides. One review comment suggests using the $typescript variable in the pnpm overrides to ensure the TypeScript version remains synchronized with devDependencies.

Comment thread package.json Outdated

@spike-rabbit spike-rabbit left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think we also must use the pnpm semantic-elease plugin. If not npm will install a bunch of things when releasing.
With that:

  • you can use alias in the peer dependencies to workspace deps
  • I hope it works with the dist packages as well somehow... may needs scripting

Comment thread package.json Outdated
@spliffone spliffone force-pushed the build/migrate-to-pnpm branch 7 times, most recently from 81ca237 to 44ade0a Compare April 23, 2026 04:54
@chintankavathia

Copy link
Copy Markdown
Member

I remember we discussed about using pnpm in past and one of the reason for not switching was:
So far most of the consumer projects are using yarn and npm. Since npm has the most problems with the dependency management we tend to stay on npm. Since we discover this problem earlier.

What exactly got changed now?

@spliffone

spliffone commented Apr 23, 2026

Copy link
Copy Markdown
Member Author

I remember we discussed about using pnpm in past and one of the reason for not switching was: So far most of the consumer projects are using yarn and npm. Since npm has the most problems with the dependency management we tend to stay on npm. Since we discover this problem earlier.

What exactly got changed now?

@chintankavathia yes most of our consumer still use yarn or npm while almost all dependency issues are in npm environments. This PR is just an consideration to solve the frequent issue we have with the package-lock.json updates (see also #1914). Just two things:

  • with npm we might figure out dependency issues with siemens lint, but since we have a mono-repo workspace I don't believe we find issues related to element.
  • I thought the decision to use npm was driven by the semantic-release support

So let's discuss it in the core-meeting what is the right approach.

@spliffone spliffone added the core-team-discussion Topics that should be discussed in the core team meeting label Apr 23, 2026
Comment thread package.json Outdated
Comment on lines +161 to +164
"prismjs": "1.30.0",
"qrcode-generator": "2.0.4",
"react": "19.2.5",
"react-dom": "19.2.5",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

please confirm here: is this really needed to move live-preview dependencies here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We have two options:

  1. we add them to the root package so they are automatically node_modules top level dependencies
  2. we add add them to the specific dependencies to hoist patterns so the are add to node_modules top level dependencies

@spike-rabbit spike-rabbit left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

To provide some more details regarding releasing:

In pnpm workspaces one can declare (peer)dependencies using the workspace: syntax.
With that I hope we can eliminate the use of custom updating the peer dependencies.

The only problem is, that I don't know how this behaves with releasing from a dist directory, so when the actual workspace package is not the target.

@spliffone spliffone force-pushed the build/migrate-to-pnpm branch from 44ade0a to 2dc8e2a Compare April 28, 2026 06:38
@spliffone spliffone requested a review from ljanner as a code owner April 28, 2026 10:47
@kfenner

kfenner commented Apr 28, 2026

Copy link
Copy Markdown
Member

@spliffone @spike-rabbit 3 hours ago, new pnpm major release v11: https://github.com/pnpm/pnpm/releases/tag/v11.0.0

Thanks to @pwuersch

@pwuersch pwuersch left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hey guys, chiming in here because @kfenner was asking for some feedback from users that have used pnpm before.

pnpm has sped up our local installs quite a bit since we migrated away from Yarn already three years ago. Probably NPM has become more competitive over the years. The headlining reasons to use pnpm are quite convincing:

  • Shared package store, which is faster and more efficient,
  • Allow-listing of dependencies that are allowed to execute package lifecycle scripts -> mitigates almost every recent supply-chain attack we've seen, as the compromised package must be in the allowed dependencies to cause damage.

While this is already great, the real benefit in working with projects that use pnpm is the developer experience:

  • Unmet peerDependencies are printed in an actually useful way,
  • It still adheres to most of the vanilla npm configuration (e.g., overriding registry URLs and other settings via .npmrc),
  • Very nice integration in mise-en-place or corepack, whichever you prefer,
  • Amazing lockfiles with diffs you can actually read.

All in all, I enjoy working with pnpm and it's become my default choice for a package manager when using Node.js.

Comment thread .github/workflows/build-and-test.yaml Outdated
- run: npm ci --prefer-offline --no-audit --include=optional
- run: npx playwright test --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
- run: pnpm install --frozen-lockfile
- run: pnpm exec playwright test --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit: the exec here is technically not required (but can add some clarity I guess): https://pnpm.io/cli/exec#examples

Comment thread package.json Outdated
@spliffone spliffone force-pushed the build/migrate-to-pnpm branch 4 times, most recently from 41131b6 to e98d9fb Compare April 28, 2026 16:52
@spliffone spliffone marked this pull request as draft April 28, 2026 17:43
@spliffone spliffone force-pushed the build/migrate-to-pnpm branch 2 times, most recently from 2cd4908 to 3c125f9 Compare April 28, 2026 19:10
@spliffone

Copy link
Copy Markdown
Member Author

@spliffone @spike-rabbit 3 hours ago, new pnpm major release v11: https://github.com/pnpm/pnpm/releases/tag/v11.0.0

Thanks to @pwuersch

Sadly pnpm 11 handles optionalDependencies differently and I wasn't able to link the brand dependency in the root node_modules folder which means the prepare brand script is always failing and the pipeline never succeed. So I guess we should go with version 10 at the moment.

@spliffone spliffone force-pushed the build/migrate-to-pnpm branch from 3c125f9 to 040c1e6 Compare April 28, 2026 21:06
@kfenner

kfenner commented Apr 29, 2026

Copy link
Copy Markdown
Member

@spliffone @spike-rabbit 3 hours ago, new pnpm major release v11: https://github.com/pnpm/pnpm/releases/tag/v11.0.0
Thanks to @pwuersch

Sadly pnpm 11 handles optionalDependencies differently and I wasn't able to link the brand dependency in the root node_modules folder which means the prepare brand script is always failing and the pipeline never succeed. So I guess we should go with version 10 at the moment.

Hmm, is this a good sign?

@pwuersch

Copy link
Copy Markdown
Member

@spliffone @spike-rabbit 3 hours ago, new pnpm major release v11: pnpm/pnpm@v11.0.0 (release)
Thanks to @pwuersch

Sadly pnpm 11 handles optionalDependencies differently and I wasn't able to link the brand dependency in the root node_modules folder which means the prepare brand script is always failing and the pipeline never succeed. So I guess we should go with version 10 at the moment.

@spliffone locally, with a normal pnpm install using pnpm v11.0.0 I have the following file structure:

node_modules/@simpl
├── brand
└── docs-composer

Also the prepare-brand script succeeds when running pnpm prepare-brand. Did you change something in the meantime, or am I missing something?

@spliffone

Copy link
Copy Markdown
Member Author

@spliffone @spike-rabbit 3 hours ago, new pnpm major release v11: pnpm/pnpm@v11.0.0 (release)
Thanks to @pwuersch

Sadly pnpm 11 handles optionalDependencies differently and I wasn't able to link the brand dependency in the root node_modules folder which means the prepare brand script is always failing and the pipeline never succeed. So I guess we should go with version 10 at the moment.

@spliffone locally, with a normal pnpm install using pnpm v11.0.0 I have the following file structure:

node_modules/@simpl
├── brand
└── docs-composer

Also the prepare-brand script succeeds when running pnpm prepare-brand. Did you change something in the meantime, or am I missing something?

Yes, I started the migration again and dropped a few settings. Now it seems to work

@spliffone spliffone force-pushed the build/migrate-to-pnpm branch 12 times, most recently from c9e05c9 to 54fb13e Compare May 4, 2026 18:33
- use pnpm/action-setup from v6
- add missing schematics devDependencies for CI build
- use host-level auth token for all code.siemens.com registries
- use semantic-release-pnpm plugin
@spliffone spliffone force-pushed the build/migrate-to-pnpm branch from b1c2300 to c1c4479 Compare May 5, 2026 08:54
@spliffone spliffone force-pushed the build/migrate-to-pnpm branch from 1f41493 to 21a9b91 Compare May 5, 2026 11:10
@spliffone

spliffone commented May 7, 2026

Copy link
Copy Markdown
Member Author

See #1900

Summary:

(+) way more powefull than npm
(+) more security
(+) releasing is less complex: no postversion
(+) stable lockfile
(+) no -- args passing
(+) better diffing because yaml lockfile

(-) more configuraiton
(-) needs to be installed
(-) tarball (requires config)

Vote:

👍 We want PNPM as the new package manager
👎 Stick to the pain we know for all the NPM lovers
 

@siemens/siemens-element-members Please share your voice on the package manager topic!

@kfenner

kfenner commented May 13, 2026

Copy link
Copy Markdown
Member

See #1900

Summary:

(+) way more powefull than npm (+) more security (+) releasing is less complex: no postversion (+) stable lockfile (+) no -- args passing (+) better diffing because yaml lockfile

(-) more configuraiton (-) needs to be installed (-) tarball (requires config)

Vote:

👍 We want PNPM as the new package manager 👎 Stick to the pain we know for all the NPM lovers  

@siemens/siemens-element-members Please share your voice on the package manager topic!

@spliffone I would say the voting is complete and the majority is positive about switching to pnpm. Should we do this migration for Element v50 so we stick to npm here on the main branch until we start merging stuff for v50 and v49.x also stays on npm, OK?

@kfenner kfenner removed the core-team-discussion Topics that should be discussed in the core team meeting label May 18, 2026
@spliffone spliffone added this to the 51.0.0 milestone Jun 10, 2026
@kfenner kfenner modified the milestones: 52.0.0, 50.0.0 Jun 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants