S
S
szQocks2021-11-01 18:04:25
React
szQocks, 2021-11-01 18:04:25

Why does babel compile React in 25k+ lines of code?

If I compile regular js, then everything is ok, a few lines of code and everything compiles as it should, but when I start compiling react - in general, the simplest component with a hello word line, the output is 30k lines of code. My question is, is this how it should be? Or what to do about it?

// webpack.config.js

const path = require('path');
const miniCssExtractPlugin = require('mini-css-extract-plugin');

module.exports = {
    mode: 'development',// production / development
    entry: {
        index: "./src/index.js"
    },
    output: {
        filename: "[name].bundle.js",
        path: path.resolve(__dirname, 'public'),
        clean: true,
    },
    module: {
        rules: [
            {
                test: /\.(js|jsx)$/,
                exclude: /node_modules/,
                use: {
                    loader: "babel-loader"
                }
            },
            {
                test: /\.s?css$/i,
                use: [miniCssExtractPlugin.loader, "css-loader", "sass-loader", "postcss-loader"]
            }
        ]
    },
    resolve: {
        extensions: ['.js', '.jsx'],
    },
    plugins: [new miniCssExtractPlugin()],

    devtool: 'source-map',
}


// babel.config.js
module.exports = {
    presets: ["@babel/preset-env", "@babel/preset-react"]
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Aetae, 2021-11-01
@szQocks

Naturally compiles everything that is needed for react from node_modules.
And how else will the react work, without the react itself?)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question