Skip to content

Commit beec6ae

Browse files
authored
[WTF-2452] Fix transformation for require of external library with as output format (#157)
## Checklist - Contains unit tests ❌ - Contains breaking changes ❌ - Compatible with: MX 7️⃣, 8️⃣, 9️⃣ - Did you update version and changelog? ✅ - PR title properly formatted (`[XX-000]: description`)? ✅ ## This PR contains - [x] Bug fix - [ ] Feature - [ ] Refactor - [ ] Documentation - [ ] Other (describe) ## What is the purpose of this PR? Fix transformation by the commonjs plugin in case the output format is es and an external library is required. ## Relevant changes For React client `require` statements to external libraries need to be rewritten to an `import` statement. However as the externally libraries were marked as `ignore` in the commonjs plugin configuration those require statements were left untouched, causing the runtime error "require is not defined". This has been resolved by no longer marking external libraries as `ignored`. ## What should be covered while testing? Building widget which needs this transformation can be bundled and run without a custom rollup config. Examples are: [calendar-web](https://github.com/mendix/web-widgets/tree/1bf7b6306b72156851e831498549e92280234792/packages/pluggableWidgets/calendar-web) [color-picker-web](https://github.com/mendix/web-widgets/tree/1bf7b6306b72156851e831498549e92280234792/packages/pluggableWidgets/color-picker-web) [document-viewer-web](https://github.com/mendix/web-widgets/tree/1bf7b6306b72156851e831498549e92280234792/packages/pluggableWidgets/document-viewer-web)
2 parents 5b4e86c + b0dab5a commit beec6ae

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

packages/pluggable-widgets-tools/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66

77
## [Unreleased]
88

9+
### Changed
10+
11+
- We fixed an issue where `require` was not transformed to `import` for the `es` output format which could result in an error when the widget was used in a project with React client enabled.
12+
913
## [11.3.0] - 2025-11-12
1014

1115
### Changed

packages/pluggable-widgets-tools/configs/rollup.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ export default async args => {
133133
presets: [["@babel/preset-env", { targets: { safari: "12" } }]],
134134
allowAllFormats: true
135135
},
136-
external: webExternal,
136+
external: outputFormat === "es" ? [] : webExternal,
137137
licenses: production && outputFormat === "amd"
138138
})
139139
],

packages/pluggable-widgets-tools/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@mendix/pluggable-widgets-tools",
3-
"version": "11.3.0",
3+
"version": "11.3.1",
44
"description": "Mendix Pluggable Widgets Tools",
55
"engines": {
66
"node": ">=20"

0 commit comments

Comments
 (0)