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(babel): new way for detecting tags imports #974

Merged
merged 1 commit into from May 30, 2022
Merged

Conversation

Anber
Copy link
Collaborator

@Anber Anber commented May 30, 2022

Motivation

@linaria/atomic introduced the new pair of tags with their processing logic. It increased the complexity of babel-preset.

Another point is adding an ability to process already transpilled files.

Summary

In this PR, I changed the way how template tags are detected and resolved:

  • there are no more hardcoded packages and tags names;
  • if the package imports a tag that can be processed by Linaria, its package.json should have linaria.tags section with a list of imported tags and links to processors that encapsulates all logic for processing those tags;
"linaria": {
  "tags": {
    "css": "./lib/processors/css.js",
    "styled": "./lib/processors/styled.js"
  }
},
  • in addition to import … from …, this PR introduces support for transpilled imports, so it's become possible to use pure tsc compiler + @linaria/cli for post-processing and extracting styles from compiled code.

Test plan

A bunch of tests were added.

@callstack-bot
Copy link

Hey @Anber, thank you for your pull request 🤗.
The coverage report for this branch can be viewed here.

@Anber Anber merged commit 3305cfb into master May 30, 2022
@Anber Anber deleted the tags-resolver branch May 30, 2022 18:35
@ntucker
Copy link

ntucker commented Jun 3, 2022

FYI: this upgrades loader-utils but doesn't migrate the usage of it based on breaking changes. See #977

@Anber
Copy link
Collaborator Author

Anber commented Jun 3, 2022

Ooops. Thank you!

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