Skip to content

feat(@angular/build): add dataurl, base64 loaders #30422

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

Merged
merged 1 commit into from
Jun 3, 2025

Conversation

imirkin
Copy link
Contributor

@imirkin imirkin commented May 30, 2025

This passes through the existing esbuild functionality to support dataurl and base64 loaders, in addition to the pre-existing text, binary, and file loaders.

Both the dataurl and base64 loaders return strings with the relevant content. There is no way to control whether the dataurl method uses base64 or plain text encoding, and no way to control the mime type it detects.

Fixes #30391

PR Checklist

Please check to confirm your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

Currently only the text/binary/file esbuild loaders are usable.

Issue Number: #30391

What is the new behavior?

This adds the dataurl/base64 loaders as well.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

It wasn't clear to me how to cause the documentation at e.g. https://angular.dev/tools/cli/build-system-migration#file-extension-loader-customization to be updated. I updated the comments in schema.json.

@angular-robot angular-robot bot added detected: feature PR contains a feature commit area: @angular/build labels May 30, 2025
@imirkin imirkin force-pushed the esbuild-more-loaders branch from 2ae5328 to 8bb46cd Compare May 30, 2025 02:35
@alan-agius4 alan-agius4 requested a review from clydin May 30, 2025 07:30
@alan-agius4 alan-agius4 added the action: review The PR is still awaiting reviews from at least one requested reviewer label May 30, 2025
@imirkin
Copy link
Contributor Author

imirkin commented May 30, 2025

Let me know if you want me to fix the lint issue. Prettier wants some IMO questionable formatting:

  let loaderExtensions:
    | Record<string, 'text' | 'binary' | 'file' | 'dataurl' | 'base64'>
    | undefined;

and

      if (
        value !== 'text' &&
        value !== 'binary' &&
        value !== 'file' &&
        value !== 'dataurl' &&
        value !== 'base64' &&
        value !== 'empty'
      ) {
        continue;
      }

But if that's the project style, happy to include.

Pass through the existing esbuild functionality to support dataurl and
base64 loaders, in addition to the pre-existing text, binary, and file
loaders.

Both the dataurl and base64 loaders return strings with the relevant
content. There is no way to control whether the dataurl method uses
base64 or plain text encoding, and no way to control the mime type it
detects.

Fixes angular#30391
@imirkin imirkin force-pushed the esbuild-more-loaders branch from 8bb46cd to 2f7b262 Compare May 30, 2025 23:25
@clydin clydin added target: minor This PR is targeted for the next minor release and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Jun 3, 2025
@alan-agius4 alan-agius4 added the action: merge The PR is ready for merge by the caretaker label Jun 3, 2025
@dgp1130 dgp1130 merged commit 8f305ef into angular:main Jun 3, 2025
32 checks passed
@dgp1130
Copy link
Collaborator

dgp1130 commented Jun 3, 2025

Thanks for the contribution, great addition to the CLI!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
action: merge The PR is ready for merge by the caretaker area: @angular/build detected: feature PR contains a feature commit target: minor This PR is targeted for the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for a data url file loader with application/esbuild builders
4 participants