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(solid): initial draft implementation #1096

Open
wants to merge 36 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
18475d5
feat(solid): initial
raveclassic Sep 3, 2022
82f0a87
fix(solid): fix build
raveclassic Sep 3, 2022
29e5fd4
build(solid): migrate to babel-preset-jest
raveclassic Sep 5, 2022
433f121
build(solid): transpile tests with linaria and solid
raveclassic Sep 5, 2022
e8b0acb
test(solid): add initial tests
raveclassic Sep 5, 2022
a07fa50
test(solid): add manual transpilation test
raveclassic Sep 5, 2022
f6ff5da
test(solid): add manual transpilation test
raveclassic Sep 6, 2022
76593ea
build: update lockfile
raveclassic Oct 23, 2022
f363ba4
build: reset lockfile
raveclassic Oct 23, 2022
241b2ff
build(solid): cleanup dependencies
raveclassic Oct 23, 2022
3879f2f
build(solid): add @jest/transform
raveclassic Oct 23, 2022
d984d00
test(solid): custom jest transformer for tests
raveclassic Oct 23, 2022
80adc16
test(solid): render test components
raveclassic Oct 23, 2022
e29558c
Merge branch 'master' into solid
raveclassic Nov 25, 2022
b5ce464
build(solid): reset lockfile to master
raveclassic Nov 25, 2022
dfc98d5
build(solid): update lockfile for solid package
raveclassic Nov 25, 2022
0cda584
build(solid): lock dev babel dependencies to repo versions
raveclassic Nov 25, 2022
6454b58
fix(solid): align processor constructor with the latest updates in re…
raveclassic Nov 25, 2022
530a670
build(solid): reset lockfile to master
raveclassic Nov 25, 2022
389ff64
test(solid): drop tests
raveclassic Nov 25, 2022
7d0ee92
build(solid): bring dependencies back
raveclassic Nov 25, 2022
e90bc5d
feat(examples/solid): add initial example
raveclassic Nov 25, 2022
67ad092
build(solid): align build steps with react package
raveclassic Nov 25, 2022
276f023
build(examples/solid): downgrade vite to be aligned with @linaria/vite
raveclassic Nov 25, 2022
f76a554
chore(solid): fix exports
raveclassic Nov 25, 2022
01e844d
feat(examples/solid): finish example
raveclassic Nov 25, 2022
3e55c5c
chore(solid): remove processor export
raveclassic Nov 25, 2022
97b721a
build(solid): use tsconfig.lib.json in tsup
raveclassic Nov 26, 2022
ae9dd9c
test(solid): add type-level tests
raveclassic Nov 26, 2022
1258690
chore(solid): drop linaria config
raveclassic Nov 26, 2022
f155943
build(solid): add node typings
raveclassic Nov 26, 2022
8669970
fix(react): fix additional props signature
raveclassic Nov 27, 2022
5ca500c
feat(solid): require class prop
raveclassic Nov 27, 2022
10a8a95
feat(solid): require style prop
raveclassic Nov 27, 2022
7630006
Merge branch 'master' into solid
raveclassic Nov 27, 2022
b03f733
build(solid): upgrade @babel/types@^7.20.2
raveclassic Nov 27, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ esm/
types/
dist/
build/
tsconfig.tsbuildinfo
*.tsbuildinfo

.linaria-cache

# IntelliJ IDEA
.idea
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Zero-runtime CSS in JS library.
- Use **JavaScript for logic**, no CSS preprocessor needed
- Optionally use any **CSS preprocessor** such as Sass or PostCSS
- Supports **atomic styles** with `@linaria/atomic`
- Supports [solidjs](https://solidjs.com/) with `@linaria/sollid`

**[Why use Linaria](/docs/BENEFITS.md)**

Expand Down
7 changes: 0 additions & 7 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,5 @@ module.exports = {
},
},
},
{
/**
* we have to transpile JSX in tests
*/
test: /\/(__tests__|__fixtures__|packages\/teskit\/src)\//,
presets: ['@babel/preset-react'],
},
],
};
2 changes: 1 addition & 1 deletion packages/babel/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export * from './utils/collectTemplateDependencies';
export { default as collectTemplateDependencies } from './utils/collectTemplateDependencies';
export { default as withLinariaMetadata } from './utils/withLinariaMetadata';
export { default as Module } from './module';
export { default as transform } from './transform';
export { default as transform, transformSync } from './transform';
export * from './types';
export { default as loadLinariaOptions } from './transform-stages/helpers/loadLinariaOptions';
export type { PluginOptions } from './transform-stages/helpers/loadLinariaOptions';
Expand Down
12 changes: 9 additions & 3 deletions packages/react/babel.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
const config = require('../../babel.config');

module.exports = config;
module.exports = {
extends: '../../babel.config',
overrides: [
{
test: ['__tests__/**/*.tsx'],
presets: ['@babel/preset-react'],
},
],
};
46 changes: 46 additions & 0 deletions packages/solid/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<p align="center">
<img alt="Linaria" src="https://raw.githubusercontent.com/callstack/linaria/HEAD/website/assets/[email protected]" width="496">
</p>

<p align="center">
Zero-runtime CSS in JS library.
</p>

---

# @linaria/solid

### 📖 Please refer to the [GitHub](https://github.com/callstack/linaria#readme) for full documentation.

**[Why use Linaria](../../docs/BENEFITS.md)**

## Features

- supports a subset of `styled-components` syntax (`styled.div`, `styled(Component)`, property interpolations)

## Limitations

- does not support theming through arguments to property interpolations (yet)

## Installation

```sh
npm install @linaria/babel-preset @linaria/solid babel-preset-solid
```

or

```sh
yarn install @linaria/babel-preset @linaria/solid babel-preset-solid
```

## Configuration

For the time of this writing, `@linaria/solid` supports configuration only via babel configuration.
Just add `solid` to the `"presets"` section in your `babel.config.js` _after_ `"@linaria"`:

```json
{
"presets": ["@linaria", "solid"]
}
```
42 changes: 42 additions & 0 deletions packages/solid/__tests__/jest-transformer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
const linaria = require('@linaria/babel-preset');
const babel = require('@babel/core');
const path = require('path');

const SELF = path.resolve(__dirname);
const ROOT_BABEL_CONFIG = path.resolve(SELF, '../../../babel.config.js');

const transformer = {
process: (sourceText, sourcePath) => {
const babelResult = babel.transform(sourceText, {
filename: sourcePath,
// pick monorepo's babel.config.js with typescript and env presets
// jsx should not be transpiled at this step
// it will be transpiled later with babel-preset-solid
babelrc: false,
configFile: ROOT_BABEL_CONFIG,
});
if (!babelResult || !babelResult.code) {
throw new Error('Cannot transpile source with babel');
}
const linariaResult = linaria.transformSync(
babelResult.code,
{ filename: sourcePath },
(what) => require.resolve(what)
);
const solidResult = babel.transform(linariaResult.code, {
filename: sourcePath,
presets: ['solid'],
// pick monorepo's babel.config.js with typescript and env presets
babelrc: false,
configFile: ROOT_BABEL_CONFIG,
});
return {
code: `
require('style-inject')(${JSON.stringify(linariaResult.cssText)});
${solidResult.code}
`,
};
},
};

module.exports = transformer;
9 changes: 9 additions & 0 deletions packages/solid/__tests__/processors/components.linaria.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { styled } from '../../src';

interface TagProps {
readonly bg?: string;
}
export const Tag = styled.div<TagProps>`
color: red;
background: ${(props) => props.bg};
`;
Loading