-
Notifications
You must be signed in to change notification settings - Fork 154
build(all): use es2019 target to support on Node12 #925
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
Conversation
const createCaptureAsyncFuncMock = function(provider: ProviderServiceInterface): CaptureAsyncFuncMock { | ||
return jest.spyOn(provider, 'captureAsyncFunc') | ||
.mockImplementation((methodName, callBackFn) => { | ||
const subsegment = new Subsegment(`### ${methodName}`); | ||
jest.spyOn(subsegment, 'flush').mockImplementation(() => null); | ||
callBackFn(subsegment); | ||
}); | ||
}; |
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.
Note to @dreamorosi
I found that we missed the case that the subsegment IS defined in our test. So I add this to get coverage back to 100%
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.
Thanks for the note and good spot.
strategy: | ||
matrix: | ||
version: [12, 14, 16] | ||
fail-fast: false | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: "Use NodeJS 16" | ||
- name: "Use NodeJS" | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '16' | ||
node-version: ${{ matrix.version }} | ||
- name: Install [email protected] |
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.
Some unit tests fail in NodeJS12, so I make use of matrix strategy here to make sure that we don't introduce any issue later.
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.
This is great!
Thanks for diving deep into this, I really really appreciate it.
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.
Great Job !
node 12 tests failing :/ |
@flochaz It should fail until we release a new version that supports node12. |
Ah yeah true :) |
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.
Description of your changes
See issue #899 on the bug description.
In target
es2020
, it support?.
so the TS transpiler will not transform this syntax.For example:
will be:
Previously, we have been building our packages on target
es2020
. When customers consume our modules, it will still have?.
. If customers use NodeJS12 (which ises2019
), it will throw an errorSyntaxError: 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.
?.
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 beundefined
in some case.crypto.randomUUID
that we use in e2e tests. So we have to adduuid
as adevDependency
Important note Notice that one of the
pr-lint-and-test
fails. This is intentional. I added the additional checks on NodeJS12 and NodeJS14. (We tested only on Node16). The failing one is Node12, and it fails onexamples/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.How to verify this change
Switch to NodeJS 12 and run all tests
Related issues, RFCs
#899
PR status
Is this ready for review?: YES
Is it a breaking change?: NO
Checklist
Breaking change checklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.