
Security News
/Research
npm Phishing Email Targets Developers with Typosquatted Domain
A phishing attack targeted developers using a typosquatted npm domain (npnjs.com) to steal credentials via fake login pages - watch out for similar scams.
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 callbacks for the chunks. If this object is not handled properly, 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:
NOTE: memory leaks is a rare case now which in theory should never happen at all. However, you may still want to use
AsyncModulePlugin
to have the ability to re-fetch chunk after error. If you do not plan to try loading chunks again after fail (e.g. "Cannot retrieve data. Click here to try again" functionality), it's totally fine to not useAsyncModulePlugin
. See #1 for details.
// 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
/Research
A phishing attack targeted developers using a typosquatted npm domain (npnjs.com) to steal credentials via fake login pages - watch out for similar scams.
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.