feat(babel): expose CSS extraction from AST logic #737
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 compilesFollow 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 the2.0.x
branch?