recently, developed react component , want publish it.
in package,
"dependencies": { "react": "^0.14.6", "react-dom": "^0.14.6", "react-timer-mixin": "^0.13.3" }
when build package webpack
command, bundle containing react, react-dom , react-timer-mixin
.
seems wrong practice...
thus, question how build package without dependencies publishing.
*i think chuck-vendor method separate main bundle , dependencies multiple bundle file. requirement building lib.
if building library, need register these dependencies externals.
to summarise, add externals
property in webpack config , set array containing names (string) of modules exclude.
a more complex case require specify how should imported dependencies in function of import system. can achieve using object.
module.exports = { output: { librarytarget: "umd" }, externals: [ "add", { "subtract": { root: "subtract", commonjs2: "./subtract", commonjs: ["./math", "subtract"], amd: "subtract" } } ] }
see here more information library , externals.
if using es 2015 , babel 6, may encounter issue export of library being module object instead of want (e.g. component). have @ question solve it.