Skip to content

Commit

Permalink
feat: Add @wxt-dev/module-solid package (#730)
Browse files Browse the repository at this point in the history
  • Loading branch information
aklinker1 authored Jun 14, 2024
1 parent 38b71d1 commit 771ea03
Show file tree
Hide file tree
Showing 6 changed files with 244 additions and 17 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
"packageManager": "[email protected]",
"scripts": {
"check": "check && pnpm -r run check",
"check": "check && pnpm -r --sequential run check",
"test": "vitest",
"test:coverage": "vitest run --coverage.enabled \"--coverage.include=packages/wxt/src/**\" \"--coverage.exclude=packages/wxt/src/core/utils/testing/**\" \"--coverage.exclude=**/*.d.ts\" \"--coverage.exclude=**/fixtures/**\"",
"prepare": "simple-git-hooks",
Expand Down
32 changes: 32 additions & 0 deletions packages/module-solid/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# `@wxt-dev/module-solid`

Enables the use of [SolidJS](https://www.solidjs.com/) in your web extension, in HTML pages and content scripts.

This plugin makes a few changes:

1. Adds `vite-plugin-solid` to vite
2. Adds the [`solid-js` preset](https://github.com/unjs/unimport/blob/main/src/presets/solid.ts) to auto-imports

## Usage

```sh
pnpm i solid-js
pnpm i -D @wxt-dev/module-solid
```

Then add the module to your config:

```ts
// wxt.config.ts
export default defineConfig({
// Required
modules: ['@wxt-dev/module-solid'],

// Optional: Pass options to the module:
solid: {
vite: {
// ...
},
},
});
```
41 changes: 41 additions & 0 deletions packages/module-solid/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"name": "@wxt-dev/module-solid",
"version": "1.0.0",
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"exports": {
".": {
"import": {
"types": "./dist/index.d.mts",
"default": "./dist/index.mjs"
},
"require": {
"types": "./dist/index.d.cts",
"default": "./dist/index.cjs"
}
}
},
"files": [
"dist"
],
"scripts": {
"build": "pnpm -s build-deps && unbuild",
"check": "pnpm -s build-deps && check",
"build-deps": "pnpm -ws build-deps @wxt-dev/module-solid"
},
"peerDependencies": {
"wxt": ">=0.18.5"
},
"dependencies": {
"vite-plugin-solid": "^2.10.2"
},
"devDependencies": {
"@aklinker1/check": "^1.3.1",
"publint": "^0.2.8",
"typescript": "^5.4.5",
"unbuild": "^2.0.0",
"wxt": "workspace:*"
}
}
27 changes: 27 additions & 0 deletions packages/module-solid/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import 'wxt';
import { addImportPreset, addViteConfig, defineWxtModule } from 'wxt/modules';
import solid, { Options as PluginOptions } from 'vite-plugin-solid';

export default defineWxtModule<SolidModuleOptions>({
name: '@wxt-dev/module-solid',
configKey: 'solid',
setup(wxt, options) {
const { vite } = options ?? {};

addViteConfig(wxt, () => ({
plugins: [solid(vite)],
}));

addImportPreset(wxt, 'solid-js');
},
});

export interface SolidModuleOptions {
vite?: PluginOptions;
}

declare module 'wxt' {
export interface InlineConfig {
solid?: SolidModuleOptions;
}
}
4 changes: 4 additions & 0 deletions packages/module-solid/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "../../tsconfig.base.json",
"exclude": ["node_modules/**", "dist/**"]
}
155 changes: 139 additions & 16 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 771ea03

Please sign in to comment.