angular / angular/angular-cli

assets entry for the build-angular does not support yarn pnp package paths?

未关闭
#25,263 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
area: @angular-devkit/build-angular
主要语言
TypeScript
星标
27k
派生
11.8k
平均合并
14 小时 23 分钟
30 天内合并 PR
162

描述

### 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

It does not appear to be possible to include assets and paths from a yarn pnp package.

It seems that build-angular builder supports pnp package resolution for styles, but not assets.

I would expect the assets path (dictionary specification option) to work to copy paths from pacakges in the pnp environment.

### Minimal Reproduction

% ng new test-yarn-example --style scss --no-routing
% cd test-yarn-example
% yarn add ng2-pdfjs-viewer

Next, add the path to the angular.json.

Just adding the string will result in the error saying it must be in the project source root.

Adding the dictionary version, yields no error but does not copy the assets either.

```
{
"glob": "**/*",
"input": "node_modules/ng2-pdfjs-viewer/pdfjs",
"output": "/assets/pdfjs"
}
```
% yarn build

### Exception or Error

```text
Unable to copy assets: The ng2-pdfjs-viewer/node_modules/pdfjs asset path must start with the project source root.
```

### Your Environment

```text
Angular CLI: 16.0.2
Node: 18.15.0
Package Manager: yarn 3.5.0
OS: darwin arm64

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

Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1600.2 (cli-only)
@angular-devkit/build-angular 16.0.2
@angular-devkit/core 16.0.2 (cli-only)
@angular-devkit/schematics 16.0.2 (cli-only)
@schematics/angular 16.0.2 (cli-only)
rxjs 7.8.1
typescript 5.0.4
```

### Anything else relevant?

_No response_

贡献指南

打开贡献指南

调研方向

首先使用提供的 ng new、yarn add、angular.json 中的 assets 条目和 yarn build 步骤重现问题,然后跟踪 build-angular 的 assets 处理及其包路径解析。完成的标准是:接受来自 Yarn Plug'n'Play 包的 assets 字典路径,并将其复制到配置的输出目录,而不会出现 project source-root 错误。

由索引模型根据 Issue 内容生成。

评估

技术栈
angular, typescript
领域
build-system
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
48/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。