escodegen icon indicating copy to clipboard operation
escodegen copied to clipboard

Using escodegen.browser.js and require.js - estraverse exports are undefined

Open gadisn opened this issue 8 years ago • 0 comments

I'm using the escodegen.browser.js in conjunction with require.js in a web application, and the exports from estraverse (and specifically attachComments) are undefined.

If I remove the use of require.js, the estraverse exports are available.

It seem like the problem is coming from the umd block which is added to traverse.js in its build process: if (typeof define === 'function' && define.amd) { define(['exports'], factory); } else if (typeof exports !== 'undefined') { factory(exports); } else { factory(root.estraverse = {}); }

Is this code really needed in the version which is intended only for browser (as the name suggests – escodegen.browser.js)?

I've noticed that if I replace the umd block with "factory(exports);" the problem is solved.

Can you please review?

gadisn avatar Jun 07 '16 08:06 gadisn