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

unbundle: more control over vendor / async-vendor #19

Open
bompus opened this issue Dec 6, 2022 · 2 comments
Open

unbundle: more control over vendor / async-vendor #19

bompus opened this issue Dec 6, 2022 · 2 comments

Comments

@bompus
Copy link

bompus commented Dec 6, 2022

if (staticImportedScan(id, getModuleInfo, new Map(), [])) {
    return "vendor";
  } else {
    return "async-vendor";
}

Currently, this produces very large vendor / async-vendor (2MB+) bundles for me. This might be better if these could possibly:

  1. Returned undefined for default rollup splitting logic.
  2. Return the name of the npm package, such as lodash or date-fns ( returning undefined might actually do this? )

Of course, people like options, so if there is some way to turn this into a new option on the plugin, that is always ideal so folks can opt-in to the behavior they would like.

@sanyuan0704
Copy link
Owner

I think you can use customSplitting config to split the chunk appropriately, such as:

// vite.config.ts
import { chunkSplitPlugin } from 'vite-plugin-chunk-split';

{
  plugins: [
    // ...
    chunkSplitPlugin({
      customSplitting: {
        lodash: ['lodash'],
      }
    })
  ]
}

@bompus
Copy link
Author

bompus commented Dec 12, 2022

I could use customSplitting, but then every user ( and myself ) has to remember to add every dependency added to the project to the array, and it's inevitable that one will be forgotten at some point unless it's automated.

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

2 participants