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
npm run generate
should not always generate a new entry file.
#25133
Comments
Start a new pull request in StackBlitz Codeflow. |
You don't even need to change anything. Just run 'npm run generate' two times in a row. To really illustrate the problem, I copied the resulting As you can see, even though nothing has changed content-wise, every single OK, we see here that every page (and every component as it turns out) has changed because they all rely on the file name of the I found this issue when I realized that with every new release, I had to download every Vuetify component, again. Loads of data! I first thought it was a problem with Vuetify, but I tracked it down to this |
Just want to suggest that there's a typo in the issue's title, it should be |
npm run generage
should not always generate a new entry file.npm run generate
should not always generate a new entry file.
It seems that the priority of this issue is not very high. If possible, I can try to fix this problem. My solution is to migrate the
看起来这个问题的优先级不是很高,如果可以的话,我可以尝试修复这个问题。
|
@xuyifeiOnly 你是怎么配置的?我的理解是目前nuxt还不支持这个功能呢。我的解决方案说是要把buildId从appConfig中迁移到nuxtConfig中,实际意思是指要提交pr去修改nuxt的构建逻辑。我估计改动还不小。 |
@kaokei |
@xuyifeiOnly 当然了,entry.js的内容中包含了buildId,这个buildId是一个随机生成的字符串。所以每次构建都会产生一个新的buildId,这样就导致entry.js的文件内容发生了变化,既然内容都变化了,entry.js的hash肯定会变化。 |
@kaokei 这个看起来只能等官方解决了 |
There is a bug/issue in bundling done by Rollup, (hence Vite and hence Nuxt) because of which even if the buildId is not random, it still generates different hashes. You can try this with the following: export default defineNuxtConfig({
appConfig: {
nuxt: {
buildId: '1',
},
},
.... With this, if you run However, for my and everyone's bad luck, it still doesn't work and with a small change, all hashes change again. Why? Because of the Vite bug/issue discussed here: This has to be a P1. Why will anyone choose Nuxt/Vite/Rollup if Caching performance is so badly hit. In my case I am working on a PWA. So all customers have to download the entire build again for a small typo change. |
This works perfectly for me. export default defineNuxtConfig({
appConfig: {
nuxt: {
buildId: '1',
},
},
vite: {
build: {
rollupOptions: {
output: {
entryFileNames: '_nuxt/[name].js',
},
},
},
},
... Hash is changed only for the file where changes are made (and if that is included in other files) |
this saved me, just upgraded from nuxt 3.6 to 3.11 and multiple instances of the same app stopped working because the file hash for the CDN version of entry.js won't match the version in the app instances, even though they are built from the exact same source code. |
For me at least this seems to cause stale cache issues. That entry file includes |
This should be resolved in the nightly release, or in the next release. Let me know if not and I'll reopen. |
Describe the feature
I have already written a demo that allows for a quick examination of the issue.
The current issue is as follows:
When I run the
npm run generate
command, it generates not onlyabout.js
andindex.js
but also an additionalentry.js
. Initially, I thought thatentry.js
was thevendor
file, and I expected that when I didn't modify the dependencies innode_modules
, thisentry.js
file would remain unchanged. However, in reality, every time I modify the content of any file inpages/index.vue
orpages/about.vue
,npm run generate
creates a newentry.js
. Since other JS files depend onentry.js
, this ultimately leads to the regeneration of all JS files.The desired outcome is:
The
entry.js
file should remain stable and not change constantly. The ultimate goal is that modifying a page in the pages directory should not impact the build output of other pages.我已经写好一个demo,可以快速查看现象。
目前的现象是:
当我运行
npm run generate
命令时,除了生成了about.js
和index.js
以外,还生成了一个entry.js
。我本以为这个
entry.js
就是vendor
文件,我理解当我没有修改node_modules
依赖时,这个entry.js文件应该是不会有变化的。但实际上,我修改
pages/index.vue
或者pages/about.vue
中任意一个文件的内容时,npm run generate
都会重新生成一个新的entry.js
,又因为其他js文件都是依赖于entry.js
文件,最终导致所有js文件都重新生成了。期待的效果是:
entry.js
文件应该是稳定的,不应该总是变化。最终目标是当我修改pages目录中某一个页面时,不应该影响到其他页面的构建产出。
Additional information
Final checks
The text was updated successfully, but these errors were encountered: