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

typescripts "importsNotUsedAsValues" not honored #334

Closed
lucaelin opened this issue Apr 16, 2022 · 2 comments
Closed

typescripts "importsNotUsedAsValues" not honored #334

lucaelin opened this issue Apr 16, 2022 · 2 comments

Comments

@lucaelin
Copy link

lucaelin commented Apr 16, 2022

Hey hey, and thank you for all the great work!
I've stumbles upon an issue with the importsNotUsedAsValues option in typescript. This option is supposed to fix the need for duplicate import statements when importing a module with both a type export and side-effects, like defining a custom-element.
Without this option, typescript strips all import statements, that only import types. This also gets rid off any side-effects that would happen during the import, see https://www.typescriptlang.org/tsconfig#importsNotUsedAsValues .

Starting in v14, esbuild now aligns with behavior of tsc, see https://github.com/evanw/esbuild/releases/tag/v0.14.0 .

This plugin does not seem to honor the setting. I've created a demo project to show the difference in the build output with all three options: tsc, esbuild, and rollup-plugin-esbuild. You can find it here: https://github.com/lucaelin/preserveValueImports-test . I have not included @rollup/plugin-typescript, but it also follows the behavior of tsc.

Would I be possible to have this option honored using this plugin as well? Thanks!

Edit: Fix documentation URL

@lucaelin
Copy link
Author

I've only now realized that this can be fixed using the tsconfigRaw-option, which also requires removing the tsconfig-option and making sure the file is actually json-compatible to not require additional libraries...

I'll keep it open because this behavior wasn't intuitive to me and might still be worth implementing.

@sxzz
Copy link
Collaborator

sxzz commented Sep 20, 2023

Fixed in #370

@sxzz sxzz closed this as completed Sep 20, 2023
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

No branches or pull requests

2 participants