simontonsoftware / s-libs

A collection of libraries for any of javascript, rxjs, or angular.
MIT License
43 stars 5 forks source link

Add extendMetadata to public api to avoid restricted imports #94

Closed njourdain closed 1 year ago

njourdain commented 1 year ago

I don't see any reason why this function should be restricted.

ersimont commented 1 year ago

Can you provide some more info about what error or warning you are seeing, and how you produce it?

njourdain commented 1 year ago

In my example, I have a class that extends ComponentContext. The constructor adds provider like this :

super(
      componentType,
      extendMetadata(moduleMetadata, {
        providers: [
          MockBlobService,
          { provide: BlobService, useExisting: MockBlobService },
        ],
      }),
    );

Which requires the following import

// eslint-disable-next-line no-restricted-imports -- test
import { extendMetadata } from '@s-libs/ng-dev/lib/angular-context/angular-context';

And building this code generates the following error : Error: Module not found: Error: Package path ./lib/angular-context/angular-context is not exported from package /Users/nicolasjourdain/Documents/Repositories/Sama/clone/workspace-core/node_modules/@s-libs/ng-dev (see exports field in /Users/nicolasjourdain/Documents/Repositories/Sama/clone/workspace-core/node_modules/@s-libs/ng-dev/package.json)

ersimont commented 1 year ago

Ah I see. That function is intended for internal use within the library. It even has a special case just for ComponentContext. If you want similar functionality, I recommend creating your own similar function (probably without the special case).