You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ESM support in the latest Node.js version induce a new loading mechanism. Instead of the current register strategy, a Node.js ESM loader 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. You can see it in action in the CSV parser.
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.
The text was updated successfully, but these errors were encountered:
As you can see in its README, at least when I wrote it it didn’t work for imports of CommonJS files. That’s why I didn’t propose it over here, as just about any project has some CommonJS imports (maybe not of first-party code, but of dependencies). But perhaps this can be addressed? Clearly other projects like ts-node have shipped loaders using the current API, so maybe there’s a way around this limitation.
If you’d like to open a PR here to add a CoffeeScript loader, I would ask that:
It be written in CoffeeScript and compiled into lib like everything else, ideally without requiring a new cake command. It could be part of the main codebase like register is.
You try to solve the “imports of CommonJS” issue. If there’s no workaround, we would need to document this as a prominent known issue.
You find a way to test it. I think this would probably involve spawning a Node child process that can take the loader as a --loader argument.
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 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. You can see it in action in the CSV parser.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 nownode --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.
The text was updated successfully, but these errors were encountered: