jashkenas / jashkenas/coffeescript
feat: CoffeeScript ESM loader
- Dominant language
- CoffeeScript
- Stars
- 16.6k
- Forks
- 2k
- PR merge metrics
- No merged PRs in 30d
Description
## Request type
feature
## Description
ESM support in the latest Node.js version induce a new loading mechanism. Instead of the current `register` strategy, a [Node.js ESM loader](https://nodejs.org/api/esm.html#loaders) must be provided. I couln't find one yet available for CoffeeScript.
## Context
While converting some of my packages to ES modules, I had to update the Mocha.js arguments used in the unit tests to no longer use `--require coffeescript/register` but `--loader my-coffee-esm-loader` instead. I search through the repository but I couldn't fine one. There are some good examples such as nodejs/node#36396 and the official Node.js doc on [ESM transpiler loader](https://nodejs.org/api/esm.html). You can see it in action in the [CSV parser](https://github.com/adaltas/node-csv/blob/4958529c229ff0188a187c15e76e32f0adfe43c3/packages/csv-parse/test/loaders/coffee.js).
This is in the context of Mocha but the same apply with Node.js since the `--loader` argument of Mocha is a Node.js one.
While the traditional CommonJS way to activate CoffeeScript was `node --require coffeescript/register ...`, the ESM counterpart is now `node --loader my-coffee-esm-loader ...`.
## Proposal
Would you be interested to include an _official_ Node.js ESM loader in this package, or would you rather me publish an external package ? It wouldn't take long to prepare a pull request, the code is just a few lines and heavily inspired from nodejs/node#36396.
Contributor guide
Research direction
Start with the Node.js ESM loader documentation and the linked CSV parser loader example, then compare them with the current `coffeescript/register` entry point used by Mocha unit tests. Confirm that the proposed loader can replace `--require coffeescript/register` with `--loader` for CoffeeScript ES modules, and validate it through the affected unit-test invocation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- coffeescript, node.js
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100