libraryTarget umd & code splitting

When splitting code in webpack, the chunks are loaded with temporary script tags:

/******/    var head = document.getElementsByTagName('head')[0];
/******/    var script = document.createElement('script');
/******/    script.type = 'text/javascript';
/******/    script.charset = 'utf-8';
/******/    script.async = true;
/******/    script.timeout = 120000;

/******/    script.src = __webpack_require__.p + "" + ({}[chunkId]||chunkId) + "." + "<some_key>" + ".js";

When creating an umd library, the library might be loaded by another bundler again (webpack, jspm, etc.). In that case, the script tag loading isn’t nice. It would be better to keep the AMD (or System.import for webpack 2) in the chunks which will be interpreted by the other bundler. I didn’t find an option to enable this. Is it a missing feature? Or am I missing something and code splitting in umd libraries not possible?

Author: Fantashit

3 thoughts on “libraryTarget umd & code splitting

  1. This feature would be super handy for us. What’s the difficulty in implementing it? I guess, replacing the temp script stuff with System.import is not complicated, right? Is the problem the current jsonp in the bundles?

Comments are closed.