[英]How to get a lodash custom (reduced) build suitable for es modules import?
I mean for example:我的意思是例如:
lodash include=each,find,filter,map,some,debounce,defer,delay,throttle,uniq,assign,extend,merge,omit,without,findIndex,compact,replace,groupBy,max,uniqueId
When I try to import in es modules, I get a warning like this:当我尝试导入 es 模块时,我收到如下警告:
Bundled and transpiled successfully, but with warnings: The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten打包并转译成功,但有警告:'this'关键字相当于ES模块顶层的'undefined',已被重写
Is there any option to have the same custom (reduced) of build, but suitable to be imported in modules and then available through '_'
as always?是否有任何选项可以拥有相同的自定义(减少)构建,但适合在模块中导入,然后像往常一样通过
'_'
提供?
Thank you谢谢
You could create your own aggregating module in a local file...such as tools/lodash.js
:您可以在本地文件中创建自己的聚合模块...例如
tools/lodash.js
:
export {
each, find, filter, map, some, debounce, defer, delay, throttle,
uniq, assign, extend, merge, omit, without, findIndex, compact,
replace, groupBy, max, uniqueId
} from 'lodash';
Then when you wanted these tools you could add然后,当您想要这些工具时,您可以添加
import * as _ from './tools/lodash`;
If you don't like the import * as _
syntax, you could do a straight import in your aggregating module and then do an export default { each, find, ... };
如果您不喜欢
import * as _
语法,您可以在聚合模块中直接导入,然后执行export default { each, find, ... };
. . That would allow you to do
import _ from './tools/lodash';
这将允许您
import _ from './tools/lodash';
. .
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.