Repository navigation
Conversation
r0b1n
force-pushed
the
feat/shared-mobx-bundle
branch
from
November 12, 2026 09:13
d81e27b to
c61ad9f
Compare
Add withSharedLibs to @mendix/rollup-web-widgets. It builds mobx and mobx-react-lite as standalone AMD/ESM bundles at a versioned path (com/mendix/shared/<lib>/<version>/) inside each MPK and points the widget bundles at them instead of inlining a copy. Widgets with the same library version ship identical files at the same path, so they collapse into one copy when deployed together; different versions sit side by side instead of overwriting each other. Use it in the Data Widgets widgets, file-uploader, image-cropper, date-time-picker and maps.
r0b1n
force-pushed
the
feat/shared-mobx-bundle
branch
2 times, most recently
from
November 17, 2026 09:31
ac2ec62 to
cc23c18
Compare
r0b1n
marked this pull request as ready for review
November 17, 2026 09:40
This comment has been minimized.
This comment has been minimized.
Contributor
AI Code Review
What was reviewed
Skipped (out of scope): CI: pending: Run code quality check, Plan E2E matrix, sigridci · unrelated failures: security/snyk (external scanner, 17 tests; the code and license Snyk checks pass) Questions
Positives
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull request type
Dependency changes (any modification to dependencies in
package.json)Description
Every widget that uses mobx inlines its own copy (~57 KB per widget). A page with a grid, three filters, sorting, gallery and selection helper downloads it 7 times.
This adds
withSharedLibsto@mendix/rollup-web-widgets. The helper builds mobx and mobx-react-lite once, as standalone bundles. The charts already share Plotly the same way (com/mendix/shared/charts/), and the same mechanism has run in Studio Pro since Mendix 9.6. The lowest minimum version among the migrated widgets is 9.17.Migrated: datagrid, the 4 datagrid filters, dropdown-sort, gallery, selection-helper, file-uploader, image-cropper, date-time-picker, maps. Not migrated yet: charts / custom-chart.
How it works
editorPreviewandeditorConfigkeep bundling mobx.@mendix/rollup-web-widgetsdepends on. The build fails if a widget resolves a different version.__mx_isolated_mobxGlobals) makes old inlined copies and the shared copy use the same global state.Usage:
Only stable third-party libraries used by many widgets should be shared, not
@mendix/widget-plugin-*. To share another library, add it toLIBRARIESinsharedLibs.mjsand as a dependency of@mendix/rollup-web-widgets.datagrid-web/rollup.config.jsis renamed to.mjsso it can import the helper.Licensing
A widget's own
dependencies.jsonno longer lists mobx, the same way it never listed React. Each shared library gets its owndependencies.{json,txt}instead.SBOM_Generator.jarreads everydependencies.jsonin the MPK. On file-uploader it reports the same 16 components onmainand on this branch, mobx and mobx-react-lite included.Results (production, uncompressed ESM)
Grid + 3 filters + sort + gallery + selection helper: 851 KB → 516 KB, including the shared files (~63 KB, loaded once). Each MPK now carries the shared files (~37 KB zipped).
Verified
node --test, run by CI) forwithSharedLibs: import paths for a normal and a moved (maps-web) output, mobx-react-lite → mobx, existing externals preserved, the version-mismatch error, and invalid library lists.observerre-renders.What should be covered while testing?
pnpm startwithMX_PROJECT_PATH.