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

Support --namedExport option #255

Open
mizdra opened this issue May 25, 2024 · 0 comments
Open

Support --namedExport option #255

mizdra opened this issue May 25, 2024 · 0 comments
Labels
Status: Abandoned The issue or Pull Request is wontfix Type: Add Add new features.

Comments

@mizdra
Copy link
Owner

mizdra commented May 25, 2024

Background

In css-loader@7, namedExport now defaults to true (I'm not sure of the motivation behind this change.).

So css-loader@7 forces you to import CSS Modules files as follows:

import * as styles from './foo.module.css';

On the other hand, happy-css-modules generates .d.ts with default export.

declare const styles:
& Readonly<{ "basic": string }>
& Readonly<{ "cascading": string }>
& Readonly<{ "cascading": string }>
& Readonly<{ "pseudo_class_1": string }>
& Readonly<{ "pseudo_class_2": string }>
& Readonly<{ "pseudo_class_3": string }>
& Readonly<{ "multiple_selector_1": string }>
& Readonly<{ "multiple_selector_2": string }>
& Readonly<{ "combinator_1": string }>
& Readonly<{ "combinator_2": string }>
& Readonly<{ "at_rule": string }>
& Readonly<{ "selector_list_1": string }>
& Readonly<{ "selector_list_2": string }>
& Readonly<{ "local_class_name_1": string }>
& Readonly<{ "local_class_name_2": string }>
& Readonly<{ "local_class_name_3": string }>
& Readonly<{ "local_class_name_4": string }>
;
export default styles;
//# sourceMappingURL=./1.css.d.ts.map

Therefore happy-css-modules forces you to import CSS Modules files as follows:

import styles from './foo.module.css';

This causes compatibility problems.

My opinion

I don't know how to solve this.

happy-css-modules previously supported --namedExport option. However, it was removed due to problems with definition jumps not working.

There was also a problem with TypeScript completion items containing a large number of tokens (a token is the internal name of the item being exported).

For this reason, I think we should not support --namedExport option.

Workaround

Please set the namedExport option to false in css-loader.

@mizdra mizdra added the Type: Add Add new features. label May 25, 2024
@mizdra mizdra changed the title Compatibility with css-loader@7 Support --namedExports option Nov 11, 2024
@mizdra mizdra added the Status: Abandoned The issue or Pull Request is wontfix label Nov 11, 2024
@mizdra mizdra mentioned this issue Nov 11, 2024
@mizdra mizdra changed the title Support --namedExports option Support --namedExport option Nov 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Abandoned The issue or Pull Request is wontfix Type: Add Add new features.
Projects
None yet
Development

No branches or pull requests

1 participant