lodash-es All In One
lodash-es All In One
$ yarn add lodash-es
#$ yarn add -S lodash-es
$ npm i lodash-es
# $ npm i -S lodash-es
// import lodash_es form 'lodash-es';
import {filter} form 'lodash-es';
import {filter} form './node_modules/lodash-es/lodash.js';
import filter form './node_modules/lodash-es/filter.js';
https://www.npmjs.com/package/lodash-es
you don't need lodash
anymore
https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore
https://www.npmjs.com/package/eslint-plugin-you-dont-need-lodash-underscore
https://youmightnotneed.com/lodash
https://thejs.dev/jmitchell/its-time-to-let-go-of-lodash-nqc
https://www.npmjs.com/package/lodash
https://github.com/lodash/lodash
ESM
demo
// import { filter } from "lodash-es";
// Uncaught TypeError: Failed to resolve module specifier "lodash-es". Relative references must start with either "/", "./", or "../". ❌
// import { filter } from "./node_modules/lodash-es/filter";
// GET http://127.0.0.1:5500/vite-2.x/esm/node_modules/lodash-es/filter net::ERR_ABORTED 404 (Not Found) ❌
// import { filter } from "./node_modules/lodash-es/filter.js";
// Uncaught SyntaxError: The requested module './node_modules/lodash-es/filter.js' does not provide an export named 'filter' (at app.js:6:10) ❌
// import * as filter from "./node_modules/lodash-es/filter.js";
// app.js:35 Uncaught TypeError: filter is not a function ❌
// export default filter; ✅
// import filter from "./node_modules/lodash-es/filter.js";
// export default filter; ✅
import { filter } from "./node_modules/lodash-es/lodash.js";
if(console.clear) {
console.clear();
}
const log = console.log;
log('esm 🚀');
const arr = [
{
id: 2022,
},
{
id: 2012,
},
{
id: 2050,
}
]
const year = arr.filter(obj => obj.id === 2022);
const filter_year = filter(arr, obj => obj.id === 2022);
log('current year =', year);
log('filter year =', filter_year);
lodash
https://www.npmjs.com/package/lodash
https://github.com/lodash/lodash
GitHub PR & git commits squash ❌
https://github.com/lodash/lodash/pull/4756
https://github.com/lodash/lodash/pull/4756/commits/a1484b5aaef68113766f81808386161e172c794c
solutions
git merge with squash commits
https://www.cnblogs.com/xgqfrms/p/16464515.html
https://www.cnblogs.com/xgqfrms/p/16457911.html
refs
©xgqfrms 2012-2020
www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!
原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!
本文首发于博客园,作者:xgqfrms,原文链接:https://www.cnblogs.com/xgqfrms/p/16470746.html
未经授权禁止转载,违者必究!