Skip to content

Commit

Permalink
add some profiling
Browse files Browse the repository at this point in the history
and es6 module crosspiler is not slow!!!
  • Loading branch information
jonathanong committed Aug 18, 2014
1 parent 9f783d9 commit 2dc9ec1
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/js.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ var recast = lazy('recast')
var uglify = lazy('uglify-js')
var esprima = lazy('esprima')
var debug = require('debug')('ecstacy:js')
var profile = require('debug')('ecstacy:js:profile')
var convert = require('convert-source-map')
var applySourceMap = require('apply-source-map')
var db = require('polyfills-db').recast
Expand Down Expand Up @@ -62,16 +63,20 @@ JS.prototype.minify = function (name) {

JS.prototype._recast = function (code, map, transforms) {
// i wish there was a way to cache this
profile('recasting AST')
var ast = recast().parse(code, {
esprima: esprima(),
sourceFileName: this.name + '.js'
})
profile('recasted AST')
transforms.forEach(function (transform) {
ast = transform.transform(ast)
profile('performed transform "%s"', transform.name)
})
var result = recast().print(ast, {
sourceMapName: this.name + '.js'
})
profile('stringified AST')
return {
code: convert.removeMapFileComments(result.code),
map: map
Expand Down

2 comments on commit 2dc9ec1

@Swatinem
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn’t expect it to be :-)

@jonathanong
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i did :) mostly because i don't know what i'm doing haha

Please sign in to comment.