From 839386ca6cb852638f9899949aee62e4fa0d7944 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9F=A7=91=F0=9F=8F=BB=E2=80=8D=F0=9F=92=BB=20Romain=20M?= =?UTF-8?q?arcadier?= Date: Thu, 9 Jun 2022 13:07:55 +0200 Subject: [PATCH] fix: @jsii/check-node crashes on loading with older node releases It was built with ES2020 target, which fails to load with Node 10 and 12 as it makes use of the ?? syntax, which is not available in those releases. Changing the TypeScript target so that code continues to load in older node releases. --- packages/@jsii/check-node/src/constants.ts | 2 -- packages/@jsii/check-node/tsconfig.json | 9 +++++++-- packages/@jsii/runtime/webpack.config.js | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/@jsii/check-node/src/constants.ts b/packages/@jsii/check-node/src/constants.ts index d91a0d794c..7cf2cc1953 100644 --- a/packages/@jsii/check-node/src/constants.ts +++ b/packages/@jsii/check-node/src/constants.ts @@ -27,8 +27,6 @@ export class NodeRelease { // Past end-of-life releases new NodeRelease(13, { endOfLife: new Date('2020-06-01') }), new NodeRelease(15, { endOfLife: new Date('2021-06-01') }), - - // Deprecated releases new NodeRelease(12, { endOfLife: new Date('2022-04-30'), supportedRange: '^12.7.0', diff --git a/packages/@jsii/check-node/tsconfig.json b/packages/@jsii/check-node/tsconfig.json index 9ffe2e5dea..b7e5c54869 100644 --- a/packages/@jsii/check-node/tsconfig.json +++ b/packages/@jsii/check-node/tsconfig.json @@ -1,9 +1,14 @@ { "extends": "../../../tsconfig-base", "compilerOptions": { + "target": "es2018", // Needs to target older releases of node or else it'll crash on start when using those "outDir": "./lib", "rootDir": "./src", }, - "include": ["src/**/*.ts"], - "exclude": ["jest.config.ts"], + "include": [ + "src/**/*.ts" + ], + "exclude": [ + "jest.config.ts" + ], } diff --git a/packages/@jsii/runtime/webpack.config.js b/packages/@jsii/runtime/webpack.config.js index 12366cf655..81ebe00e7b 100644 --- a/packages/@jsii/runtime/webpack.config.js +++ b/packages/@jsii/runtime/webpack.config.js @@ -18,7 +18,7 @@ module.exports = { iife: false, }, devtool: 'source-map', - target: 'node14.5', + target: 'node12', // Continue to target node 12 so that check-node does not fail to load on it. node: { global: false, __filename: false,