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

Added support for the Angular compiler. #990

Merged
merged 1 commit into from
Sep 5, 2024

Conversation

jeroen1602
Copy link
Contributor

Summary

The Angular compiler looks for the main field using a few fields in the package.json. The order it uses is:

  • es2020
  • es2015
  • browser
  • module
  • main

The first entry the Angular compiler would find before this change was the 'browser' entry point. This is however compiled as an umd and Angular is looking for an esm so it would complain (it would still work though). Adding es2020 as an entry point fixes this problem.

Fixes #869

Background & Context

Tasks

  1. Create an Angular application
  2. Add this package as a dependency npm install --save ./path/to/project
  3. Import DOMPurify in the AppComponent and just sanitize some string in the ngOnInit function
  4. Run npm run build to build this application and see that the warning about common js modules is resolved.

Dependencies

  • Resolved dependency
  • Open dependency

The Angular compiler looks for the main field using a few fields in the package.json. The order it uses is:
- es2020
- es2015
- browser
- module
- main

The first entry the Angular compiler would find before this change was the 'browser' entry point. This is however compiled as an `umd` and Angular is looking for an `esm` so it would complain (it would still work though). Adding `es2020` as an entry point fixes this problem.
@jeroen1602
Copy link
Contributor Author

jeroen1602 commented Sep 3, 2024

I don't known how I did it but somehow I changed more files than I wanted, will try to amend this commit.

Edit: Never mind it is a pre-commit step so it's probably meant to do this.

@cure53
Copy link
Owner

cure53 commented Sep 5, 2024

Most excellent, thank you :)

@cure53 cure53 merged commit 1e2cb9b into cure53:main Sep 5, 2024
8 checks passed
@jeroen1602 jeroen1602 deleted the angular_support branch September 9, 2024 09:23
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.

Trying to use in Angular 16, getting "CommonJS or AMD dependencies can cause optimization bailouts."
2 participants