我们目前正在使用angular-tree-component来显示树结构双ListBox.with ng服务一切正常,问题在打包并将库添加到另一个项目时启动:抛出警告
'defaultsDeep'不会被'node_modules \ angular-tree-component \ node_modules \ lodash \ lodash.js'导出
在另一个项目中打包和页面加载时,'defaultsdeep'函数的每个实例都被undefined替换。
我的package.json看起来像这样
{
"name": "ap-example-component-library",
"version": "0.0.2",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build --prod",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"packagr": "ng-packagr -p ng-package.json"
},
"private": false,
"dependencies": {
"@angular/animations": "^5.1.0",
"@angular/cdk": "^5.0.0-rc.2",
"@angular/common": "^5.1.0",
"@angular/compiler": "^5.1.0",
"@angular/core": "^5.1.0",
"@angular/forms": "^5.1.0",
"@angular/http": "^5.1.0",
"@angular/material": "^5.1.1",
"@angular/platform-browser": "^5.1.0",
"@angular/platform-browser-dynamic": "^5.1.0",
"@angular/router": "^5.1.0",
"@ng-bootstrap/ng-bootstrap": "^1.0.0",
"angular-tree-component": "^7.0.1",
"angular2-multiselect-dropdown": "^2.5.0",
"ap-agency-component-library": "0.0.29",
"ap-company-component-library": "0.0.25",
"ap-office-component-library": "0.0.24",
"ap-shared-service-library": "0.0.20",
"bootstrap": "4.0.0-beta.2",
"core-js": "^2.4.1",
"font-awesome": "^4.7.0",
"hammerjs": "^2.0.8",
"jquery": "^3.2.1",
"ng-circle-progress": "^0.9.9",
"popper.js": "^1.12.9",
"rxjs": "^5.5.6",
"zone.js": "^0.8.19"
},
"devDependencies": {
"@angular-devkit/core": "0.0.29",
"@angular/cli": "1.6.4",
"@angular/compiler-cli": "^5.1.0",
"@angular/language-service": "^5.1.0",
"@types/jasmine": "~2.8.3",
"@types/jasminewd2": "~2.0.2",
"@types/node": "~6.0.60",
"codelyzer": "^4.0.1",
"jasmine-core": "~2.8.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~2.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"ng-packagr": "^1.6.0",
"protractor": "~5.1.2",
"ts-node": "~3.2.0",
"tslint": "~5.9.1",
"typescript": "~2.5.3",
"lodash": "4.17.5"
}
}
ng- packagr.json:
{
"$schema": "./node_modules/ng-packagr/ng-package.schema.json",
"lib": {
"entryFile": "public_api.ts"
}
}
我们正在使用Angular 5.Have尝试了几个选项,例如将lodash导入为dev依赖项,在ng-package.json:lib部分添加外部,安装loadash特定模块以及其他一些。非常感谢任何帮助。
答案 0 :(得分:0)
问题:我们也尝试了所有这些,从我们的原始版本开始:
import * as _ from 'lodash'
症状:我们检查了生成的es5包,我们的代码已被转换为
import { chain, omit, pick, slice } from 'lodash';
因而错误。
解决方案:我们将导入更改为 require ,所有内容都自行解决:
const _ = require('lodash');