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

Dynamic imports causes 404 in production #3823

Closed
paulxuca opened this issue Feb 16, 2018 · 3 comments · Fixed by #4639
Closed

Dynamic imports causes 404 in production #3823

paulxuca opened this issue Feb 16, 2018 · 3 comments · Fixed by #4639

Comments

@paulxuca
Copy link
Contributor

Currently attempting to deploy a next.js to production with dynamic imports (without using next/dynamic since we're importing a non-react library), and running into issues with 404s on the dynamically imported chunks.

The built folder structure looks like:

.next
	- app.js
	- BUILD_ID
	- 0-cd29260af35981b4adfc.js
	- ...etc
	

While loading the page, a javascript file at /_next/webpack/0-cd29260af35981b4adfc.js is loaded, pointing to the file 0-cd29260af35981b4adfc.js to be in the .next/chunks directory, which it's not. Moving that file manually to the chunks folder fixes it. Currently, the request 404s.

  • [x ] I have searched the issues of this repository and believe that this is not a duplicate.

Expected Behavior

The request for the dynamically loaded javascript file should not 404.

Current Behavior

The request for the dynamically loaded javascript 404s.

Your Environment

Tech Version
next 5.0.0
node 8.9.4
OS MacOs
browser Chrome
etc
@timneutkens
Copy link
Member

Could you provide a reproducible repository 🙏 Then we can look into it 👍

@chilijung
Copy link

chilijung commented Jul 7, 2018

@paulxuca I also had this problem, dynamic import is working in dev mode but break in production (I could find the output files in .next folder. But loading the wrong path prod files. Have you find a solution for this?

@timneutkens here a repo you could reproduce this issue.: https://github.com/Canner/canner-firebase-cms/tree/nextjs

Where our CMS component dynamic import: https://github.com/Canner/canner/blob/master/src/components/Generator.js#L153-L159

log in to dashboard page, all the CMS components is loading via dynamic import, in dev mode, dynamic import works, but in prod, it breaks it was loading the wrong path.

built file in .next folder looks like this:

2018-07-07 11 26 18

Loading 404 files in prod server.

2018-07-07 11 27 21

@timneutkens
Copy link
Member

Should be fixed by #4639

@lock lock bot locked as resolved and limited conversation to collaborators Jul 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants