-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
fix(upload): file-type does not support commonjs #24848
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
markkaylor
commented
Nov 14, 2025
mathildeleg
approved these changes
Nov 14, 2025
Contributor
mathildeleg
left a comment
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, well done ✅
Adzouz
approved these changes
Nov 14, 2025
Contributor
Adzouz
left a comment
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.
Tested and it works now, good job 👏
Contributor
|
I tested further, LGTM 🚀 |
araksyagevorgyan
approved these changes
Nov 14, 2025
chaitya-titan
pushed a commit
to chaitya-titan/strapi
that referenced
this pull request
Nov 14, 2025
2 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does it do?
Replace static import with dynamic import for file-type package to support ESM-only modules in both CommonJS/ESM builds.
The maintainer mentions this approach here: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
Why is it needed?
file-type is ESM-only and lacks CommonJS exports. When Strapi builds its CommonJS output, the bundler fails to transform the static import to require(). This breaks app startup on Node.js < 22, which has stricter ESM/CommonJS interop. Dynamic imports work at runtime in both module formats.
How to test it?
You will need to be able to switch node versions with something like https://github.com/nvm-sh/nvm
Switch to node 20 (
nvm install 20if it's not already installed.nvm use 20to use it,node -vto confirm)Create a strapi app with
npx create-strapi-app@0.0.0-experimental.f9ca9ac9518346cac58a4a3a576bc9d9d795570d test-fix --quickstartUpdate the config in
config/plugins.js:Run
npm run developthere should NOT be an errorGo to the media library and try to upload a video, it should be rejected
Try to upload other file types not in the deniedTypes list, it should work
Test the same for all node versions up to 24
Related issue(s)/PR(s)
Resolves #24829