-
Notifications
You must be signed in to change notification settings - Fork 12k
Library with Typescript files fails to compile in AOT #6228
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
Comments
Does this also happen if you run AOT via |
@filipesilva I'm actually not sure, because |
We can take a look if you can create a simple repro of this issue, but off the top of my head nothing occurs to me. |
@filipesilva Alright, I've pushed up a simple repo with the error present. Its pulled from our actual app then altered to remove company info and irrelevant stuff, but I'm sure there's still unused imports and stuff. https://github.com/swimmadude66/BrokenPathNgToolsWebpack When running the webpack AOT build via
|
@swimmadude66 the library you're using isn't AOT compatible, that is why it doesn't work. There isn't a lot of guidance around as to how build a AOT compatible library, but you can find a WIP at angular/angular#16486. |
@filipesilva the library we are using is just regular ts files. We are referencing them the same way we would a local file, but inside did you look at the repo I posted above? |
I did look at the repo, that's is how I identified the problem. In your package.json you are trying to install that library... but you also want to not really use it as a library, but rather as just a bunch of files your project uses. This, unfortunately, doesn't work very well. You either have a library or you don't, and the middleground where you just have a few TS files in Kind of like when people publish ES6 libs to In the WIP guide I linked you there's a section on why you can't just publish TS files to npm that explains it a bit more. I know you're not publishing to npm, but you're kinda of pretending your folder is a library anyway. And the problem isn't that it's on npm, it's how the library is packaged and how it's meant to be consumed. The TLDR is that all if you want to have a library you do have to package it, just having the TS files there won't work. It might have worked on a certain setup, with certain dependencies, but that's not how libraries are meant to be consumed and thus not really a supported scenario. I'm not trying to downplay how this sort of thing is frustrating... I know it is, and I know that guidance is scarce, and that means that it's really hard to set stuff up. On my plate is to do a CLI story on how to work with linked libs, which I hope will help. |
@filipesilva alright, I understand now. Thanks for the thoughtful response. This is pretty frustrating, but I guess it makes sense that this is an edge-use case that doesn't necessarily warrant consideration in this sort of project. My team is working on flattening our shared code in to each partner project and re-thinking how we can reuse components if not through imports. |
@swimmadude66 the story I had for linked libs was merged https://github.com/angular/angular-cli/blob/master/docs/documentation/stories/linked-library.md, but bear in mind that this guidance requires at least |
Also, there is a WIP guide for libraries in angular/angular#16486, sample repo at https://github.com/filipesilva/angular-quickstart-lib for now. Hope this helps. |
Thanks. We just removed our shared library entirely and flattened it into each partner implementation. Its not exactly DRY, but if it wont work with the framework we chose, we will have to come up with something else. |
@filipesilva Cool stuff with the guide. Are there any plans to support such library and integration configuration with the CLI as well? |
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. |
Versions.
node v6.10.0
npm v3.10.10
Windows 10
Repro steps.
We have a shared component library in our node_modules. We use some, but not all, of the components in our actual app. In some cases, we use a component which has another component's selector string in its template, while overriding the component referenced. When we run AoT, the errors claim that the overridden component can not be found. However, the path logged is incorrect, which is probably why it cannot be found.
eg.
node_modules/@shared/angular/components/demo/template.html
is<other-component><other-component>
src/components/other/component.ts
has some customized codeIf we run AoT through @ngtools/webpack we get something like this:
Desired functionality.
I'd expect it to resolve to the correct file. removing the
$$_gendir
from the second path makes it point to the correct file, so clearly there's just a path resolution error somewhere.The text was updated successfully, but these errors were encountered: