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
Secondary entry point not working consistently in typescript <2.6 #677
Comments
Update: Getting some odd behavior... The demo app compilation fails initially, but when any code is changed to cause a recompile, the app works (though the error still exists in the terminal) Reproduction
Gif of recompile: |
I can 100% confirm this behaviour with the 2.2 ng-packagr Look here: Boils down to this:
Don't think that this is working as expected. Otherwise all of my peer dependencies spread over different modules will land in the main entry file despite carefully curating my different entry points . A dependency would land in the main entry event when not using the origin module. I would also love to help you with a more minimal example with |
Hi, @benjamincharity @georgiee thanks for the good issue reports! I am going to look at it. |
I checked your repros and looked at the generated In PR #685, the feature seems to be working, even with The error is reported in the app's build in |
Thanks a lot for your response. I just compiled the samples and run the consumer part of your test suites. Nothing wrong in there indeed. I also looked into the examples of secondary and primary. The only difference I spot is that the entry point of To be honest, I hurried here too quickly after tinkering with ng-packagr so much. So I will double check the issue trackers of Angular CLI and webpack too ✌️ But before doing so I will try to drop in my example into your sample/consumer environment. Thanks a lot! |
Hello, I did the following criss-cross checkings for confirmation.
This is clearly a problem further down in the pipeline. When comparing the two package.json files I noticed some gaps in the versioning.
I tested all of them with a clean
👇 Typescript Angular Release v6 is imminent but the CLI schematics are still pointing to 2.5.3 (https://github.com/angular/devkit/blob/891f4706c89967b9bbe14da57c02e49f35f13799/packages/schematics/angular/application/files/package.json) Everything is fine on the ng-packagr side. We maintainers of an Angular library have now to deal with the problem that our users will run into that problem as their friendly Angular CLI is pointing to an outdated version of TS when creating an App. Looks like fun 😑 |
Summary: to use secondary entry points, you need to use typescript 2.6 (or later) in the app? |
Yes👌 |
For me there is something that even with typescript >2.6 isn't working regarding dependency injection and extended services. I have a FooModule and a BarModule in a structure like this: foo/bar. In my BarModule I have a SettingsService and use the APP_INITIALIZER inject token to load() my settings from a backend service before the app starts. Now in my app I have a MySettingsService which extends the SettingsService from my library to modify some settings and tell the SettingsService where the backend service is located etc and provide the SettingsService token with useExisting MySettingsService. If i use both modules via one primary entry point, everything works fine, MySettingsService.load() is executed and everywhere in FooModule and BarModule MySettingsService is used instead of SettingsService. If i use secondary entry points however the SettingsService.load() function is executed and MySettingsService isn't used. Any ideas why this is working differently with secondary entry points? |
You have given a pretty good mental image of what you are doing. But without a working minimal example it's pretty hard to answer if its a mistake on your side, a bug in Angular or something off with the library. I have at least no immediate idea what's wrong. You should reproduce it in a project and provide it- also test some variants like this when preparing:
|
I was facing this issue as well and figured that the problem is likely due to a missing I noticed that Angular packages themselves do also include an https://github.com/angular/angular/blob/6.0.x/packages/common/http/index.ts: /**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
// This file is not used to build this module. It is only used during editing
// by the TypeScript language service and during build for verification. `ngc`
// replaces this file with production index.ts when it rewrites private symbol
// names.
export * from './public_api'; To get the For more information on why the double indirection seems to exist, see nrwl/nx#155 for a discussion. |
This issue has been automatically locked due to inactivity. |
Type of Issue
Description
Desire: A single library with multiple entry points:
ng-packaged
repo as my starting point and changed a few names and added a secondary entry forkeycodes
.ERROR in src/app/app.component.ts(9,24): error TS2307: Cannot find module '@terminus/test/keycodes'.
How To Reproduce
My test library (cloned from
ng-packaged
): https://github.com/GetTerminus/testA fresh CLI project with the library added: https://github.com/benjamincharity/test-demo
test-demo
projectyarn install && ng serve
Expected Behaviour
No errors should exist in the terminal during a build consuming the library.
I know this should be supported so I'm assuming I'm missing something simple? Any direction would be appreciated! 🙏
Version Information
Please include all version numbers that might be relevant, e.g. third-party libraries
The text was updated successfully, but these errors were encountered: