From b16134b91f5d3e3be41563508f43065bafa75d15 Mon Sep 17 00:00:00 2001 From: Shrujal Shah Date: Thu, 21 Oct 2021 10:29:42 +0530 Subject: [PATCH] update version checks for v16 (#1522) * update version checks for v16 Ref: https://github.com/nodejs/node/pull/40504 * add test to check old ESM Loader Hooks API on v16.11.1 * fix wrong version number --- .github/workflows/continuous-integration.yml | 15 +++++++++++---- src/esm.ts | 4 ++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index bc954cd9e..4bd5898c5 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -48,7 +48,7 @@ jobs: matrix: os: [ubuntu, windows] # Don't forget to add all new flavors to this list! - flavor: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] + flavor: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] include: # Node 12.15 # TODO Add comments about why we test 12.15; I think git blame says it's because of an ESM behavioral change that happened at 12.16 @@ -94,26 +94,33 @@ jobs: typescript: next typescriptFlag: next # Node 16 + # Node 16.11.1 + # Earliest version that supports old ESM Loader Hooks API: https://github.com/TypeStrong/ts-node/pull/1522 - flavor: 8 + node: 16.11.1 + nodeFlag: 16_11_1 + typescript: latest + typescriptFlag: latest + - flavor: 9 node: 16 nodeFlag: 16 typescript: latest typescriptFlag: latest downgradeNpm: true - - flavor: 9 + - flavor: 10 node: 16 nodeFlag: 16 typescript: 2.7 typescriptFlag: 2_7 downgradeNpm: true - - flavor: 10 + - flavor: 11 node: 16 nodeFlag: 16 typescript: next typescriptFlag: next downgradeNpm: true # Node nightly - - flavor: 11 + - flavor: 12 node: nightly nodeFlag: nightly typescript: latest diff --git a/src/esm.ts b/src/esm.ts index 5502d0155..35bca748a 100644 --- a/src/esm.ts +++ b/src/esm.ts @@ -54,10 +54,10 @@ export function createEsmHooks(tsNodeService: Service) { }); // The hooks API changed in node version X so we need to check for backwards compatibility. - // TODO: When the new API is backported to v12, v14, v16, update these version checks accordingly. + // TODO: When the new API is backported to v12, v14, update these version checks accordingly. const newHooksAPI = versionGteLt(process.versions.node, '17.0.0') || - versionGteLt(process.versions.node, '16.999.999', '17.0.0') || + versionGteLt(process.versions.node, '16.12.0', '17.0.0') || versionGteLt(process.versions.node, '14.999.999', '15.0.0') || versionGteLt(process.versions.node, '12.999.999', '13.0.0');