Skip to content

Commit 04c0f60

Browse files
committed
chore: added warning
1 parent a5abd0b commit 04c0f60

File tree

7 files changed

+37
-1
lines changed

7 files changed

+37
-1
lines changed

packages/aws-fargate/esm-loader.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
'use strict';
66

77
/**
8+
* IMPORTANT: This file is deprecated, no longer supported, and will be removed in the next major release (v6).
9+
*
810
* IMPORTANT NOTE: From Node.js version 18.19 and above, the ESM loaders operate off-thread.
911
* Consequently, ESM instrumentation using '--experimental-loader' becomes deprecated.
1012
* Instead, we are using '--import' for loading instrumentation and relocated the Instana collector

packages/azure-container-services/esm-loader.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
'use strict';
66

77
/**
8+
* IMPORTANT: This file is deprecated, no longer supported, and will be removed in the next major release (v6).
9+
*
810
* IMPORTANT NOTE: From Node.js version 18.19 and above, the ESM loaders operate off-thread.
911
* Consequently, ESM instrumentation using '--experimental-loader' becomes deprecated.
1012
* Instead, we are using '--import' for loading instrumentation and relocated the Instana collector

packages/collector/esm-loader.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
'use strict';
66

77
/**
8+
* IMPORTANT: This file is deprecated, no longer supported, and will be removed in the next major release (v6).
9+
*
810
* IMPORTANT NOTE: From Node.js version 18.19 and above, the ESM loaders operate off-thread.
911
* Consequently, ESM instrumentation using '--experimental-loader' becomes deprecated.
1012
* Instead, we are using '--import' for loading instrumentation and relocated the Instana collector

packages/core/src/tracing/index.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,8 @@ exports.init = function init(_config, downstreamConnection, _processIdentityProv
183183
console.debug(`The App is using the following preload flags: ${preloadFlags}`);
184184
}
185185

186-
// Consider removing this in the next major release of the @instana package.
186+
// v18.19 and above usage of --experimental-loader flag no longer supported
187+
// TODO: Remove warnings in the next major release(v6)
187188
if (coreUtil.esm.hasExperimentalLoaderFlag()) {
188189
// eslint-disable-next-line no-console
189190
console.warn(
@@ -194,6 +195,20 @@ exports.init = function init(_config, downstreamConnection, _processIdentityProv
194195
'https://www.ibm.com/docs/en/instana-observability/current?topic=nodejs-collector-installation.'
195196
);
196197
}
198+
199+
// Warning for usage of the legacy 'esm-loader.mjs' file.
200+
// This loader worked with '--experimental-loader' in Node.js versions below 18.19.
201+
// TODO: Remove 'esm-loader.mjs' file and this warning in the next major release (v6).
202+
if (coreUtil.esm.hasEsmLoaderFile()) {
203+
// eslint-disable-next-line no-console
204+
console.warn(
205+
"Detected use of 'esm-loader.mjs'. This file is no longer supported and will be removed in next major release. " +
206+
"To ensure tracing by Instana, please use the 'esm-register.mjs' file instead. For more information, " +
207+
'refer to the Instana documentation: ' +
208+
'https://www.ibm.com/docs/en/instana-observability/current?topic=nodejs-collector-installation.'
209+
);
210+
}
211+
197212
config = _config;
198213
processIdentityProvider = _processIdentityProvider;
199214

packages/core/src/util/esm.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,17 @@ exports.hasExperimentalLoaderFlag = function hasExperimentalLoaderFlag() {
1616
);
1717
};
1818

19+
/**
20+
* Check if esm-loader.mjs is being used.
21+
* @returns {boolean} - True if esm-loader.mjs is present in Node options or execArgv, false otherwise.
22+
*/
23+
exports.hasEsmLoaderFile = function hasEsmLoaderFile() {
24+
return (
25+
(process.env.NODE_OPTIONS && process.env.NODE_OPTIONS.includes('esm-loader.mjs')) ||
26+
process.execArgv.some(arg => arg.includes('esm-loader.mjs'))
27+
);
28+
};
29+
1930
/**
2031
* Checks if the application is an ECMAScript Modules (ESM) app by inspecting
2132
* the presence of flags like --experimental-loader and --import in the environment.

packages/google-cloud-run/esm-loader.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
'use strict';
66

77
/**
8+
* IMPORTANT: This file is deprecated, no longer supported, and will be removed in the next major release (v6).
9+
*
810
* IMPORTANT NOTE: From Node.js version 18.19 and above, the ESM loaders operate off-thread.
911
* Consequently, ESM instrumentation using '--experimental-loader' becomes deprecated.
1012
* Instead, we are using '--import' for loading instrumentation and relocated the Instana collector

packages/serverless-collector/esm-loader.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
'use strict';
66

77
/**
8+
* IMPORTANT: This file is deprecated, no longer supported, and will be removed in the next major release (v6).
9+
*
810
* IMPORTANT NOTE: From Node.js version 18.19 and above, the ESM loaders operate off-thread.
911
* Consequently, ESM instrumentation using '--experimental-loader' becomes deprecated.
1012
* Instead, we are using '--import' for loading instrumentation and relocated the Instana collector

0 commit comments

Comments
 (0)