Skip to content

Commit e2a5bae

Browse files
authored
new: Add Solid.js support. (#6)
* Add to babel. * Add more support. * Enable CI caching.
1 parent e1e00f1 commit e2a5bae

13 files changed

Lines changed: 157 additions & 7 deletions

File tree

.github/workflows/pr.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ jobs:
77
steps:
88
- uses: actions/checkout@v3
99
- uses: actions/setup-node@v3
10+
with:
11+
cache: yarn
1012
- uses: beemojs/conventional-pr-action@v2
1113
env:
1214
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ This repository is a collection of moon owned and maintained configurations and
88
developer tools -- primarily tools used by moonrepo and its authors.
99

1010
It aims to provide a strict, modern, developer accessible, convention over configuration approach to
11-
JavaScript, TypeScript, and React projects! All of these configs have been designed for local and
12-
developer tooling based development!
11+
JavaScript, TypeScript (first), and React/Solid projects! All of these configs have been designed
12+
for local and developer tooling based development!
1313

1414
## Packages
1515

packages/babel-preset/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ module.exports = {
2929
- Enables native `async`/`await` and avoids Regenerator.
3030
- Enables `export` default and namespace from syntax.
3131
- Supports the `react` preset and both JSX runtimes.
32+
- Supports the `solid` preset with SSR and hydration.
3233
- Converts `__DEV__`, `__PROD__`, and `__TEST__` to `process.env` checks.
3334
- Wraps `invariant()` in `process.env` conditionals.
3435

@@ -43,6 +44,7 @@ The following options can be passed to the preset.
4344
(`auto` modules).
4445
- `react` (`boolean | classic | automatic`) - Enable the React plugin and the defined JSX runtime.
4546
Defaults to `false`.
47+
- `solid` (`boolean | ssr`) - Enable the Solid.js plugin. Hydration is always enabled.
4648
- `targets` (`Record<string, string> | string[] | string`) - Override the target environment.
4749
Defaults to Node.js `current`.
4850

packages/babel-preset/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@
4444
"@babel/preset-react": "^7.18.6",
4545
"@babel/preset-typescript": "^7.18.6",
4646
"babel-plugin-conditional-invariant": "^2.0.1",
47-
"babel-plugin-env-constants": "^2.0.1"
47+
"babel-plugin-env-constants": "^2.0.1",
48+
"babel-preset-solid": "^1.4.8"
4849
},
4950
"devDependencies": {
5051
"@babel/core": "^7.18.10"

packages/babel-preset/src/index.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@ export interface BabelPresetMoonOptions {
88
loose?: boolean;
99
modules?: boolean;
1010
react?: boolean | 'automatic' | 'classic';
11+
solid?: boolean | 'ssr';
1112
targets?: Record<string, string> | string[] | string;
1213
}
1314

1415
export default function babelPresetMoon(
1516
api: unknown,
16-
{ decorators, loose, modules, react, targets }: BabelPresetMoonOptions = {},
17+
{ decorators, loose, modules, react, solid, targets }: BabelPresetMoonOptions = {},
1718
) {
1819
let looseMode = loose ?? false;
1920

@@ -67,6 +68,13 @@ export default function babelPresetMoon(
6768
]);
6869
}
6970

71+
if (solid) {
72+
presets.push([
73+
'babel-preset-solid',
74+
{ generate: solid === 'ssr' ? 'ssr' : 'dom', hydratable: true },
75+
]);
76+
}
77+
7078
return {
7179
plugins,
7280
presets,

packages/eslint-config/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ The following additional configs can also be extended, but are not enabled by de
4141
[jsx-a11y](https://www.npmjs.com/package/eslint-plugin-jsx-a11y) plugins.
4242
- Only applies to `*.tsx` files and also extends the `browser` preset.
4343
- Enables automatic JSX runtime if `react` version is 17+.
44+
- `moon/solid` - Enables the [solid](https://www.npmjs.com/package/eslint-plugin-solid) plugin.
45+
- Only applies to `*.tsx` files and also extends the `browser` preset.
4446

4547
## Features
4648

packages/eslint-config/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"lib/**/*.{js,map}",
1818
"node.js",
1919
"react.js",
20+
"solid.js",
2021
"src/**/*.{ts,tsx,json}"
2122
],
2223
"repository": {
@@ -52,6 +53,7 @@
5253
"eslint-plugin-react-hooks": "^4.6.0",
5354
"eslint-plugin-react-perf": "^3.3.1",
5455
"eslint-plugin-simple-import-sort": "^7.0.0",
56+
"eslint-plugin-solid": "^0.7.1",
5557
"eslint-plugin-unicorn": "^43.0.2"
5658
},
5759
"devDependencies": {

packages/eslint-config/solid.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// eslint-disable-next-line import/no-commonjs
2+
module.exports = require('./lib/solid');
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import type eslint from 'eslint';
2+
3+
const config: eslint.Linter.ConfigOverride = {
4+
files: ['*.ts', '*.tsx'],
5+
plugins: ['solid'],
6+
extends: [require.resolve('./browser.js'), 'plugin:solid/typescript'],
7+
parserOptions: {
8+
ecmaFeatures: {
9+
jsx: true,
10+
},
11+
},
12+
};
13+
14+
export default config;

packages/tsconfig/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,6 @@ Extend the config from your root `tsconfig.json`.
3636
- Supports React through the `tsconfig.react.json` config.
3737
- Enables the `dom` lib.
3838
- Sets JSX transform to `react`.
39+
- Supports Solid.js through the `tsconfig.solid.json` config.
3940
- Strict and performant by default (of course).
4041
- Does _not_ check JavaScript files.

0 commit comments

Comments
 (0)