ktsn / vue-auto-routing

Generate Vue Router routing automatically
MIT License
254 stars 19 forks source link

It's not allowed to load an initial chunk on demand. The chunk name "index" is already used by an entrypoint. #7

Closed ndarilek closed 5 years ago

ndarilek commented 5 years ago

Getting the above with a Vue-CLI project attempting to add multiple entrypoints. I did:

  pages: {
    "index": "src/main.ts",
    "conversions": "src/conversions.ts"
  }

I created both files, and even a public/conversions.html. It isn't immediately obvious where the Webpack chunk name is set when configuring multiple pages.

Essentially, I want to create a separate bundle with a slightly different Apollo initialization that strips out authentication. The easiest solution seemed to be multiple pages with the simpler entrypoint syntax, but I don't know how to achieve this with vue-auto-routing. I'm actually using the CLI plugin, but the error is in node_modules/vue-auto-routing/index.js, so I'm filing the issue here.

Thanks.

ktsn commented 5 years ago

Can you provide the error message and reproducible vue cli project?

ndarilek commented 5 years ago

The full error:

 ERROR  Failed to compile with 1 errors                                                                                                                                       11:42:29 AM
 error  in ./node_modules/vue-auto-routing/index.js
It's not allowed to load an initial chunk on demand. The chunk name "index" is already used by an entrypoint.
 ERROR  Build failed with errors.
error Command failed with exit code 1.

Here is a minimal reproduction. If I change index to index2 in vue.config.js, things work fine, but I get an index2.html. What I want is for src/main.js to be the index entrypoint, outputting index.html, and src/anotherentrypoint.js to map to anotherentrypoint.html. Note that, in this case, I don't create the second entrypoint to keep things minimal. IMO, I should be able to override the default entrypoint at index, but either vue-autorouting isn't letting me, or this error isn't saying what it seems.

Thanks.

ktsn commented 5 years ago

Thank you for providing the info. I've added a new option chunkNamePrefix for vue-auto-routing to avoid such conflict. And also added this option in vue-cli-plugin-auto-routing. https://github.com/ktsn/vue-cli-plugin-auto-routing#options

Please update to vue-auto-routing@0.4.0 and vue-cli-plugin-auto-routing@0.3.0 and config pluginOptions.autoRouting.chunkNamePrefix in vue.config.js.

ndarilek commented 5 years ago

Thanks!