-
-
Notifications
You must be signed in to change notification settings - Fork 21
Open
Description
Background
Currently, Hasty Server supports both CommonJS (require()) and ES Modules (import) module systems. While this dual support is helpful for compatibility, maintaining both systems increases complexity and goes against the Node.js ecosystem's direction towards ES Modules as the standard.
Current State
- The project currently supports both module systems
- Package can be imported using both
require()andimport - Examples in documentation show both syntaxes
- No clear preference is indicated in the documentation
Proposed Changes
-
Package Structure Updates:
- Convert all source files to use
.mjsextension - Update
package.jsonto include"type": "module" - Remove CommonJS-specific code paths
- Convert all source files to use
-
Documentation Updates:
- Update all code examples to use ES Module syntax
- Add migration guide for users moving from CommonJS
- Update installation and usage instructions
-
Implementation Details:
- Replace
module.exportswithexport default - Convert any
require()calls toimportstatements - Update test files to use ES Module syntax
- Implement proper error messages for CommonJS usage attempts
- Replace
Benefits
- Aligned with Node.js future direction
- Simplified codebase maintenance
- Better tree-shaking support
- Cleaner syntax and improved developer experience
- Better compatibility with modern JavaScript tools and bundlers
Breaking Changes
This will be a breaking change requiring a major version bump:
- Users will need to update their import statements
- Projects using CommonJS will need to migrate
- Minimum Node.js version requirement may need to be updated
Implementation Plan
- Create new branch for ES Module migration
- Update source files one at a time
- Update tests to ensure functionality remains intact
- Update documentation and examples
- Create comprehensive migration guide
- Release as major version update (e.g., v1.0.0)
Questions to Consider
- What should be the minimum supported Node.js version?
- Should we provide a transition period with both systems?
- How can we best support users during migration?
Would appreciate feedback on this proposal, especially regarding the implementation plan and transition strategy.
Metadata
Metadata
Assignees
Labels
No labels