by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    explosivesushi
    @explosivesushii_twitter
    I’m sure you will figure it out
    Good luck :-)
    MicroDreamIT
    @MicroDreamIT
    I am trying my best. Because i have you.
    explosivesushi
    @explosivesushii_twitter
    I think you will learn a lot more without my help :-) so keep on going!
    MicroDreamIT
    @MicroDreamIT
    can i ask your help?
    Cristi Jora
    @cristijora
    @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
    @cristijora
    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 https://unpkg.com/vue@2.3.4/dist/
    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
    @cristijora
    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
    MicroDreamIT
    @MicroDreamIT
    @cristijora got it bro, now i am turning to webpack.conf with automatic es5 transformer
    MicroDreamIT
    @MicroDreamIT
    8c531aafc7d5aeee5d55e36ead2626c3bb1ce6e2
    MicroDreamIT
    @MicroDreamIT
    Please ask me any question regarding Shapecss