-
-
Notifications
You must be signed in to change notification settings - Fork 273
fix: set a name to exported fn #299
fix: set a name to exported fn #299
Conversation
this can help debugging and also removes the warning https://nextjs.link/codemod-ndc from next.js
Codecov Report
@@ Coverage Diff @@
## master #299 +/- ##
==========================================
+ Coverage 76.02% 76.19% +0.16%
==========================================
Files 6 6
Lines 146 147 +1
Branches 51 51
==========================================
+ Hits 111 112 +1
Misses 30 30
Partials 5 5
Continue to review full report at Codecov.
|
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.
What is the problem? Can you provide example
@evilebottnawi next.js logs this when every worker is built, which is a bit noisy:
The code of this log is here https://github.com/vercel/next.js/blob/8221c180a55828b39a7e1e01811365bfaaa0dd19/packages/next/build/babel/plugins/no-anonymous-default-export.ts#L59-L68. But adding a function name in this lib it can also help while debugging errors, since stack trace errors will have names. |
No sure it will fix the problem with hot reloading, but I can merge it |
package.json
Outdated
"schema-utils": "^3.0.0", | ||
"loader-utils": "^2.0.0" | ||
"loader-utils": "^2.0.0", | ||
"lodash.camelcase": "^4.3.0", |
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.
Please avoid using this module, it is deprecated, we don't need extra module for simple logic
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.
@evilebottnawi Sorry for my delay.
I've tried to use simpler solutions like https://stackoverflow.com/a/2970667, but they can fail with RangeError
.
So since lodash.camelcase is deprecated I have remplace it with camelcase.
camelcase:
- It has recent activity, latest release was published 1 month ago.
- It doesn't depend on more dependencies.
- It's small https://bundlephobia.com/result?p=camelcase@6.2.0. More than 3 times smaller than lodash.camelcase.
If still doesn't work, I can try inlining this code https://github.com/sindresorhus/camelcase/blob/master/index.js here.
eba886e
to
b218745
Compare
b218745
to
d01618c
Compare
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 just don't use ${typeOfWorker}_fn
name without any additional logic?
@alexander-akait by Lines 38 to 47 in 464bf30
I can make that change, that would still solve the issue with noisy logs from next.js! The only difference is that unique function names can help while debugging. |
I don't think you need unique function here because you already have stack trace in console with link on file, line and column |
@alexander-akait done! |
Thanks |
Thanks for your time @alexander-akait ! |
This PR contains a:
Motivation / Use-Case
This can help debugging since error stack traces will have names.
And also removes the warning of anonymous functions next.js https://nextjs.link/codemod-ndc from.
Breaking Changes
None
Additional Info
None