google / traceur-compiler

Traceur is a JavaScript.next-to-JavaScript-of-today compiler
Apache License 2.0
8.18k stars 580 forks source link

Make compatible with TypeScript compiler (by adding ".js" postfix if it was missing) #1999

Closed iislucas closed 8 years ago

iislucas commented 8 years ago

If a module fails to load, and the module name does not end in ".js", and adding ".js" postfix will make the file load, then do that. This makes traceur compatible with TypeScript, which current emits import statements that don't include the ".js" postfix.

See: https://github.com/google/traceur-compiler/issues/1997 and https://github.com/Microsoft/TypeScript/issues/5460

Added test, and testes with make test

Review on Reviewable

arv commented 8 years ago

I think this needs to be guarded by an option. We don't want to go back to allowing this by default.


Reviewed 2 of 2 files at r1. Review status: 1 of 2 files reviewed at latest revision, 2 unresolved discussions.


src/runtime/TraceurLoader.js, line 155 [r1] (raw file): Missing {}


test/unit/runtime/Loader.js, line 150 [r1] (raw file): You can use ES6 here so a template literal would have been cleaner.


Comments from the review on Reviewable.io

iislucas commented 8 years ago

Just closing the loop on this. I ended up finding another way to do this, so I don't mind leaving this as is. If someone else needs traceur, then can easily finish this up. :)

arv commented 8 years ago

OOC did TypeScript finally change this?

iislucas commented 8 years ago

I don't think so; I just found an easier way using the closure compiler, which solves another problem I was having also (actually doing the module loading).