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

nuxt build generates a hidden file under .nuxt/dist/client/commons/ #7703

Closed
cainaf opened this issue Jul 11, 2020 · 5 comments
Closed

nuxt build generates a hidden file under .nuxt/dist/client/commons/ #7703

cainaf opened this issue Jul 11, 2020 · 5 comments

Comments

@cainaf
Copy link

cainaf commented Jul 11, 2020

Versions

  • nuxt: 2.13.3
  • node: 13.14.0
  • @nuxt/typescript-build: 1.0.3
  • @nuxt/typescript-runtime: 0.4.10

The problem

A hidden chunk-file is generated when running nuxt-ts build. This is the full path of the file generated for me:

  • /.nuxt/dist/client/commons/.a9cf80a.js

The problem is that this hidden file is later inaccessible by the http server and thus this chunk returns 404 in a built application.

After some digging, I found in the docs that chunk names are preceded by an id as follows:

  • [id].[contenthash].js

My first thought was that probably this id was coming out as zero (0) and being omitted in a number conversion or something like that (still don't know if that is the case though). But I managed to solve the problem with a workaround and the result also indicates the same cause.

Reproduction

I've done many builds, but this is the first time it happened. So I don't know exactly the cause. But the result was this file:

Captura de Tela 2020-07-11 às 11 54 04

All other chunks are normally accessed and this is the only one that came out that way, as a hidden file. So when trying to access it via http:

Captura de Tela 2020-07-11 às 11 55 19

Just for testing purposes, I renamed it without the dot, and it was then accessible:

Captura de Tela 2020-07-11 às 11 56 29

So when building the app and deploying to my servers, only this chunk was inaccessible and breaking some behavior of the application.

My Solution

Digging in the docs, I found out that I could change built filename patterns. I did that by prefixing a letter c to the chunkId:

Captura de Tela 2020-07-11 às 11 57 12

The result was the following files. None came as a hidden file and one came with a id=0:

Captura de Tela 2020-07-11 às 12 00 58

That solved my problem. No hidden files were generated and the application was able to access all built chunks. The zero id may itself also indicate this could be the cause of the problem.

@japboy
Copy link

japboy commented Jul 12, 2020

Same thing happens to me with;

  • nuxt: 2.13.3
  • node: 12.18.1
  • @nuxt/typescript-build: 1.0.3
  • @nuxt/typescript-runtime: 0.4.10

And @cainaf's solution also saved me;

Digging in the docs, I found out that I could change built filename patterns. I did that by prefixing a letter c

Thank you.

@maikueo
Copy link

maikueo commented Jul 12, 2020

Same problem here.
I have page components that use asyncData, and have some normal components that use the new fetch hook functionality from 2.12.

This problem only affects the pages that have components with the new fetch hook for me.

thank you @cainaf , the chunk workaround works nicely!

@danielroe
Copy link
Member

Should be fixed by #7667

@vaiil
Copy link

vaiil commented Jul 17, 2020

I have same problem on version 2.13.3 (2.13.2 works fine). Changing filename pattern resolves that problem, but there is another one: that file includes a lot of shared components that shouldn't be loaded together.
Try to explain:
I use different components for mobile and desktop (I import them as async components using @nuxtjs/device to detect version), but these components could have same logic, that is extracted to a common file.
For example, we have HomePage and AboutPage.
Home page imports asynchronously ComponentAMobile or ComponentADesktop, each of them import synchronously ComponentACommonLogic.js
About page imports asynchronously ComponentBMobile or ComponentBDesktop, each of them import synchronously ComponentBCommonLogic.js

And in this case ComponentACommonLogic and ComponentBCommonLogic will be placed in that hidden file. But home page doesn't need ComponentBCommonLogic.

@stale
Copy link

stale bot commented Aug 16, 2020

Thanks for your contribution to Nuxt.js!
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If you would like this issue to remain open:

  1. Verify that you can still reproduce the issue in the latest version of nuxt-edge
  2. Comment the steps to reproduce it

Issues that are labeled as pending will not be automatically marked as stale.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants