fix: dynamic imports with webpack 5 #294
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #209
why, yes, this IS a tragic hack..
now a serverless function generated for a page (that requires it) will look like:

previously it was:
nextPage/index.js
now it is:
nextPage/nextPage/index.js
to accommodate looking for chunks two levels up in webpack 5this is still backwards compatible with webpack 4, but unfortunately with next installed @ ^10.2.0 now in our project, we only test the webpack 5 behavior (< 10.2.0 was still default webpack 4).
i spent a good deal of time exploring the next source and webpack source to see if there was anything we could possibly do upstream to avoid this work. there's really nothing; it's just a breaking change in a major webpack update. everything runs fine on vercel, and i somehow couldn't identify any changes in the next source made to accommodate dynamic imports with webpack 5 - it appears they just work with the same source for wp4 and wp5? not sure.