Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐞 Angular buildable lib : Can't find stylesheet to import #26942

Closed
1 of 4 tasks
Yberion opened this issue Jul 15, 2024 · 4 comments
Closed
1 of 4 tasks

🐞 Angular buildable lib : Can't find stylesheet to import #26942

Yberion opened this issue Jul 15, 2024 · 4 comments
Assignees
Labels
scope: angular Issues related to Angular support in Nx type: bug

Comments

@Yberion
Copy link

Yberion commented Jul 15, 2024

Current Behavior

I'm getting an error trying to build a lib that contain scss using @angular/material.

On my real app, when the lib wasn't buildable it worked fine.

Maybe I'm doing something wrong with the setup or usage of scss import (@use)

Expected Behavior

No error.

GitHub Repo

https://github.com/Yberion/angular-nx

Steps to Reproduce

  1. pnpm install --no-frozen-lockfile
  2. pnpm run lib:test:build

Nx Report

Node   : 20.15.1
OS     : win32-x64
pnpm   : 9.5.0

nx                 : 19.4.3
@nx/js             : 19.4.3
@nx/jest           : 19.4.3
@nx/linter         : 19.4.3
@nx/eslint         : 19.4.3
@nx/workspace      : 19.4.3
@nx/angular        : 19.4.3
@nx/devkit         : 19.4.3
@nx/eslint-plugin  : 19.4.3
@nrwl/tao          : 19.4.3
@nx/web            : 19.4.3
@nx/webpack        : 19.4.3
typescript         : 5.5.3

Failure Logs

> nx run test:build:production

Building Angular Package

------------------------------------------------------------------------------
Building entry point '@angular-monorepo/test'
------------------------------------------------------------------------------
- Compiling with Angular sources in Ivy full compilation mode.
✔ Compiling with Angular sources in Ivy full compilation mode.
Copying assets
Writing package manifest
Built @angular-monorepo/test

------------------------------------------------------------------------------
Building entry point '@angular-monorepo/test/src/lib/components/button-date'
------------------------------------------------------------------------------
- Compiling with Angular sources in Ivy full compilation mode.
✖ Compiling with Angular sources in Ivy full compilation mode.
 NX   Can't find stylesheet to import.

5 │ @use '@material/typography' as mdc-typography;
  │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  node_modules\@angular\material\core\m2\_typography.scss 5:1                  @forward
  node_modules\@angular\material\core\m2\_index.scss 40:1                      @forward
  @angular\_index.scss 2:1                                                     @use
  libs\test\src\lib\styles\core\_colors.scss 1:1                               @use
  libs\test\src\lib\components\button-date\src\button-date.component.scss 1:1  root stylesheet
Pass --verbose to see the stacktrace.

Package Manager Version

pnpm 9.5.0

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

I'm not sure, but there's a similar problem here angular/angular-cli#27167

Removing parallel or setting to 1 does not fix the problem.

@davidpanic
Copy link

I have the exact same issue, managed to work around it by installing @material/typography (and a few others) directly (pnpm install --save @material/typography). This probably occurs due to pnpm's stricter dependency resolution requirements that make it so blazingly fast.

@Yberion
Copy link
Author

Yberion commented Jul 23, 2024

Ah, maybe this won't be necessary in the futur:

I'm also getting the same errors with:

I'll just wait the next version.

I had to manually install all of them, it's the first time I'm getting this somehow.
That doesn't say why it does work properly with pnpm when the lib is not buildable.
Works fine when building my app that uses the (not buildable) lib.

@Yberion
Copy link
Author

Yberion commented Jul 24, 2024

The probem with Angular Material is fixed starting from Angular Material 18.1.2 as they don't use packages listed above (angular/components#29472).

The issue is still relevant as it could occure in other packages.

@Coly010
Copy link
Contributor

Coly010 commented Aug 20, 2024

The library build here uses Angular's ng-packagr under the hood. I'm going to close this issue as it has been scoped to a particular package which has been updated and fixed. If this arises for other packages, we can reopen and address.

@Coly010 Coly010 closed this as completed Aug 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: angular Issues related to Angular support in Nx type: bug
Projects
None yet
Development

No branches or pull requests

4 participants