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

feat: import assertions for genImport and genDynamicImport #34

Merged
merged 3 commits into from
Nov 9, 2022

Conversation

kazupon
Copy link
Contributor

@kazupon kazupon commented Nov 5, 2022

motivation

In @nuxtjs/i18n, we need to import i18n resources such as JSON.
nuxt-modules/i18n#1518 (comment)

implementation

This PR is implemented with { assert?: { type: string } } of CodegenOptions.
Ideally, the arguments of functions such as genImport should be implemented with a few more changes as defined in the tc39 spec.
https://tc39.es/proposal-import-assertions/

However, that would be a breaking change since it would change the interface, and it would affect the nuxt3 release schedule. so we are implementing it this way.

@@ -29,6 +29,7 @@
"devDependencies": {
"@nuxtjs/eslint-config-typescript": "latest",
"c8": "latest",
"@vitest/coverage-c8": "latest",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@codecov
Copy link

codecov bot commented Nov 5, 2022

Codecov Report

Merging #34 (aec1309) into main (dcbd7e5) will increase coverage by 95.55%.
The diff coverage is 100.00%.

@@            Coverage Diff            @@
##           main      #34       +/-   ##
=========================================
+ Coverage      0   95.55%   +95.55%     
=========================================
  Files         0        7        +7     
  Lines         0      225      +225     
  Branches      0       72       +72     
=========================================
+ Hits          0      215      +215     
- Misses        0       10       +10     
Impacted Files Coverage Δ
src/esm.ts 95.28% <100.00%> (ø)
src/types.ts 100.00% <100.00%> (ø)
src/string.ts 83.33% <0.00%> (ø)
src/object.ts 96.96% <0.00%> (ø)
src/index.ts 100.00% <0.00%> (ø)
src/utils.ts 100.00% <0.00%> (ø)
src/typescript.ts 97.50% <0.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

src/esm.ts Outdated Show resolved Hide resolved
src/esm.ts Outdated Show resolved Hide resolved
@pi0 pi0 changed the title feat: import assertions feat: import assertions for genImport and genDynamicImport Nov 9, 2022
Copy link
Member

@pi0 pi0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks 💯

@pi0 pi0 merged commit 71c4ad2 into unjs:main Nov 9, 2022
@kazupon kazupon deleted the feat/import-assertions branch November 9, 2022 10:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants