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

bug: transpile() doesn't resovle css imports to node modules #5967

Open
3 tasks done
Jinjiang opened this issue Sep 4, 2024 · 2 comments
Open
3 tasks done

bug: transpile() doesn't resovle css imports to node modules #5967

Jinjiang opened this issue Sep 4, 2024 · 2 comments
Labels
Bug: Validated This PR or Issue is verified to be a bug within Stencil

Comments

@Jinjiang
Copy link

Jinjiang commented Sep 4, 2024

Prerequisites

Stencil Version

4.21.0

Current Behavior

Reproduction: https://github.com/Jinjiang/reproductions/tree/try-stencil-20240904

const input = `
@import './debug/style.css';
@import '~foo/style.css';
`

const result = compiler.transpileSync(
  input,
  {
    currentDirectory: process.cwd(),
    file: 'my-component.css',
  }
)

The 2nd CSS import pointing to foo/style.css isn't properly resolved. The output is:

import styleCss from './debug/style.css';
const myComponentCss = styleCss + "\n\n@import '~foo/style.css';\n";
export default myComponentCss;

Expected Behavior

The style.css in package foo should be resolved and loaded. Or any other ways can properly resovle CSS imports to a package specifier like <package-name>/<filepath> would be fine.

System Info

System: node 20.16.0
    Platform: linux (5.15.153.1-microsoft-standard-WSL2)
   CPU Model: unknown (10 cpus)
    Compiler: /home/jinjiang/code/reproductions/node_modules/.pnpm/@[email protected]/node_modules/@stencil/core/compiler/stencil.js
       Build: 1724698030
     Stencil: 4.21.0 🐷
  TypeScript: 5.5.3
      Rollup: 2.56.3
      Parse5: 7.1.2
      jQuery: 4.0.0-pre

Steps to Reproduce

https://github.com/Jinjiang/reproductions/tree/try-stencil-20240904

How to reproduce:

pnpm install
pnpm debug

The @import '~@foo/style.css' is not resolved correctly.

Code Reproduction URL

https://github.com/Jinjiang/reproductions/tree/try-stencil-20240904

Additional Information

No response

@ionitron-bot ionitron-bot bot added the triage label Sep 4, 2024
@Jinjiang
Copy link
Author

Jinjiang commented Sep 5, 2024

Well, I've found this loc:

// do not resolve this path cuz it starts with node resolve id ~

Does that mean I need to handle that on my own? Is there any setup examples I can refer to?

Thanks.

@christian-bromann
Copy link
Member

@Jinjiang thanks for raising the issue.

Your use case may just not be considered when this was developed. I will ingest this into the backlog. Please note that the current Stencil team has its own priorities and can't guarantee to look into this soon. Therefor we would appreciate any contributions that can help to resolve this bug.

@christian-bromann christian-bromann added Bug: Validated This PR or Issue is verified to be a bug within Stencil and removed triage labels Sep 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug: Validated This PR or Issue is verified to be a bug within Stencil
Projects
None yet
Development

No branches or pull requests

2 participants