Skip to content

Conversation

@yjoer
Copy link
Contributor

@yjoer yjoer commented Jul 2, 2025

While exploring the idea of dropping ncc and using webpack to build the loader directly in this branch, I noticed that 31 outputs differ from their corresponding coverage outputs. These differences are consistent across the changes made here, so I believe we can update the coverage outputs to reflect this variation.

asset-node-require
bindings-failure
browserify
browserify-minify
browserify-uglify
custom-emit-require-multiassign
esm
express-template
express-template-engine
ffmpeg-installer
jsonc-parse-wrapper
main-equal
module-require
mongoose
node-gyp-build-resolve
non-analyzable-requires
oracledb
pkginfo
process-env
require-dirname-tpl
require-dynamic-fallback
require-multiassign
require-resolve-like
require-wrapper
require-wrapper2
require-wrapper3
resolve-from
tla
when-wrapper
wildcard-require
wildcard-require2

Remove the use of the deprecated Webpack MainTemplate.
If `__nccwpck__` is not present, fall back to `__webpack_require__`.
It fixes the regression from 1.7.3 to 1.7.4 vercel#188 and it also allows for compatibility with `rspack` https://github.com/web-infra-dev/rspack.
@styfle
Copy link
Member

styfle commented Jul 2, 2025

Let's revert yarn.lock since that isn't strictly necessary to fix the regression right? All you need is the regex replace.

@yjoer
Copy link
Contributor Author

yjoer commented Jul 2, 2025

Would it be possible to update webpack to v5.99.9 before this? I had the text fixtures updated for that version. If we eventually have to update webpack, the corresponding work is already done here.

ran and updated all tests
@styfle
Copy link
Member

styfle commented Jul 2, 2025

They should be separate. A regression fix should be shipped as a patch and webpack update can be minor.

I think that was the mistake in the previous release when the regression was introduced.

@yjoer
Copy link
Contributor Author

yjoer commented Jul 2, 2025

Nevermind. I reapplied the changes with webpack v5.76.0 to keep things simple. The coverage outputs are generally no longer divided into two categories. That's only applicable for v5.99.9. However, I kept the commits intact while patching the files, so don't let that cause any confusion.

const fs = require('fs');

expect(output.length).toBe(16);
expect([16, 17]).toContain(output.length);
Copy link
Member

Choose a reason for hiding this comment

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

Can you explain why this is no longer 16?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The explanation is in the second half of the description in #194. In short, running the build within the test many times, webpack sometimes outputs lines with "assets by status" on top of "assets by path". Allowing an extra line would avoid unexpected test failures.

Copy link
Member

Choose a reason for hiding this comment

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

Why “sometimes”? I would expect the output to be deterministic.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know what exactly caused this. The build config isn't changed. The output files and bytes appeared to be similar, but I got different outputs by running the test 13 times for this attempt.

2025-07-03_19-49-09.mp4

Copy link
Member

Choose a reason for hiding this comment

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

Ok we can keep this for now and see if upgrading webpack fixes it in a future PR

/******/ /* webpack/runtime/asset-relocator-loader */
/******/ (() => {
/******/ if (typeof __webpack_require__ !== 'undefined') __webpack_require__.ab = __dirname + "/";
/******/ })();
Copy link
Member

Choose a reason for hiding this comment

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

Is the IIFE required? Perhaps we can make this diff much smaller if we kept the output similar so there is no IIFE wrapper.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think the IIFE is necessary. The isolation is turned on by default with RuntimeModule, but we can override the method to turn it off. Another patch is incoming.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The changes are available in the latest commit 0fe6976

styfle
styfle previously approved these changes Jul 3, 2025
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.

Looks good, just need to fix the coverage

@yjoer
Copy link
Contributor Author

yjoer commented Jul 3, 2025

Codecov deprecated their language-specific uploaders https://about.codecov.io/blog/codecov-uploader-deprecation-plan/. This might need to be fixed and tested from your end.

@styfle styfle mentioned this pull request Jul 3, 2025
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.

Great work, thanks! 🎉

@styfle styfle changed the title fix: 1.7.3 to 1.7.4 regression fix: 1.7.3 to 1.7.4 regression __nccwpck_require__ is not defined Jul 3, 2025
@styfle styfle enabled auto-merge (squash) July 3, 2025 15:24
@styfle styfle merged commit ee4ce15 into vercel:main Jul 3, 2025
9 checks passed
@github-actions
Copy link

github-actions bot commented Jul 3, 2025

🎉 This PR is included in version 1.7.5 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Regression 1.7.3 to 1.7.4: __nccwpck_require__ is not defined

3 participants