|
6 | 6 | 'use strict'; |
7 | 7 |
|
8 | 8 | const { isNodeJsTooOld, minimumNodeJsVersion } = require('@instana/core/src/util/nodeJsVersionCheck'); |
| 9 | +const { hasEsmLoaderFile, hasExperimentalLoaderFlag } = require('@instana/core/src/util/esm'); |
9 | 10 | const { isProcessAvailable } = require('@instana/core/src/util/moduleAvailable'); |
10 | 11 |
|
11 | 12 | if (!isProcessAvailable()) { |
@@ -34,6 +35,38 @@ if (isNodeJsTooOld()) { |
34 | 35 | return; |
35 | 36 | } |
36 | 37 |
|
| 38 | +// v18.19 and above usage of --experimental-loader flag no longer supported |
| 39 | +// TODO: Remove error log in the next major release(v6) |
| 40 | +if (hasExperimentalLoaderFlag()) { |
| 41 | + // eslint-disable-next-line no-console |
| 42 | + console.error( |
| 43 | + 'Node.js introduced breaking changes in versions 18.19.0 and above, leading to the discontinuation of support ' + |
| 44 | + `for the --experimental-loader flag by Instana. The current Node.js version is ${process.version} and` + |
| 45 | + 'this process will not be monitored by Instana. ' + |
| 46 | + "To ensure tracing by Instana, please use the '--import' flag instead. For more information, " + |
| 47 | + 'refer to the Instana documentation: ' + |
| 48 | + 'https://www.ibm.com/docs/en/instana-observability/current?topic=nodejs-collector-installation.' |
| 49 | + ); |
| 50 | + module.exports.default = function noOp() {}; |
| 51 | + // @ts-ignore TS1108 |
| 52 | + return; |
| 53 | +} |
| 54 | + |
| 55 | +// This loader worked with '--experimental-loader' in Node.js versions below 18.19. |
| 56 | +// TODO: Remove 'esm-loader.mjs' file and this log in the next major release (v6). |
| 57 | +if (hasEsmLoaderFile()) { |
| 58 | + // eslint-disable-next-line no-console |
| 59 | + console.error( |
| 60 | + "Detected use of 'esm-loader.mjs'. This file is no longer supported and will be removed in next major release. " + |
| 61 | + 'This process will not be monitored by Instana. ' + |
| 62 | + "To ensure tracing by Instana, please use the 'esm-register.mjs' file instead. For more information, " + |
| 63 | + 'refer to the Instana documentation: ' + |
| 64 | + 'https://www.ibm.com/docs/en/instana-observability/current?topic=nodejs-collector-installation.' |
| 65 | + ); |
| 66 | + module.exports.default = function noOp() {}; |
| 67 | + // @ts-ignore TS1108 |
| 68 | + return; |
| 69 | +} |
37 | 70 | let isMainThread = true; |
38 | 71 | try { |
39 | 72 | isMainThread = require('worker_threads').isMainThread; |
|
0 commit comments