as-ideas / oil

191 stars 56 forks source link

better options for npm dependents (cjs, module, browser) #210

Closed bobaaaaa closed 3 years ago

bobaaaaa commented 6 years ago

When I add oil as a npm dependency (via yarn add @ideasio/oil.js) the main field of the package.json points to a dev server. A better option would be:

{
  "main": "dist/latest/oil.cjs.js",
  "module": "dist/latest/oil.esm.js",
  "browser": "dist/latest/oil.umd.js"
}

See example with rollup (I could not find an example with webpack): https://github.com/rollup/rollup-starter-lib

For ES6+ project the import would be: import '@ideasio/oil.js';

Info: When I install the latest version (1.2.4) the oil.min.js says /*! 1.2.4-SNAPSHOT */. I think thats not correct.

ltparis2018 commented 6 years ago

Thanks for your hints. The problem with the SNAPSHOT is fixed now with release 1.2.5. I could reproduce the problem with package.json. This issue stays open until it is fixed too.

hypery2k commented 5 years ago

Webpack can do this, too. Here's an example.

If needed I can support on this.

tholman commented 5 years ago

👍 Would be useful to be able to import the module cleanly, rather than having to point to a file in the release folder.