Skip to content

Conversation

fgnass
Copy link
Contributor

@fgnass fgnass commented Feb 6, 2025

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:

  1. Many decap packages depend on Node.js built-ins (particularly path)
  2. Currently, these are only polyfilled via webpack configuration in the pre-built bundle
  3. Users consuming decap-cms-app directly must manually configure their build tools to provide these polyfills

Solution:

  1. Leverage the standard browser field in package.json to specify browser-compatible alternatives
    • This is widely supported by modern build tools (webpack, Vite, Rollup, etc.)
    • Eliminates need for manual polyfill configuration
  2. Reduce polyfill requirements by:
    • Using @iarna/toml/parse-string instead of full @iarna/toml to eliminate stream dependency
    • Updating minimatch to a more recent version which removes Node.js built-in dependencies

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:

A picture of a cute animal (not mandatory but encouraged)

🐣

@fgnass fgnass requested a review from a team as a code owner February 6, 2025 13:22
@fgnass
Copy link
Contributor Author

fgnass commented Feb 22, 2025

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 added a commit to fgnass/decap-cms that referenced this pull request Feb 25, 2025
@martinjagodic
Copy link
Member

@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.

@martinjagodic
Copy link
Member

I take it back. This PR solves #7521, so I would merge as is.

martinjagodic
martinjagodic previously approved these changes Jun 27, 2025
@martinjagodic martinjagodic merged commit 5eca35d into decaporg:main Jul 10, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants