Skip to content

[Angular] core package should be a bundled dependency #84

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

Closed
JakeLo123 opened this issue May 6, 2024 · 1 comment · Fixed by #113
Closed

[Angular] core package should be a bundled dependency #84

JakeLo123 opened this issue May 6, 2024 · 1 comment · Fixed by #113
Assignees
Labels
Angular Chalk DX general issue not necessarily an observable bug, but needs change

Comments

@JakeLo123
Copy link
Collaborator

JakeLo123 commented May 6, 2024

[Angular] Core Package Should Be a Bundled Dependency

Situation

@fusionauth-sdk/core is a dependency of the three SDKs (React, Angular, Vue). We are using a monorepo to manage these SDKs because they share this framework-agnostic core logic.

Problem

We want to bundle the core package with each SDK for distribution since it's not listed on the npm registry. We use Vite to do this for React and Vue. Angular is slightly different in that @angular-devkit/build-angular:ng-packagr—the builder for Angular libraries—doesn't support bundling dependencies whose source code lives outside the Angular workspace. We've not been able to find a compatible way to bundle the core package into the Angular SDK for distribution.

Solution

Copy the core package src directory into the Angular package without transpiling it and allow Angular's library builder to handle the rest as if it's not an external dependency. The Angular SDK will use relative paths to import the core module from the copied directory.

A script get-sdk-core from the Angular SDK package.json copies it into a git-ignored directory packages/sdk-angular/projects/fusionauth-angular-sdk/src/sdkcore. When developing/debugging, changes should not be made to the git-ignored directory; they should be made in packages/core and then consumed with get-sdk-core.

Drawbacks

Drawbacks of this approach include:

  • We can't use absolute paths within the core package.
  • It may be confusing to new developers on the project. We should add documentation that clarifies why this decision was made.

Alternate Solution

Publish the @fusionauth-sdk/core and allow SDKs to consume it as a non-bundled dependency.

Drawbacks

  • Another set of public documentation to maintain.
  • Adding another publishing cycle/versioning for the dependency.
@JakeLo123 JakeLo123 added Angular general issue not necessarily an observable bug, but needs change labels May 6, 2024
@JakeLo123 JakeLo123 mentioned this issue May 6, 2024
1 task
@JakeLo123 JakeLo123 changed the title [Angular] Create custom webpack config [Angular] core package should be a bundled dependency May 22, 2024
@JakeLo123
Copy link
Collaborator Author

JakeLo123 commented May 22, 2024

I've filed an issue in the ng-packagr repo and see if I can get a better handle on this. ng-packagr/ng-packagr#2853

UPDATE: ng-packagr doesn't handle bundling dependencies. Will probably have to do something custom to build the core package into the angular bundle.

@JakeLo123 JakeLo123 self-assigned this Jun 3, 2024
@JakeLo123 JakeLo123 linked a pull request Jun 5, 2024 that will close this issue
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Angular Chalk DX general issue not necessarily an observable bug, but needs change
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant