TheSwanFactory / hclang

Homoiconic C - a universal data format for computation
https://theswanfactory.wordpress.com/2016/12/20/homoiconic-c-a-universal-language-for-code-and-data/
MIT License
4 stars 0 forks source link

experimental-loader to register #169

Closed drernie closed 11 months ago

drernie commented 11 months ago

I just started getting a new version of this error all the time when I run mocha with TypeScript using ESM modules. Possibly due to using the latest node/npm.

Anyone else seeing this?

(node:38547) ExperimentalWarning: `--experimental-loader` may be removed in the future; instead use `register()`:
--
import 'data:text/javascript,
  import { register } from "node:module"; 
  import { pathToFileURL } from "node:url"; 
  register("ts-node/esm", pathToFileURL("./"));
'
--
(Use `node --trace-warnings ...` to show where the warning was created)
drernie commented 11 months ago

Possibly related to:

This team is spun off from the Modules team. We aim to implement the use cases that went unfulfilled by the initial ES modules implementation that can be achieved via loaders.

drernie commented 11 months ago

Current .mocharc.json

{
  "node-option": [
      "experimental-specifier-resolution=node",
      "loader=ts-node/esm"
  ],
  "url" : "https://stackoverflow.com/questions/64261239/mocha-tests-with-esm-support-for-native-es6-modules"
}
drernie commented 11 months ago

Can use: npx mocha "test/ops/*" --loader=ts-node/esm but still get warning.

drernie commented 11 months ago

First official notice I've seen that 'import' is replacing 'loader' in node:

https://github.com/nodejs/node/issues/44094

Is --loader going away?

Sorta, it's going off-thread – so if you use it to e.g. define a global variable, it will be defined on the loader thread global scope and won't be available in the REPL anymore – but once this land, --import would be available and a better fit for your use-case.

drernie commented 11 months ago

Some details about 'register' at: https://nodejs.org/api/module.html

drernie commented 11 months ago

Sample log file

ts-esm.txt

Proposed import

ts-esm-js.txt