-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
Allow ESM module for custom middlewares #14280
Conversation
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.
Hey, thank you for taking the time to open a PR,
If we want to enable loading ESM here, we could use the import-default
util from here and move it to the @strapi/utils
package, so that we're consistent with the rest of the logic where we allow using ESMs.
@Convly Thanks ! I've updated the code to use import-default function. |
Hey, really sorry for the late answer, it got lost in the Github notifications. |
@Convly No problem for the delay and thank you for your response. I've moved import-default to strapi/utils package as asked 👍 |
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.
Thanks, I'm afraid those files would break if we don't change the importDefault require
- /packages/core/strapi/lib/core/loaders/apis.js
- /packages/core/strapi/lib/core/loaders/middlewares.js
- /packages/core/strapi/lib/core/loaders/policies.js
- /packages/core/strapi/lib/core/loaders/src-index.js
packages/core/strapi/lib/core/app-configuration/load-config-file.js
Outdated
Show resolved
Hide resolved
Codecov ReportBase: 58.76% // Head: 50.21% // Decreases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #14280 +/- ##
==========================================
- Coverage 58.76% 50.21% -8.55%
==========================================
Files 1322 280 -1042
Lines 32043 9698 -22345
Branches 5988 2121 -3867
==========================================
- Hits 18829 4870 -13959
+ Misses 11352 3979 -7373
+ Partials 1862 849 -1013
Flags with carried forward coverage won't be shown. Click here to find out more. Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
Oh, sorry. I thought I've updated all occurrences. It's now updated. |
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.
LGTM
Thanks for your contribution 🚀
(I'll just do a last round of verification (probably today or tomorrow) before merging) |
What does it do?
Fix issue #14146
Why is it needed?
With TS version of Strapi, we can use ESM module imports but we can't import custom middleware in
.ts
module file.How to test it?
See #14146
Related issue(s)/PR(s)
#14146