Skip to content
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

Add support for import assertions #746

Merged
merged 2 commits into from Sep 15, 2022
Merged

Conversation

alangpierce
Copy link
Owner

Fixes #744
Fixes #566

In ESM mode, we parse import assertions and usually just pass them through to the output code, though TS import elision needs to know how to remove them as well.

In CJS mode, we always remove import assertions since require can handle JSON files.

Fixes #744
Fixes #566

In ESM mode, we parse import assertions and usually just pass them through to
the output code, though TS import elision needs to know how to remove them as
well.

In CJS mode, we always remove import assertions since `require` can handle JSON
files.
@codecov
Copy link

codecov bot commented Sep 14, 2022

Codecov Report

Merging #746 (295cee3) into main (0ae8d9b) will increase coverage by 0.08%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #746      +/-   ##
==========================================
+ Coverage   87.43%   87.51%   +0.08%     
==========================================
  Files          54       55       +1     
  Lines        5856     5887      +31     
  Branches     1389     1394       +5     
==========================================
+ Hits         5120     5152      +32     
  Misses        466      466              
+ Partials      270      269       -1     
Impacted Files Coverage Δ
src/parser/tokenizer/readWordTree.ts 100.00% <ø> (ø)
src/TokenProcessor.ts 95.16% <100.00%> (+0.37%) ⬆️
src/parser/tokenizer/keywords.ts 100.00% <100.00%> (ø)
src/parser/traverser/statement.ts 83.58% <100.00%> (+0.13%) ⬆️
src/transformers/CJSImportTransformer.ts 88.55% <100.00%> (+0.14%) ⬆️
src/transformers/ESMImportTransformer.ts 94.87% <100.00%> (+0.75%) ⬆️
src/util/removeMaybeImportAssertion.ts 100.00% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@github-actions
Copy link

github-actions bot commented Sep 14, 2022

Benchmark results

Before this PR: 392.1 thousand lines per second
After this PR: 394.8 thousand lines per second

Measured change: 0.7% faster (0.36% slower to 1.18% faster)
Summary: Likely no significant difference

@alangpierce alangpierce merged commit fb4c1c4 into main Sep 15, 2022
@alangpierce alangpierce deleted the support-import-assertions branch September 15, 2022 06:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant