├── .changeset ├── README.md └── config.json ├── .eslintignore ├── .eslintrc.cjs ├── .gitattributes ├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.yaml │ └── feature-request.yaml └── workflows │ ├── format-check .yml │ ├── lint-check.yml │ ├── publish.yml │ └── type-check.yml ├── .gitignore ├── .vscode └── settings.json ├── CHANGELOG.md ├── LICENSE ├── README.md ├── bun.lockb ├── package.json ├── prettier.config.cjs ├── src └── index.ts └── tsconfig.json /.changeset/README.md: -------------------------------------------------------------------------------- 1 | # Changesets 2 | 3 | Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works 4 | with multi-package repos, or single-package repos to help you version and publish your code. You can 5 | find the full documentation for it [in our repository](https://github.com/changesets/changesets) 6 | 7 | We have a quick list of common questions to get you started engaging with this project in 8 | [our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md) 9 | -------------------------------------------------------------------------------- /.changeset/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://unpkg.com/@changesets/config@2.3.1/schema.json", 3 | "changelog": "@changesets/cli/changelog", 4 | "commit": false, 5 | "fixed": [], 6 | "linked": [], 7 | "access": "public", 8 | "baseBranch": "main", 9 | "updateInternalDependencies": "patch", 10 | "ignore": [] 11 | } 12 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | \*.tsbuildinfo 3 | .eslintcache 4 | 5 | .env 6 | .env.development.local 7 | .env.test.local 8 | .env.production.local 9 | .env.local 10 | 11 | dist/ 12 | .tshy/ 13 | .tshy-build-tmp/ 14 | -------------------------------------------------------------------------------- /.eslintrc.cjs: -------------------------------------------------------------------------------- 1 | /** @type {import('eslint').Linter.Config} */ 2 | module.exports = { 3 | env: { 4 | es2021: true, 5 | node: true, 6 | }, 7 | extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended"], 8 | overrides: [ 9 | { 10 | env: { 11 | node: true, 12 | }, 13 | files: [".eslintrc.{js,cjs}"], 14 | parserOptions: { 15 | sourceType: "script", 16 | }, 17 | }, 18 | ], 19 | parser: "@typescript-eslint/parser", 20 | parserOptions: { ecmaVersion: "latest", sourceType: "module" }, 21 | plugins: ["@typescript-eslint", "simple-import-sort", "import"], 22 | rules: { 23 | "simple-import-sort/imports": "error", 24 | "simple-import-sort/exports": "error", 25 | "import/first": "error", 26 | "import/newline-after-import": "error", 27 | "import/no-duplicates": ["error", { "prefer-inline": true }], 28 | "no-duplicate-imports": "error", 29 | "@typescript-eslint/consistent-type-imports": [ 30 | "error", 31 | { fixStyle: "inline-type-imports" }, 32 | ], 33 | }, 34 | }; 35 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.yaml: -------------------------------------------------------------------------------- 1 | name: 🐛 Report a bug 2 | description: File a bug report 3 | labels: ["bug"] 4 | body: 5 | - type: markdown 6 | attributes: 7 | value: | 8 | Thank you for submitting a bug report! 9 | 10 | Please be patient, this is a volunteer-driven project. The best way to ensure your bug report is addressed is: 11 | 12 | 1. Provide as much information as possible. 13 | 2. Share a minimal reproduction. Bonus points for linking to a [CodeSandbox](https://codesandbox.io) or similar! 14 | 3. Be kind and patient. We all have lives outside of this project. 15 | 4. Consider contributing a fix! We will do our best to help you. 16 | - type: input 17 | attributes: 18 | label: In which versions of the package (and relevant enviroment tools such as Node.js) have you observed the bug? 19 | validations: 20 | required: true 21 | - type: textarea 22 | id: description 23 | attributes: 24 | label: What steps will reproduce the bug? 25 | description: Explain the bug and provide a minimal code example that reproduces the problem (or a link to a repo/sandbox). 26 | validations: 27 | required: true 28 | - type: textarea 29 | id: expected-behavior 30 | attributes: 31 | label: What behavior did you expect? 32 | description: A clear and concise description of what you expected to happen. 33 | validations: 34 | required: true 35 | - type: textarea 36 | id: actual-behavior 37 | attributes: 38 | label: What actually happened? 39 | description: A clear and concise description of what actually happened. 40 | validations: 41 | required: true 42 | - type: textarea 43 | id: workaround 44 | attributes: 45 | label: Workaround 46 | description: If you have a workaround, please share it here. 47 | - type: textarea 48 | id: proposed-fix 49 | attributes: 50 | label: Proposed fix 51 | description: If you have a proposed solution, please share it here. 52 | - type: textarea 53 | id: other-remarks 54 | attributes: 55 | label: Other remarks 56 | description: Any other information you'd like to share that is relevant to the issue being reported. 57 | - type: checkboxes 58 | id: contribute 59 | attributes: 60 | label: Contribution 61 | description: Let us know if you'd like to contribute to the project. If so, we will be happy to help you and your reported issue will likely be prioritized. 62 | options: 63 | - label: I would like to try to contribute a fix 64 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature-request.yaml: -------------------------------------------------------------------------------- 1 | name: 💡 Request a feature 2 | description: Suggest a new feature or enhancement 3 | labels: ["enhancement"] 4 | body: 5 | - type: markdown 6 | attributes: 7 | value: | 8 | Thank you for submitting a feature request! 9 | 10 | Please be patient, this is a volunteer-driven project. The best way to ensure your feature request is addressed is: 11 | 12 | 1. Provide detailed information about the use case for the feature. 13 | 2. Be kind and patient. We all have lives outside of this project. 14 | 3. Consider contributing the feature yourself! We will do our best to help you. 15 | 16 | Please note that feature requests are not guaranteed to be implemented. The project's maintainers will decide whether or not to implement a feature request based on its usefulness to the project and its alignment with the project's goals. 17 | 18 | Regardless of the outcome, we appreciate your interest in the project! 19 | - type: textarea 20 | id: description 21 | attributes: 22 | label: Description 23 | description: Describe the feature you'd like to see added to the project. 24 | validations: 25 | required: true 26 | - type: textarea 27 | id: workaround 28 | attributes: 29 | label: Workaround / userland implementation 30 | description: If you have a workaround or userland implementation, please share it here. 31 | - type: textarea 32 | id: other-remarks 33 | attributes: 34 | label: Other remarks 35 | description: Any other information you'd like to share that is relevant to the feature request being submitted. 36 | - type: checkboxes 37 | id: contribute 38 | attributes: 39 | label: Contribution 40 | description: Let us know if you'd like to contribute to the project. If so, we will be happy to help you and your feature request will likely be prioritized. 41 | options: 42 | - label: I would like to contribute 43 | -------------------------------------------------------------------------------- /.github/workflows/format-check .yml: -------------------------------------------------------------------------------- 1 | name: Check format 2 | on: 3 | pull_request: 4 | jobs: 5 | check-format: 6 | runs-on: ubuntu-latest 7 | steps: 8 | - uses: actions/checkout@v3 9 | - uses: oven-sh/setup-bun@v1 10 | with: 11 | bun-version: latest 12 | - uses: actions/setup-node@v3 13 | with: 14 | node-version: 16.x 15 | - run: bun install --frozen-lockfile --ignore-scripts 16 | - name: Check format 17 | run: bunx prettier . --check 18 | -------------------------------------------------------------------------------- /.github/workflows/lint-check.yml: -------------------------------------------------------------------------------- 1 | name: Lint 2 | on: 3 | pull_request: 4 | jobs: 5 | lint: 6 | runs-on: ubuntu-latest 7 | steps: 8 | - uses: actions/checkout@v3 9 | - uses: oven-sh/setup-bun@v1 10 | with: 11 | bun-version: latest 12 | - uses: actions/setup-node@v3 13 | with: 14 | node-version: 16.x 15 | - run: bun install --frozen-lockfile --ignore-scripts 16 | - name: Lint 17 | run: bunx eslint . 18 | -------------------------------------------------------------------------------- /.github/workflows/publish.yml: -------------------------------------------------------------------------------- 1 | name: Publish 2 | on: 3 | push: 4 | branches: 5 | - "main" 6 | 7 | concurrency: ${{ github.workflow }}-${{ github.ref }} 8 | 9 | jobs: 10 | publish: 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: actions/checkout@v3 14 | - uses: oven-sh/setup-bun@v1 15 | with: 16 | bun-version: latest 17 | - uses: actions/setup-node@v3 18 | with: 19 | node-version: 16.x 20 | - run: bun install --frozen-lockfile --ignore-scripts 21 | - name: Create release pull request or publish 22 | id: changesets 23 | uses: changesets/action@v1 24 | with: 25 | publish: bun run publish 26 | env: 27 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 28 | NPM_TOKEN: ${{ secrets.NPM_TOKEN }} 29 | -------------------------------------------------------------------------------- /.github/workflows/type-check.yml: -------------------------------------------------------------------------------- 1 | name: Check types 2 | on: 3 | pull_request: 4 | jobs: 5 | check-types: 6 | runs-on: ubuntu-latest 7 | steps: 8 | - uses: actions/checkout@v3 9 | - uses: oven-sh/setup-bun@v1 10 | with: 11 | bun-version: latest 12 | - uses: actions/setup-node@v3 13 | with: 14 | node-version: 16.x 15 | - run: bun install --frozen-lockfile --ignore-scripts 16 | - name: Check types 17 | run: bunx tsc --noEmit 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | \*.tsbuildinfo 3 | .eslintcache 4 | 5 | .env 6 | .env.development.local 7 | .env.test.local 8 | .env.production.local 9 | .env.local 10 | 11 | dist/ 12 | .tshy/ 13 | .tshy-build/ 14 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "typescript.tsdk": "node_modules/typescript/lib" 3 | } 4 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # bun-plugin-solid 2 | 3 | ## 1.0.0 4 | 5 | ### Major Changes 6 | 7 | - 48b9cec: Initial release 8 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2023 Dani Guardiola 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # bun-plugin-solid 2 | 3 | A plugin to compile Solid.js code with Bun. 4 | 5 | ```bash 6 | bun add -D bun-plugin-solid 7 | ``` 8 | 9 | ```tsx 10 | import { SolidPlugin } from "bun-plugin-solid"; 11 | 12 | await Bun.build({ 13 | // ... 14 | plugins: [SolidPlugin()], 15 | }); 16 | ``` 17 | 18 | ## Options 19 | 20 | All passed options are forwarded to [`babel-preset-solid`](https://www.npmjs.com/package/babel-preset-solid). For example: 21 | 22 | ```tsx 23 | await Bun.build({ 24 | // ... 25 | plugins: [SolidPlugin({ generate: "ssr", hydratable: true })], 26 | }); 27 | ``` 28 | 29 | ## About this plugin and motivation 30 | 31 | This plugin uses babel under the hood, which is not ideal. However, there is (currently) no clear public roadmap for proper compilation of Solid.js in Bun, so this plugin is a temporary solution for those (like me) who want to use Bun to build their Solid.js projects. 32 | 33 | The hope is that it'll become obsolete once there is a better solution, at which point it can simply be removed. 34 | 35 | The plugin will only run in for `.jsx` and `.tsx` files. 36 | -------------------------------------------------------------------------------- /bun.lockb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DaniGuardiola/bun-plugin-solid/5c1e57b9ce5de29154a9edddca5fc428b1714b63/bun.lockb -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "bun-plugin-solid", 3 | "description": "A plugin to compile Solid.js with Bun.", 4 | "version": "1.0.0", 5 | "author": { 6 | "email": "hi@daniguardio.la", 7 | "name": "Dani Guardiola", 8 | "url": "https://dio.la/" 9 | }, 10 | "license": "MIT", 11 | "type": "module", 12 | "files": [ 13 | "dist" 14 | ], 15 | "scripts": { 16 | "prepare": "tshy", 17 | "publish": "changeset publish" 18 | }, 19 | "dependencies": { 20 | "@babel/core": ">=7.0.0", 21 | "@babel/preset-typescript": ">=7.0.0", 22 | "babel-preset-solid": ">=1.8.0" 23 | }, 24 | "devDependencies": { 25 | "@types/babel__core": ">=7.0.0", 26 | "@changesets/cli": "^2.26.2", 27 | "@typescript-eslint/eslint-plugin": "^6.10.0", 28 | "@typescript-eslint/parser": "^6.10.0", 29 | "bun-types": "latest", 30 | "eslint": "^8.53.0", 31 | "eslint-plugin-import": "^2.29.0", 32 | "eslint-plugin-simple-import-sort": "^10.0.0", 33 | "prettier": "^3.0.3", 34 | "tshy": "^1.8.0", 35 | "typescript": "^5.2.2" 36 | }, 37 | "tshy": { 38 | "dialects": [ 39 | "esm" 40 | ], 41 | "exports": { 42 | "./package.json": "./package.json", 43 | ".": "./src/index.ts" 44 | } 45 | }, 46 | "exports": { 47 | "./package.json": "./package.json", 48 | ".": { 49 | "import": { 50 | "types": "./dist/esm/index.d.ts", 51 | "default": "./dist/esm/index.js" 52 | } 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /prettier.config.cjs: -------------------------------------------------------------------------------- 1 | module.exports = {}; 2 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | import { transformAsync } from "@babel/core"; 2 | // @ts-expect-error - Types not important. 3 | import ts from "@babel/preset-typescript"; 4 | // @ts-expect-error - Types not important. 5 | import solid from "babel-preset-solid"; 6 | import { type BunPlugin } from "bun"; 7 | 8 | export interface SolidPluginOptions { 9 | generate?: "dom" | "ssr"; 10 | hydratable?: boolean; 11 | } 12 | 13 | export function SolidPlugin(options: SolidPluginOptions = {}): BunPlugin { 14 | return { 15 | name: "bun-plugin-solid", 16 | setup: (build) => { 17 | build.onLoad({ filter: /\.(js|ts)x$/ }, async (args) => { 18 | const { readFile } = await import("node:fs/promises"); 19 | const code = await readFile(args.path, "utf8"); 20 | const transforms = await transformAsync(code, { 21 | filename: args.path, 22 | presets: [ 23 | [solid, options], 24 | [ts, {}], 25 | ], 26 | }); 27 | 28 | return { 29 | contents: transforms!.code!, 30 | loader: "js", 31 | }; 32 | }); 33 | }, 34 | }; 35 | } 36 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "lib": ["ESNext"], 4 | "module": "NodeNext", 5 | "target": "esnext", 6 | "moduleResolution": "NodeNext", 7 | "moduleDetection": "force", 8 | "strict": true, 9 | "downlevelIteration": true, 10 | "skipLibCheck": true, 11 | "declaration": true, 12 | "jsx": "react-jsx", 13 | "allowSyntheticDefaultImports": true, 14 | "forceConsistentCasingInFileNames": true, 15 | "allowJs": true, 16 | "types": [ 17 | "bun-types" // add Bun global 18 | ] 19 | }, 20 | "include": ["src/**/*"] 21 | } 22 | --------------------------------------------------------------------------------