Using ES6 boilerplate generator, I have built a moduleA that exports CommonJS (via Babel), UMD (via Rollup, unminified & minified version), and
ES2015 via Babel. In other words, my module's package.json
has
"main": "cjs/index.js",
"browser": "dist/moduleA.js",
"module": "es/index.js",
"jsxnext:main": "es/index.js",
Now I am building a moduleB that uses similar setup. What would be the best way to reference moduleA from moduleB? What would be the difference between require("moduleA")
vs import { X } from "moduleA"
. Basically I do not understand how different export options (main/browser/module) can be used from another module. Thanks!