diff --git a/.gitignore b/.gitignore index f75efae..e6f6486 100644 --- a/.gitignore +++ b/.gitignore @@ -75,4 +75,5 @@ typings/ # FuseBox cache .fusebox/ -dist \ No newline at end of file +dist +.DS_Store \ No newline at end of file diff --git a/README.md b/README.md index a6b5587..62b9866 100644 --- a/README.md +++ b/README.md @@ -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)

Example @@ -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 @@ -48,7 +48,7 @@ pnpm add babel-plugin-solid-labels `.d.ts` ```ts -/// +/// ``` ### Babel @@ -58,7 +58,7 @@ pnpm add babel-plugin-solid-labels ```json { "plugins": [ - ["babel-plugin-solid-labels", { "dev": false }] + ["solid-labels/babel", { "dev": false }] ] } ``` @@ -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 diff --git a/docs/ctf.md b/docs/ctf.md index 8aa71d9..4b79af8 100644 --- a/docs/ctf.md +++ b/docs/ctf.md @@ -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 -/// +/// ``` All CTFs are declared globally so there's no need to import. diff --git a/examples/comments/package.json b/examples/comments/package.json index 881bb2e..18bc6d9 100644 --- a/examples/comments/package.json +++ b/examples/comments/package.json @@ -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", diff --git a/examples/comments/tsconfig.eslint.json b/examples/comments/tsconfig.eslint.json index 7054d63..1a3371c 100644 --- a/examples/comments/tsconfig.eslint.json +++ b/examples/comments/tsconfig.eslint.json @@ -17,7 +17,7 @@ "jsxImportSource": "solid-js", "types": [ "vite/client", - "babel-plugin-solid-labels" + "solid-labels" ] }, "include": ["./src"] diff --git a/examples/comments/tsconfig.json b/examples/comments/tsconfig.json index 839361b..f030670 100644 --- a/examples/comments/tsconfig.json +++ b/examples/comments/tsconfig.json @@ -17,7 +17,7 @@ "jsxImportSource": "solid-js", "types": [ "vite/client", - "babel-plugin-solid-labels" + "solid-labels" ] }, "include": ["./src"] diff --git a/examples/ctf/.eslintrc.cjs b/examples/ctf/.eslintrc.cjs index 0c3d27b..a582e27 100644 --- a/examples/ctf/.eslintrc.cjs +++ b/examples/ctf/.eslintrc.cjs @@ -9,6 +9,7 @@ module.exports = { }, "rules": { "no-unused-labels": "off", - "no-labels": "off" + "no-labels": "off", + "react/jsx-no-undef": "off" } }; diff --git a/examples/ctf/package.json b/examples/ctf/package.json index f98cc89..16da857 100644 --- a/examples/ctf/package.json +++ b/examples/ctf/package.json @@ -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", diff --git a/examples/ctf/src/App.tsx b/examples/ctf/src/App.tsx index 32df6e1..8d0620d 100644 --- a/examples/ctf/src/App.tsx +++ b/examples/ctf/src/App.tsx @@ -1,6 +1,5 @@ import type { Accessor, JSX, Setter } from 'solid-js'; -// @refresh granular function useCounter(): [Accessor, Setter] { const count = $signal(0); @@ -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; } diff --git a/examples/ctf/tsconfig.eslint.json b/examples/ctf/tsconfig.eslint.json index 7054d63..1a3371c 100644 --- a/examples/ctf/tsconfig.eslint.json +++ b/examples/ctf/tsconfig.eslint.json @@ -17,7 +17,7 @@ "jsxImportSource": "solid-js", "types": [ "vite/client", - "babel-plugin-solid-labels" + "solid-labels" ] }, "include": ["./src"] diff --git a/examples/ctf/tsconfig.json b/examples/ctf/tsconfig.json index 839361b..f030670 100644 --- a/examples/ctf/tsconfig.json +++ b/examples/ctf/tsconfig.json @@ -17,7 +17,7 @@ "jsxImportSource": "solid-js", "types": [ "vite/client", - "babel-plugin-solid-labels" + "solid-labels" ] }, "include": ["./src"] diff --git a/examples/labels/.eslintrc.js b/examples/labels/.eslintrc.cjs similarity index 66% rename from examples/labels/.eslintrc.js rename to examples/labels/.eslintrc.cjs index e559378..84134b2 100644 --- a/examples/labels/.eslintrc.js +++ b/examples/labels/.eslintrc.cjs @@ -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", diff --git a/examples/labels/package.json b/examples/labels/package.json index f9451b3..41b9f9d 100644 --- a/examples/labels/package.json +++ b/examples/labels/package.json @@ -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" diff --git a/examples/labels/src/App.tsx b/examples/labels/src/App.tsx index ce6d2bc..d2b17ae 100644 --- a/examples/labels/src/App.tsx +++ b/examples/labels/src/App.tsx @@ -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}`; @@ -6,7 +8,7 @@ export default function App(): JSX.Element { console.log(message); } - function increment() { + function increment(): void { count += 1; } diff --git a/examples/labels/tsconfig.eslint.json b/examples/labels/tsconfig.eslint.json index 7054d63..1a3371c 100644 --- a/examples/labels/tsconfig.eslint.json +++ b/examples/labels/tsconfig.eslint.json @@ -17,7 +17,7 @@ "jsxImportSource": "solid-js", "types": [ "vite/client", - "babel-plugin-solid-labels" + "solid-labels" ] }, "include": ["./src"] diff --git a/examples/labels/tsconfig.json b/examples/labels/tsconfig.json index 839361b..f030670 100644 --- a/examples/labels/tsconfig.json +++ b/examples/labels/tsconfig.json @@ -17,7 +17,7 @@ "jsxImportSource": "solid-js", "types": [ "vite/client", - "babel-plugin-solid-labels" + "solid-labels" ] }, "include": ["./src"] diff --git a/images/banner.png b/images/banner.png deleted file mode 100644 index d6bbd7b..0000000 Binary files a/images/banner.png and /dev/null differ diff --git a/images/comments.png b/images/comments.png new file mode 100644 index 0000000..4911ca9 Binary files /dev/null and b/images/comments.png differ diff --git a/images/ctf.png b/images/ctf.png new file mode 100644 index 0000000..4009cf3 Binary files /dev/null and b/images/ctf.png differ diff --git a/images/example.png b/images/example.png deleted file mode 100644 index 9ef8563..0000000 Binary files a/images/example.png and /dev/null differ diff --git a/images/labels.png b/images/labels.png new file mode 100644 index 0000000..9bcf9f6 Binary files /dev/null and b/images/labels.png differ diff --git a/images/open-graph.png b/images/open-graph.png deleted file mode 100644 index 08e21f1..0000000 Binary files a/images/open-graph.png and /dev/null differ diff --git a/packages/babel/pridepack.json b/packages/babel/pridepack.json deleted file mode 100644 index 02099fc..0000000 --- a/packages/babel/pridepack.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "target": "es2018" -} \ No newline at end of file diff --git a/packages/babel/.eslintrc.cjs b/packages/core/.eslintrc.cjs similarity index 100% rename from packages/babel/.eslintrc.cjs rename to packages/core/.eslintrc.cjs diff --git a/packages/babel/.gitignore b/packages/core/.gitignore similarity index 100% rename from packages/babel/.gitignore rename to packages/core/.gitignore diff --git a/packages/babel/README.md b/packages/core/README.md similarity index 53% rename from packages/babel/README.md rename to packages/core/README.md index 8ee4891..62b9866 100644 --- a/packages/babel/README.md +++ b/packages/core/README.md @@ -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)

Example @@ -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 @@ -36,11 +36,11 @@ 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 @@ -48,7 +48,7 @@ pnpm add babel-plugin-solid-labels `.d.ts` ```ts -/// +/// ``` ### Babel @@ -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 diff --git a/packages/babel/src/components.ts b/packages/core/babel/components.ts similarity index 100% rename from packages/babel/src/components.ts rename to packages/core/babel/components.ts diff --git a/packages/babel/src/core/accessor-variable.ts b/packages/core/babel/core/accessor-variable.ts similarity index 100% rename from packages/babel/src/core/accessor-variable.ts rename to packages/core/babel/core/accessor-variable.ts diff --git a/packages/babel/src/core/assert.ts b/packages/core/babel/core/assert.ts similarity index 100% rename from packages/babel/src/core/assert.ts rename to packages/core/babel/core/assert.ts diff --git a/packages/babel/src/core/deferred-variable.ts b/packages/core/babel/core/deferred-variable.ts similarity index 100% rename from packages/babel/src/core/deferred-variable.ts rename to packages/core/babel/core/deferred-variable.ts diff --git a/packages/babel/src/core/deref-memo-variable.ts b/packages/core/babel/core/deref-memo-variable.ts similarity index 100% rename from packages/babel/src/core/deref-memo-variable.ts rename to packages/core/babel/core/deref-memo-variable.ts diff --git a/packages/babel/src/core/deref-memo.ts b/packages/core/babel/core/deref-memo.ts similarity index 100% rename from packages/babel/src/core/deref-memo.ts rename to packages/core/babel/core/deref-memo.ts diff --git a/packages/babel/src/core/deref-signal-variable.ts b/packages/core/babel/core/deref-signal-variable.ts similarity index 100% rename from packages/babel/src/core/deref-signal-variable.ts rename to packages/core/babel/core/deref-signal-variable.ts diff --git a/packages/babel/src/core/deref-signal.ts b/packages/core/babel/core/deref-signal.ts similarity index 100% rename from packages/babel/src/core/deref-signal.ts rename to packages/core/babel/core/deref-signal.ts diff --git a/packages/babel/src/core/destructure-variable.ts b/packages/core/babel/core/destructure-variable.ts similarity index 100% rename from packages/babel/src/core/destructure-variable.ts rename to packages/core/babel/core/destructure-variable.ts diff --git a/packages/babel/src/core/errors.ts b/packages/core/babel/core/errors.ts similarity index 100% rename from packages/babel/src/core/errors.ts rename to packages/core/babel/core/errors.ts diff --git a/packages/babel/src/core/get-import-identifier.ts b/packages/core/babel/core/get-import-identifier.ts similarity index 100% rename from packages/babel/src/core/get-import-identifier.ts rename to packages/core/babel/core/get-import-identifier.ts diff --git a/packages/babel/src/core/is-awaited.ts b/packages/core/babel/core/is-awaited.ts similarity index 100% rename from packages/babel/src/core/is-awaited.ts rename to packages/core/babel/core/is-awaited.ts diff --git a/packages/babel/src/core/is-in-typescript.ts b/packages/core/babel/core/is-in-typescript.ts similarity index 100% rename from packages/babel/src/core/is-in-typescript.ts rename to packages/core/babel/core/is-in-typescript.ts diff --git a/packages/babel/src/core/is-static.ts b/packages/core/babel/core/is-static.ts similarity index 100% rename from packages/babel/src/core/is-static.ts rename to packages/core/babel/core/is-static.ts diff --git a/packages/babel/src/core/is-yielded.ts b/packages/core/babel/core/is-yielded.ts similarity index 100% rename from packages/babel/src/core/is-yielded.ts rename to packages/core/babel/core/is-yielded.ts diff --git a/packages/babel/src/core/memo-variable.ts b/packages/core/babel/core/memo-variable.ts similarity index 100% rename from packages/babel/src/core/memo-variable.ts rename to packages/core/babel/core/memo-variable.ts diff --git a/packages/babel/src/core/proto.ts b/packages/core/babel/core/proto.ts similarity index 100% rename from packages/babel/src/core/proto.ts rename to packages/core/babel/core/proto.ts diff --git a/packages/babel/src/core/signal-variable.ts b/packages/core/babel/core/signal-variable.ts similarity index 100% rename from packages/babel/src/core/signal-variable.ts rename to packages/core/babel/core/signal-variable.ts diff --git a/packages/babel/src/core/types.ts b/packages/core/babel/core/types.ts similarity index 100% rename from packages/babel/src/core/types.ts rename to packages/core/babel/core/types.ts diff --git a/packages/babel/src/core/unwrap-node.ts b/packages/core/babel/core/unwrap-node.ts similarity index 100% rename from packages/babel/src/core/unwrap-node.ts rename to packages/core/babel/core/unwrap-node.ts diff --git a/packages/babel/src/env.d.ts b/packages/core/babel/env.d.ts similarity index 100% rename from packages/babel/src/env.d.ts rename to packages/core/babel/env.d.ts diff --git a/packages/core/babel/index.ts b/packages/core/babel/index.ts new file mode 100644 index 0000000..eb0cc2a --- /dev/null +++ b/packages/core/babel/index.ts @@ -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 { + 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); + }, + }, + }; +} diff --git a/packages/babel/src/transform-comment.ts b/packages/core/babel/transform-comment.ts similarity index 100% rename from packages/babel/src/transform-comment.ts rename to packages/core/babel/transform-comment.ts diff --git a/packages/babel/src/transform-ctf.ts b/packages/core/babel/transform-ctf.ts similarity index 100% rename from packages/babel/src/transform-ctf.ts rename to packages/core/babel/transform-ctf.ts diff --git a/packages/babel/src/transform-label.ts b/packages/core/babel/transform-label.ts similarity index 100% rename from packages/babel/src/transform-label.ts rename to packages/core/babel/transform-label.ts diff --git a/packages/babel/example.js b/packages/core/example.js similarity index 100% rename from packages/babel/example.js rename to packages/core/example.js diff --git a/packages/babel/package.json b/packages/core/package.json similarity index 75% rename from packages/babel/package.json rename to packages/core/package.json index 10477a7..d9f23ae 100644 --- a/packages/babel/package.json +++ b/packages/core/package.json @@ -1,9 +1,6 @@ { "version": "0.15.1", "type": "module", - "types": "./dist/types/index.d.ts", - "main": "./dist/cjs/production/index.cjs", - "module": "./dist/esm/production/index.mjs", "exports": { ".": { "development": { @@ -12,7 +9,16 @@ }, "require": "./dist/cjs/production/index.cjs", "import": "./dist/esm/production/index.mjs", - "types": "./dist/types/index.d.ts" + "types": "./dist/types/src/index.d.ts" + }, + "./babel": { + "development": { + "require": "./dist/cjs/development/babel.cjs", + "import": "./dist/esm/development/babel.mjs" + }, + "require": "./dist/cjs/production/babel.cjs", + "import": "./dist/esm/production/babel.mjs", + "types": "./dist/types/babel/index.d.ts" } }, "files": [ @@ -30,7 +36,7 @@ "labels", "reactivity" ], - "name": "babel-plugin-solid-labels", + "name": "solid-labels", "devDependencies": { "@babel/core": "^7.23.2", "@types/babel__core": "^7.20.3", @@ -48,6 +54,11 @@ "@babel/core": "^7.23", "solid-js": "^1.3" }, + "dependencies": { + "@babel/helper-module-imports": "^7.22.15", + "@babel/traverse": "^7.23.2", + "@babel/types": "^7.23.0" + }, "scripts": { "prepublish": "pridepack clean && pridepack build", "build": "pridepack build", @@ -57,17 +68,12 @@ "watch": "pridepack watch", "test": "vitest" }, - "dependencies": { - "@babel/helper-module-imports": "^7.22.15", - "@babel/traverse": "^7.23.2", - "@babel/types": "^7.23.0" - }, "description": "Simple, reactive labels for SolidJS", "repository": { "url": "https://github.com/lxsmnsyc/solid-labels.git", "type": "git" }, - "homepage": "https://github.com/lxsmnsyc/solid-labels/tree/main/packages/babel", + "homepage": "https://github.com/lxsmnsyc/solid-labels/tree/main/packages/core", "bugs": { "url": "https://github.com/lxsmnsyc/solid-labels/issues" }, @@ -77,6 +83,13 @@ "author": "Alexis Munsayac", "private": false, "typesVersions": { - "*": {} - } + "*": { + "babel": [ + "./dist/types/babel/index.d.ts" + ] + } + }, + "types": "./dist/types/src/index.d.ts", + "main": "./dist/cjs/production/index.cjs", + "module": "./dist/esm/production/index.mjs" } diff --git a/packages/core/pridepack.json b/packages/core/pridepack.json new file mode 100644 index 0000000..c5f81cf --- /dev/null +++ b/packages/core/pridepack.json @@ -0,0 +1,7 @@ +{ + "target": "es2018", + "entrypoints": { + ".": "src/index.ts", + "./babel": "babel/index.ts" + } +} \ No newline at end of file diff --git a/packages/babel/src/index.ts b/packages/core/src/index.ts similarity index 87% rename from packages/babel/src/index.ts rename to packages/core/src/index.ts index 3b782ce..549d591 100644 --- a/packages/babel/src/index.ts +++ b/packages/core/src/index.ts @@ -1,12 +1,6 @@ -import type * as babel from '@babel/core'; import type * as solid from 'solid-js'; import type * as solidWeb from 'solid-js/web'; import type * as solidStore from 'solid-js/store'; -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'; declare global { type Accessor = solid.Accessor; @@ -174,22 +168,3 @@ declare module 'solid-js' { } } } - -export type { Options }; - -export default function solidLabelsPlugin(): babel.PluginObj { - 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); - }, - }, - }; -} diff --git a/packages/babel/test/__snapshots__/ctf.test.ts.snap b/packages/core/test/__snapshots__/ctf.test.ts.snap similarity index 100% rename from packages/babel/test/__snapshots__/ctf.test.ts.snap rename to packages/core/test/__snapshots__/ctf.test.ts.snap diff --git a/packages/babel/test/ctf.test.ts b/packages/core/test/ctf.test.ts similarity index 99% rename from packages/babel/test/ctf.test.ts rename to packages/core/test/ctf.test.ts index 3c6d038..c104696 100644 --- a/packages/babel/test/ctf.test.ts +++ b/packages/core/test/ctf.test.ts @@ -1,7 +1,7 @@ /* eslint-disable no-template-curly-in-string */ import * as babel from '@babel/core'; import { describe, expect, it } from 'vitest'; -import plugin from '../src'; +import plugin from '../babel'; async function compile(code: string, dev?: boolean): Promise { const result = await babel.transformAsync(code, { diff --git a/packages/babel/tsconfig.eslint.json b/packages/core/tsconfig.eslint.json similarity index 91% rename from packages/babel/tsconfig.eslint.json rename to packages/core/tsconfig.eslint.json index e9d0d37..0e5267a 100644 --- a/packages/babel/tsconfig.eslint.json +++ b/packages/core/tsconfig.eslint.json @@ -1,6 +1,6 @@ { "exclude": ["node_modules"], - "include": ["src", "types", "test"], + "include": ["src", "types", "test", "babel"], "compilerOptions": { "module": "ESNext", "lib": ["ESNext", "DOM"], diff --git a/packages/babel/tsconfig.json b/packages/core/tsconfig.json similarity index 89% rename from packages/babel/tsconfig.json rename to packages/core/tsconfig.json index d168ea5..de6933e 100644 --- a/packages/babel/tsconfig.json +++ b/packages/core/tsconfig.json @@ -1,13 +1,13 @@ { "exclude": ["node_modules"], - "include": ["src", "types"], + "include": ["src", "types", "babel"], "compilerOptions": { "module": "ESNext", "lib": ["ESNext", "DOM"], "importHelpers": true, "declaration": true, "sourceMap": true, - "rootDir": "./src", + "rootDir": "./", "strict": true, "noUnusedLocals": true, "noUnusedParameters": true, diff --git a/packages/rollup/README.md b/packages/rollup/README.md index f332435..5554edd 100644 --- a/packages/rollup/README.md +++ b/packages/rollup/README.md @@ -7,15 +7,15 @@ ## Install ```bash -npm install --D rollup-plugin-solid-labels +npm install --D solid-labels rollup-plugin-solid-labels ``` ```bash -yarn add -D rollup-plugin-solid-labels +yarn add -D solid-labels rollup-plugin-solid-labels ``` ```bash -pnpm add -D rollup-plugin-solid-labels +pnpm add -D solid-labels rollup-plugin-solid-labels ``` ## Usage diff --git a/packages/rollup/env.d.ts b/packages/rollup/env.d.ts deleted file mode 100644 index d12ab13..0000000 --- a/packages/rollup/env.d.ts +++ /dev/null @@ -1 +0,0 @@ -/// diff --git a/packages/rollup/package.json b/packages/rollup/package.json index 8a10694..7e2ce17 100644 --- a/packages/rollup/package.json +++ b/packages/rollup/package.json @@ -17,8 +17,7 @@ }, "files": [ "dist", - "src", - "env.d.ts" + "src" ], "engines": { "node": ">=10" @@ -45,6 +44,7 @@ "unplugin-solid-labels": "0.15.1" }, "peerDependencies": { + "solid-labels": "^0.15", "rollup": "^3 || ^4" }, "scripts": { diff --git a/packages/unplugin/README.md b/packages/unplugin/README.md index c18d912..7bee20f 100644 --- a/packages/unplugin/README.md +++ b/packages/unplugin/README.md @@ -7,15 +7,15 @@ ## Install ```bash -npm install --D unplugin-solid-labels +npm install --D solid-labels unplugin-solid-labels ``` ```bash -yarn add -D unplugin-solid-labels +yarn add -D solid-labels unplugin-solid-labels ``` ```bash -pnpm add -D unplugin-solid-labels +pnpm add -D solid-labels unplugin-solid-labels ``` ## Usage diff --git a/packages/unplugin/package.json b/packages/unplugin/package.json index 56bc5e8..eb79be9 100644 --- a/packages/unplugin/package.json +++ b/packages/unplugin/package.json @@ -21,6 +21,7 @@ "eslint-config-lxsmnsyc": "^0.6.5", "pridepack": "2.5.1", "rollup": "^4.0.2", + "solid-labels": "0.15.1", "tslib": "^2.6.2", "typescript": "^5.2.2", "vite": "^4.5.0" @@ -28,10 +29,10 @@ "dependencies": { "@babel/core": "^7.23.2", "@rollup/pluginutils": "^5.0.2", - "babel-plugin-solid-labels": "0.15.1", "unplugin": "^1.3.1" }, "peerDependencies": { + "solid-labels": "^0.15", "rollup": "^3 || 4", "vite": "^3 || ^4" }, diff --git a/packages/unplugin/src/index.ts b/packages/unplugin/src/index.ts index 7194372..0ff048c 100644 --- a/packages/unplugin/src/index.ts +++ b/packages/unplugin/src/index.ts @@ -1,5 +1,5 @@ -import type { Options } from 'babel-plugin-solid-labels'; -import solidLabelsBabel from 'babel-plugin-solid-labels'; +import type { Options } from 'solid-labels/babel'; +import solidLabelsBabel from 'solid-labels/babel'; import * as babel from '@babel/core'; import type { Plugin } from 'vite'; import type { FilterPattern } from '@rollup/pluginutils'; diff --git a/packages/vite/README.md b/packages/vite/README.md index a8d69f0..0c0ee8b 100644 --- a/packages/vite/README.md +++ b/packages/vite/README.md @@ -7,15 +7,15 @@ ## Install ```bash -npm install --D vite-plugin-solid-labels +npm install --D solid-labels vite-plugin-solid-labels ``` ```bash -yarn add -D vite-plugin-solid-labels +yarn add -D solid-labels vite-plugin-solid-labels ``` ```bash -pnpm add -D vite-plugin-solid-labels +pnpm add -D solid-labels vite-plugin-solid-labels ``` ## Usage diff --git a/packages/vite/env.d.ts b/packages/vite/env.d.ts deleted file mode 100644 index d12ab13..0000000 --- a/packages/vite/env.d.ts +++ /dev/null @@ -1 +0,0 @@ -/// diff --git a/packages/vite/package.json b/packages/vite/package.json index 1eb7c4f..f2a6a23 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -17,8 +17,7 @@ }, "files": [ "dist", - "src", - "env.d.ts" + "src" ], "engines": { "node": ">=10" @@ -38,6 +37,7 @@ "eslint-config-lxsmnsyc": "^0.6.5", "pridepack": "2.5.1", "rollup": "^4.0.2", + "solid-labels": "0.15.1", "tslib": "^2.6.2", "typescript": "^5.2.2", "vite": "^4.5.0" @@ -46,6 +46,7 @@ "unplugin-solid-labels": "0.15.1" }, "peerDependencies": { + "solid-labels": "^0.15", "vite": "^3 || ^4" }, "scripts": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index fcf75b3..aeb1864 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -27,15 +27,15 @@ importers: specifier: ^1.8.0 version: 1.8.0 devDependencies: - babel-plugin-solid-labels: - specifier: 0.15.1 - version: link:../../packages/babel eslint: specifier: ^8.51.0 version: 8.51.0 eslint-config-lxsmnsyc: specifier: ^0.6.5 version: 0.6.5(eslint@8.51.0)(typescript@5.2.2) + solid-labels: + specifier: 0.15.1 + version: link:../../packages/core typescript: specifier: ^5.2.2 version: 5.2.2 @@ -55,15 +55,15 @@ importers: specifier: ^1.8.0 version: 1.8.0 devDependencies: - babel-plugin-solid-labels: - specifier: 0.15.1 - version: link:../../packages/babel eslint: specifier: ^8.51.0 version: 8.51.0 eslint-config-lxsmnsyc: specifier: ^0.6.5 version: 0.6.5(eslint@8.51.0)(typescript@5.2.2) + solid-labels: + specifier: 0.15.1 + version: link:../../packages/core typescript: specifier: ^5.2.2 version: 5.2.2 @@ -83,15 +83,15 @@ importers: specifier: ^1.8.0 version: 1.8.0 devDependencies: - babel-plugin-solid-labels: - specifier: 0.15.1 - version: link:../../packages/babel eslint: specifier: ^8.51.0 version: 8.51.0 eslint-config-lxsmnsyc: specifier: ^0.6.5 version: 0.6.5(eslint@8.51.0)(typescript@5.2.2) + solid-labels: + specifier: 0.15.1 + version: link:../../packages/core typescript: specifier: ^5.2.2 version: 5.2.2 @@ -106,6 +106,40 @@ importers: version: link:../../packages/vite packages/babel: + dependencies: + solid-labels: + specifier: 0.15.1 + version: link:../core + devDependencies: + '@babel/core': + specifier: ^7.23.2 + version: 7.23.2 + '@types/node': + specifier: ^20.8.7 + version: 20.8.7 + eslint: + specifier: ^8.51.0 + version: 8.51.0 + eslint-config-lxsmnsyc: + specifier: ^0.6.5 + version: 0.6.5(eslint@8.51.0)(typescript@5.2.2) + pridepack: + specifier: 2.5.1 + version: 2.5.1(eslint@8.51.0)(tslib@2.6.2)(typescript@5.2.2) + solid-js: + specifier: ^1.8.0 + version: 1.8.0 + tslib: + specifier: ^2.6.2 + version: 2.6.2 + typescript: + specifier: ^5.2.2 + version: 5.2.2 + vitest: + specifier: ^0.34.6 + version: 0.34.6 + + packages/core: dependencies: '@babel/helper-module-imports': specifier: ^7.22.15 @@ -153,6 +187,9 @@ importers: packages/rollup: dependencies: + solid-labels: + specifier: ^0.15 + version: link:../core unplugin-solid-labels: specifier: 0.15.1 version: link:../unplugin @@ -187,9 +224,6 @@ importers: '@rollup/pluginutils': specifier: ^5.0.2 version: 5.0.2(rollup@4.0.2) - babel-plugin-solid-labels: - specifier: 0.15.1 - version: link:../babel unplugin: specifier: ^1.3.1 version: 1.5.0 @@ -212,6 +246,9 @@ importers: rollup: specifier: ^4.0.2 version: 4.0.2 + solid-labels: + specifier: 0.15.1 + version: link:../core tslib: specifier: ^2.6.2 version: 2.6.2 @@ -243,6 +280,9 @@ importers: rollup: specifier: ^4.0.2 version: 4.0.2 + solid-labels: + specifier: 0.15.1 + version: link:../core tslib: specifier: ^2.6.2 version: 2.6.2 @@ -1031,16 +1071,6 @@ packages: dev: true optional: true - /@eslint-community/eslint-utils@4.3.0(eslint@8.34.0): - resolution: {integrity: sha512-v3oplH6FYCULtFuCeqyuTd9D2WKO937Dxdq+GmHOLL72TTRriLxz2VLlNfkZRsvj6PKnOPAtuT6dwrs/pA5DvA==} - engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} - peerDependencies: - eslint: ^6.0.0 || ^7.0.0 || >=8.0.0 - dependencies: - eslint: 8.34.0 - eslint-visitor-keys: 3.4.3 - dev: true - /@eslint-community/eslint-utils@4.3.0(eslint@8.51.0): resolution: {integrity: sha512-v3oplH6FYCULtFuCeqyuTd9D2WKO937Dxdq+GmHOLL72TTRriLxz2VLlNfkZRsvj6PKnOPAtuT6dwrs/pA5DvA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} @@ -1058,7 +1088,7 @@ packages: eslint: ^6.0.0 || ^7.0.0 || >=8.0.0 dependencies: eslint: 8.34.0 - eslint-visitor-keys: 3.3.0 + eslint-visitor-keys: 3.4.3 dev: true /@eslint-community/eslint-utils@4.4.0(eslint@8.51.0): @@ -1068,7 +1098,7 @@ packages: eslint: ^6.0.0 || ^7.0.0 || >=8.0.0 dependencies: eslint: 8.51.0 - eslint-visitor-keys: 3.3.0 + eslint-visitor-keys: 3.4.3 dev: true /@eslint-community/regexpp@4.4.0: @@ -2229,7 +2259,7 @@ packages: debug: 4.3.4 globby: 11.1.0 is-glob: 4.0.3 - semver: 7.3.7 + semver: 7.5.4 tsutils: 3.21.0(typescript@5.2.2) typescript: 5.2.2 transitivePeerDependencies: @@ -2263,7 +2293,7 @@ packages: peerDependencies: eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 dependencies: - '@eslint-community/eslint-utils': 4.3.0(eslint@8.34.0) + '@eslint-community/eslint-utils': 4.4.0(eslint@8.34.0) '@types/json-schema': 7.0.9 '@types/semver': 7.3.13 '@typescript-eslint/scope-manager': 5.62.0 @@ -2271,7 +2301,7 @@ packages: '@typescript-eslint/typescript-estree': 5.62.0(typescript@5.2.2) eslint: 8.34.0 eslint-scope: 5.1.1 - semver: 7.3.7 + semver: 7.5.4 transitivePeerDependencies: - supports-color - typescript @@ -2283,7 +2313,7 @@ packages: peerDependencies: eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 dependencies: - '@eslint-community/eslint-utils': 4.3.0(eslint@8.51.0) + '@eslint-community/eslint-utils': 4.4.0(eslint@8.51.0) '@types/json-schema': 7.0.9 '@types/semver': 7.3.13 '@typescript-eslint/scope-manager': 5.62.0 @@ -2291,7 +2321,7 @@ packages: '@typescript-eslint/typescript-estree': 5.62.0(typescript@5.2.2) eslint: 8.51.0 eslint-scope: 5.1.1 - semver: 7.3.7 + semver: 7.5.4 transitivePeerDependencies: - supports-color - typescript @@ -2302,7 +2332,7 @@ packages: engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dependencies: '@typescript-eslint/types': 5.62.0 - eslint-visitor-keys: 3.3.0 + eslint-visitor-keys: 3.4.3 dev: true /@typescript-eslint/visitor-keys@5.9.1: @@ -3662,7 +3692,7 @@ packages: eslint-plugin-import: 2.27.5(@typescript-eslint/parser@5.62.0)(eslint-import-resolver-typescript@3.6.1)(eslint@8.34.0) object.assign: 4.1.4 object.entries: 1.1.6 - semver: 6.3.0 + semver: 6.3.1 dev: true /eslint-config-airbnb-base@15.0.0(eslint-plugin-import@2.27.5)(eslint@8.51.0): @@ -3677,7 +3707,7 @@ packages: eslint-plugin-import: 2.27.5(@typescript-eslint/parser@5.62.0)(eslint-import-resolver-typescript@3.6.1)(eslint@8.51.0) object.assign: 4.1.4 object.entries: 1.1.6 - semver: 6.3.0 + semver: 6.3.1 dev: true /eslint-config-airbnb@19.0.4(eslint-plugin-import@2.27.5)(eslint-plugin-jsx-a11y@6.7.1)(eslint-plugin-react-hooks@4.6.0)(eslint-plugin-react@7.32.2)(eslint@8.34.0): @@ -4164,7 +4194,7 @@ packages: object.values: 1.1.6 prop-types: 15.8.1 resolve: 2.0.0-next.4 - semver: 6.3.0 + semver: 6.3.1 string.prototype.matchall: 4.0.8 dev: true @@ -4188,7 +4218,7 @@ packages: object.values: 1.1.6 prop-types: 15.8.1 resolve: 2.0.0-next.4 - semver: 6.3.0 + semver: 6.3.1 string.prototype.matchall: 4.0.8 dev: true