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

Enhancement: Add option to process arbitrary named exports #117

Merged
merged 2 commits into from
Dec 11, 2023
Merged

Conversation

nmn
Copy link
Contributor

@nmn nmn commented Dec 10, 2023

What changed / motivation ?

By default you import stylex from the @stylexjs/stylex package and the compiler detects and compiles that. It has also been possible to set up custom import paths for custom aliases. However, so far it was expected that you'd still use import * as <name> from a custom source.

This PR adds the ability to mark stylex to be a named export from a custom path. This lets enables the following pattern:

import {html, css} from 'browser';

const styles = css.create({
  foo: {...}
});

css.props(styles.foo);

This will enable larger UI frameworks to incorporate StyleX within their own API.

Additional Context

Added a couple of tests which are passes as expected.

Pre-flight checklist

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Dec 10, 2023
@nmn nmn requested a review from necolas December 10, 2023 06:34
Copy link

compressed-size: runtime library

Size change: 0.00 kB
Total size: 2.36 kB

View unchanged
Filename: gzip (minify) kB size kB change % change
./packages/stylex/lib/stylex.js 1.02 (3.53) 0.00 (0.00) 0.0% (0.0%)
./packages/stylex/lib/StyleXSheet.js 1.34 (3.41) 0.00 (0.00) 0.0% (0.0%)

Copy link

github-actions bot commented Dec 10, 2023

compressed-size: e2e bundles

Size change: 0.00 kB
Total size: 1122.94 kB

View unchanged
Filename: gzip (minify) kB size kB change % change
./apps/rollup-example/.build/bundle.js 998.63 (9939.85) 0.00 (0.00) 0.0% (0.0%)
./apps/rollup-example/.build/stylex.css 124.30 (874.43) 0.00 (0.00) 0.0% (0.0%)

Copy link
Contributor

@necolas necolas left a comment

Choose a reason for hiding this comment

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

lgtm

@nmn nmn merged commit 4e1be33 into main Dec 11, 2023
9 checks passed
@nmn nmn deleted the import-named branch December 11, 2023 22:22
@necolas
Copy link
Contributor

necolas commented Dec 20, 2023

please could we cut a release containing this patch? or is there other stuff we're waiting to include?

@nmn
Copy link
Contributor Author

nmn commented Dec 21, 2023

The Babel plugin bundle occasionally adds a special character. I'm trying to fix that so I can cut a release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants