vazco / universe-modules

Use ES6 / ES2015 modules in Meteor with SystemJS
https://atmospherejs.com/universe/modules
MIT License
52 stars 7 forks source link

Support for TypeScript? #17

Closed Gaelan closed 8 years ago

Gaelan commented 9 years ago

There is already a TypeScript compiler package for Meteor, meteortypescript:compiler. How hard would it be to integrate that with this project?

MacRusher commented 9 years ago

universe:modules uses Babel under the hood, and TypeScript is using it own conventer. See https://github.com/Microsoft/TypeScript/issues/1641 for more details.

Only idea that comes to my mind is to make TS emit ES2015 code and then pipe it into Babel. I'm afraid that this won't be a trivial task, but if you have some ideas on how this could be implemented we're open for pull requests.

I know that some people use universe:modules with TS, but i think that they're preprocessing .ts files into .import.js files. But there was some problems with new syntax for importing from packages. See https://github.com/vazco/universe-modules/issues/7 for more info.

Gaelan commented 9 years ago

@MacRusher Why couldn't you simply create a build plugin that uses the TypeScript compiler instead of Babel's? Does Universe depend on some aspect of Babel's generated code that Universe depends one?

MacRusher commented 9 years ago

@Gaelan Because that would actually require to rewrite package from scratch using only TypeScript. We're using Babel and SystemJS and this is a design decision.

I'm willing to support TypeScript, but only if maintain cost will be reasonable.

Meteor 1.2 will introduce new build plugin system that will be more flexible. IMHO best solution will be to pipe ES2015 output from some TypeScript package to our modules. This way we can keep this package clean and "source agnostic" and let all TS related work to specialized package.

Gaelan commented 9 years ago

@MacRusher Huh, I'm confused. I'd think you could just add a check in the build plugin to use the TypeScript compiler (configured to use SystemJS) if the file is TS or Babel otherwise. Why wouldn't that work? Does a large hunk of code depend on Babel specifically?