StyLua
StyLua copied to clipboard
Add ESM support to WASM package
Summary
This PR adds proper ES Module (ESM) support to the WASM package while maintaining full backwards compatibility with CommonJS. The package now works seamlessly in both module systems without requiring any changes from existing users.
Changes
- Dual module support: The package now generates both
.cjs(CommonJS) and.mjs(ESM) files from a single source - Build process improvements: Updated the build script to use Rollup for generating both module formats
- Simplified exports: Uses standard Node.js export conditions (
require/import) that work across all environments - Type definitions: Single TypeScript definition file that works for both module systems
Technical Details
The implementation uses Rollup to transform a single ESM source file into both CommonJS and ESM outputs. This ensures consistency between the two formats and reduces maintenance burden. The WASM module is automatically initialized when imported, making the API identical for both module systems.