Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion config/babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,20 @@
*/
const path = require('path');

// Check if JSX transform is able
const hasJsxRuntime = (() => {
if (process.env.DISABLE_NEW_JSX_TRANSFORM === 'true') {
return false;
}

try {
require.resolve('react/jsx-runtime');
return true;
} catch (e) {
return false;
}
})();

module.exports = function (api) {
const env = process.env.BABEL_ENV || process.env.NODE_ENV;
const es5Standalone = process.env.ES5 && process.env.ES5 !== 'false';
Expand Down Expand Up @@ -47,7 +61,7 @@ module.exports = function (api) {
development: env !== 'production' && !es5Standalone,
// Will use the native built-in instead of trying to polyfill
// behavior for any plugins that require one.
useBuiltIns: true
...(!hasJsxRuntime ? {useBuiltIns: true} : {runtime: 'automatic'})
}
],
['@babel/preset-typescript']
Expand Down
22 changes: 21 additions & 1 deletion config/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,20 @@ module.exports = function (env) {
// Sets the browserslist default fallback set of browsers to the Enact default browser support list.
app.setEnactTargetsAsDefault();

// Check if JSX transform is able
const hasJsxRuntime = (() => {
if (process.env.DISABLE_NEW_JSX_TRANSFORM === 'true') {
return false;
}

try {
require.resolve('react/jsx-runtime');
return true;
} catch (e) {
return false;
}
})();

// Check if TypeScript is setup
const useTypeScript = fs.existsSync('tsconfig.json');

Expand Down Expand Up @@ -463,7 +477,13 @@ module.exports = function (env) {
resolvePluginsRelativeTo: __dirname,
// @remove-on-eject-begin
baseConfig: {
extends: [require.resolve('eslint-config-enact')]
extends: [require.resolve('eslint-config-enact')],
rules: {
...(!hasJsxRuntime && {
'react/jsx-uses-react': 'warn',
'react/react-in-jsx-scope': 'warn'
})
}
},
useEslintrc: false,
// @remove-on-eject-end
Expand Down