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

feat: Add support namedExports #179

Merged
merged 2 commits into from
Jun 5, 2024
Merged

Conversation

dungjk
Copy link
Contributor

@dungjk dungjk commented May 20, 2024

Greetings,

I've experienced with esbuild-sass-plugin and esbuild for quite long time. I also work with rollup and rollup-plugin-postcss. My most wanted feature on esbuild-sass-plugin is namedExports.

What is namedExports?

// Default import
import styles from './style.scss';

const Component = () => {
    return <div className={clsx(styles.class_foo, style.class_bar)} />
}

//Named import
import { class_foo, class_bar } from './style.scss';

const Component = () => {
    return <div className={clsx(class_foo, class_bar)} />
}

Why namedExport?

  • Easier to switch to esbuild from rollup.
  • More convenience on importing class names from css/scss module: import { class_foo, class_bar } from 'my-scss-module.scss';
  • Save some bytes by allow tree shaking remove unused import names.
  • Allow cross build using esbuild + esbuild-sass-plugin on development env, rollup + rollup-plugin-postcss for production build.
  • more...

Is this PR introduce breaking changes?

No, this PR open support for named import in addition to default import.
You can still use default import as before together with named import.

How to use namedExports?

See readme.md file.
I've added some document to getting started.

I've also add a new fixture to project test/fixture/named-exports and new e2e unit test..

Hope this help.

Regards.

@dungjk
Copy link
Contributor Author

dungjk commented May 27, 2024

Hello @glromeo
I've completed my implement and code adjustments. Ready for reviewing.
Hope you have some time to review this PR.
Thanks and no worry, just want to make contact.

PS: This is my first contribute to this project, it take me some time to recognize your coding style 🔥 and take several changes to match with your.

@glromeo
Copy link
Owner

glromeo commented Jun 5, 2024

Thank you for this contribution... I see you put a lot of thoughts into it which I appreciate a lot!

@glromeo glromeo merged commit 0151ef4 into glromeo:main Jun 5, 2024
1 check passed
@glromeo
Copy link
Owner

glromeo commented Jun 5, 2024

...it's the first time I see someone's else code without the urge to go and refactor it to my taste 😆
take it as a huge compliment for that matter!

@dungjk dungjk deleted the feature/named_exports branch June 6, 2024 11:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants