Reputation: 51
I have created a lib Angular by command:
ng generate library wrapper-cesium-panorama
Then I build it:
ng build cesium-panorama-lib
After I moved to /dict/cesium-panorama-lib
folder and made:
npm publish
It cratead a npm package.
Then I have installed this package in existing Angular app:
npm i cesium-panorama-lib
It created package in /node_modules
folder:
I try to use this library in Angular app:
import { CesiumPanoramaLibModule } from "cesium-panorama-libi";
It can not find path. Then I tried:
import { CesiumPanoramaLibModule } from "cesium-panorama-lib/src/public-api";
imports: [CesiumPanoramaLibModule]
It works, but after build app I got this message:
ERROR in ./node_modules/cesium-panorama-lib/src/public-api.ts
Module build failed (from ./node_modules/@ngtools/webpack/src/index.js):
Error: C:\Users\poDesktop\AngularPrototype\node_modules\cesium-panorama-lib\src\public-api.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.
The missing file seems to be part of a third party library. TS files in published libraries are often a sign of a badly packaged library. Please open an issue in the library repository to alert its author and ask them to package the library using the Angular Package Format
at AngularCompilerPlugin.getCompiledFile (C:\Users\ponom\Desktop\AngularPrototype\node_modules\@ngtools\webpack\src\angular_compiler_plugin.js:913:23)
What do I do wrong and how to use it? I meantored that other packages has index.js
in root directory
Upvotes: 1
Views: 468
Reputation: 2361
you should export all your component and modules you want expose in public-api.ts
then when you have installed your library you should be able to import your modules/component like this: import { CesiumPanoramaLibModule } from "cesium-panorama-lib";
if you cannot import it like this, then you have a problem in your library
Upvotes: 1