Vue-cli: module.id is incremented when add a new page

Created on 23 Jul 2018  路  6Comments  路  Source: vuejs/vue-cli

Version

3.0.0-rc.5

Reproduction link

https://github.com/PanJiaChen/chunk-test

Steps to reproduce

  1. npm install
  2. add a new router (Don't add at the end)
  3. npm run build
  4. diff generated files

What is expected?

I only added one file, so the final result should not change other pages.xxx.js.

What is actually happening?

About.vue js file id has been changed. Caused the file moduleId behind it to change.

image

Every time I add a new page, it may cause the cache of other pages to become invalid.

enhancement

Most helpful comment

Before the official release of webpack5, I found that NamedChunksPlugin can be used to solve this problem.

new webpack.NamedChunksPlugin(chunk => {
  if (chunk.name) {
    return chunk.name
  }
  return Array.from(chunk.modulesIterable, m => m.id).join('_')
})

All 6 comments

webpack records can solved this.

Note to docs: as reference for PR: https://webpack.js.org/configuration/other-options/#recordspath

The question is, where do we put this? It feels like something we should keep abstracted away, but the webpack docs recommend adding it to version control, which means the user has to be aware of it.

The records file is only used for human inspection and not used during runtime... I don't think there really is a way to fix this in webpack at the moment, maybe you should open an issue for webpack instead.

webpack 4.0 to 4.16: Did you know?

image

Maybe webpack5 will fix it. :dizzy_face:

Before the official release of webpack5, I found that NamedChunksPlugin can be used to solve this problem.

new webpack.NamedChunksPlugin(chunk => {
  if (chunk.name) {
    return chunk.name
  }
  return Array.from(chunk.modulesIterable, m => m.id).join('_')
})

@PanJiaChen good find!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

brunoseco picture brunoseco  路  35Comments

yyx990803 picture yyx990803  路  80Comments

yyx990803 picture yyx990803  路  34Comments

xrei picture xrei  路  40Comments

GeertClaes picture GeertClaes  路  31Comments