我有一个要转换为使用角度cli(v7)的应用程序。该应用程序处于正常工作状态。
该应用包含2个站点和一个公共库:
- ui-site-1
- ui-site-2
- ui-lib
我正在使用ng build来构建和打包UI-lib,但在FESM2015阶段存在指向public_api.ts的错误:
public_api.ts:
// Lots of exports...
export { setup } from './core/connect/setup'; <-- Falls over if including this.
connect / setup.js
function setup(p1, p2, p3) {
// Some code
}
function method12(p1, p2, p3) {
// Some code
}
export { setup };
错误:
Could no resolve './setup' from ui-lib/dist/esm2015/core/setup.js
注意:如果我将文件转换为.ts,则ng build运行良好,并创建了一个dist文件夹。但是,在setup.js中,我引入了许多其他.js文件,因此将所有这些都转换为.ts并解决类型问题现在不是一个选择
更新:
tsconfig.json
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"importHelpers": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2017",
"dom"
],
"paths": {
"my-lib": [
"dist/my-lib"
],
"my-lib/*": [
"dist/my-lib/*"
]
}
}
}
tsconfig.lib.json:
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../../out-tsc/lib",
"target": "es2015",
"module": "es2015",
"moduleResolution": "node",
"declaration": true,
"sourceMap": true,
"inlineSources": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"importHelpers": true,
"types": []
},
"angularCompilerOptions": {
"annotateForClosureCompiler": false,
"skipTemplateCodegen": true,
"strictMetadataEmit": false,
"fullTemplateTypeCheck": true,
"strictInjectionParameters": true,
"enableResourceInlining": true
},
"exclude": [
"src/test.ts",
"**/*.spec.ts"
],
"include": [
"src/**/*",
"./src/**/*",
]
}
答案 0 :(得分:1)
connect / setup.js应该是:
export function setup(p1, p2, p3) {
// Some code
}
function method12(p1, p2, p3) {
// Some code
}