TypeScript refuses to emit files from node_modules with getEmitOutput()
See original GitHub issueHi. In out company we use workflow when all packages are written in pure TypeScript and we publish and consume them as-is, without any pre-compilation. I know that it’s slower, but it’s very convenient for developers, because they don’t need to run several parallel tsc --watch
processes.
We used webpack
and awesome-typescript-loader
for this and everything worked fine. But I see that now TypeScript refuses to emit files from node_modules
directory using getEmitOutput()
, because of isSourceFileFromExternalLibrary
check here.
Can we make this configurable?
Issue Analytics
- State:
- Created 7 years ago
- Reactions:12
- Comments:8 (3 by maintainers)
Top Results From Across the Web
import of library works in javascript file but fails in typescript file
I am trying to import a new module @microsoft/applicationinsights-web into my file test.ts . Unfortunately it says module not found even though ...
Read more >A Complete Guide to Using TypeScript in Node.js - Better Stack
We are currently set up to compile both JavaScript and TypeScript files, but type checking will not be performed on JavaScript files unless...
Read more >node_modules/typescript/lib/typescript.d.ts - Google Git
* Gets a type checker that can be used to semantically analyze source files in the program. */. getTypeChecker(): TypeChecker ...
Read more >TSConfig Reference - Docs on every TSConfig option
A TSConfig file in a directory indicates that the directory is the root of a TypeScript ... Other packages under node_modules/@types/* will not...
Read more >webpack/webpack - Gitter
getEmitOutput (/home/gchiara/desenvolvimento/webpack/node_modules/ ... What I think is happening is that typescript won't load any .js files because you ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Outside
node_modules
TypeScript emits.js
files for any.ts
files Iimport
, whether they’re listed underfiles
intsconfig.json
or not. This is very nice.I have a monorepo structured like boennemann/alle. It makes the monorepo very easy to work with, requiring minimal tooling. The trick is to place all code under
node_modules
so Node’s module lookup strategy will find them without having to create any symlinks.Unfortunately I’m running into this issue… Now it’s necessary to either omit
files
, list all of them or use a wildcard. In this case there would be a reasonable strategy: when a.ts
file included infiles
is located undernode_modules
then for any further.ts
files it imports from the same directory or a subdirectory (without entering any deepernode_modules
directories), a.js
file should still be emitted.Alternatively a configuration option in
tsconfig.json
listing paths where.js
files should be emitted, whether undernode_modules
or not, should fix this issue for everyone’s possible use cases.@jjrv said it right. At the moment in
ts-jest
, eitherts-jest
has to useProgram
as fallback or readjest
config to solve the issue. I hope TypeScript can solve this natively.