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

bug with merging cacheGroups #145

Closed
alexander-akait opened this issue Aug 29, 2020 · 2 comments
Closed

bug with merging cacheGroups #145

alexander-akait opened this issue Aug 29, 2020 · 2 comments

Comments

@alexander-akait
Copy link

alexander-akait commented Aug 29, 2020

Reproducible test repo: https://github.com/artem-malko/webpack-5-beta-config-bug

Ref: webpack/webpack#11396

Simple reproducible example

console.log(
  merge(
    { 
      optimization: {
        runtimeChunk: {
          name: 'runtime',
        },
    
        splitChunks: {
          minChunks: 2,
              minSize: 30000,
      
              cacheGroups: {
            clientApplication: {
              name: 'clientApplication',
                  test: /applications\/client/,
                  chunks: 'all',
                  enforce: true,
            },
          },
        },
      }
    },
    {
      optimization: {
        runtimeChunk: {
          name: 'runtime',
        },

        splitChunks: {
          minChunks: 2,
          minSize: 30000,

          cacheGroups: {
            clientApplication: {
              name: 'clientApplication',
              test: /applications\/client/,
              chunks: 'all',
              enforce: true,
            },
          },
        },
      }
    }
  ).optimization?.splitChunks
);

test is Object

@bebraw
Copy link
Member

bebraw commented Aug 30, 2020

Thanks for the report. The problem was that there was a check missing against merging a RegExp against another RegExp. In this case in the configuration definition it was set up so that the optimization part was merged to itself optimization due to a ... elsewhere in the configuration.

@artem-malko I've fixed the issue in 5.1.3 but I would recommend against doing ...clientConfig.optimization, in your production configuration as that will cause the same configuration to appear twice although it will be merged away. Can you explain why you did your own merge for that particular configuration? What's the use case?

@artem-malko
Copy link

@bebraw Hm, nice catch) May be it's because where was no any webpack-merge many years ago) So, we merged our configs manually)

You're right! I'll remove ...clientConfig.optimization from my config) optimization part will be used without it too) Thx

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

3 participants