angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

new text loader in 17.1.0-rc.1 doesn't load files from node_modules

Open jnizet opened this issue 5 months ago • 1 comments

Command

serve

Is this a regression?

  • No

Description

Using the new loader support in version 17.1 to load the content of a file as text using an import statement works fine, but not when the file is under node_modules, unless using a complete relative path such as ../../node_modules/bootstrap-icons/icons/save.svg.

When using the path that looks more logical to me (bootstrap-icons/icons/save.svg), then the CLI outputs a warning in the console:

Cannot optimize dependency: bootstrap-icons/icons/save.svg, present in 'optimizeDeps.include'

and instead of loading the file content, it loads the text /@fs/home/projects/stackblitz-starters-ycv7cm/repro/node_modules/bootstrap-icons/icons/save.svg

Minimal Reproduction

https://stackblitz.com/edit/stackblitz-starters-ycv7cm?file=repro%2Fsrc%2Fapp%2Fapp.component.ts

  • cd repro
  • npm i
  • ng serve

Exception or Error

No response

Your Environment

Angular CLI: 17.1.0-rc.1
Node: 18.18.0
Package Manager: npm 9.4.2
OS: linux x64

Angular: 17.1.0-rc.0
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1701.0-rc.1
@angular-devkit/build-angular   17.1.0-rc.1
@angular-devkit/core            17.1.0-rc.1
@angular-devkit/schematics      17.1.0-rc.1
@angular/cli                    17.1.0-rc.1
@schematics/angular             17.1.0-rc.1
rxjs                            7.8.1
typescript                      5.3.3
zone.js                         0.14.3

Anything else relevant?

No response

jnizet avatar Jan 14 '24 19:01 jnizet

I've just run into this problem as well. Thanks for pointing out that a relative path can be used as a workaround. I didn't think to try that.

reduckted avatar Jan 19 '24 12:01 reduckted

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.