Remove webpack bootstrap for single-module apps

There’s a couple of entry points within my application which either a) don’t rely on any other modules or b) only rely on external modules.

I’d ideally like to remove the ‘webpack bootstrap’ for these entry points, since AFAIK it doesn’t add any value, but does add marginal runtime overhead.

I made the following change to MainTemplate which seems to work. It omits the module boilerplate when there’s only a single module, but is quite hacky (mostly around the coupling to require):
master...ljwagerfield:single-module-template

Are there any better ways of disabling the ‘module loading’ boilerplate?

Author: Fantashit

8 thoughts on “Remove webpack bootstrap for single-module apps

  1. Hi. There is no way to disable the webpack bootstrap code from the config file?

    I just need to modify the MainTemplate.js file to remove the bootstrap code for single module files?

  2. @sokra maybe such option can be added in webpack 4, there are often times when you don’t need this bootstrap code in your bundle. I’m pretty sure we can test this in alpha version if added.

  3. To explain our need for this a bit. We use webpack for our main bundle, but also need to process each language files individually (i.e. an entry point for each lang file). Each language file is a simple es6 file that imports other files, each containing lang strings. Our sole need for these lang files is to copy the generated bundle to a new location, rename them to include the hash for cache-busting and uglify. This is all well within the purview of webpack – it’s very straightforward to set up (go Webpack!) – so we figured it would be ideal. However, ultimately we need to consume the file as a simple JSON object because it’s asynchronously loaded by the client-side code. Since there’s no way to remove the bootstrap code wrapping the content we had to get a separate process using Grunt that handles this portion. Pity!

  4. To explain our need for this a bit.

    My need is much simpler. I’m using webpack to pack everything into a single deliverable. It makes no sense to have a loader in that case.

  5. Plus one comments are being marked as spam now? I hope that’s a bot rather than a team member who’s put more energy into that, rather than addressing the issue.

    Is there any update on this? This issue has been open for over 2 years…

Comments are closed.