problem description
publish one of your packaged components to npm, with reference to some blog posts. Install is successful in another project. If you introduce typescript, you can report an error. You can run and access it with ng serve local operation, but you can also report an error when packaged with ng build-- prod-- aot. (please see the following figure for specific errors)
:https://www.jianshu.com/p/1f6...;
ng-zorror-antd tsconfig.json index.tsindex.ts
npm:
main file code:
package.json:
{
"name": "ngx-common-components",
"version": "1.0.5",
"description": "provide some common components",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"files": [
"index.js",
"index.d.ts",
"src/*.js",
"src/*.d.ts",
"src/**/*.js",
"src/**/*.d.ts",
"README.md",
"LICENSE",
"package.json"
],
"keywords": [
"angular ng"
],
"author": "****",
"license": "MIT",
"dependencies": {
"@angular/animations": "^6.0.0",
"@angular/common": "^6.0.0",
"@angular/compiler": "^6.0.0",
"@angular/core": "^6.0.0",
"@angular/forms": "^6.0.0",
"@angular/http": "^6.0.0",
"@angular/platform-browser": "^6.0.0",
"@angular/platform-browser-dynamic": "^6.0.0",
"@angular/router": "^6.0.0",
"core-js": "^2.5.4",
"rxjs": "^6.0.0",
"zone.js": "^0.8.26"
},
"devDependencies": {
"@angular/compiler-cli": "^6.0.0",
"@angular-devkit/build-angular": "~0.6.0",
"typescript": "~2.7.2",
"@angular/cli": "~6.0.0",
"@angular/language-service": "^6.0.0",
"@types/jasmine": "~2.8.6",
"@types/jasminewd2": "~2.0.3",
"@types/node": "~8.9.4",
"codelyzer": "~4.2.1",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~1.7.1",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~1.4.2",
"karma-jasmine": "~1.1.1",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.3.0",
"ts-node": "~5.0.1",
"tslint": "~5.9.1"
}
}
tsconfig.json:
{
"compileOnSave": false,
"compilerOptions": {
"target": "es5",
"module": "es2015",
"sourceMap": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"declaration": true,
"lib": ["es2015", "dom"],
"typeRoots": [
"node_modules/@types"
]
},
"angularCompilerOptions": {
"skipTemplateCodegen": true
}
}
Root directory index.ts:
export * from "./src/ngx-common-components.module"
export {LoadingComponent} from "./src/loading/loading.component"
export {LoadingModule} from "./src/loading/loading.module"
module.ts:
import {CUSTOM_ELEMENTS_SCHEMA, ModuleWithProviders, NgModule} from "@angular/core";
import {LoadingModule} from "./loading/loading.module";
export * from "./loading"
@NgModule({
exports: [
LoadingModule
],
schemas: [
CUSTOM_ELEMENTS_SCHEMA
]
})
export class NgxCommonComponentsModule {
/**
* @deprecated Use `NgxCommonComponentsModule` instead.
*/
static forRoot(): ModuleWithProviders{
return{
ngModule: NgxCommonComponentsModule
}
}
}
public_api.ts:
export * from "./loading.component"
export * from "./loading.module"
index.ts: under the loading directory
export * from "./public_api"
what result do you expect? What is the error message actually seen?
the expected result is that your released package will work properly, as shown in the above error message.