You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If using the ESM syntax isn't possible for you and you wish to continue using the CJS require syntax, read usage as CommonJS module below.
Build
Configure the build script in your package.json like the following:
{
"scripts": {
"build": "webpack"
}
}
Then, in your terminal, run:
npm run build
Result
To see the result, open the dist/index.html file.
That's it!
Usage as CommonJS module
In case you want to import LazyLoad using the require directive, you must configure WebPack to load the scripts from the package.json's main fields instead. More info.
So edit your webpack.config.js file and add or edit the resolve.mainFields setting to ["main", "browser", "module"] like follows:
module.exports={// other configuration fields hereresolve: {mainFields: ["main","browser","module"]}};
This tells WebPack to resolve your requires to the packages main field, which must contain contains the UMD version of the installed modules. More info.
For an example usage, see the commonJS branch on this very repo.