
Security News
Knip Hits 500 Releases with v5.62.0, Improving TypeScript Config Detection and Plugin Integrations
Knip hits 500 releases with v5.62.0, refining TypeScript config detection and updating plugins as monthly npm downloads approach 12M.
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
async-module
always uses lazy
mode from bundle-loader
, this means that chunk loading starts only after returned function is called.
// async-module returns function which accepts 2 callback: for success and for fail
// Exports of the requested module are passed into success callback as a first argument
require('async-module!./file.js')(function onLoad(mod) {
mod.doSomething();
}, function onError() {
// error happened
});
By default webpack
does not provides access to installedChunks
object which stores loading callback for the chunks. If this object is not handled property, this may cause memory leaks and won't allow to try to load module again since it will stuck in pending state (see webpack/webpack#1380 for details). To fix this issue, you need to include AsyncModulePlugin
which will export installedChunks
to the async-module-loader
. This is how you can do it:
// webpack.config.js
var AsyncModulePlugin = require('async-module-loader/plugin');
module.exports = {
// ...
plugins: [
// ... other plugins
new AsyncModulePlugin()
]
// ...
}
name
: You may set name for bundle. See documentationrequire('async-module?name=my-chunk!./file.js')(..., ...);
FAQs
Async modules (chunks) loader for webpack with built-in error callbacks
The npm package async-module-loader receives a total of 30 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
Knip hits 500 releases with v5.62.0, refining TypeScript config detection and updating plugins as monthly npm downloads approach 12M.
Security News
The EU Cyber Resilience Act is prompting compliance requests that open source maintainers may not be obligated or equipped to handle.
Security News
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.