Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

manifest plugins slows down build by 70 times #301

Open
mukeshsoni opened this issue Nov 6, 2023 · 1 comment
Open

manifest plugins slows down build by 70 times #301

mukeshsoni opened this issue Nov 6, 2023 · 1 comment

Comments

@mukeshsoni
Copy link

mukeshsoni commented Nov 6, 2023

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/'],
@nyngwang
Copy link

nyngwang commented Mar 1, 2024

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants