Disable batching of javascript files

We are using webpack to package Typescript files. The problem is the Bitbucket server is repackaging them (as bundle.js) and we are loosing the source maps.

I know there was a way to disable this, so the bitbucket server just serves the unaltered javascript.

Does anybody know how?

You can disable batching by adding the following to your pom.xml:

             ...
            <plugin>
                <groupId>com.atlassian.maven.plugins</groupId>
                <artifactId>bitbucket-maven-plugin</artifactId>
                ...
                <configuration>
                    ...
                    <compressResources>false</compressResources>
                    ...
                </configuration>
                ...
            </plugin>
             ...

Please make sure to also check out the Webpack plugin from atlassian: atlassian-webresource-webpack-plugin - npm

1 Like

Hi @MihaiVoicescu,

The compressResources would only disable compression but not batching, which is a good idea if you create and minify your bundles using webpack and webpack WRM plugin. If your bundle is already compressed, then the compressResources is actually doing an extra job that is not needed.

However, I wouldn’t recommend disabling the batching in the production environment. This would slow down downloading the assets.

More information about the compressResources can be found here: https://developer.atlassian.com/server/framework/atlassian-sdk/amps-build-configuration-reference/#compressresources

As for the problem with sourcemaps it’s a known issue. The Web-Resource Manager (WRM) can’t combine the sourcemaps created by webpack. We have an open ticket for that: https://ecosystem.atlassian.net/browse/PLUGWEB-447

Usually, when I need to debug the code in the developrment environment I create a bundle without minification. Example:

// webpack.config.js
const SKIP_MINIMIZE = process.env.SKIP_MINIMIZE === 'true';

const minimizeBundle = !SKIP_MINIMIZE;

if (!minimizeBundle) {
    console.log('[Webpack] Skipping minimization of the bundles');
}

module.exports = {
   // the rest of the config
    optimization: {
        minimize: minimizeBundle,
        // the rest of the minimization config
    },
});
}

With this setting, you can run a webpack with the environment variable SKIP_MINIMIZE e.g.

SKIP_MINIMIZE=true webpack --mode=production

I hope that helps. Let me know in case you have more questions.

Thanks,
Maciej Adamczak
Atlassian Developer

Hi @MihaiVoicescu ,

In addition to what Adam said, you might be able to use the “quickreload” plugin to disable batching. See this page: Quick Reload - Controlling web batching (Scroll down to “Controlling Web Batching”)
This should leave source maps intact.

Cheers,
Wolfgang

Agree with @wkritzinger

It should be working with quick reload - I have some function using this in my bash profile to switch it on / off - I am usually doing it at the same time as switching dev mode on / off :

curl -X PUT "http://localhost:$CONTEXT/rest/qr/systemproperties/atlassian.dev.mode/${VALUE}"
curl -X PUT "http://localhost:$CONTEXT/rest/qr/systemproperties/plugin.webresource.batching.off/${VALUE}"