A Webpack loader that provides a promise-based alternative to bundle-loader for code splitting. It wraps lazy-loaded chunks behind a function that returns a Promise<module>, allowing you to control when the chunk is fetched. The loader requires a promise library parameter (e.g., 'bluebird', 'Q', or 'global'). Supports named chunks and filename/name substitutions in bundle names. Stable version 1.0.0, by Dan Abramov. Useful for single-page apps needing promise-based lazy loading with Webpack.
npm install promise-loaderVerified import paths — ran on the pinned version, not inferred.
This shows how to configure promise-loader in Webpack to load files ending with .async.js lazily using Bluebird promises.
Add a parameter like 'bluebird', 'Q', or 'global' to the loader query: require('promise?bluebird!./file.js').Always use the returned function and await its promise. If you need synchronous loading, use bundle-loader instead.
For Webpack 5+, consider using a custom rule with the 'use' property and options object, or use a different loader like @webpack-contrib/promise-loader.
Ensure a global Promise is present, either via native Promise or a polyfill like core-js or es6-promise.
Install the promise-loader package: npm install promise-loader --save-dev. Then use require('promise?bluebird!./file.js') with the loader prefix.Add a query string with a promise library, e.g., require('promise?bluebird!./file.js'). Then load() returns a Promise.Install the promise library: npm install bluebird. Alternatively, use 'global' if you have a global Promise.
No dependency data recorded yet.