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

Restructure #19

Merged
merged 2 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,5 @@ typings/
# FuseBox cache
.fusebox/

dist
dist
.DS_Store
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@

# ![banner](https://github.com/LXSMNSYC/solid-labels/blob/main/images/banner.png?raw=true)
# `solid-labels`

[![NPM](https://img.shields.io/npm/v/babel-plugin-solid-labels.svg)](https://www.npmjs.com/package/babel-plugin-solid-labels) [![JavaScript Style Guide](https://badgen.net/badge/code%20style/airbnb/ff5a5f?icon=airbnb)](https://github.com/airbnb/javascript)
[![NPM](https://img.shields.io/npm/v/solid-labels.svg)](https://www.npmjs.com/package/solid-labels) [![JavaScript Style Guide](https://badgen.net/badge/code%20style/airbnb/ff5a5f?icon=airbnb)](https://github.com/airbnb/javascript)

<p align="center">
<img
src="https://github.com/LXSMNSYC/solid-labels/blob/main/images/example.png?raw=true"
src="https://github.com/LXSMNSYC/solid-labels/blob/main/images/ctf.png?raw=true"
alt="Example"
style="width: 80%; height: auto;"
/>
Expand All @@ -14,15 +14,15 @@
## Install

```bash
npm install babel-plugin-solid-labels
npm install solid-labels
```

```bash
yarn add babel-plugin-solid-labels
yarn add solid-labels
```

```bash
pnpm add babel-plugin-solid-labels
pnpm add solid-labels
```

## Features
Expand All @@ -48,7 +48,7 @@ pnpm add babel-plugin-solid-labels
`<any file>.d.ts`

```ts
/// <reference types="babel-plugin-solid-labels" />
/// <reference types="solid-labels" />
```

### Babel
Expand All @@ -58,7 +58,7 @@ pnpm add babel-plugin-solid-labels
```json
{
"plugins": [
["babel-plugin-solid-labels", { "dev": false }]
["solid-labels/babel", { "dev": false }]
]
}
```
Expand All @@ -69,6 +69,7 @@ pnpm add babel-plugin-solid-labels

- [Vite](https://github.com/lxsmnsyc/solid-labels/tree/main/packages/vite)
- [Rollup](https://github.com/lxsmnsyc/solid-labels/tree/main/packages/rollup)
- [Unplugin](https://github.com/lxsmnsyc/solid-labels/tree/main/packages/unplugin)

### Disabling features

Expand Down
2 changes: 1 addition & 1 deletion docs/ctf.md
Original file line number Diff line number Diff line change
Expand Up @@ -1033,7 +1033,7 @@ These CTFs are auto-imported components from `solid-js` and `solid-js/web`. You
On any `d.ts` file, add a reference markup

```ts
/// <reference types="babel-plugin-solid-labels" />
/// <reference types="solid-labels" />
```

All CTFs are declared globally so there's no need to import.
2 changes: 1 addition & 1 deletion examples/comments/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
"serve": "vite preview"
},
"devDependencies": {
"babel-plugin-solid-labels": "0.15.1",
"eslint": "^8.51.0",
"eslint-config-lxsmnsyc": "^0.6.5",
"solid-labels": "0.15.1",
"typescript": "^5.2.2",
"vite": "^4.5.0",
"vite-plugin-solid": "^2.7.2",
Expand Down
2 changes: 1 addition & 1 deletion examples/comments/tsconfig.eslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"jsxImportSource": "solid-js",
"types": [
"vite/client",
"babel-plugin-solid-labels"
"solid-labels"
]
},
"include": ["./src"]
Expand Down
2 changes: 1 addition & 1 deletion examples/comments/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"jsxImportSource": "solid-js",
"types": [
"vite/client",
"babel-plugin-solid-labels"
"solid-labels"
]
},
"include": ["./src"]
Expand Down
3 changes: 2 additions & 1 deletion examples/ctf/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module.exports = {
},
"rules": {
"no-unused-labels": "off",
"no-labels": "off"
"no-labels": "off",
"react/jsx-no-undef": "off"
}
};
2 changes: 1 addition & 1 deletion examples/ctf/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
"serve": "vite preview"
},
"devDependencies": {
"babel-plugin-solid-labels": "0.15.1",
"eslint": "^8.51.0",
"eslint-config-lxsmnsyc": "^0.6.5",
"solid-labels": "0.15.1",
"typescript": "^5.2.2",
"vite": "^4.5.0",
"vite-plugin-solid": "^2.7.2",
Expand Down
7 changes: 3 additions & 4 deletions examples/ctf/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type { Accessor, JSX, Setter } from 'solid-js';

// @refresh granular
function useCounter(): [Accessor<number>, Setter<number>] {
const count = $signal(0);

Expand All @@ -16,11 +15,11 @@ export default function App(): JSX.Element {

const message = $memo(`Count: ${count}`);

effect: {
$effect(() => {
console.log(message);
}
});

function increment() {
function increment(): void {
count += 1;
}

Expand Down
2 changes: 1 addition & 1 deletion examples/ctf/tsconfig.eslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"jsxImportSource": "solid-js",
"types": [
"vite/client",
"babel-plugin-solid-labels"
"solid-labels"
]
},
"include": ["./src"]
Expand Down
2 changes: 1 addition & 1 deletion examples/ctf/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"jsxImportSource": "solid-js",
"types": [
"vite/client",
"babel-plugin-solid-labels"
"solid-labels"
]
},
"include": ["./src"]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
module.exports = {
"root": true,
"extends": [
"lxsmnsyc/typescript/react"
"lxsmnsyc/typescript/solid"
],
"parserOptions": {
"project": "./tsconfig.eslint.json",
"tsconfigRootDir": __dirname,
},
"rules": {
"react/no-unused-prop-types": "off",
"react/require-default-props": "off",
"react/destructuring-assignment": "off",
"no-var": "off",
"no-restricted-syntax": "off",
"no-labels": "off",
Expand Down
2 changes: 1 addition & 1 deletion examples/labels/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
"serve": "vite preview"
},
"devDependencies": {
"babel-plugin-solid-labels": "0.15.1",
"eslint": "^8.51.0",
"eslint-config-lxsmnsyc": "^0.6.5",
"typescript": "^5.2.2",
"solid-labels": "0.15.1",
"vite": "^4.5.0",
"vite-plugin-solid": "^2.7.2",
"vite-plugin-solid-labels": "0.15.1"
Expand Down
4 changes: 3 additions & 1 deletion examples/labels/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import type { JSX } from 'solid-js/jsx-runtime';

export default function App(): JSX.Element {
signal: var count = 0;
memo: var message = `Count: ${count}`;
Expand All @@ -6,7 +8,7 @@ export default function App(): JSX.Element {
console.log(message);
}

function increment() {
function increment(): void {
count += 1;
}

Expand Down
2 changes: 1 addition & 1 deletion examples/labels/tsconfig.eslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"jsxImportSource": "solid-js",
"types": [
"vite/client",
"babel-plugin-solid-labels"
"solid-labels"
]
},
"include": ["./src"]
Expand Down
2 changes: 1 addition & 1 deletion examples/labels/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"jsxImportSource": "solid-js",
"types": [
"vite/client",
"babel-plugin-solid-labels"
"solid-labels"
]
},
"include": ["./src"]
Expand Down
Binary file removed images/banner.png
Binary file not shown.
Binary file added images/comments.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/ctf.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed images/example.png
Binary file not shown.
Binary file added images/labels.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed images/open-graph.png
Binary file not shown.
3 changes: 0 additions & 3 deletions packages/babel/pridepack.json

This file was deleted.

File renamed without changes.
File renamed without changes.
68 changes: 16 additions & 52 deletions packages/babel/README.md → packages/core/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@

# ![banner](https://github.com/LXSMNSYC/solid-labels/blob/main/images/banner.png?raw=true)
# `solid-labels`

[![NPM](https://img.shields.io/npm/v/babel-plugin-solid-labels.svg)](https://www.npmjs.com/package/babel-plugin-solid-labels) [![JavaScript Style Guide](https://badgen.net/badge/code%20style/airbnb/ff5a5f?icon=airbnb)](https://github.com/airbnb/javascript)
[![NPM](https://img.shields.io/npm/v/solid-labels.svg)](https://www.npmjs.com/package/solid-labels) [![JavaScript Style Guide](https://badgen.net/badge/code%20style/airbnb/ff5a5f?icon=airbnb)](https://github.com/airbnb/javascript)

<p align="center">
<img
src="https://github.com/LXSMNSYC/solid-labels/blob/main/images/example.png?raw=true"
src="https://github.com/LXSMNSYC/solid-labels/blob/main/images/ctf.png?raw=true"
alt="Example"
style="width: 80%; height: auto;"
/>
Expand All @@ -14,15 +14,15 @@
## Install

```bash
npm install babel-plugin-solid-labels
npm install solid-labels
```

```bash
yarn add babel-plugin-solid-labels
yarn add solid-labels
```

```bash
pnpm add babel-plugin-solid-labels
pnpm add solid-labels
```

## Features
Expand All @@ -36,19 +36,19 @@ pnpm add babel-plugin-solid-labels
## Usage

- [Labels](https://github.com/LXSMNSYC/solid-labels/tree/main/docs/labels.md)
[![Open in CodeSandbox](https://img.shields.io/badge/Open%20in-CodeSandbox-blue?style=flat-square&logo=codesandbox)](https://codesandbox.io/s/github/LXSMNSYC/solid-labels/tree/main/examples/vite-example-comments)
[![Open in CodeSandbox](https://img.shields.io/badge/Open%20in-CodeSandbox-blue?style=flat-square&logo=codesandbox)](https://codesandbox.io/s/github/LXSMNSYC/solid-labels/tree/main/examples/labels)
- [Comments](https://github.com/LXSMNSYC/solid-labels/tree/main/docs/comments.md)
[![Open in CodeSandbox](https://img.shields.io/badge/Open%20in-CodeSandbox-blue?style=flat-square&logo=codesandbox)](https://codesandbox.io/s/github/LXSMNSYC/solid-labels/tree/main/examples/vite-example-comments)
[![Open in CodeSandbox](https://img.shields.io/badge/Open%20in-CodeSandbox-blue?style=flat-square&logo=codesandbox)](https://codesandbox.io/s/github/LXSMNSYC/solid-labels/tree/main/examples/comments)
- [Compile-Time Functions](https://github.com/LXSMNSYC/solid-labels/tree/main/docs/ctf.md)
[![Open in CodeSandbox](https://img.shields.io/badge/Open%20in-CodeSandbox-blue?style=flat-square&logo=codesandbox)](https://codesandbox.io/s/github/LXSMNSYC/solid-labels/tree/main/examples/vite-example-ctf)
[![Open in CodeSandbox](https://img.shields.io/badge/Open%20in-CodeSandbox-blue?style=flat-square&logo=codesandbox)](https://codesandbox.io/s/github/LXSMNSYC/solid-labels/tree/main/examples/ctf)
- [Solid Namespace](https://github.com/LXSMNSYC/solid-labels/tree/main/docs/namespace.md)

### Typescript

`<any file>.d.ts`

```ts
/// <reference types="babel-plugin-solid-labels" />
/// <reference types="solid-labels" />
```

### Babel
Expand All @@ -58,54 +58,18 @@ pnpm add babel-plugin-solid-labels
```json
{
"plugins": [
["babel-plugin-solid-labels", { "dev": false }]
["solid-labels/babel", { "dev": false }]
]
}
```

### Vite
**NOTE**: You don't have to use this if you're using Vite or Rollup plugins

`vite-plugin-solid`
## Integrations

```js
// vite.config.js
import { defineConfig } from 'vite';
import solidPlugin from 'vite-plugin-solid';
import solidLabels from 'babel-plugin-solid-labels';

export default defineConfig({
plugins: [
solidPlugin({
babel: {
plugins: [
[solidLabels, { dev: process.env.NODE_ENV !== 'production' }]
],
},
}),
],
});
```

`solid-start`

```js
// vite.config.js
import { defineConfig } from 'vite';
import solidStart from 'solid-start';
import solidLabels from 'babel-plugin-solid-labels';

export default defineConfig({
plugins: [
solidStart({
babel: {
plugins: [
[solidLabels, { dev: process.env.NODE_ENV !== 'production' }]
],
},
}),
],
});
```
- [Vite](https://github.com/lxsmnsyc/solid-labels/tree/main/packages/vite)
- [Rollup](https://github.com/lxsmnsyc/solid-labels/tree/main/packages/rollup)
- [Unplugin](https://github.com/lxsmnsyc/solid-labels/tree/main/packages/unplugin)

### Disabling features

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
25 changes: 25 additions & 0 deletions packages/core/babel/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import type * as babel from '@babel/core';
import type { State, Options } from './core/types';
import transformComponents from './components';
import transformCTF from './transform-ctf';
import transformLabels from './transform-label';
import transformComments from './transform-comment';

export type { Options };

export default function solidLabelsPlugin(): babel.PluginObj<State> {
return {
name: 'solid-labels',
pre(): void {
this.hooks = new Map();
},
visitor: {
Program(path, state): void {
transformComments(state, path);
transformLabels(state, path);
transformCTF(state, path);
transformComponents(state, path);
},
},
};
}
File renamed without changes.
Loading
Loading