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

[BREAKING] Enable Ivy distribution #90

Merged
merged 31 commits into from
Sep 23, 2022

Conversation

denysoblohin-okta
Copy link
Collaborator

@denysoblohin-okta denysoblohin-okta commented Mar 28, 2022

  • Enable Ivy and partial compiling
  • BREAKING - Minimum supported version of Angular is 12
  • Updated to ESM. Package now corresponds to APF 13, compatible with APF 12
  • Updated dependencies (OKTA-527550, OKTA-514732, OKTA-514733, OKTA-534503)

Issue: #86
Internal ref: OKTA-530587

@@ -17,6 +17,9 @@
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"allowedCommonJsDependencies": [
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To fix warnings like

Warning: @babel/runtime-corejs3/core-js/map depends on 'core-js-pure/features/map'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Appreciate the work! Thank you for taking the time to do this POC.

It would be nice if this could be amended to notate that it's not actually a "fix," it merely instructs angular to not emit the warning. The optimization phase can still bail out if there's a conflict in the upstream dep, which will result in an unnecessarily fat build.

A fix would either be transpiling or rewriting the build with ecmascript modules. As a consumer I would appreciate the warning being present until such time as this is the case as it provides ready answer to the inevitable "why is my output so large?" question when the build triggers budget warnings.

re:

https://angular.io/guide/build#configuring-commonjs-dependencies


The Angular CLI outputs warnings if it detects that your browser application depends on CommonJS modules. To disable these warnings, add the CommonJS module name to allowedCommonJsDependencies option in the build options located in angular.json file.

CommonJs impact on optimization:
https://web.dev/commonjs-larger-bundles/

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.
Current warnings:

 Warning: /node_modules/@okta/okta-auth-js/esm/browser/AuthStateManager.js depends on 'p-cancelable'. CommonJS or AMD dependencies can cause optimization bailouts.
 For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

 Warning: /node_modules/@okta/okta-auth-js/esm/browser/OktaAuth.js depends on 'tiny-emitter'. CommonJS or AMD dependencies can cause optimization bailouts.
 For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

 Warning: /node_modules/@okta/okta-auth-js/esm/browser/fetch/fetchRequest.js depends on 'cross-fetch'. CommonJS or AMD dependencies can cause optimization bailouts.
 For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies
 
 Warning: /node_modules/unload/dist/es/index.js depends on 'detect-node'. CommonJS or AMD dependencies can cause optimization bailouts.
 For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

@@ -24,7 +24,7 @@
"typeRoots": [
"node_modules/@types/"
],
"types": ["node", "webappsec-credential-management"],
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed if building on Angular 12

@@ -14,6 +14,7 @@ export { OktaAuthModule } from './okta/okta.module';
export { OktaAuthGuard } from './okta/okta.guard';
export { OktaConfig, OKTA_CONFIG, OKTA_AUTH } from './okta/models/okta.config';
export { OktaAuthStateService } from './okta/services/auth-state.service';
export { OktaHasAnyGroupDirective } from './okta/has-any-group.directive';
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To fix build on Angular 12:

src/okta/has-any-group.directive.ts:5:14 - error NG3001: Unsupported private class OktaHasAnyGroupDirective. This class is visible to consumers via OktaAuthModule -> OktaHasAnyGroupDirective, but is not exported from the top-level library entrypoint.

5 export class OktaHasAnyGroupDirective {

@denysoblohin-okta denysoblohin-okta changed the title POC Ivy distribution [POC] Ivy distribution Mar 28, 2022
@denysoblohin-okta denysoblohin-okta marked this pull request as ready for review March 28, 2022 19:22
@denysoblohin-okta denysoblohin-okta marked this pull request as draft March 28, 2022 19:53
@denysoblohin-okta denysoblohin-okta force-pushed the od-ivy-OKTA-469350 branch 2 times, most recently from f0163a9 to 9a8c284 Compare March 28, 2022 20:33
@denysoblohin-okta denysoblohin-okta changed the title [POC] Ivy distribution [BREAKING] Enable Ivy distribution Sep 15, 2022
@denysoblohin-okta denysoblohin-okta marked this pull request as ready for review September 15, 2022 18:41
build.js Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants