-
Notifications
You must be signed in to change notification settings - Fork 140
Open
Labels
Description
- Related issues: Migrate TypeScript Output from CommonJS (CJS) to ES Modules (ESM) - Epic #2615
- What is the area that this feature belongs to: Code Maintainence
TLDR: Migrate all core files to TypeScript to faciliate future switch from CommonJS (require/module.exports) to ESM (import/export) for consistency, type safety, and modern dependency support.
Is your feature request related to a problem? Please describe.
Currently, in #1913 we migrated the core package and most of its associated files to TypeScript, but left the files under lib/markdown-it/plugins as .js using CommonJS (require/module.exports).
Reasons to migrate these plugins to TypeScript now
-
Uniformity and consistency
- The rest of the core package is now TypeScript. Keeping these plugins in JS breaks consistency and makes the codebase harder to maintain.
-
ESM interoperability
- Some modern dependencies are ESM-only. Migrating plugins to TypeScript (and using
import/export) facilitates smooth interop without relying on workarounds like dynamicimport()or mixed module handling.
- Some modern dependencies are ESM-only. Migrating plugins to TypeScript (and using
-
Type safety and better tooling
- TypeScript provides static type checking, IDE auto-completion, and easier refactoring. Migrating these plugins improves developer experience and reduces the risk of runtime errors.
-
Future-proofing
- As Node.js and modern tooling increasingly favor ESM, converting these plugins now reduces future migration pain and ensures compatibility with upcoming libraries and tooling
-
Dependency updates
- Some plugins rely on older JS-only versions of dependencies (e.g.,
htmlparser2v3). Migrating to TypeScript allows us to upgrade to newer versions that include types and ESM support, improving maintainability and ecosystem compatibility.
- Some plugins rely on older JS-only versions of dependencies (e.g.,
Proposed plan
- Convert
lib/markdown-it/plugins/*.js→*.ts. - Replace
require/module.exportswithimport/export. - Add TypeScript types where applicable.
- Update associated test files to
.tsif necessary. - Upgrade plugin dependencies to their latest ESM/TypeScript-compatible versions.
Impact
- No functional change; purely a migration for consistency, type safety, ESM interoperability, and future compatibility.
Describe the solution you'd like
Do the necessary
Describe alternatives you've considered
No response
Additional context
No response
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Discussion