#Can I replace webpack with bun?

1 messages · Page 1 of 1 (latest)

austere cloud
#

Its mentioned that bun is faster than webpack, but I haven't been able to find any guides on how to replace webpack with bun IN AN EXISTING PROJECT

I have inherited a semi complicated project that uses webpack for dev and production, and both are importing a shared base file

It's so slow when I run it in the CI I wanna cry, and bun seems like a great solution, but I simply failed to try and recreate the webpack logic using bun

Is there some official guide that explains how to integrate bun into an existing project? Would it help if I pasted the webpack configs here?

Thanks

karmic vale
#

It's a totally new bundler with a different plugin API - Bun doesn't try to be Webpack-compatible

So the answer is "yes" but it would require a full migration

austere cloud
#

@karmic vale I'm down for a complete migration, but does bun support everything I need? I'll paste the web pack configs if that's relevant:

webpack.devserver.js:

const {merge} = require('webpack-merge');
const {BundleAnalyzerPlugin} = require('webpack-bundle-analyzer');
const FaviconsWebpackPlugin = require('favicons-webpack-plugin');
const {common} = require('./webpack.common');

const plugins = [new FaviconsWebpackPlugin('../src/assets/logo/favicon_red.png')];
if (process.env.ANALYZE) {
    console.log('Running BundleAnalyzerPlugin');
    plugins.push(new BundleAnalyzerPlugin());
}

module.exports = merge(common, {
    entry: ['./index.js'],
    mode: 'development',
    devtool: 'source-map',
    plugins,
});
#

I can't send the common config file for some reason, discord limits the char count

austere cloud
#

Bump, since I need to make the decision soon

paper birch
#

You’re using a very basic webpack config. Just make the switch

austere cloud
#

Note that There's the imported common config

paper birch
#

show the failure

#

whats your error

karmic vale
#

Most of these plugins don't have equivalents yet in Bun

#

and I'm guessing there are many more in common

austere cloud
karmic vale
#

We're not trying to be a drop-in replacement. Bun's bundler takes more cues from esbuild, and we're aiming to be compatible with all esbuild plugins

#

Webpack's plugin system has some systemic performance issues

#

But some sort of adapter isn't out of the question

#

But it's not a high priority