webpack-manifest-plugin icon indicating copy to clipboard operation
webpack-manifest-plugin copied to clipboard

manifest plugins slows down build by 70 times

Open mukeshsoni opened this issue 2 years ago • 1 comments

I am trying to use rspack-manifest-plugin as a replace for webpackmanifestplugin. Using rspack-manifest-plugin slows down our build from 5 seconds to 350 seconds. A whopping 70 times.

I will not be able to share a reproducible repo since the code is private. I can share some part of the rspack config file -

const path = require('path')
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin')
const manifestPlugin = require('rspack-manifest-plugin').WebpackManifestPlugin
require('dotenv').config()

module.exports = function (env, argv) {
    const isProduction = argv.mode === 'production'
    var baseSrcPath = '.'
    const targetDir = '/path/to/target/directory'
    const sourceMapDir = 'sourcemaps'

    var plugins = [
        new manifestPlugin({
            writeToFileEmit: true,
        }),
        new ForkTsCheckerWebpackPlugin({
            typescript: {
                memoryLimit: 3096,
            },
        }),
    ]

    return {
        entry: {
            main: '/path/to/entry/file',
        },
        output: {
            pathinfo: isProduction,
            path: path.resolve(targetDir),
            publicPath: '/path/to/public/directory/',
            filename: '[name].[contenthash].js',
            sourceMapFilename: `${sourceMapDir}/[name].[contenthash].js.map`,
            chunkFilename: '[name].[contenthash].js',
        },
        resolve: {
            fallback: {
                net: false,
                fs: false,
                path: false,
                zlib: false,
                tls: false,
                http: false,
                https: false,
                url: false,
            },
            modules: [path.join(__dirname, '/src'), 'node_modules', 'src/pp/core/less/'],
            extensions: ['.js', '.jsx', '.ts', '.tsx', '.less'],
            alias: {
                // Some path aliases here
            },
        },
        mode: argv.mode || 'development',
        builtins: {
            presetEnv: {
                targets: ['Chrome >= 48'],
            },
        },
        module: {
            rules: [
                {
                    test: /\.mjs$/,
                    include: /node_modules/,
                    type: 'javascript/auto',
                    resolve: {
                        fullySpecified: false,
                    },
                },
                {
                    test: /\.less$/,
                    use: [
                        {
                            loader: 'style-loader',
                        },
                        {
                            loader: 'css-loader',
                            options: {
                                url: false,
                            },
                        },
                        {
                            loader: 'less-loader',
                            options: {
                                lessOptions: {
                                    url: false,
                                    javascriptEnabled: true,
                                    module: true,
                                },
                            },
                        },
                    ],
                },
                {
                    test: /\.(png|jpe?g|gif)$/i,
                    type: 'asset/resource',
                },
                {
                    test: /backbone\.js$/,
                    use: {
                        loader: 'imports-loader',
                        options: {
                            additionalCode: 'var define = false; /* Disable AMD for misbehaving libraries */',
                        },
                    },
                },
            ],
        },
        plugins,
    }
}

This is stopping us from moving from webpack to rspack. The manifest file generation is a must for us since we use that with our python backend to inject the right js bundle name into our html. The webpack build takes around ~37 seconds now. So rspack's build time of 5 seconds is a great win for us. But with the manifest file generation, it jumps to 350 seconds. And the incremental build times are also around 14-15 seconds. Let me know if i can help with any other information.

I tried to comment some parts of the code from the config file and find the bottleneck and i saw that this line in the config adds the most delay

            modules: [path.join(__dirname, '/src'), 'node_modules', 'src/pp/core/less/'],

mukeshsoni avatar Nov 06 '23 04:11 mukeshsoni

Can you update your title first? It read very unprofessional. At first glance, I thought you were trying to blame this plugin for being slow.

On the other hand, if it's rspack-manifest-plugin that makes your workflow slow down, then why did you post it here? How do I make a fix in this repo to fix a problem on the other repo that you no longer use? Can you think about these questions yourself before posting?

nyngwang avatar Mar 01 '24 20:03 nyngwang