Skip to content

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

Closed
@jnizet

Description

@jnizet

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions