Skip to content

Commit 4854e2e

Browse files
ijemmydreamorosi
authored andcommitted
build(all): use es2019 target to support on Node12 (#925)
Switching to target 2019 to support Node12 Previously, we have been building our packages on target es2020. When customers consume our modules, it will still have ?.. If customers use NodeJS12 (which is es2019), it will throw an error SyntaxError: Unexpected token '.'. The . is the second character of ?. syntax. To fix this, we change all of the target to 2019. However, this cause a lot of breaks in our current code. 1. Branch coverage will drop as ?. is broken into a conditional statement. We need to add new test cases or tell TS that the value does exist by adding !. This is really case by case as the value cannot really be undefined in some case. 2. NodeJS12 doesn't have crypto.randomUUID that we use in e2e tests. So we have to add uuid as a devDependency This commit also adds the additional checks on NodeJS12 and NodeJS14. (We tested only on Node16). The failing one is Node12, and it fails on examples/sam package. This package uses the npm published version of our library. And it really should fail as the currently published library is target 2020. Once we publish a new version, this should be fixed automatically.
1 parent ef09f81 commit 4854e2e

31 files changed

+203
-93
lines changed

.github/workflows/pr_lint_and_test.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,16 @@ jobs:
77
runs-on: ubuntu-latest
88
env:
99
NODE_ENV: dev
10+
strategy:
11+
matrix:
12+
version: [12, 14, 16]
13+
fail-fast: false
1014
steps:
1115
- uses: actions/checkout@v3
12-
- name: "Use NodeJS 16"
16+
- name: "Use NodeJS"
1317
uses: actions/setup-node@v3
1418
with:
15-
node-version: '16'
19+
node-version: ${{ matrix.version }}
1620
- name: Install [email protected]
1721
run: npm i -g npm@next-8
1822
- name: "Setup npm"

.github/workflows/run-e2e-tests.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,14 @@ jobs:
4949
matrix:
5050
package: [logger, metrics, tracer]
5151
version: [12, 14, 16]
52+
fail-fast: false
5253
steps:
5354
- name: "Checkout"
5455
uses: actions/checkout@v3
55-
- name: "Use NodeJS 16"
56+
- name: "Use NodeJS"
5657
uses: actions/setup-node@v3
5758
with:
58-
node-version: 16
59+
node-version: ${{ matrix.version }}
5960
- name: "Install [email protected]"
6061
run: npm i -g npm@next-8
6162
- name: "Install monorepo packages"

examples/cdk/tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"compilerOptions": {
33
"experimentalDecorators": true,
44
"noImplicitAny": true,
5-
"target": "ES2020",
5+
"target": "ES2019",
66
"module": "commonjs",
77
"declaration": true,
88
"outDir": "lib",
@@ -22,7 +22,7 @@
2222
"watchDirectory": "useFsEvents",
2323
"fallbackPolling": "dynamicPriority"
2424
},
25-
"lib": [ "es2020" ],
25+
"lib": [ "es2019" ],
2626
"types": [
2727
"jest",
2828
"node"

examples/lambda-functions/tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"compilerOptions": {
33
"experimentalDecorators": true,
44
"noImplicitAny": true,
5-
"target": "ES2020",
5+
"target": "ES2019",
66
"module": "commonjs",
77
"declaration": true,
88
"declarationMap": true,
@@ -21,7 +21,7 @@
2121
"watchDirectory": "useFsEvents",
2222
"fallbackPolling": "dynamicPriority"
2323
},
24-
"lib": [ "es2020" ],
24+
"lib": [ "es2019" ],
2525
"types": [
2626
"node"
2727
]

examples/sam/src/tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"compilerOptions": {
33
"experimentalDecorators": true,
44
"noImplicitAny": true,
5-
"target": "ES2020",
5+
"target": "ES2019",
66
"module": "commonjs",
77
"declaration": true,
88
"declarationMap": true,
@@ -21,7 +21,7 @@
2121
"watchDirectory": "useFsEvents",
2222
"fallbackPolling": "dynamicPriority"
2323
},
24-
"lib": [ "es2020" ],
24+
"lib": [ "es2019" ],
2525
"types": [
2626
"node"
2727
]

examples/sam/tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"compilerOptions": {
33
"experimentalDecorators": true,
44
"noImplicitAny": true,
5-
"target": "ES2020",
5+
"target": "ES2019",
66
"module": "commonjs",
77
"declaration": true,
88
"declarationMap": true,
@@ -21,7 +21,7 @@
2121
"watchDirectory": "useFsEvents",
2222
"fallbackPolling": "dynamicPriority"
2323
},
24-
"lib": [ "es2020" ],
24+
"lib": [ "es2019" ],
2525
"types": [
2626
"node"
2727
]

package-lock.json

Lines changed: 86 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
"@types/aws-lambda": "^8.10.72",
5959
"@types/jest": "^27.4.0",
6060
"@types/node": "^17.0.8",
61+
"@types/uuid": "^8.3.4",
6162
"@typescript-eslint/eslint-plugin": "^5.12.1",
6263
"@typescript-eslint/parser": "^5.12.1",
6364
"archiver": "^5.3.0",
@@ -79,7 +80,8 @@
7980
"ts-node": "^10.0.0",
8081
"typedoc": "^0.22.11",
8182
"typedoc-plugin-missing-exports": "^0.22.6",
82-
"typescript": "^4.1.3"
83+
"typescript": "^4.1.3",
84+
"uuid": "^8.3.2"
8385
},
8486
"files": [
8587
"lib/**/*"

packages/commons/tsconfig-dev.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"compilerOptions": {
33
"experimentalDecorators": true,
44
"noImplicitAny": true,
5-
"target": "ES2020",
5+
"target": "ES2019",
66
"module": "commonjs",
77
"declaration": true,
88
"declarationMap": true,
@@ -23,7 +23,7 @@
2323
"watchDirectory": "useFsEvents",
2424
"fallbackPolling": "dynamicPriority"
2525
},
26-
"lib": [ "es2020" ],
26+
"lib": [ "es2019" ],
2727
"types": [
2828
"jest",
2929
"node"

packages/commons/tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"compilerOptions": {
33
"experimentalDecorators": true,
44
"noImplicitAny": true,
5-
"target": "ES2020",
5+
"target": "ES2019",
66
"module": "commonjs",
77
"declaration": true,
88
"declarationMap": true,
@@ -23,7 +23,7 @@
2323
"watchDirectory": "useFsEvents",
2424
"fallbackPolling": "dynamicPriority"
2525
},
26-
"lib": [ "es2020" ],
26+
"lib": [ "es2019" ],
2727
"types": [
2828
"jest",
2929
"node"

0 commit comments

Comments
 (0)