escodegen
escodegen copied to clipboard
Cannot build browser version from npm install
After installing escoden into my project (with npm install escodegen) I tried to build the browser version as instructed (npm install followed by npm run-script build). However, this fails in the second step because tools/entry-point.js is not part of the installation.
I was able to work around it (I think) by running ./node_modules/.bin/cjsify -a path: escodegen.js > escodegen.browser.js manually.
Ideally, I think the browser version would be included in the npm install which would avoid the need for any further steps.
Same here.
+1. I also had to change your command slightly to ./node_modules/.bin/cjsify -a path: escodegen.js > escodegen.browser.js -e escodegen, otherwise it didn't export the module correctly. Using that, I could finally do:
import { escodegen } from './node_modules/escodegen/escodegen.browser'
Additionally, the pre-built browser version available with recent releases is broken (at least with require and similar), as escodegen is undefined below and the import fails.
require.define('/tools/entry-point.js', function (module, exports, __dirname, __filename) {
(function () {
'use strict';
global.escodegen = require('/escodegen.js', module);
escodegen.browser = true; // Uncaught ReferenceError: escodegen is not defined
}());
});
Ideally, I think the browser version would be included in the npm install which would avoid the need for any further steps.
👍
after 2 years this is still a problem :/