Skip to content

Same chunkhash for different output #8027

@smelukov

Description

@smelukov

Bug report

What is the current behavior?

Our current config is:

module.exports = {
    mode: 'production',
    entry: {
        'babel-stuff': [
            './var/www/s/babel-external-helpers.js',
            'babel-polyfill'
        ]
        // ... many other entrypoints
    },
    output: {
        path: 'some path to output',
        publicPath: '/s/cc/',
        filename: 'bundles/[chunkhash].js',
        chunkFilename: 'chunks/[chunkhash].js'
    },
    devtool: false,
    plugins: [
      // extract css
    ],
    optimization: {
        splitChunks: {
            maxInitialRequests: 10,
            maxAsyncRequests: 10,
            chunks: 'all',
            // disable css-splitting till fix the bug in mini-css-extract-plugin
            cacheGroups: {
                vendors: {
                    test: /\/node_modules\/.+\.js$/,
                    priority: -10
                },
                default: {
                    test: /\.js$/,
                    minChunks: 2,
                    priority: -20,
                    reuseExistingChunk: true
                }
            }
        },
        module: {
            noParse: [
                // some regexps
            ],
            rules: [
                {
                    test: /\.js$/,
                    use: [
                        {
                            loader: 'babel-loader',
                            options: {
                                cacheDirectory: 'path/to/cache'
                            }
                        }
                    ]
                },
                // other loaders for styl/css/svg/etc... 
            ]
        }
    };

And we got the same chunkshash 03ac84533a4d9ba84a13 for different file content on the output directory.

diff path/to/good/03ac84533a4d9ba84a13.js path/to/bad/03ac84533a4d9ba84a13.js -U 10
--- path/to/good/03ac84533a4d9ba84a13.js     2018-09-13 18:41:47.000000000 +0300
+++ path/to/bad/03ac84533a4d9ba84a13.js      2018-09-13 18:41:47.000000000 +0300
@@ -65,21 +65,21 @@
         return u.d(r, "a", r), r
     }, u.o = function(e, r) {
         return Object.prototype.hasOwnProperty.call(e, r)
     }, u.p = "/s/cc/";
     var a = window.webpackJsonp = window.webpackJsonp || [], f = a.push.bind(a);
     a.push = r, a = a.slice();
     for (var l = 0; l < a.length; l++) {
         r(a[l]);
     }
     var c = f;
-    i.push([2729, 847]), t()
+    i.push([2729, 849]), t()
 }({
     2729: function(e, r, t) {
         t(2730), e.exports = t(2731)
     }, 2730: function(e, r) {
         (function() {
             void 0, function(e) {
                 var r = e.babelHelpers = {};
                 r.typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(e) {
                     return typeof e
                 } : function(e) {

Because of it, long term caching is not working correctly...

If the current behavior is a bug, please provide the steps to reproduce.

Not sure how to reproduce exactly this
behavior...
We just modified our code base inside other entry points (not in babel-stuff) and got the different content in the output file of babel-stuff asset, but the same hash for it.

What is the expected behavior?

  • Different chunkhash for different output
  • Same output content for entry points that were not changed (e.g. babel-stuff)

Other relevant information:
webpack version: 4.17.2
Node.js version: 8.11.4
Operating System: MacOS 10.12.6
Additional tools:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions