
Security News
Deno 2.4 Brings Back deno bundle, Improves Dependency Management and Observability
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.
async-module-loader
Advanced tools
Async modules (chunks) loader for webpack with built-in error callbacks
async-module-loader
for webpackBased on https://github.com/webpack/bundle-loader with improvements of error handling
npm install async-module-loader
webpack documentation: Using loaders
Also you will need to use a AsyncModulePlugin
.
async-module-loader
returns function which accepts 2 callbacks: for success and for fail
Exports of the requested module are passed into success callback as a first argument
require('async-module-loader!./file.js')(function onLoad(mod) {
mod.doSomething();
}, function onError() {
// error happened
});
Also you can use Promises with promise
option specified, like this:
require('async-module-loader?promise!./file.js').then(function onLoad(mod) {
mod.doSomething();
}, function onError() {
// error happened
});
require('async-module-loader?name=my-chunk!./file.js')(function onLoad(mod) {
mod.doSomething();
}, function onError() {
// error happened
});
If you do not want your module to be executed immediately (maybe because some animation is in play), then you can tell to async-module-loader
to load a chunk, but not execute it. In such, a function will be passed to the success callback instead of a module.exports
object of requested chunk. Call that function then you will need you chunk executed:
require('async-module-loader?noexec!./file.js')(function onLoad(executeChunk) {
setTimeout(function() {
var mod = executeChunk();
mod.doSomething();
}, 500);
}, function onError() {
// error happened
});
To make async-module-loader
work correctly you need to add AsyncModulePlugin
to your plugins.
// webpack.config.js
var AsyncModulePlugin = require('async-module-loader/plugin');
module.exports = {
// ...
plugins: [
// ... other plugins
new AsyncModulePlugin()
]
// ...
}
name
: Use this to specify output name for requested chunk. See webpack documentation
promise
: Use this to return a promise from async-module-loader
.
noexec
: Use this to delay chunk execution
FAQs
Async modules (chunks) loader for webpack with built-in error callbacks
The npm package async-module-loader receives a total of 19 weekly downloads. As such, async-module-loader popularity was classified as not popular.
We found that async-module-loader demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.
Security News
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.