Skip to content

[WTF-2349]: Migrate widget-tools repo to pnpm#132

Merged
weirdwater merged 11 commits into
masterfrom
pnpm-workspaces
Aug 20, 2025
Merged

[WTF-2349]: Migrate widget-tools repo to pnpm#132
weirdwater merged 11 commits into
masterfrom
pnpm-workspaces

Conversation

@weirdwater

@weirdwater weirdwater commented Jul 22, 2025

Copy link
Copy Markdown
Collaborator

This PR contains

  • Bug fix
  • Feature
  • Refactor
  • Documentation
  • Other (describe)

What is the purpose of this PR?

Pnpm is an alternative package manager that has leaves a smaller footprint when installing dependencies. It also has great workspaces support which makes it easer to depend on other projects in the same monorepo as well as synchronizing dependencies between them. Another benefit is that other teams at Mendix use it to manage monorepos, so this move unifies our way of working.

Relevant changes

  • Lockfiles have been replaced
  • Top-level scripts have been moved to the packages level, minimizing risk of dependencies colliding due to nestedness.
  • Cheerio has been added to resolutions to allow enzyme tests to continue to function
  • CI scripts have been updated to use pnpm

What should be covered while testing?

  • CI actions continue to function as expected
  • Widgets continue to use the pwt unhindered

Comment thread .github/workflows/CreateGWRelease.yml Outdated
Comment thread package.json

@iobuhov iobuhov 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.

LGTM

Comment thread packages/pluggable-widgets-tools/CHANGELOG.md Outdated
Comment thread packages/pluggable-widgets-tools/package.json
@weirdwater
weirdwater enabled auto-merge August 7, 2025 11:24
@iobuhov

iobuhov commented Aug 19, 2025

Copy link
Copy Markdown
Contributor

Merge?

@weirdwater

Copy link
Copy Markdown
Collaborator Author

Waiting for a second team approval, but capacity has been low in the last two weeks

@mlaponder

mlaponder commented Aug 20, 2025

Copy link
Copy Markdown
Collaborator

QA: When running pnpm run build in my widget folder I get the following error:

[!] (plugin typescript) RollupError: @rollup/plugin-typescript TS2688: Cannot find type definition file for 'jest'.
  The file is in the program because:
    Entry point of type library 'jest' specified in compilerOptions

@weirdwater

Copy link
Copy Markdown
Collaborator Author

QA: When running pnpm run build in my widget folder I get the following error:

[!] (plugin typescript) RollupError: @rollup/plugin-typescript TS2688: Cannot find type definition file for 'jest'.
  The file is in the program because:
    Entry point of type library 'jest' specified in compilerOptions

Good catch, I only tested widgets with npm as my goal was to perform the migration without affecting consumers of the PWT. I was able to reproduce your issue with the latest version of the PWT on npm, so this is already the case for existing users using pnpm. To work around the error you must install @types/jest, @types/node, and @types/react as dependencies of the widget.

npx @mendix/generator-widget@latest widget
cd widget
rm -rf node_modules
pnpm install
pnpm build
# The build will fail at this point. 
#👇🏻 To fix it, install missing dependencies
pnpm add -D @types/jest @types/node @types/react
pnpm build # This will succeed

The root cause is the difference in strategy between npm and pnpm with respect to structuring the node_modules directory and linking dependencies. When installing the PWT with npm, the packages are installed directly to the node_modules directory, making them readily available to rollup. But pnpm structures the dependencies as a tree, isolating them from each other.

Considering this is the current behavior of the PWT I would like to proceed with this PR and suggest we address this annoyance in a future story.

@weirdwater
weirdwater merged commit d8cb6d0 into master Aug 20, 2025
7 checks passed
@weirdwater
weirdwater deleted the pnpm-workspaces branch August 20, 2025 14:45
weirdwater added a commit that referenced this pull request Aug 22, 2025
A few dependencies slipped through the cracks when migrating to pnpm:
#132
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants