feat(esm): Support running Tailwind setup in ESM projects#350
Conversation
✅ Deploy Preview for cedarjs canceled.
|
There was a problem hiding this comment.
Greptile Summary
This PR addresses a specific issue with TailwindCSS configuration generation in ESM projects within the Cedar framework. The change modifies the tailwindcssHandler.js file to fix a behavioral quirk where TailwindCSS's init command automatically generates ESM syntax (export default {) when it detects "type": "module" in a project's package.json, even when targeting a .cjs configuration file.
The solution implements a simple string replacement that converts the generated ESM export syntax back to CommonJS (module.exports = {) after the Tailwind config file is created. This ensures that Cedar's .cjs configuration files maintain proper CommonJS syntax regardless of whether the project is configured for ESM or CJS modules.
This change fits into Cedar's broader ESM preparation work (referenced as part of #349) and maintains the framework's consistent approach of using .cjs files for configuration that need to work across both module systems. The fix is surgical and targeted, only affecting the specific case where TailwindCSS generates incompatible syntax, while preserving all other functionality of the Tailwind setup process.
Confidence score: 5/5
- This PR is safe to merge with minimal risk as it addresses a specific compatibility issue with a simple, well-documented fix
- Score reflects the targeted nature of the change, clear problem identification, and proper solution that maintains backward compatibility
- No files require special attention as the change is isolated to a single handler with clear purpose and scope
1 file reviewed, no comments
The code comment explains this pretty well
This is part of the ESM prep work started in #349