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

build(angular): use partial compilation for published angular library #6636

Conversation

yharaskrik
Copy link

@yharaskrik yharaskrik commented Jan 2, 2023

Before submitting a pull request, please take a look at our
Contributing guidelines and verify:

  • If you've added code that should be tested, please add tests.
  • Ensure your code lints and the test suite passes (yarn lint) & (yarn test).

@Lms24 Lms24 self-requested a review January 3, 2023 00:21
@Lms24
Copy link
Member

Lms24 commented Jan 3, 2023

Hi @yharaskrik, thanks for opening this PR! So I tried setting compilationMode: 'partial' a while ago when changing the Angular SDK's build process (#4641). This was quite some time ago so I might have missed something back then. However, I found that I was getting a build error because setting partial was not yet supported for Angular 10 production builds (i.e. ng build --prod). I'm curious if I missed something back then or if this is still a problem (CI will probably tell us).

Also, remind me if possible, does this actually fix #5268 in the sense that we get rid of the compiler warning? My impression was that ngcc would still be needed to upcompile the SDK to more recent, Ivy-only Angular versions?

@Lms24 Lms24 added the Package: angular Issues related to the Sentry Angular SDK label Jan 3, 2023
@yharaskrik
Copy link
Author

Hi @yharaskrik, thanks for opening this PR! So I tried setting compilationMode: 'partial' a while ago when changing the Angular SDK's build process (#4641). This was quite some time ago so I might have missed something back then. However, I found that I was getting a build error because setting partial was not yet supported for Angular 10 production builds (i.e. ng build --prod). I'm curious if I missed something back then or if this is still a problem (CI will probably tell us).

Also, remind me if possible, does this actually fix #5268 in the sense that we get rid of the compiler warning? My impression was that ngcc would still be needed to upcompile the SDK to more recent, Ivy-only Angular versions?

Hmm I ran the builds locally and they worked so it seems the flag is ok? Although I'm unsure if that flag existed in Angular 10. Is there a reason you guys are using Ng 10 to compile your SDK and not a newer version?

Yes it will get rid of that warning. that warning is shown when a library is not compiled with partial or full (ie. Was compiled in the view engine format)

@Lms24
Copy link
Member

Lms24 commented Jan 3, 2023

Is there a reason you guys are using Ng 10 to compile your SDK and not a newer version

Yes, Angular libraries are only forward-compatible, meaning if I compile with ng10, the library will work with all Angular versions starting with ng10 but there's no guarantee for any version below ng10. Our minimum supported Angular version is still Angular 10 which we can't change until we release a new major version. So we can't compile with a newer Angular version. To remove the ngcc warning, we previously decided to drop Angular 10 and 11 in the next major which should enable us to fully support Ivy going forward.

That being said, if your PR works indeed and I missed something when working on #4641 (which could very well be the case), we might just get around this overall. That is, assuming that the partial format continues to work in future Angular versions as well. Do you by any chance happen to have some context around this?

We need to carefully test this change though, meaning we have to build the SDK with this change and test it in every Angular version from 10-15. A good test would include the usage of TraceDirective as it is the one component in our SDK that actually requires Angular-specific compilation.

I might have some time in the next days to test this properly.

@yharaskrik
Copy link
Author

yharaskrik commented Jan 3, 2023 via email

@Lms24
Copy link
Member

Lms24 commented Jan 5, 2023

Hi @yharaskrik so I've tested your changes with Angular 10 and Angular 15. For NG10, things still seem to work (as I expected) but for NG15, I'm getting build errors at application build time, which to me look a lot like Ivy incompatibility errors:

NG13:

ngTest13/node_modules/@angular/core/core"' has no exported member 'ɵɵNgModuleDefWithMeta'.

58     static ɵmod: i0.ɵɵNgModuleDefWithMeta<TraceModule, [typeof TraceDirective], never, [typeof TraceDirective]>;

NG15:

ngTest15/node_modules/@angular/core/index"' has no exported member 'ɵɵFactoryDef'.

36     static ɵfac: i0.ɵɵFactoryDef<SentryErrorHandler, never>;

I'd have loved to have seen this worked as it would have resolved a tricky issue. Unfortunately, there seems no way around dopping Ng10 and 11 support and compiling for Ivy with Ng12.
Please let me know if you have other ideas. Otherwise I'm gonna close this PR.

Thanks for taking a look though, appreciate the help!

@yharaskrik
Copy link
Author

Hi @yharaskrik so I've tested your changes with Angular 10 and Angular 15. For NG10, things still seem to work (as I expected) but for NG15, I'm getting build errors at application build time, which to me look a lot like Ivy incompatibility errors:

NG13:

ngTest13/node_modules/@angular/core/core"' has no exported member 'ɵɵNgModuleDefWithMeta'.

58     static ɵmod: i0.ɵɵNgModuleDefWithMeta<TraceModule, [typeof TraceDirective], never, [typeof TraceDirective]>;

NG15:

ngTest15/node_modules/@angular/core/index"' has no exported member 'ɵɵFactoryDef'.

36     static ɵfac: i0.ɵɵFactoryDef<SentryErrorHandler, never>;

I'd have loved to have seen this worked as it would have resolved a tricky issue. Unfortunately, there seems no way around dopping Ng10 and 11 support and compiling for Ivy with Ng12. Please let me know if you have other ideas. Otherwise I'm gonna close this PR.

Thanks for taking a look though, appreciate the help!

Ya, I think you are right. Unfortunately I guess we will have to wait. Thanks anyway!

@yharaskrik yharaskrik closed this Jan 5, 2023
@Yberion
Copy link

Yberion commented Feb 17, 2023

Hello @Lms24, just for information, following recent updates from Angular which will probably land with Angular 16, NGCC got removed, meaning that this library won't work anymore with View Engine unless you compile with "compilationMode": "partial".

angular/angular#49101

@Lms24
Copy link
Member

Lms24 commented Feb 17, 2023

Hi @Yberion - we're aware. We recently decided to create a new, ivy compatible package: #5268 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Package: angular Issues related to the Sentry Angular SDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants