antfu-collective / vite-ssg

Static site generation for Vue 3 on Vite
MIT License
1.27k stars 129 forks source link

using build.rollupOptions.output.manualChunks #395

Open kolirt opened 3 months ago

kolirt commented 3 months ago

Describe the bug

How can I use manualChunks?

vite.config.ts

export default defineConfig({
  build: {
    rollupOptions: {
      output: {
        manualChunks: {
          lottie: ['vue3-lottie']
        }
      }
    }
  },
})

logs

 ERROR                                                                                                                                                                                                                    11:23:55
[vite-ssg] An internal error occurred.

 ERROR  [vite-ssg] Please report an issue, if none already exists: https://github.com/antfu/vite-ssg/issues                                                                                                               11:23:55

/node_modules/rollup/dist/es/shared/parseAst.js:337
        base = Object.assign(new Error(base.message), base);
                             ^

Error [RollupError]: "vue3-lottie" cannot be included in manualChunks because it is resolved as an external module by the "external" option or plugins.
    at error (/node_modules/rollup/dist/es/shared/parseAst.js:337:30)
    at ModuleLoader.loadEntryModule (/node_modules/rollup/dist/es/shared/node-entry.js:18049:20)
    at async Promise.all (index 0)
    at async Promise.all (index 0) {
  code: 'EXTERNAL_MODULES_CANNOT_BE_INCLUDED_IN_MANUAL_CHUNKS'
}

Reproduction

-

System Info

System:
    OS: Linux 6.5 Ubuntu 23.10 23.10 (Mantic Minotaur)
    CPU: (12) x64 AMD Ryzen 5 3600 6-Core Processor
    Memory: 21.60 GB / 31.28 GB
    Container: Yes
    Shell: 5.2.15 - /bin/bash
  Binaries:
    Node: 18.20.0 - ~/n/bin/node
    Yarn: 1.22.21 - ~/n/bin/yarn
    npm: 10.5.0 - ~/n/bin/npm
  Browsers:
    Chrome: 123.0.6312.86

Used Package Manager

yarn

Validations