-
Notifications
You must be signed in to change notification settings - Fork 157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement Tree Shaking in LiveScript #906
Comments
it should be possible to do tree shaking since in ls we can do nice imports like this: {foo,bar} = require 'lib' |
Tree shaking requires both whole-program compilation and some way of both figuring out all of the dependencies statically (without running the code). This is "dependencies between program entities" more than just "what something imports". The LiveScript compiler does modular compilation, so it can't really do tree shaking. |
So it has to be a separate transformation process ? PureScript has a cool Tree Shaking algorithm built into pulp and so is ES6 with RollUp - just thinking that we should not be left behind. |
RollUp does it with ES6 syntax - but that type of import is also present in LS :D so it means theoretically it should be possible to do it for ls |
This probably would be trivial if we did this. ps. I wish I had time to work on it, but I don't. It would be great if someone could pick it up. Once a basic atchitecture is set up, others can collaborate on the details and edge cases. |
@JoyKrishnaMondal it's more about semantics than syntax, although the syntax helps. First thing you need to be able to do tree shaking is whole-program optimisation, though. This means LiveScript's compiler would have to stop doing modular compilation. IOW, instead of:
You'd need:
So the I'm not sure it's worth it, though. A better approach would be generating ES6 modules and just letting people post-process it with Rollup. This way you get to keep modular compilation (less changes to make), and still get the optimisation if you want. This might require changing the module system to not allow importing of regular CommonJS modules, though, since you can't do tree shaking on those. |
@robotlolita makes sense - but for now LS only compiles to CommonJS rather than ES6. I am thinking Tree Shaking is overblown if it cannot do CommonJS optimization. Better to use Google Closure Compiler and let things stabilize. |
I have been thinking about dead code elimination and Tree Shaking.
Since LS compiles to ES5, its not atm possible to implement Tree Shaking :(
Thoughts ?
The text was updated successfully, but these errors were encountered: