Announcing a newly written Typescript compiler that is a drop-in replacement for typescript and adornis:typescript.
Note that this is an early version, use at your own risk.
Source code here:
Key features:
- Obeys your tsconfig.json settings, but has only been tested with a few variations, most notably only with target and module set to “ESNext”, and overwrites a few obvious settings like “incremental” and “emit”.
- Uses the Typescript 3.6 createIncrementalProgram API to compile all ts sources at once, and keeps the incremental build support file in .meteor/local/.typescript-incremental so you can save it on your build server. That means that it’s pretty fast, unlike derivatives of barbatus:typescript.
- Shows compilation progress and diagnostics (type errors etc) using bright green and red letters to make you happy.
- Uses the core BabelCompiler for all the Babel stuff, just like the built-in typescript package.
- SourceMaps are supported.
- Written in Typescript (bootstrapped using the core typescript package)
I’ve tested the new compiler on a slightly modified meteor create --typescript
sample and on our own app which is semi- large (>500 typescript files) and it seems to work just fine.
Here are some things it doesn’t do yet:
- Filter out files from compilation based on meteor rules (.meteorignore etc) - you have to add these to the exclude filter in tsconfig.json
- Abort the compilation if there are type errors that prevent some js from being emitted. That would be a trivial change.
- The incremental compilation support seems a bit flaky - not sure if I’m using the API wrong or if there’s a bug. Sometimes it just recompiles everything from scratch.
- No unit tests. Yeah - I know…
- The “compiling” progress is actually “emit” progress. Does it matter?
I personally think it’s a good idea to keep this compiler outside of the meteor code package so it can be updated without locking it to a Meteor release - there really isn’t anything in there that uses any private Meteor internals (but it would be nice to use the Console package in meteor/tools if I could figure out how to access it).
I’d also be happy to put this under community ownership or if that doesn’t happen then get in touch and I can add you as a collaborator.
Install using
meteor add refapp:meteor-typescript