pugjs / then-pug

**EXPERIMENTAL** Async promise based Jade
42 stars 5 forks source link

hybrid regenerator / uglify solution #7

Closed jeromew closed 10 years ago

jeromew commented 10 years ago

In 2.0.0, in order to support node 0.10.x, we use regenerator.

Now that I use 2.0.0 in my project (0.11.9) I can see that this solution is way slower fo parsing than the original "uglify_hack" solution (regenerator ~12 sec ; uglify_hack ~ 2 sec)

@ForbesLindesay would you agree if I add an option switch to activate the uglify_hack solution ? the option name could be "uglify_has_generator_support" default false.

ForbesLindesay commented 10 years ago

If we do this we should just auto-detect generator support:

var supportsGenerators = true;
try {
  Function('', 'function* () {}');
} catch (ex) {
  supportsGenerators = false;
}

Then just use the hack if generator support exists, and keep an eye out for when UglifyJS gets generator support so se can remove the hack.

jeromew commented 10 years ago

This was added with commit https://github.com/then/then-jade/commit/48dc78667eac8aa0d36afbc35615096322a4b696