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

fix: webpack 5 wrapper handling #186

Merged
merged 4 commits into from
Apr 14, 2021
Merged

fix: webpack 5 wrapper handling #186

merged 4 commits into from
Apr 14, 2021

Conversation

guybedford
Copy link
Contributor

Fixes #185 adding support for the new Webpack 5 namespace form which is a function not an object with an a property. The fix supports both webpack 4 and webpack 5 in an indirect way by creating the wrapper Object.assign(() => require('x'), { a: require('x') }), with the expression entirely evaluated virtually within the static evaluation system as a way to inform the evaluation result.

Copy link
Member

@styfle styfle left a comment

Choose a reason for hiding this comment

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

Thanks!

@codecov
Copy link

codecov bot commented Apr 14, 2021

Codecov Report

Merging #186 (275013e) into master (9c848ca) will increase coverage by 0.12%.
The diff coverage is 100.00%.

❗ Current head 275013e differs from pull request most recent head 09600d4. Consider uploading reports for the commit 09600d4 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master     #186      +/-   ##
==========================================
+ Coverage   80.18%   80.31%   +0.12%     
==========================================
  Files          13       13              
  Lines        1383     1392       +9     
  Branches      529      531       +2     
==========================================
+ Hits         1109     1118       +9     
  Misses        107      107              
  Partials      167      167              
Impacted Files Coverage Δ
src/analyze.ts 87.68% <100.00%> (ø)
src/utils/static-eval.ts 82.46% <100.00%> (+0.46%) ⬆️
src/utils/wrappers.ts 71.73% <100.00%> (+0.31%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9c848ca...09600d4. Read the comment docs.

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.

It looks like this still fails using the repo here https://github.com/sozonome/nextjs-webpack5-api-route-vercel-deployment-error and tracing .next/server/pages/api/posts.js after yarn build

The module cache/bootstrap code is also moved to a separate file in webpack 5 webpack-runtime.js, could this be causing a conflict here?

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.

Awesome, looks like it's catching it now! 🎉 🎉

@styfle styfle merged commit bd87d04 into master Apr 14, 2021
@styfle styfle deleted the webpack-5-wrapper branch April 14, 2021 21:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tracing fails with webpack 5 and concatenated path import
3 participants