fix: use correct import attributes syntax #957
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🧰 Changes
(PR description stolen from readmeio/rdme#993)
TC39 updated their import assertions to be import attributes and it's a bit of a mess now that we're running tests against Node v22.
Here's what importing JSON in ESM used to look like:
now it looks like this:
Support for this new
with
keyword was added in Node v18.20.0 and Node v20.10.0 (and is supported on all v21 and v22 channels), but importantly the olderassert
keyword is not supported in Node v22, so unfortunately ourpackage.json#engines.node
field is going to look a little ridiculous for the time being.Details: https://github.com/tc39/proposal-import-attributes?tab=readme-ov-file#history
🧬 QA & Testing
Annoyingly, we don't have anything in our unit tests to catch this sort of thing at the moment because we have stuff like this:
api/packages/api/src/codegen/languages/typescript/index.ts
Lines 127 to 130 in 353cd8b
but I confirmed that Node v22 works again with this change. See the before:
And the after: