respect wepack export condition for importing

Abierto
#27,100 4 comentarios 12 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
35/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
sass, scss, typescript, webpack

Línea de trabajo

Comienza en packages/angular_devkit/build_angular/src/tools/webpack/configs/styles.ts alrededor de la línea 382 y sigue cómo las importaciones de estilos resuelven las condiciones de exportación de los paquetes. Ejecuta los comandos build, extract-i18n, serve y test con el ejemplo de paquete; se considera terminado cuando webpack selecciona su condición y la resolución existente de sass, less y style sigue funcionando.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

area: @angular-devkit/build-angular devkit/build-angular:browser feature feature: insufficient votes
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

  "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.

Lenguaje dominante
TypeScript
Estrellas
27k
Forks
11.8k
Merge medio
16 h 35 min
PR fusionados (30 d)
176

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de angular/angular-cli

Todos los issues de angular/angular-cli

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.