Skip to content

Commit

Permalink
Fixes #37819 - Remove @theforeman/builder usage
Browse files Browse the repository at this point in the history
  • Loading branch information
MariaAga committed Sep 17, 2024
1 parent 1a5c1b9 commit 370d14e
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 12 deletions.
6 changes: 5 additions & 1 deletion .babelrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
const path = require('path');
const babelPresets = path.resolve(__dirname, 'webpack','babel', 'presets.js');
console.log('babelPresets', babelPresets);

module.exports = {
presets: ['@theforeman/builder/babel'],
presets: require(babelPresets),
};
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"checkbox",
"clearbutton",
"clearfix",
"commonjs",
"comms",
"consts",
"cpu",
Expand Down
17 changes: 8 additions & 9 deletions config/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const { ModuleFederationPlugin } = require('webpack').container;
var pluginUtils = require('../script/plugin_webpack_directories');
var { generateExportsFile }= require('../webpack/assets/javascripts/exportAll');
var CompressionPlugin = require('compression-webpack-plugin');
const root = path.resolve(__dirname, '..');

class AddRuntimeRequirement {
// to avoid "webpackRequire.l is not a function" error
Expand All @@ -32,7 +33,7 @@ class AddRuntimeRequirement {
}

const supportedLocales = () => {
const localeDir = path.join(__dirname, '..', 'locale');
const localeDir = path.resolve(root, 'locale');

// Find all files in ./locale/*
const localesFiles = fs.readdirSync(localeDir);
Expand Down Expand Up @@ -86,7 +87,7 @@ const commonConfig = function() {
},
},
resolveLoader: {
modules: [path.resolve(__dirname, '..', 'node_modules')],
modules: [path.resolve(root, 'node_modules')],
},
module: {
rules: [
Expand All @@ -97,7 +98,7 @@ const commonConfig = function() {
exclude: /node_modules(?!\/(@novnc|unidiff))/,
loader: 'babel-loader',
options: {
presets: [require.resolve('@theforeman/builder/babel')],
presets: [require.resolve('../webpack/babel')],
},
},
{
Expand Down Expand Up @@ -152,7 +153,7 @@ const coreConfig = function() {
'..',
'webpack/assets/javascripts/bundle.js'
);
config.context = path.resolve(__dirname, '..');
config.context = root;
if (config.mode == 'production') {
var chunkFilename = '[name]-[chunkhash].js'
} else {
Expand All @@ -162,14 +163,12 @@ const coreConfig = function() {
config.entry = {
bundle: { import: bundleEntry, dependOn: ['vendor', 'reactExports'] },
vendor: vendorEntry,
reactExports: path.join(
__dirname,
'..',
reactExports: path.resolve(root,
'webpack/assets/javascripts/all_react_app_exports.js'
),
};
config.output = {
path: path.join(__dirname, '..', 'public', 'webpack'),
path: path.resolve(root, 'public', 'webpack'),
publicPath: '/webpack/',
library: {
name: ['TheForeman', '[name]'],
Expand Down Expand Up @@ -262,7 +261,7 @@ const pluginConfig = function(plugin) {
};
var configModules = config.resolve.modules || [];
// make webpack to resolve modules from core first
configModules.unshift(path.resolve(__dirname, '..', 'node_modules'));
configModules.unshift(path.resolve(root, 'node_modules'));
// add plugin's node_modules to the reslver list
configModules.push(path.resolve(pluginRoot, 'node_modules'));
configModules.push('node_modules/');
Expand Down
13 changes: 11 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
4 changes: 4 additions & 0 deletions webpack/babel/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
const presets = require('./presets');
const plugins = require('./plugins');

module.exports = () => ({ presets, plugins });
8 changes: 8 additions & 0 deletions webpack/babel/plugins.js
Original file line number Diff line number Diff line change
@@ -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'),
];
6 changes: 6 additions & 0 deletions webpack/babel/presets.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const presets = [
[require.resolve('@babel/preset-env'), { modules: 'commonjs' }],
require.resolve('@babel/preset-react'),
];

module.exports = presets;

0 comments on commit 370d14e

Please sign in to comment.