-
Notifications
You must be signed in to change notification settings - Fork 825
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat!: Update node to 22 #14079
base: dev
Are you sure you want to change the base?
feat!: Update node to 22 #14079
Conversation
cwd: process.cwd(), | ||
env: process.env, | ||
stdio: 'inherit', | ||
shell: isWin ? true : undefined, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using shell: true
is required in latest versions of node (all LTS lines) to run .cmd
files on Windows.
@@ -152,7 +153,7 @@ const createCustomResource = ( | |||
): void => { | |||
const triggerCode = fs.readFileSync(authTriggerAssetFilePath, 'utf-8'); | |||
const authTriggerFn = new lambda.Function(stack, 'authTriggerFn', { | |||
runtime: lambda.Runtime.NODEJS_18_X, | |||
runtime: new lambda.Runtime('nodejs22.x', RuntimeFamily.NODEJS, { supportsInlineCode: true }), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Node 22 is not available as enum in currently used version of CDK.
This is a workaround recommended here https://github.com/aws/aws-cdk/blob/8b472fc5a68c2c83349dbfc11fa502f08d0bd5c8/packages/aws-cdk-lib/aws-lambda/lib/runtime.ts#L50-L51 .
// as they bundle AWS SDK v2. This mechanism isn't viable to upgrade to nodejs18.x | ||
// as that version bundles AWS SDK v3 which is not compatible. | ||
const lambdaRuntimeVersion = 'nodejs16.x'; | ||
const previousLambdaRuntimeVersions = ['nodejs18.x']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the pre-18 runtimes are long gone. So we can move the baseline in this file at this point.
const fileContents = fs.readFileSync(awsExportsPath, 'utf-8'); | ||
// transpile the file contents to CommonJS | ||
const { code } = transformSync(fileContents, { | ||
plugins: [babelTransformEsmToCjs], | ||
configFile: false, | ||
babelrc: false, | ||
}); | ||
const mod = new Module('aws-exports.js'); | ||
// @ts-expect-error This is private api. | ||
mod._compile(code, 'aws-exports.js'); | ||
mod.paths = [projectRoot]; | ||
return mod.exports; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The esm
3rd party package that was used here before causes V8 to crash with segfault.
I have replaced this with solution borrowed from here
amplify-cli/packages/amplify-frontend-javascript/lib/frontend-config-creator.js
Lines 286 to 299 in 2ce4283
const fileContents = fs.readFileSync(targetFilePath, 'utf-8'); | |
try { | |
// transpile the file contents to CommonJS | |
const { code } = babel.transformSync(fileContents, { | |
plugins: [babelTransformEsmToCjs], | |
configFile: false, | |
babelrc: false, | |
}); | |
const mod = new Module(); | |
mod._compile(code, 'aws-exports.js'); | |
// add paths to the module to account for node_module imports in aws-exports.js (should there be any) | |
mod.paths = [projectPath]; | |
// the transpiled result will contain `exports.default` | |
awsExports = mod.exports?.default || mod.exports; |
Description of changes
This PR:
pkg
/pkg-fetch
withyao-pkg/pkg
. Theyao-pkg/pkg
is actively developed fork of archivedpkg
project.node22
binaries when producing CLI binaryCompanion PR: #14078
Issue #, if available
Description of how you validated changes
Obtained passing e2e run.
Checklist
yarn test
passesBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.