Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot build escodegen.browser.js or the minimized equivalent #397

Open
OmnibusSoftware opened this issue Sep 10, 2019 · 1 comment
Open

Comments

@OmnibusSoftware
Copy link

I figured it out and the reasons:

A. escodegen build depend on the 'cjsify' tool which is part of the commonjs-everywhere npm package.

B. The npm installed version of escodegen does not have the tools/ folder, which the build requires.

These details are currently not specified in the README.MD file. I recommend to add the following to the file:

  1. Download or clone the escodegen repository (https://github.com/estools/escodegen/)
  2. Run 'npm install -g commonjs-everywhere'
  3. Run 'npm run-script build' to generate the escodegen.browser.js file.
  4. Run 'npm run-script build-min' to generate the escodegen.browser.min.js file.

This will make it more clear for new users.

@OmnibusSoftware
Copy link
Author

After playing more with it, I found that using commonjs-everywhere cannot turn the node.js module to a browser-compatible JS library, at least not a standard (i.e. browser independent) one. I observed 2 issues:

  1. In the generated escodegen.browser.js file, there is one occurrence of 'setImmediate()' function which is only supported by IE / Edge, not Chrome or Firefox.
  2. In the generated escodegen.browser.js file, there is one occurrence of 'require(...)' function, which is not standard JS code.

I ended up using another tool 'browserify' to convert the js file and it worked perfectly on my Chrome. Haven't tried it on other browsers yet but it should not too much of an issue.

README.RD and package.json may be updated to include this recommendation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants