Skip to content

Allow option to omit empty JS and map files from output. #22864

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

Closed
electricessence opened this issue Mar 25, 2018 · 3 comments
Closed

Allow option to omit empty JS and map files from output. #22864

electricessence opened this issue Mar 25, 2018 · 3 comments
Labels
Duplicate An existing issue was already created

Comments

@electricessence
Copy link

Files/modules that only contain interfaces, declarations, or type aliases (no real JS code) still produce *.js files.

One previous solution was to name all interface only files to *.d.ts and subsequently no JS file was generated, BUT neither is a copy of the *.d.ts file in the output directory. Therefore a second task had to be added to copy these files.

Another solution would be to keep all files as *.ts but find and delete empty files but this is tedious and difficult if you have header comments and source maps.

Optimally, *.ts files that simply do not contain any usable/importable JS (totally empty except comments) should have the option to be omitted from output.

@jwbay
Copy link
Contributor

jwbay commented Mar 25, 2018

There's some discussion about this in #10908.

@electricessence
Copy link
Author

@jwbay thanks. I couldn't find the respective one. We can close this and reopen that.

I know there's "potential" side effects for having a module missing. But the compiler doesn't reference other modules if there's nothing used. It's not a huge issue in the end because it won't end up being used by either a module loader or included in bundles that have tree shaking. It's just more optimal that the TS compiler provide this feature than having to read the AST file and then delete offending files. :/

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Mar 26, 2018
@RyanCavanaugh
Copy link
Member

We won't be adding this behavior; more complex build toolchains are widely available for customizing the exact emit policy.

@microsoft microsoft locked and limited conversation to collaborators Jul 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

3 participants