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

Add support for --outDir option #270

Merged
merged 9 commits into from
Nov 4, 2024

Conversation

apple-yagi
Copy link
Contributor

I created a Pull Request because I wanted the outputFolder option available in typed-css-modules to also be present in happy-css-modules. Could you please review it?

@apple-yagi apple-yagi force-pushed the add-output-folder-option branch 2 times, most recently from 57eaeb6 to 0256375 Compare June 29, 2024 11:21
@apple-yagi apple-yagi force-pushed the add-output-folder-option branch from 0256375 to 0c96314 Compare June 30, 2024 03:33
@mizdra
Copy link
Owner

mizdra commented Jul 23, 2024

Thanks for your contribution! I will review it at a later date.

@mizdra
Copy link
Owner

mizdra commented Nov 3, 2024

@apple-yagi Question: how does tsc or tsserver load *.d.ts?

For example, imagine the following project.

repo: https://github.com/mizdra/hcm-output-folder-test

+ package.json
+ tsconfig.json
+ src
| + Button.tsx
| + Button.module.css
+ dist
  + Button.module.css.d.ts
  + Button.module.css.d.ts.map
// package.json
{
  "scripts": {
    "dev:hcm": "hcm -o dist 'src/**/*.module.css'"
  }
}
// src/Button.tsx
import styles from from './Button.module.css';
export function Button() {
  return <button class={styles.button}>Click me!</button>
}

We need to tell tsc and tsserver that the type definition file for Button.module.css is Button.module.css.d.ts. How do we achieve that?

I believe I need to use paths in tsconfig.json and rewrite import speficier to non-relative paths to achieve that. Is that what you expect?

To clarify my opinion: I am positive about implementing --outputFolder. However, if there is work that users need to do to use --outputFolder, it needs to be documented. I want to be clear about it.

@apple-yagi
Copy link
Contributor Author

@mizdra Thank you for checking.

I will resolve the issue by using the compilerOptions.rootDirs in tsconfig. By doing so, I can use the outputFolder without having to change paths and such.

I've created a Pull Request, so please give it a try.
Thank you!

mizdra/hcm-output-folder-test#1

@mizdra
Copy link
Owner

mizdra commented Nov 4, 2024

Wow, this is a good solution. I am going to document the solution. Thank you!

README.md Outdated Show resolved Hide resolved
@mizdra mizdra added the Type: Add Add new features. label Nov 4, 2024
@mizdra mizdra changed the title Add support for outputFolder option Add support for outDir option Nov 4, 2024
Copy link
Owner

@mizdra mizdra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thank you for your great contribution! Sorry for the late review.

@mizdra mizdra changed the title Add support for outDir option Add support for --outDir option Nov 4, 2024
@mizdra mizdra merged commit c7eb706 into mizdra:main Nov 4, 2024
6 checks passed
@apple-yagi apple-yagi deleted the add-output-folder-option branch November 4, 2024 07:05
@mizdra
Copy link
Owner

mizdra commented Nov 4, 2024

This feature is shipped in v3.2.0.

https://github.com/mizdra/happy-css-modules/releases/tag/v3.2.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Add Add new features.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants