typescript-declaration-webpack-plugin icon indicating copy to clipboard operation
typescript-declaration-webpack-plugin copied to clipboard

Combine only typings that are part of the bundle

Open kacpak opened this issue 7 years ago • 2 comments

Hi, correct me if I'm wrong, but this merges all typings generated by build. I think those are generated for all typescript files in directory. Would it be possible to merge only those that were touched by webpack?

So assume that I build 2 packages from 1 source. One has entry a, other has entry a and b. Both of them would provide the same typings even though the first one has only partial functionality.

You think this could be improved? Or does this plugin already do this (I wasn't able to test it yet)? Or maybe ts-loader changed it's behavior and I missed that :P Then please ignore me :)

kacpak avatar Sep 05 '18 12:09 kacpak

Hi there, currently this plugin is merging all typings generated by ts-loader. The Problem is that ts-loader is generating typings for the full source, regardless if it's touched or not.

In case of your example, yes both of them would have identical typings.

I have planned to solve this issue in the future, when I have some time to spare for this project. In the meantime I don't think there is a solution for this problem :/

chitter99 avatar Sep 07 '18 11:09 chitter99

My assumption here is that the first step could be just removing export keyword in front of everything, that is not exported from entry point. Or in other words removing exports from every file which is not entry point before merging them.

This will probably mean, that declaration file will contain some redundant types, but I would say it does not matter that much.

I am wondering how hard this is.

gyzerok avatar Apr 30 '21 10:04 gyzerok