Hey Stephan, thank for your feedback!
Yes it’s possible. Do I recommend? Nope.
But why? — To load the chunks dynamically you will end up adding the webpack runtime to the library you’re developing, bloating it with code to do the loading/resolution.
So, what’s the best option? — If your library is composed by pure functions, you can mark it as side-effect free on your package.json:
This makes any project that uses you lib (and webpack) to tree shake it (remove unused code).
The other option and more straight forward way is to provide your library in multiple files (like lodash, or rxjs does), provide the full bundle on
yourlib/index.js and splitted files on
// Load the full build.
var _ = require('lodash');// Load method categories.var array = require('lodash/array');
Hope I helped you developing your library Stephan Unkels!