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

Allow re-exporting of templates such as styled and css from internal files #851

Closed
jpnelson opened this issue Oct 5, 2021 · 3 comments
Closed
Labels
feature: proposal 💬 New feature proposal that needs to be discussed needs: triage 🏷 Issue needs to be checked and prioritized

Comments

@jpnelson
Copy link
Contributor

jpnelson commented Oct 5, 2021

Describe the feature

We'd like to be able to re-export the css and styled template literals. Currently, the babel plugin will only detect and replace imports from the linaria library. This, for example, would not work:

./my-folder/linaria

export { css } from 'linaria';

./index.js

import { css } from './my-folder/linaria'

const className = css`
  background: red;
`

Since css is not being imported directly from linaria

Motivation

We have some linaria specific utilities (eg. shared styles and the like) that we house in a separate folder. It's a little cumbersome to also import the public API – if we could, we would re-export it from our internal folder to keep everything in one place.

Possible implementations

We could implement this either by adding logic to try to resolve the imports (might be tricky with custom configs) or to allow specifying which import paths may contain styled and css – I'd be happy to take direction on which of these is preferred.

@jpnelson jpnelson added the feature: proposal 💬 New feature proposal that needs to be discussed label Oct 5, 2021
@github-actions github-actions bot added the needs: triage 🏷 Issue needs to be checked and prioritized label Oct 5, 2021
@Anber
Copy link
Collaborator

Anber commented Oct 8, 2021

Hi @jpnelson

Just custom import paths will not help because css and styled can be reexported in different ways and with different names. Probably we need to introduce a new config option for a custom resolve function and completely refactored hasImport which will use that option.

@jpnelson
Copy link
Contributor Author

jpnelson commented Dec 6, 2021

@Anber I had a go at this here: #882 – it turned out to be not too tricky, let me know what you think! 🙏

@jpnelson
Copy link
Contributor Author

Done in #882

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature: proposal 💬 New feature proposal that needs to be discussed needs: triage 🏷 Issue needs to be checked and prioritized
Projects
None yet
Development

No branches or pull requests

2 participants