Coder Social home page Coder Social logo

es6 -> commonjs about cryptocompare HOT 8 CLOSED

exodusmovement avatar exodusmovement commented on July 30, 2024
es6 -> commonjs

from cryptocompare.

Comments (8)

jprichardson avatar jprichardson commented on July 30, 2024

I don't understand... this module is using commonjs....

from cryptocompare.

jprichardson avatar jprichardson commented on July 30, 2024

Have a look... https://github.com/ExodusMovement/cryptocompare/blob/0.1.0/index.js

from cryptocompare.

jprichardson avatar jprichardson commented on July 30, 2024

Ah, I'm guessing you're referring to the usage of the enhanced object literals on the exports... this module exists to serve Exodus and if I commit to this small portion, that means I'll tie it to ES5. I can't do that when it's so easy to babelify these things. But it does work just fine in newer Node/commonjs versions (I forgot which version started supporting the new object literal syntax.. v5?) without Babel.

from cryptocompare.

CraigglesO avatar CraigglesO commented on July 30, 2024

I mean to write es5 commonjs

es6 modules don't work well with webpack/uglify config because as of yet, uglify still can not process new es6 like () => and ${var} strings

from cryptocompare.

jprichardson avatar jprichardson commented on July 30, 2024

If you're delivering for Node.js/Electron, you don't need to uglify a 3rd party module. If you're delivering to the browser, you need to browserify/webpack anyways since it has module.exports.

from cryptocompare.

CraigglesO avatar CraigglesO commented on July 30, 2024

Yes, I am delivering to a browser. My point is, your code does not work with uglify. I am sure I could switch to babili and I wouldn't have issues. But when it bundles everything into one minified js file for production, it errors, because uglify.js does not recognize the es6 code that is used in the index file.

Does that make sense?

I just mean it would be cool if you updated the npm package with something like requirejs
http://renderedtext.com/blog/2013/01/23/compile-requirejs-project-to-single-file/

from cryptocompare.

CraigglesO avatar CraigglesO commented on July 30, 2024

The easiest way I can think of to simplify the code though (install babel first):
babel index.js > out.js

This makes the file usable for everything.

from cryptocompare.

jprichardson avatar jprichardson commented on July 30, 2024

If you're delivering to the browser, you're using Webpack or Browserify, right? If so, drop in a Babel plugin in the pipeline before you Uglify and the problem is solved.

from cryptocompare.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.