question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Package imported solely in import with `webpackChunkName` must not be splitted by `splitChunks`

See original GitHub issue

Bug report

When a package is imported solely with in import with webpackChunkName flag, such package must be not create an extra vendor chunk.

How to reproduce?

checkout https://github.com/atk4/ui/commit/034f075b056dd0436d966176c1a8763c214df2d0 and run npm run build in js dir

in https://github.com/atk4/ui/blob/034f075b056dd0436d966176c1a8763c214df2d0/js/src/services/vue.service.js#L84 this file:

https://github.com/atk4/ui/blob/034f075b056dd0436d966176c1a8763c214df2d0/js/src/vue-components/query-builder/query-builder.component.vue is imported which imports fomantic-ui-group.component.vue and fomantic-ui-rule.component.vue (in the same dir) which import from vue-query-builder package

no other files import from vue-query-builder package

What is the current behavior?

public/js/vendor-vue-query-builder.js is created but the content should go into public/js/atk-vue-query-builder.js especially when https://github.com/atk4/ui/blob/034f075b056dd0436d966176c1a8763c214df2d0/js/webpack.config.js#L41-L44 lines are removed (tested, the files are still vendored)

What is the expected behavior?

I would expect webpack to detect vue-query-builder is used from single (already chunked) exported (already chunked) public/js/atk-vue-query-builder.js file and NOT create additional/uneeded public/js/vendor-vue-query-builder.js chuck

Other relevant information: webpack version: 5.75.0 / latest

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
mvorisekcommented, Nov 28, 2022

@alexander-akait big thank you ❤️

defaultVendors: false + removed cache group for the files that should be inlined by webpackChunkName annotated import is working

0reactions
alexander-akaitcommented, Nov 28, 2022

Try this:

 splitChunks: {
                cacheGroups: {
                    defaultVendors: false,
                    vendorVueFlatpickr: {
                        test: /[\\/]node_modules[\\/](flatpickr|vue-flatpickr-component)[\\/]/,
                        name: 'vendor-vue-flatpickr',
                    },
                    vendorVue: {
                        test: /[\\/]node_modules[\\/](?!(vue-flatpickr-component|vue-query-builder)[\\/])([^\\/]+[-.])?vue([-.][^\\/]+)?[\\/]/,
                        name: 'vendor-vue',
                    },
                    vendor: {
                        test: /[\\/]node_modules[\\/](?!(([^\\/]+[-.])?vue([-.][^\\/]+)?|flatpickr)[\\/])/,
                        name: 'vendor',
                    },
                },
            },
Read more comments on GitHub >

github_iconTop Results From Across the Web

Fixing WebpackChunkName for Dynamic Imports - Time to Hack
I thought of analyzing our bundle with Webpack Bundle Analyzer and seeing how splitChunks has done the splitting. For some reason, I could...
Read more >
Dynamically imported chunks don't get split properly ... - GitHub
webpackChunkName is NOT a working solution here because the chunk name can only be determined after compilation. Other relevant information:
Read more >
The 100% correct way to split your chunks with Webpack
Code splitting: dynamically loading code, so that users only download the code they need for the part of the site that they're viewing....
Read more >
Code Splitting - webpack
Code splitting is one of the most compelling features of webpack. This feature allows you to split your code into various bundles which...
Read more >
How to name a webpack chunk (including split and common ...
In this post, we look at named outputs, including dynamic imports, split chunks, and common chunks. I recently wrote about code splitting ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found