respect wepack export condition for importing
- 主要語言
- TypeScript
- 星號
- 27k
- 分支
- 11.8k
- 平均合併
- 14 小時 23 分鐘
- 30 天內合併 PR
- 162
描述
### Command
build, extract-i18n, serve, test
### Description
The root problem I am trying to solve is the different import behavior of esbuild and webpack for url resources like described here ( https://github.com/angular/angular-cli/issues/24470 ).
We have a npm package shipping company fonts and scss file to import them.
I know that there are other possibilities, but I also discovered that we could have different entrypoints for webpack and esbuild
when using conditions in the package.json as described here: https://webpack.js.org/guides/package-exports/#conditions-preprocessor-and-runtimes.
This was leading me to this package.json
```json
"exports": {
"./styles/*": {
"webpack": {
"sass": "./dist/styles/webpack/*.scss",
"less": "./dist/styles/webpack/*.less",
"style": "./dist/styles/webpack/*.css"
},
"sass": "./dist/styles/*.scss",
"less": "./dist/styles/*.less",
"style": "./dist/styles/*.css"
},
"./*": "./dist/fonts/*"
}
```
The only problem here is, that this does not work. Webpack is loading the normal sass styles.
### Describe the solution you'd like
It would be really cool if the webpack condition is matched.
### Describe alternatives you've considered
We could offer a scss variable so that consumers can override the font path or just casually export the file. This still does not solve the problem when using esbuild and the karma runner but at least they could do something.
I am not sure how much effort it is fixing this, but in case you just need to add `webpack` here: https://github.com/angular/angular-cli/blob/main/packages/angular_devkit/build_angular/src/tools/webpack/configs/styles.ts#L382 it would be really cool if you could do it.
貢獻指南
研究方向
從 packages/angular_devkit/build_angular/src/tools/webpack/configs/styles.ts 約第 382 行開始,追蹤 style 匯入如何解析套件的匯出條件。使用套件範例執行 build、extract-i18n、serve 和 test 命令;當 webpack 選取其條件,且現有的 sass、less 和 style 解析仍能正常運作時,即表示完成。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- sass, scss, typescript, webpack
- 領域
- build-system, tooling
- Issue 類型
- 功能
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100