Skip to content

Commit 4c18a20

Browse files
committed
fix(nodejs): register import in the middle for nodejs24.x runtime
1 parent 5acc437 commit 4c18a20

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

nodejs/packages/layer/src/loader.mjs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,16 @@ export function registerLoader() {
7676
}
7777
}
7878

79-
if (_isHandlerAnESModule()) {
79+
function _getNodeRuntimeVersion() {
80+
const executionEnv = process.env.AWS_EXECUTION_ENV || '';
81+
const match = executionEnv.match(/nodejs(\d+)\.x/);
82+
if (!match) {
83+
return undefined;
84+
}
85+
return Number(match[1]);
86+
}
87+
88+
if (_isHandlerAnESModule() || _getNodeRuntimeVersion() >= 24) {
8089
/*
8190
We could activate ESM loader hook of the "import-in-the-middle" library,
8291
- by "--loader=import-in-the-middle/hook.mjs" Node CLI option, but "--loader" option has been deprecated

0 commit comments

Comments
 (0)