Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
    I am trying my best. Because i have you.
    I think you will learn a lot more without my help :-) so keep on going!
    can i ask your help?
    Cristi Jora
    @MicroDreamIT so what's the issue exactly ?
    I read the comments above and I can say the following:
    If you want something that can be used with npm as well as a direct script and have a nice development you probably want to write the code in es6
    and compile it to es5 for browser
    this is usually done with libraryTarget: "umd"
    Cristi Jora
    also you could compile to common js which is the (require) version and es version which is the es6 version with imports
    you can see that here
    there are basically 3 versions
    vue.js is the broswer (umd) version
    vue.common.js is the version which works with require
    vue.esm.js is the version which works with imports and code splitting/tree shaking
    then via package json you can specify the target files for each bundling type
    "main" should point to the common.js version
    while "module" should point to the esm version
    which is basically an instant cdn for any npm module
    By doing all this stuff you achieve:
    1. Automatic CDN for the browser (umd) version which can be included directly with a script tag
    2. A common js version which is linked with "main" in package.json that can be used with older bundlers (webpack 1 and browserify )
    3. An esm version which is linked via "module" in package.json that can be used with webpack 2/3 or rollup and can benefit from tree shaking and other good stuff
    Cristi Jora
    So if you
    var shapecss = require('shapecss') it will get the commonjs version automatically
    import shapecss from 'shapecss' will get the esm module version automatically
    @cristijora got it bro, now i am turning to webpack.conf with automatic es5 transformer
    Please ask me any question regarding Shapecss