ng-packagr

How to mix Angular Elements with the “ng g library” approach?

落花浮王杯 提交于 2019-12-03 05:47:28
问题 As you know, the "ng g library" approach helps us with the creation of libraries of reusable components. But what if I wanted those components to be compiled into web components... through the support of Angular Elements? Not only that but also that each component from the lib was to be compiled into its own folder or JS file. How to configure a dev environment that would allow me to achieve that? For example: If I create a Lib and add a custom component, I know that I can compile it,

Packaging an Angular library with i18n support

时间秒杀一切 提交于 2019-12-03 05:44:02
Angular's i18n is great, and tools like ng-packagr makes component library packaging extremely easy, but can they be combined? What if i want to package and distribute a component library having translatable components? Is it possible? How do I package such a library? Will translation files be shipped together with the package, or should they be defined in the main app? It'd be great if someone could point me at some doc. Thanks When you generate a translation file for the main app with the CLI (with ng xi18n ), elements with the attribute i18n in the library are imported in the translation

How do you debug an Angular 6 library

心已入冬 提交于 2019-12-03 02:12:08
I'm writing an Angular 6 Library and cannot figure out how to step into the typescript. I generated the app using: ng new mylibapp I then added the library using: ng g library @abc/cool-lib -p abc when I perform: ng build @abc/cool-lib it generates the code in the mylibapp/dist/abc/cool-lib folder How can I now debug this code and set breakpoints in the ts file located at mylibapp/projects/abc/cool-lib/src/lib Looking at the Angular CLI docs on libraries , it mentions the following: Some similar setups instead add the path to the source code directly inside tsconfig. This makes seeing changes

How to mix Angular Elements with the “ng g library” approach?

久未见 提交于 2019-12-02 20:26:07
As you know, the "ng g library" approach helps us with the creation of libraries of reusable components. But what if I wanted those components to be compiled into web components... through the support of Angular Elements? Not only that but also that each component from the lib was to be compiled into its own folder or JS file. How to configure a dev environment that would allow me to achieve that? For example: If I create a Lib and add a custom component, I know that I can compile it, generating a series of folders, such as esm5, esm2015, fesm5, etc. Now, the question is: How can I add, let's

angular-cli library create secondary entry point

最后都变了- 提交于 2019-11-30 14:47:29
I am trying to create what I believe is called a secondary entry point into my angular npm package. I want the following two entry points @scope/data-service @scope/data-service/models Using the angular-cli to generate the base package generates the following structure scope └───data-service │ karma.conf.js │ ng-package.json │ ng-package.prod.json │ package.json │ tsconfig.lib.json │ tsconfig.spec.json │ tslint.json │ └───src │ public_api.ts │ test.ts │ └───lib data-service.component.spec.ts data-service.component.ts data-service.module.ts data-service.service.spec.ts data-service.service.ts

'rootDir' is expected to contain all source files

妖精的绣舞 提交于 2019-11-29 13:21:32
I have an Angular CLI workspace containing two library projects, foo and bar . When I build the second of the two libraries, foo , the build fails with the following error: error TS6059: File '/code/projects/bar/src/lib/types.ts' is not under 'rootDir' '/code/projects/foo/src'. 'rootDir' is expected tocontain all source files. Error: error TS6059: File '/code/projects/bar/src/lib/types.ts' is not under 'rootDir' '/code/projects/foo/src'. 'rootDir' is expected to contain all source files. at Object.<anonymous> (/code/node_modules/ng-packagr/lib/ngc/compile-source-files.js:53:68) at Generator

Angular 6 building a library with assets

百般思念 提交于 2019-11-28 17:38:49
问题 Upon building & packaging an Angular 6 library, I can't seem to be able to instruct the Angular CLI to copy the library's assets into the dist/assets folder on every build. Assuming the project's folder structure is this - - dist - e2e - node_modules - projects - lib1 - src - lib - assets - icons - src When I run ng build lib1 or ng build lib1 --prod the assets/icons folder is not being copied into dist/lib1/assets/icons . If I run ng build then src/assets (the root src/assets) is being

'rootDir' is expected to contain all source files

随声附和 提交于 2019-11-28 07:10:39
问题 I have an Angular CLI workspace containing two library projects, foo and bar . When I build the second of the two libraries, foo , the build fails with the following error: error TS6059: File '/code/projects/bar/src/lib/types.ts' is not under 'rootDir' '/code/projects/foo/src'. 'rootDir' is expected tocontain all source files. Error: error TS6059: File '/code/projects/bar/src/lib/types.ts' is not under 'rootDir' '/code/projects/foo/src'. 'rootDir' is expected to contain all source files. at