I want to copy a singular madule from on project to another without hard copy. and need a dependency manager like npm to handle this problem. my two project develop in one company & i can clone two project in on pc.
i want to export a module from one project and import this module to another project with typescript export&import.
please help me to resolve this problem.
in order to publish an angular library first of all you should create your own public API module ( project 1 ), and with a packager (like ng-Packagr) pack the library. and finally use your library in other projects (project 2) in the @NgModule decorator, identify the export components, in export array section, like below example:
ES module export and angular export are two different things. What I propose is just ES module export which means you just export the class itself. There is nothing angular related going on in this line. Also, OP should not put MyApi in exports array btw. Angular modules do not exports services, just directives/pipes/modules.
As all the files are located under the product-list directory, the simplest way is to add all files in the directory to your component. Bit will name it accordingly. For Angular components, we also need to specify the component entry point, which in most cases will be the file containing the ngModule.
For example, to create module with routing and specs use the following command. $ ng g m guest -sp -r installing module create src/app/guest/guest-routing.module.ts create src/app/guest/guest.module.spec.ts create src/app/guest/guest.module.ts All generate module flags: PDF - Download angular-cli for free
in order to publish an angular library first of all you should create your own public API module (project 1), and with a packager (like ng-Packagr) pack the library. and finally use your library in other projects (project 2)
project 1:
exports: [ReviewComponent, ]
and modify package.json file. identity packager in script section:
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
**"packagr": "ng-packagr -p ng-package.json"**
}
create ng-package.json config:
// here is an example
{
"$schema": "./node_modules/ng-packagr/ng-package.schema.json",
"lib": {
"entryFile": "public_api.ts",}
}
create public_api.ts config. that say's which module should be packed for export purpose:
export * from './src/app/reg-review/reg-review.module'
npm run packagr
npm pack
project 2:
npm install ../ngLibs/reg/registeration-0.0.0.tgz --save
you can take advantage of these addresses:
https://www.npmjs.com/package/ng-packagr
https://medium.com/@nikolasleblanc/building-an-angular-4-component-library-with-the-angular-cli-and-ng-packagr-53b2ade0701e
There are multiple options here, depending on what you want to achieve you might pick one over another:
In the end it's about what requirements you have and how you want to work within your company.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With