Skip to content

Commit d1973e5

Browse files
[WTF-2548]: Configure Babel for New JSX Transform (#170)
## This PR contains - [x] Bug fix - [ ] Feature - [ ] Refactor - [ ] Documentation - [ ] Other (describe) ## What is the purpose of this PR? The release of 11.6.0 introduced the new JSX transform for Typescript widgets, but failed to update the babel config for Javascript widgets. Resulting in Javascript widgets built with versions 11.6.0 and 11.8.0 to error out in runtime. ## Relevant changes Updates the babel config and other references to `createElement` to use the `react/jsx-runtime` instead. ## What should be covered while testing? - Javascript widgets function in runtime
2 parents 4c1971e + 5b17e5e commit d1973e5

File tree

8 files changed

+11
-19
lines changed

8 files changed

+11
-19
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+
### Fixed
10+
11+
- We fixed the bundling of Javascript widgets which broke in 11.6.0 after migrating to [React 17's JSX Transform](https://legacy.reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html#how-to-upgrade-to-the-new-jsx-transform). (Ticket 270777)
12+
913
## [11.8.0] - 2026-03-06
1014

1115
### Added

packages/pluggable-widgets-tools/configs/eslint.js.base.json

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,13 @@
77
},
88
"settings": {
99
"react": {
10-
"createClass": "createReactClass",
11-
"pragma": "createElement",
1210
"version": "detect"
1311
}
1412
},
1513
"extends": [
1614
"eslint:recommended",
1715
"plugin:react/recommended",
16+
"plugin:react/jsx-runtime",
1817
"prettier",
1918
"plugin:prettier/recommended",
2019
"plugin:react-hooks/recommended"
@@ -25,9 +24,6 @@
2524
"babelOptions": {
2625
"presets": ["@babel/preset-react"]
2726
},
28-
"ecmaFeatures": {
29-
"jsx": true
30-
},
3127
"ecmaVersion": 2018,
3228
"sourceType": "module"
3329
},
@@ -37,8 +33,6 @@
3733
"react/prop-types": "off",
3834
"react/no-deprecated": "warn",
3935
"react/jsx-uses-vars": "error",
40-
"react/jsx-uses-react": "off",
41-
"react/react-in-jsx-scope": "off",
4236

4337
"jest/no-disabled-tests": "warn",
4438
"jest/no-focused-tests": "error",

packages/pluggable-widgets-tools/configs/eslint.ts.base.json

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,20 @@
77
},
88
"settings": {
99
"react": {
10-
"createClass": "createReactClass",
11-
"pragma": "createElement",
1210
"version": "detect"
1311
}
1412
},
1513
"extends": [
1614
"eslint:recommended",
1715
"plugin:react/recommended",
16+
"plugin:react/jsx-runtime",
1817
"plugin:@typescript-eslint/recommended",
1918
"prettier",
2019
"plugin:prettier/recommended",
2120
"plugin:react-hooks/recommended"
2221
],
2322
"parser": "@typescript-eslint/parser",
2423
"parserOptions": {
25-
"ecmaFeatures": {
26-
"jsx": true
27-
},
2824
"project": "tsconfig.json",
2925
"ecmaVersion": 2018,
3026
"sourceType": "module"
@@ -81,8 +77,6 @@
8177
"react/jsx-boolean-value": ["error", "never"],
8278
"react/no-deprecated": "warn",
8379
"react/jsx-uses-vars": "error",
84-
"react/jsx-uses-react": "off",
85-
"react/react-in-jsx-scope": "off",
8680

8781
"array-callback-return": "error",
8882
"curly": "error",

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ export default async args => {
247247
},
248248
{
249249
exclude: /node_modules/,
250-
plugins: [["@babel/plugin-transform-react-jsx", { pragma: "createElement" }]]
250+
plugins: [["@babel/plugin-transform-react-jsx", { runtime: "automatic" }]]
251251
}
252252
]
253253
}),

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ export default async args => {
204204
},
205205
{
206206
exclude: /node_modules/,
207-
plugins: [["@babel/plugin-transform-react-jsx", { pragma: "createElement" }]]
207+
plugins: [["@babel/plugin-transform-react-jsx", { runtime: "automatic" }]]
208208
}
209209
]
210210
}),

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.8.0",
3+
"version": "11.8.1",
44
"description": "Mendix Pluggable Widgets Tools",
55
"engines": {
66
"node": ">=20"

packages/pluggable-widgets-tools/test-config/jest-svg-transformer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ module.exports = {
1212
.join('');
1313

1414
return {
15-
code: `
15+
code: `
1616
const React = require('react');
1717
function ${name}(props) {
1818
return React.createElement(

packages/pluggable-widgets-tools/test-config/transform.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ module.exports = require("babel-jest").createTransformer({
66
plugins: [
77
"@babel/plugin-transform-class-properties",
88
"@babel/plugin-transform-private-methods",
9-
["@babel/plugin-transform-react-jsx", { pragma: "createElement" }]
9+
["@babel/plugin-transform-react-jsx", { runtime: "automatic" }]
1010
]
1111
});

0 commit comments

Comments
 (0)