Skip to content

new URL('...', import.meta.url) pattern isn't processed properly by Angular CLI #22388

Closed
@log2-hwan

Description

@log2-hwan

🐞 Bug report

Command (mark with an x)

  • new
  • build
  • serve
  • test
  • e2e
  • generate
  • add
  • update
  • lint
  • extract-i18n
  • run
  • config
  • help
  • version
  • doc

Is this a regression?

Yes, the previous version in which this bug was not present was: 13.0.4

Description

const svgFileUrl = new URL('./test.svg', import.meta.url);

Angular CLI used to transform this code pattern with a url pointing build destination directory so it works properly after build. But after updating to 13.1, it only transforms import.meta.url part to file: protocol url.

I'm not sure this is considered as implementation detail from webpack, but syntaxes used in the code is all from web standard and it is working properly without transformation(Angular CLI build process), so I think it should be supported by Angular CLI.

🔬 Minimal Reproduction

https://github.com/log2-hwan/angular-cli-svg-url-bug

🔥 Exception or Error

Wrong url in output js bundle

🌍 Your Environment


Angular CLI: 13.1.2
Node: 16.13.1
Package Manager: yarn 1.22.15
OS: darwin arm64

Angular: 13.1.1
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1301.2
@angular-devkit/build-angular   13.1.2
@angular-devkit/core            13.1.2
@angular-devkit/schematics      13.1.2
@angular/cli                    13.1.2
@schematics/angular             13.1.2
rxjs                            7.4.0
typescript                      4.5.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions