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

Only add optimize packages to transpile packages during production build #65245

Closed
wants to merge 3 commits into from

Conversation

aovens-quantifi
Copy link

What?

#63537 introduced an issue where compilation of a new route (like an api route) on the pages router during local webpack dev caused the hash of _document.js to change, forcing active hmr pages to do a full page refresh.

This PR simply forces the above-mentioned PR to only apply during production builds and not during dev (likely the time you care about optimizing imports anyway)

Why?

The above mentioned bug was causing issues for our local dev as the page would refresh as soon as we hit an api route

@aovens-quantifi
Copy link
Author

@ijjk I don't know how to make the CI run

Copy link
Member

@ijjk ijjk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, could you add a test case for this so we can see the issue more clearly?

@aovens-quantifi
Copy link
Author

I could add a test case for this code but I'm not sure I could add one for the issue I was having. I entered the issue in discord but not on GitHub. Adding here for posterity:

My next app (v14.2.3, pages) is performing a page refresh on the first instance of a fetch to an api route. This started happening after upgrading from 14.0.4 to 14.2.2 (more specifically from 14.1.0 to 14.2.0). I have isolated the server code to this line:

this.send({ action: HMR_ACTIONS_SENT_TO_BROWSER.RELOAD_PAGE })

Based on my reading, it is determining the _document.js content is changing, however I have made no changes to the code when this happens

@aovens-quantifi
Copy link
Author

Here is the difference between the _document.js chunks before and after the api call:
image

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants