stealjs / transpile

Transpiles from everything to everything else
https://www.npmjs.com/package/transpile
MIT License
25 stars 10 forks source link

Drop support for var-ed globals #82

Open matthewp opened 7 years ago

matthewp commented 7 years ago

The reason the global -> AMD format is so gross is because some globals define themselves with a var; like so:

var MooTools = {};

This means that we have to run eval() on the source, rather than just inlining it in a module. Other globals that set themselves on the window object will work fine.

This will be a breaking change, so next major release.

justinbmeyer commented 7 years ago

Couldn't we detect this fairly easily via the ast?

matthewp commented 7 years ago

I don't know about easily, but it would be possible. Not sure it's worth the time though.

justinbmeyer commented 7 years ago

I think it's very easy to see if there is a global var statement. Transpile already does a bunch of stuff like this (like checking for require function calls). Id imagine it would be just the same.