Skip to content

Is it possible to preserve unused imports that aren't types? #1134

@ryanatkn

Description

@ryanatkn

Question

In upgrading from 1.2.28 to 1.2.35 I'm running into a problem for my use case which requires unused imports to be preserved. This seems to have changed with the import stripping functionality in PRs #1060 and #1101. I looked through the docs, issues/PRs, and briefly the code (I know only a little Rust), and couldn't find an answer - sorry if it's obvious. :)

Is import_not_used_as_values/strip::ImportNotUsedAsValues exposed as an option? I was unable to figure out how to test with different values.

My use case is using swc to preprocess the TypeScript in Svelte files. Svelte combines JS/TS with an HTML-like templating language in the same file, so imports are often not referenced in the code given to swc. The behavior in 1.2.28 has worked for what I need, except sometimes I've had to use import type.

Thank you! I really love this project.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions