I am developing several plugins for a system that loads these plugins as AMD modules (with requirejs). Plugins are written as ES6 modules and packaged using webpack (output.libraryTarget = 'amd). Everything works as expected.
But plugins use quite a lot of common code, which is included in each entry. I tried using the CommonsChunkPlugin plugin, but the source fragment contains code that is not an AMD module. However, other entry points transmitting a common cartridge are still generated correctly. In addition, the documentation suggests that on one page it is not recommended to have several initial fragments (with JSONp running) on ββone page - there is a chance that another plugin author will use the same approach.
Is there any way to optimize this use case in AMD compatible mode? It seems to me that the error in CommonsChunkPlugin is that the initial record is not AMD (but still its code is unsafe to load into the plugin env) ... Is there some kind of configuration that I am missing?
webpack amd
ahz
source share