benmerckx / genes

Generates split ES6 modules and Typescript definitions from Haxe modules.
43 stars 8 forks source link

Support for browser modules by adding '.js' extension to generated import statements? #31

Closed cambiata closed 3 years ago

cambiata commented 3 years ago

Great project! Thanx!

I notice that out of the box, genes doesn't seem to support browser modules as the seem to need the file extension for import statements: import {Register} from "./genes/Register.js" instead of import {Register} from "./genes/Register"

Easy to hack the ModuleEmitter.emitImport() of course, replacing emitString(where); with emitString(where + '.js');, but I guess it should better be done properly - probably earlier in the chain. If not, I could create a PR if you like.

Best! / Jonas

benmerckx commented 3 years ago

Should be available now with a define: -D genes.include_extension

cambiata commented 3 years ago

Thanks!

Not a lot of people use modules directly in browsers (yet?), but great to have for quick prototype purposes.

cambiata commented 3 years ago

By the way, this kind of es6 modules output should be a first class citizen in Haxe js, shouldn't it..? Are there any ongoing discussions about that..? Haven't seen any...

benmerckx commented 3 years ago

Exporting the whole code base as a single ES6 module is in the works: https://github.com/HaxeFoundation/haxe/pull/10003

Splitting the code in modules would preferably be handled by Haxe, however this was closed without a solution: https://github.com/HaxeFoundation/haxe/issues/5831#event-2882732613

External libraries like genes can handle most of the work though, but could do it quite a bit faster if this was available: https://github.com/HaxeFoundation/haxe/issues/8625