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

Angular should disable webpack's import.meta.url parsing by default #24616

Closed
1 task
dhdaines opened this issue Jan 26, 2023 · 2 comments
Closed
1 task

Angular should disable webpack's import.meta.url parsing by default #24616

dhdaines opened this issue Jan 26, 2023 · 2 comments

Comments

@dhdaines
Copy link

Command

build

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

Previously, it was noticed that when using ES modules (which Angular very much wants you to do), one cannot reference assets using import.meta.url (which is a web standard and really ought to work). See: https://github.com/angular/angular-cli/issues?q=is%3Aissue+import.meta.url+

This issue, which describes the problem well: #22388 was closed bcause it's actually Webpack's fault and Webpack used to unconditionally rewrite import.meta.url to something useless in the absence of a loader. But now we can stop Webpack from doing that, using the parser.javascript.importMeta option: webpack/webpack#15246

... except that to do this in Angular requires a custom webpack configuration.

Since we are not supposed to have webpack-specific configuration in the angular config, it would be nice if the default behaviour of Angular was non-broken. Obviously it would have to be done while conserving the (arguably broken and inconsistent) policy of sometimes using loaders and sometimes not using them.

Minimal Reproduction

See #22388

Exception or Error

Something about not being able to access local content

Your Environment

Angular CLI: 15.1.2
Node: 18.12.1
Package Manager: npm 9.1.3
OS: linux x64

Angular: 15.1.1
... animations, cdk, common, compiler, compiler-cli, core, forms
... localize, material, platform-browser
... platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1501.2
@angular-devkit/build-angular   15.1.2
@angular-devkit/core            15.1.2
@angular-devkit/schematics      15.1.2
@angular/cli                    15.1.2
@schematics/angular             15.1.2
rxjs                            7.5.7
typescript                      4.8.4
webpack                         5.75.0

Anything else relevant?

No response

@alan-agius4
Copy link
Collaborator

Closing in favor of #24617 since it's cover the same topic.

@alan-agius4 alan-agius4 closed this as not planned Won't fix, can't repro, duplicate, stale Jan 27, 2023
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Feb 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants