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 of typescript alias paths to DtsPlugin #3363

Open
2 tasks done
NikaBuligini opened this issue Dec 16, 2024 · 3 comments
Open
2 tasks done

Add support of typescript alias paths to DtsPlugin #3363

NikaBuligini opened this issue Dec 16, 2024 · 3 comments

Comments

@NikaBuligini
Copy link
Contributor

Clear and concise description of the problem

As a developer using Module federation I want to be able to use TypeScript alias paths in my remote application so that I'm able to benefit from all of the things that come with alias paths in TypeScript like improved readability, simplified refactoring and in general a better developer experience.

I have projects using module federation for a long time. We have implemented a workaround for providing type support by generating type definitions and publishing them to npm. Later published type definitions are used in module federation consumer apps. These projects are using TypeScript alias paths and so far we haven't had a problem with that. We already migrated to Module federation 2.0 and now we are in a process of replacing the mentioned workaround with dts. Unfortunatelly, TypeScript alias paths are preventing us from moving forward.

Suggested solution

I looked into @module-federation/dts-plugin and I found out that a temporaty tsconfig file is being created based on a original tsconfig from the project before running tsc or vue-tsc for generating type declarations. I also see that only paths and baseUrl properties are being ignored from compilerOptions (here is a permalink). Then I found a comment mentioning that TypeScript compiler doesn't replace aliases, which is very much true.

There is an open source library tsc-alias that can replace alias paths with relative paths after typescript compilation. If you keep the existing alias path configuration from the original tsconfig and run tsc-alias -p path/to/temporary/tsconfig.json then it should replace aliases.

Alternative

No response

Additional context

I'm ready to contribute by opening a PR. I'm just not sure where tsc-alias should live. Right now tsc is used through npx, this means it is installed on a consumer side and it sounds reasonable to me. Should I assume that if alias paths are being configured in tsconfig consumer app has tsc-alias installed as well? So, I can use npx tsc-alias the same way.

Validations

  • Read the Contributing Guidelines.
  • Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
@zhoushaw
Copy link
Collaborator

@2heal1 Please help to deal with this problem

@zhoushaw
Copy link
Collaborator

@NikaBuligini Thank you for your question and we'll get back to you as soon as possible

@NikaBuligini
Copy link
Contributor Author

Hi @zhoushaw, do you have any updates on this?

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