nodejs icon indicating copy to clipboard operation
nodejs copied to clipboard

fix: fixed esm loader issue for node v18.19.0 and above

Open aryamohanan opened this issue 11 months ago • 0 comments

We've enabled ESM support for all Node.js versions. Starting from version 20.6, ESM loaders are off-threaded, loaded in separate thread, whereas previously we were loading our Instana collector in loader, so the change broke existing implementation. To address this, we introduced --import flag instead of the deprecated --experimental-loader, allowing the collector to be loaded in the main thread. However, --import is only available in v18.19 and later, so both styles are maintained for different Node.js versions.

We're still working on implementing native ESM support, which will be addressed in ref 117183.

To enable experimental ESM support, use the following command:

For Node.js versions greater than or equal to 18.19:

node --import /path/to/instana/node_modules/@instana/collector/register.mjs entry-point

For Node.js versions less than 18.19:

node --experimental-loader /path/to/instana/node_modules/@instana/collector/esm-loader.mjs entry-point

References:

Move ESM loaders off-thread

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

Note : Node 18.19 also have this issue, because its back-ported

Tasks

  • [x] loaders are off threaded!
  • [x] experimental-loader flag deprecated
  • [x] support all Node.js versions above 18.19
  • [x] run all unit testcases

aryamohanan avatar Mar 04 '24 07:03 aryamohanan