From ca27926cb9a3d22f1164cd740b01f6a391d4ebd6 Mon Sep 17 00:00:00 2001 From: MariaAga Date: Fri, 13 Sep 2024 12:50:32 +0100 Subject: [PATCH] Fixes #37819 - Remove @theforeman/builder usage --- .babelrc.js | 2 +- .eslintrc | 1 + config/webpack.config.js | 2 +- package.json | 13 +++++++++++-- webpack/babel/index.js | 4 ++++ webpack/babel/plugins.js | 8 ++++++++ webpack/babel/presets.js | 6 ++++++ 7 files changed, 32 insertions(+), 4 deletions(-) create mode 100644 webpack/babel/index.js create mode 100644 webpack/babel/plugins.js create mode 100644 webpack/babel/presets.js diff --git a/.babelrc.js b/.babelrc.js index 45cb3784f7a..8c83e520c33 100644 --- a/.babelrc.js +++ b/.babelrc.js @@ -1,3 +1,3 @@ module.exports = { - presets: ['@theforeman/builder/babel'], + presets: ['./webpack/babel'], }; diff --git a/.eslintrc b/.eslintrc index 0de7f9bd00b..c9f63639c21 100644 --- a/.eslintrc +++ b/.eslintrc @@ -33,6 +33,7 @@ "checkbox", "clearbutton", "clearfix", + "commonjs", "comms", "consts", "cpu", diff --git a/config/webpack.config.js b/config/webpack.config.js index 17c8186432e..899bc63cf76 100644 --- a/config/webpack.config.js +++ b/config/webpack.config.js @@ -97,7 +97,7 @@ const commonConfig = function() { exclude: /node_modules(?!\/(@novnc|unidiff))/, loader: 'babel-loader', options: { - presets: [require.resolve('@theforeman/builder/babel')], + presets: [require.resolve('../webpack/babel')], }, }, { diff --git a/package.json b/package.json index 7ae5676471f..9439085665b 100644 --- a/package.json +++ b/package.json @@ -29,8 +29,16 @@ "react-intl": "^2.8.0" }, "devDependencies": { - "@babel/core": "^7.7.0", - "@theforeman/builder": "^13.1.0", + "@babel/core": "~7.25.2", + "@babel/plugin-proposal-class-properties": "7.16.7", + "@babel/plugin-proposal-object-rest-spread": "7.16.7", + "@babel/plugin-syntax-dynamic-import": "^7.2.0", + "@babel/plugin-transform-modules-amd": "7.9.0", + "@babel/plugin-transform-modules-commonjs": "7.9.0", + "@babel/plugin-transform-modules-systemjs": "7.9.0", + "@babel/plugin-transform-object-assign": "^7.2.0", + "@babel/preset-env": "7.9.5", + "@babel/preset-react": "7.16.7", "@theforeman/eslint-plugin-foreman": "^13.1.0", "@theforeman/eslint-plugin-rules": "^13.1.0", "@theforeman/test": "^13.1.0", @@ -39,6 +47,7 @@ "argv-parse": "^1.0.1", "babel-eslint": "^10.0.0", "babel-loader": "^8.0.0", + "babel-plugin-dynamic-import-node": "2.3.0", "buffer": "^5.7.1", "compression-webpack-plugin": "^10.0.0", "cross-env": "^5.2.0", diff --git a/webpack/babel/index.js b/webpack/babel/index.js new file mode 100644 index 00000000000..75b89e8cf2b --- /dev/null +++ b/webpack/babel/index.js @@ -0,0 +1,4 @@ +const presets = require('./presets'); +const plugins = require('./plugins'); + +module.exports = () => ({ presets, plugins }); diff --git a/webpack/babel/plugins.js b/webpack/babel/plugins.js new file mode 100644 index 00000000000..810ffb498eb --- /dev/null +++ b/webpack/babel/plugins.js @@ -0,0 +1,8 @@ +module.exports = [ + require.resolve('@babel/plugin-proposal-class-properties'), + require.resolve('@babel/plugin-proposal-object-rest-spread'), + require.resolve('@babel/plugin-proposal-optional-chaining'), + require.resolve('@babel/plugin-transform-object-assign'), + require.resolve('@babel/plugin-syntax-dynamic-import'), + require.resolve('@babel/plugin-syntax-optional-chaining'), +]; diff --git a/webpack/babel/presets.js b/webpack/babel/presets.js new file mode 100644 index 00000000000..faeef37778d --- /dev/null +++ b/webpack/babel/presets.js @@ -0,0 +1,6 @@ +const presets = [ + [require.resolve('@babel/preset-env'), { modules: 'commonjs' }], + require.resolve('@babel/preset-react'), +]; + +module.exports = presets;