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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(babel): expose CSS extraction from AST logic #737

Merged
merged 1 commit into from Mar 1, 2021

Conversation

majames
Copy link
Contributor

@majames majames commented Feb 23, 2021

Hi all! 馃憢 Thanks in advance for reviewing my PR! 馃憖

Motivation

My company uses the Metro module bundler for building our JS bundles. As part of this, we specify our own custom babel transformer for mapping TypeScript source files into their transformed JS equivalent. Our custom transformer calls babel's transformFromAstSync() under the hood to do this.

One of the things we'd like to do in our transformer is extract the Linaria CSS from the source file being transformed and, therefore, because we've already created the AST all we need is the post processing CSS extraction logic.

Summary

Moved the logic for extracting CSS from the AST into the extractCssFromAst() function and export it from the@linaria/babel-preset package.

Test plan

  • yarn link @linaria/babel-preset to our project and ensure it compiles

Follow up

We're currently using Linaria v2.0.2 and so I'd also like to back port and have the change released... I'm assuming I can do this by releasing a PR against the 2.0.x branch?

@callstack-bot
Copy link

callstack-bot commented Feb 23, 2021

Hey @majames, thank you for your pull request 馃.
The coverage report for this branch can be viewed here.

@majames majames force-pushed the feat/expose-css-ast-extraction branch from 69197aa to f219c0a Compare February 23, 2021 19:02
- Moved logic for extracting CSS from the AST into
  a `extractCssFromAst()` function and exported it from the
  `@linaria/babel-preset` package
@majames majames force-pushed the feat/expose-css-ast-extraction branch from f219c0a to 853dbd5 Compare February 23, 2021 20:34
@Anber
Copy link
Collaborator

Anber commented Mar 1, 2021

Hi @majames!

I'm assuming I can do this by releasing a PR against the 2.0.x branch?
We don't have a separate @linaria/babel-preset package in the 2.0 branch, but yep, you can add transformFromAstSync to the main package.

However, the only noticeable difference between 2.x and 3.x branches is splitting into multiple packages and 3.0 still has meta package linaria that is fully backward compatible with the 2.x branch. So you can just start safely using the 3.x branch :)

I'll have tried to release that PR as well as some other fixes by the end of the week.

@Anber Anber merged commit f049a11 into callstack:master Mar 1, 2021
@majames
Copy link
Contributor Author

majames commented Mar 1, 2021

Awesome @Anber! Does that mean that hopefully by the end of the week a stable version of linaria v3 (3.0.0) will be released to the npm registry?

@Anber
Copy link
Collaborator

Anber commented Mar 2, 2021

@majames unfortunately, no. There is still a lot of work with documentation: each package in the 3.x branch should have a readme-file with at least a short description from the main documentation. The problem here that my English is not enough good and I need a lot of boring time for such work. To be honest, the documentation right now is the main stopper of Linaria's evolution :)
So if you have some free time and willing to help, I'll be glad to accept the help with it, and together we will be able to release 3.0 in a short time.

@majames
Copy link
Contributor Author

majames commented Mar 2, 2021

@Anber no problem and thanks for your hard work maintaining linaria!

To unblock us, I've released a PR back porting the change to Linaria v2 #738. It would be awesome if we could merge and release it this week! 馃殌

As for helping with the v3 documentation I'm quite busy this week but could look into helping out this coming weekend 馃檪

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.

None yet

3 participants