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
Using different name for import ng-packagr lib from dist folder is not working #12184
Comments
Hi, changing the tsconfig paths is not enough. You need to change the library name from the In your case most likely you want to name your library always with a scope Can you create a small reproduction please? |
@alan-agius4 Thank you for your answer. So I cannot use different name :( This diagram should help you understand my case, I don't have much time these days but I hope I create small reproduction soon. So the problem is about |
The tsconfig path to node module is not prohibited. Thought the library must be already compiled to JavaScript. I think what you want is to lookup from dist if exists otherwise lookup in node_modules using tsconfig paths. We have reviewed, this issue and determined that it doesn't fall into the bug report or feature request category. This issue tracker is not suitable for support requests, please repost your issue on StackOverflow using tag If you are wondering why we don't resolve support issues via the issue tracker, please check out this explanation. |
I still think this is a bug, but OK, the problem is you cannot use library which is using your library and I think this is relatively common use case. We can take care about it by decoupling our projects to smaller ones. But I don't understand why you can't see the bug here. The exception is pretty straightforward:
In CI/CD side I found some article about removing tsconfig paths before running build:prod, we did the same and it's working but solution like that is horrible from my PoV. Also guys in some Github issue mentioned if they patch compiler file, everything will be working. That means this exception is some safety check isn't it? What about bringing some angular compiler option to disable this check? EDIT: For other people which can face this problem: Workarounded by building local library from |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Hi everyone, I facing interesting problem with Angular ng-packagr powered libraries.
Bug Report or Feature Request (mark with an
x
)Command (mark with an
x
)Versions
macOS High Sierra 10.13.6
Repro steps
Generate library using ng generate library and change tsconfig path.
From:
To:
And use
import { something } from '@ui-components'
. Basically the assumption was I will use@ui-components
in ui-starter app andui-components
in all other places. But looks like there is some "magic" because any other name than original one causing the same error.The log given by the failure
Desired functionality
It should work with a different name inside "main" application.
Mention any other details that might be useful
You might want to know why I want to have this feature. Let me shorty explain our problem.
We have application called ui-starter, this application contains projects folder with ui-components library. From ui-starter project we using this library by
import { something } from 'ui-components'
with "tsconfig path hack" and everything works nice and smooth.The problem started when we add another application (table-app) which has dependency to ui-components project. This application wants to consume ui-components source code during AOT build and it fails with error:
ERROR in : Error: Trying to import a source file from a node_modules package:
It's maybe possible to have some circular dependencies but I think it's normal use case.So my assumption was let's change paths config and use some prefixed version inside ui-starter app, let's say
@ui-components
or_ui-components
. But unfortunately I am not able to use this approach. I spend lot of time reading other issues here, in stackoverflow and in other repos, that's the reason why I create my own one.Thank you very much for any help.
The text was updated successfully, but these errors were encountered: