Move polyfill resolution from webpack to package.json
Summary
This PR simplifies the setup for users consuming decap-cms-app directly by addressing Node.js built-in dependencies in a different way.
Problem:
- Many decap packages depend on Node.js built-ins (particularly
path) - Currently, these are only polyfilled via webpack configuration in the pre-built bundle
- Users consuming
decap-cms-appdirectly must manually configure their build tools to provide these polyfills
Solution:
- Leverage the standard
browserfield inpackage.jsonto specify browser-compatible alternatives- This is widely supported by modern build tools (webpack, Vite, Rollup, etc.)
- Eliminates need for manual polyfill configuration
- Reduce polyfill requirements by:
- Using
@iarna/toml/parse-stringinstead of full@iarna/tomlto eliminatestreamdependency - Updating
minimatchto a more recent version which removes Node.js built-in dependencies
- Using
These changes make the library more portable and easier to integrate across different build environments.
Test plan
- Build succeeds ✅
- tests:all pass ✅
- demo runs ✅
Checklist
Please add a x inside each checkbox:
- [x] I have read the contribution guidelines.
A picture of a cute animal (not mandatory but encouraged)
🐣
Update: I noticed that @iarna/tomlrequires a global polyfill and gray-matter requires Buffer at runtime. To fix this, I added lib/polyfill.js which is now the first thing that gets imported by bootstrap.js.
With this change in place, we could also remove the ProvidePlugin from the webpack config, but I chose to keep it in place for now to keep the change as minimal as possible.
@fgnass, I agree with the ProvidePlugin removal as part of this PR. If we don't do it now, we will probably forget about it.
I take it back. This PR solves #7521, so I would merge as is.