-
Notifications
You must be signed in to change notification settings - Fork 34
fix: 1.7.3 to 1.7.4 regression __nccwpck_require__ is not defined #195
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
Changes from 6 commits
622b0d2
218bb08
d93e768
b18a046
8c83e25
0b4cf7b
0fe6976
8a04208
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,3 +2,4 @@ node_modules | |
| dist | ||
| coverage | ||
| test/**/dist | ||
| test/unit/**/actual.js | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| const fs = require('fs') | ||
| const path = require('path') | ||
| const ncc = require('@vercel/ncc') | ||
|
|
||
| const build = () => { | ||
| const entry = path.resolve(__dirname, '../src/asset-relocator.js') | ||
|
|
||
| ncc(entry, { | ||
| externals: ["resolve"], | ||
| minify: true | ||
| }).then(({ code }) => { | ||
| const distFile = path.resolve(__dirname, '../dist/index.js') | ||
|
|
||
| // replace all __nccwpck_require__ with __webpack_require__ caused by ncc | ||
| const newCode = code.replace( | ||
| /__nccwpck_require__/g, | ||
| '__webpack_require__' | ||
| ) | ||
|
|
||
| fs.writeFileSync(distFile, newCode) | ||
| }).catch(err => { | ||
| console.error(err) | ||
|
|
||
| process.exit(1) | ||
| }) | ||
| } | ||
|
|
||
| build() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,9 +36,10 @@ module.exports = require("fs"); | |
| /******/ } | ||
| /******/ | ||
| /************************************************************************/ | ||
| /******/ /* webpack/runtime/compat */ | ||
| /******/ | ||
| /******/ if (typeof __webpack_require__ !== 'undefined') __webpack_require__.ab = __dirname + "/"; | ||
| /******/ /* webpack/runtime/asset-relocator-loader */ | ||
| /******/ (() => { | ||
| /******/ if (typeof __webpack_require__ !== 'undefined') __webpack_require__.ab = __dirname + "/"; | ||
| /******/ })(); | ||
|
||
| /******/ | ||
| /************************************************************************/ | ||
| var __webpack_exports__ = {}; | ||
|
|
||
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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