angular-cli library create secondary entry point

后端 未结 3 1958
眼角桃花
眼角桃花 2021-02-13 18:26

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
@sc         


        
3条回答
  •  一生所求
    2021-02-13 18:47

    Example Folder Layout for Secondary Entrypoints

    All you have to do is create a package.json file and put it where you want a secondary entry point to be created. One way this can be done is by mimicking the folder structure of the following example which has a testing entry point in addition to its main entry point.

    my_package
    ├── src
    |   ├── public_api.ts
    |   └── *.ts
    ├── ng-package.json
    ├── package.json
    └── testing
        ├── src
        |   ├── public_api.ts
        |   └── *.ts
        └── package.json
    

    The contents of my_package/testing/package.json can be as simple as:

    {
      "ngPackage": {}
    }
    

    No, that is not a typo. No name is required. No version is required. It's all handled for you by ng-packagr! When built, the primary entry point is imported by import {..} from '@my/library' and the secondary entry point with import {..} from '@my/library/testing'

    Source - https://github.com/ng-packagr/ng-packagr/blob/master/docs/secondary-entrypoints.md

提交回复
热议问题