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?
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?Any update on how to do this ?
@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.
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!
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.
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…
We considering it
webpack 5 alpha 31 supports this.
Here is an example: https://github.com/webpack/webpack/tree/f25906fd2fd0bbcf472d9d44dcd8d6a92e3fbe95/examples/module
The following conditions must be met:
output.module: true
(otherwise it would be wrapped in an IIFE)