Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when building library without sub entry points with tsconfig path mappings #1759

Closed
victorsc opened this issue Sep 28, 2020 · 2 comments

Comments

@victorsc
Copy link

victorsc commented Sep 28, 2020

Type of Issue

[x] Bug Report
[ ] Feature Request

Description

I am trying to build a library that does not have sub entry points but has absolute imports between its components along with path mappings in tsconfig.

How To Reproduce

I created a small library for reproducing the error.

Please note:

  1. in projects/lib-path-mapping/src/lib/comp1/comp1.component.ts
import {Comp2Component} from 'lib-path-mapping/comp2';
  1. in projects/lib-path-mapping/tsconfig.lib.json
    "baseUrl": ".",
    "paths": {
      "lib-path-mapping/*": ["src/lib/*"]
    },
  • run ng build
ERROR: Entry point lib-path-mapping/comp2 which is required by lib-path-mapping doesn't exists.
An unhandled exception occurred: Entry point lib-path-mapping/comp2 which is required by lib-path-mapping doesn't exists.

Expected Behaviour

I would expect that path mappings are considered before any sub entry checks done on the source files.

I suspect that the issue comes from

if (moduleName === primaryModuleId || moduleName.startsWith(`${primaryModuleId}/`)) {

Is it possible to take into account path mappings before adding the potentialDependency?

from

            if (moduleName === primaryModuleId || moduleName.startsWith(`${primaryModuleId}/`)) {
                potentialDependencies.add(moduleName);
            }

to

            let pathMapped = false;
            Object.keys(tsConfigOptions.paths).forEach(path => {
                if (minimatch(moduleName, path)) pathMapped = true;
            });
            if (moduleName === primaryModuleId || (!pathMapped && moduleName.startsWith(`${primaryModuleId}/`))) {
                potentialDependencies.add(moduleName);
            }

Thank you.

Version Information

$ node_modules/.bin/ng-packagr --version
ng-packagr: 10.1.0
@angular/compiler: 10.0.14
typescript: 3.9.7
rxjs: 6.6.3
node: 12.13.1
yarn: 1.21.1
@SchnWalter
Copy link
Contributor

The whole idea of ng-packagr is to package libraries in the Angular Package Format and from what I can tell, what you are trying to do isn't really compatible with APF. I would suggest that you stick to relative imports and sub-packages (sub entry points).

If what you are trying to do is work around the performance issue that you've mentioned in #1758, you should close this story and provide more information there, together with a reproduction repository.

@github-actions
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

This action has been performed automatically by a bot.

@github-actions github-actions bot locked and limited conversation to collaborators Oct 31, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants