UMD build of lodash for browser and SystemJS usage, providing utility functions in a standalone script
npm install umd-lodashjs
// webpack.config.js
const lodashFnsToExternalize = ["uniq", "flatten"];
const externals = Object.fromEntries(
lodashFnsToExternalize.map((fn) => [
lodash/${fn},
https://cdn.jsdelivr.net/npm/umd-lodash@1.1.0/dist/${fn}.min.js,
])
);
module.exports = {
// ...existing config...
externals,
// Configure externalsType/output.library.type as 'system'.
// If you use the plugins of single-spa this may be implicit.
};
`
Tip: You can use an alias (e.g., npm/umd-lodash@1.1.0/dist/${fn}.min.js) and resolve it to the CDN using a SystemJS import map in your index.html:
`html
`
This allows you to reference modules using the npm/ prefix, which SystemJS will resolve to the CDN automatically.
🌐 Usage via jsDelivr CDN
You can use any Lodash function by adding its script. Each UMD build exposes the function as a property of the global _ object (e.g., _.noop, _.chunk).
`html
`
🔧 Usage with SystemJS
`html
`
📂 Available Functions
Every Lodash function (except internals like _base*) is exported as an individual UMD build under dist/.
$3
For every Lodash function, a non-minified build is also available at dist/ in addition to the minified version. Use the non-minified files for easier debugging or development.
Example paths:
- dist/assign.min.js and dist/assign.js
- dist/chunk.min.js and dist/chunk.js
- dist/camelCase.min.js and dist/camelCase.js
- dist/uniq.min.js and dist/uniq.js
- dist/flatten.min.js and dist/flatten.js
- dist/debounce.min.js and dist/debounce.js
- dist/noop.min.js and dist/noop.js`