Open queckezz opened 10 years ago
+1. thank for putting in the time to find actual cases that fail! i don't really care about which transpiler we use, but adding test cases for every issue we find would be useful. doesn't help that ES6 modules aren't standardized yet =/
don't really care about the build output.
Hi,
I've released 0.1.3 which preserves line info and doesn't generate unneeded vars when there's only single specifier to export/import, so the output above looks like now:
module.exports.x = require("./mod.js").x;
var mod$0 = require("./mod.js");module.exports.x = mod$0.x;module.exports.y = mod$0.y;
module.exports.y = require("./mod.js").x;
var mod$1 = require("./mod.js");module.exports.y = mod$1.x;module.exports.b = mod$1.y;
Also, I developed this transform to be compatible with CommonJS modules but I'm not sure yet I did this aspect right because I didn't put this transform to production use yet.
so far, it's better than square's transpiler in that it actually works :D
btw is there a cjs -> es6 module compiler?
+1 on this too.
Currently debugging is real pain. You either get syntax error on line 1 (what fucking file??) or just undefined. I guess this would be solved too by using a different transformer.
related to #2
So I tried to use the es6 syntax today and I ran into multiple issues with it.
import store from 'store'
and it doesn't require it because it gets rewritten intovar store = require('store')['default']
so it's just consumable ifstore
is also written with es6 modules.export
statement but notexport default
.import { x as a } ...
,export { x as a }
I know that you reported some of the issues to
es6-module-transpiler
but they don't seem very active. What do you think of using https://github.com/andreypopp/es6-module-jstransform? This resolves all the above issues. A downside though is that it compiles to pretty ugly code:But for me not really a problem since it's just the build output anyway.