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

Packages re-exported under different name through typescript module declaration #746

Open
allista opened this issue Aug 1, 2024 · 1 comment
Labels
feature request Feature request

Comments

@allista
Copy link

allista commented Aug 1, 2024

Reproduction url

https://codesandbox.io/p/devbox/gq2qss?file=%2Fremotes.d.ts

Description of the issue

We're using module federation and import from remote containers at run time.
To provide type safety, we use types from the packages that provide remote containers, and re-export those types through typescript module declaration, so that the types match the names of federated containers as defined in federation configuration:

// This module name is used in module federation configuration
declare module "@my/remote-container" {
  // This is a type-only re-export from a package that
  // provides a remote container from module federation
  export * from "actual-remote-container-package";
}

In another file:

// This import works in real setup only at runtime,
// because it refers to a remote container from module federation
import {SomeThing} from '@my/remote-container';

SomeThing.foo();

With this setup knip reports both the package used to export types from under declare module as "Unused" and the import from the declared module as "Unlisted":

> knip

Unused devDependencies (1)
actual-remote-container-package  package.json
Unlisted dependencies (1)
@my/remote-container  index.ts
@allista allista added the bug Something isn't working label Aug 1, 2024
@webpro
Copy link
Collaborator

webpro commented Aug 1, 2024

Thanks @allista, this is indeed an yet unsupported feature.

FYI, at this point I'm not implementing new features so for now you could use the ignore* options (which can be regexes if that's useful).

@webpro webpro added feature request Feature request and removed bug Something isn't working labels Aug 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Feature request
Projects
None yet
Development

No branches or pull requests

2 participants