-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add
@wxt-dev/module-solid
package (#730)
- Loading branch information
Showing
6 changed files
with
244 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: { | ||
// ... | ||
}, | ||
}, | ||
}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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:*" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"extends": "../../tsconfig.base.json", | ||
"exclude": ["node_modules/**", "dist/**"] | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.