Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/30.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular lodash树抖动失败,typescript处于角度_Angular_Typescript_Lodash_Tree Shaking - Fatal编程技术网

Angular lodash树抖动失败,typescript处于角度

Angular lodash树抖动失败,typescript处于角度,angular,typescript,lodash,tree-shaking,Angular,Typescript,Lodash,Tree Shaking,我有一些使用typescript的大型项目 我试过几种方法来摇树 我认为最好先看看我的工作成果 我的构建命令是 生成命令 ng build --stats-json webpack-bundle-analyzer {{stats.json path}} 自定义加载sh.ts export { forEach } from 'lodash/forEach'; export { cloneDeep } from 'lodash/cloneDeep'; ... .. . import * as _

我有一些使用typescript的大型项目

我试过几种方法来摇树

我认为最好先看看我的工作成果

我的构建命令是

生成命令

ng build --stats-json
webpack-bundle-analyzer {{stats.json path}}
自定义加载sh.ts

export { forEach } from 'lodash/forEach';
export { cloneDeep } from 'lodash/cloneDeep';
...
..
.
import * as _ from './custom_lodash';
export class AppComponent implements OnInit {
   ...
   ngOnInit() {
       let data = {
          test: 1  
       };
       let data2 = _.cloneDeep(data);
   }
   ...
}
应用程序组件.ts

export { forEach } from 'lodash/forEach';
export { cloneDeep } from 'lodash/cloneDeep';
...
..
.
import * as _ from './custom_lodash';
export class AppComponent implements OnInit {
   ...
   ngOnInit() {
       let data = {
          test: 1  
       };
       let data2 = _.cloneDeep(data);
   }
   ...
}
不是通过定制lodash获得全部lodash,而是仅进口部分

当然,上面的示例代码与实际项目略有不同,但总体配置是相同的

我想知道为什么摇动lodash树失败了

这是我引用的站点。
我发现了问题所在

问题是node_模块中的另一个包

在我的例子中,
ngxtreeview
package使用lodash

这是ngx treeview中的示例代码

import { isNil, isString } from 'lodash';
所以,我在下面试试

import isNil from 'lodash/isString';
import isString from 'lodash/isNil';
但是。。这种解决办法是暂时的

我将尝试将问题报告给ngx treeviewgithub。不幸的是,上次编辑该包的时间超过了1年


所以,我就用叉子叉那根树枝。

我发现了问题所在

问题是node_模块中的另一个包

在我的例子中,
ngxtreeview
package使用lodash

这是ngx treeview中的示例代码

import { isNil, isString } from 'lodash';
所以,我在下面试试

import isNil from 'lodash/isString';
import isString from 'lodash/isNil';
但是。。这种解决办法是暂时的

我将尝试将问题报告给ngx treeviewgithub。不幸的是,上次编辑该包的时间超过了1年


所以,我就用叉子叉了那根树枝。

这不是预期的行为吗?@Vega对不起我的错误,我已经编辑过了that@Vega不。我建立了我引用的网站。正如那篇专栏文章所说,lodash.js已经不存在了,应该只导入了一些文件。既然你已经对
forEach
cloneDeep
函数有了本机的支持,为什么还要将lodash用于
forEach
JSON.parse(JSON.stringify(data))
?哎哟。。。。如果我只使用那个函数,你肯定是对的。这是示例代码。我的代码实际使用了10个以上的lodash函数。有些函数不支持js NativeIs,这不是预期的行为吗?@Vega抱歉我的错误,我已经编辑过了that@Vega不。我建立了我引用的网站。正如那篇专栏文章所说,lodash.js已经不存在了,应该只导入了一些文件。既然你已经对
forEach
cloneDeep
函数有了本机的支持,为什么还要将lodash用于
forEach
JSON.parse(JSON.stringify(data))
?哎哟。。。。如果我只使用那个函数,你肯定是对的。这是示例代码。我的代码实际使用了10个以上的lodash函数。有些函数不支持js native