diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0e73fc8..2fb1e23 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,7 +15,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - node-version: [ 16.x, 18.x, 20.x ] + node-version: [ 16.x, 18.x, 20.x, 22.x ] os: [ windows-latest, ubuntu-latest, macOS-latest ] # Go diff --git a/changelog.md b/changelog.md index 36e8d5c..910e61a 100644 --- a/changelog.md +++ b/changelog.md @@ -2,6 +2,14 @@ --- +## [4.0.6] 2025-01-17 + +### Changed + +- Add support for new ESM-only import error message when importing plugins in Node.js 22; thanks @lpsinger! + +--- + ## [4.0.5] 2024-04-29 ### Changed diff --git a/package.json b/package.json index 223cc91..24b288c 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "@architect/utils": "~4.0.6", "@aws-lite/client": "^0.21.1", "@aws-lite/ssm": "^0.2.3", - "lambda-runtimes": "~2.0.2" + "lambda-runtimes": "~2.0.5" }, "devDependencies": { "@architect/eslint-config": "~3.0.0", diff --git a/src/config/pragmas/plugins.js b/src/config/pragmas/plugins.js index 3e304be..3594856 100644 --- a/src/config/pragmas/plugins.js +++ b/src/config/pragmas/plugins.js @@ -21,6 +21,9 @@ module.exports = async function getPluginModules ({ arc, inventory, errors }) { if (arc?.plugins?.length) tagPlugins(arc.plugins, 'plugin') if (arc?.macros?.length) tagPlugins(arc.macros, 'macro') + let { node } = process.versions + let nodeVer = Number(node.split('.')[0]) + for (let pluginItem of pluginItems) { let { plugin, type } = pluginItem let name @@ -52,6 +55,9 @@ module.exports = async function getPluginModules ({ arc, inventory, errors }) { if (type === 'plugin') { try { plugins[name] = require(pluginPath) + if (nodeVer >= 22 && plugins[name].default) { + plugins[name] = plugins[name].default + } } catch (err) { if (hasEsmError(err)) { diff --git a/test/unit/src/config/pragmas/populate-lambda/get-runtimes-test.js b/test/unit/src/config/pragmas/populate-lambda/get-runtimes-test.js index b2b3514..ab1ee8d 100644 --- a/test/unit/src/config/pragmas/populate-lambda/get-runtimes-test.js +++ b/test/unit/src/config/pragmas/populate-lambda/get-runtimes-test.js @@ -31,7 +31,7 @@ test('Friendly runtime names (aka aliases)', t => { t.equal(config.runtimeAlias, 'java', `Alias returned lowcase as runtimeAlias: ${config.runtimeAlias}`) config = getRuntimes({ config: c('.net'), inventory }) - t.match(config.runtime, /dotnet7/, `Alias mapped to valid AWS .NET string: ${config.runtime}`) + t.match(config.runtime, /dotnet8/, `Alias mapped to valid AWS .NET string: ${config.runtime}`) t.equal(config.runtimeAlias, '.net', `Alias returned lowcase as runtimeAlias: ${config.runtimeAlias}`) config = getRuntimes({ config: c('custom'), inventory }) @@ -64,7 +64,7 @@ test('Exact runtime names', t => { t.equal(config.runtime, name, `Returned correct runtime string: ${name}`) t.notOk(config.runtimeAlias, 'Did not get runtimeAlias') - name = 'dotnet6' + name = 'dotnet8' config = getRuntimes({ config: c(name), inventory }) t.equal(config.runtime, name, `Returned correct runtime string: ${name}`) t.notOk(config.runtimeAlias, 'Did not get runtimeAlias')