Apologies if this is already discussed somewhere e...
# javascript
s
Apologies if this is already discussed somewhere else, but when I use
per-module
output granularity, is there a way to generate typescript files per module?
e
What's the use case btw? I definitely understand it for
per-file
, but I don't see it as useful for
per-module
.
s
We support 3-4 different JS teams. We publish maven artifacts for each of our modules. Each team has their own “umbrella” repo where they import the modules they care about (at the versions they care about) and publish a single node module. Currently each of these projects uses commonjs, but we would like to start using code splitting for the different modules, so we want to move to es. For codesplitting to be effective, we’d need each submodule to have its own typescript module so that we can do:
Copy code
import { Foo } from 'umbrella/submoduleA'
and in a different part of the app:
Copy code
import { Bar } from 'umbrella/submoduleB'
Right now the only way to do this with typescript support is to expose all of `umbrella and do:
Copy code
import { Foo } from 'umbrella'
The trouble with publishing separate npm modules for each submodule is that the transitive dependencies get duplicated, with no good way to de-dupe them (we could maybe write a script to just delete files, but that feels quite hacky).
e
I feel like it's a good use case, thanks for expanding on it. Could you post it in the issue too? For tracking purposes and to revive it.
s
I can! Is the one you posted the right one? I see there’s another more recent one assigned to @Artem Kobzar. https://youtrack.jetbrains.com/issue/KT-71495/KJS-es2015-only-one-typescript-file-generated
e
There are multiple issues related to the problem. I tend to pick the most upvoted one, or the recently updated one, generally. The one you linked seems specific to ES2015+, while the other one does not mention a module system. But I feel like the issues that are about per-module should be unified into a single one.
s
Ok, I’ll add it to the one you linked since that has the most upvotes.