複数のコンポーネントで配布する角度ライブラリを作成しようとしていますが、動作させることができませんでした。 1つのコンポーネントでのみ動作します。これは私が1つのコンポーネントのために作った方法です:複数のコンポーネントで配布する角型ライブラリを作成する方法
私はsample-libraryというフォルダを持っています。 SRC内部で私が持っている:
package.json:
{
"name": "sample-library",
"version": "0.1.0",
"author": {
"name": "IG"
},
"keywords": [
"angular"
],
"license": "MIT",
"main": "sample-library.umd.js",
"module": "sample-library.js",
"jsnext:main": "sample-library.js",
"typings": "sample-library.d.ts",
"peerDependencies": {
...
}
}
tsconfig.es5.json:
{
"compilerOptions": {
"declaration": true,
"module": "es2015",
"target": "es5",
"baseUrl": ".",
"stripInternal": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"moduleResolution": "node",
"outDir": "../build",
"rootDir": ".",
"lib": [
"es2015",
"dom"
],
"skipLibCheck": true,
"types": []
},
"angularCompilerOptions": {
"annotateForClosureCompiler": true,
"strictMetadataEmit": true,
"skipTemplateCodegen": true,
"flatModuleOutFile": "sample-library.js",
"flatModuleId": "sample-library"
},
"files": [
"./index.ts"
]
}
index.ts:
import { NgModule, ModuleWithProviders } from '@angular/core';
import { CommonModule } from '@angular/common';
import { SampleComponent } from './sample.component';
export * from './sample.component';
@NgModule({
imports: [
CommonModule
],
declarations: [
SampleComponent
],
exports: [
SampleComponent
]
})
export class SampleModule {
static forRoot(): ModuleWithProviders {
return {
ngModule: SampleModule,
providers: []
};
}
}
私はまた、サンプルlibrary.component.hml、サンプルlibrary.component.scssとサンプルlibrary.component.ts SRC内部を持っています。
この方法で正しく動作します。しかし、同様の方法で同じライブラリに別のコンポーネントを追加する方法がわかりません。何か案が?