escodegen icon indicating copy to clipboard operation
escodegen copied to clipboard

Cannot build browser version from npm install

Open chrislong opened this issue 10 years ago • 4 comments

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.

chrislong avatar Jul 30 '15 18:07 chrislong

Same here.

benqus avatar Jan 31 '16 17:01 benqus

+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
    }());
  });

crsmithdev avatar Jun 08 '16 09:06 crsmithdev

Ideally, I think the browser version would be included in the npm install which would avoid the need for any further steps.

👍

NodeGuy avatar Aug 17 '16 16:08 NodeGuy

after 2 years this is still a problem :/

balzss avatar Nov 14 '17 18:11 balzss