Skip to content

Commit 5b07c95

Browse files
committed
feat: Export and bootstrap the /client package
1 parent e6c0d84 commit 5b07c95

15 files changed

+92
-52
lines changed

demo/entrypoints/background.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { defineBackgroundScript } from 'exvite/client';
2+
import browser from 'webextension-polyfill';
3+
4+
export default defineBackgroundScript(() => {
5+
console.log(browser.runtime.id);
6+
});

demo/entrypoints/options/index.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>Extension Settings</title>
7+
<link rel="stylesheet" href="./style.css" />
8+
</head>
9+
<body>
10+
<p>Hello options page!</p>
11+
<script type="module" src="./main.ts"></script>
12+
</body>
13+
</html>

demo/entrypoints/options/main.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import browser from 'webextension-polyfill';
2+
3+
console.log(browser.runtime.id);

demo/entrypoints/options/style.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
html {
2+
background: black;
3+
color: white;
4+
}

demo/entrypoints/overlay.content.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { defineContentScript, mountContentScriptUi } from 'exvite/client';
2+
import browser from 'webextension-polyfill';
3+
4+
export default defineContentScript({
5+
matches: ['*://*/*'],
6+
async main() {
7+
console.log(browser.runtime.id);
8+
9+
mountContentScriptUi();
10+
},
11+
});

demo/entrypoints/popup.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>Popup</title>
7+
</head>
8+
<body>
9+
<p>Hello popup!</p>
10+
</body>
11+
</html>

demo/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55
"build": "pnpm -w build && exvite build",
66
"prepare": "pnpm -w build && exvite prepare"
77
},
8+
"dependencies": {
9+
"webextension-polyfill": "^0.10.0"
10+
},
811
"devDependencies": {
12+
"@types/webextension-polyfill": "^0.10.0",
913
"exvite": "workspace:*"
10-
},
11-
"dependencies": {
12-
"unimport": "^3.0.8"
1314
}
1415
}

demo/tsconfig.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"extends": "../tsconfig.base.json",
3+
"exclude": [".output"]
4+
}

demo/utils/logger.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default console;

package.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"files": [
1717
"dist"
1818
],
19-
"bin": "dist/cli.cjs",
19+
"bin": "dist/cli/index.cjs",
2020
"main": "./dist/index.cjs",
2121
"module": "./dist/index.js",
2222
"types": "./dist/index.d.ts",
@@ -25,13 +25,19 @@
2525
"require": "./dist/index.cjs",
2626
"import": "./dist/index.js",
2727
"types": "./dist/index.d.ts"
28+
},
29+
"./client": {
30+
"require": "./dist/client/index.cjs",
31+
"import": "./dist/client/index.js",
32+
"types": "./dist/client/index.d.ts"
2833
}
2934
},
3035
"scripts": {
3136
"dev": "tsx src/cli.ts",
3237
"build": "run-s build:*",
3338
"build:js": "tsup src/index.ts --clean --sourcemap --dts --format esm,cjs",
34-
"build:cli": "tsup src/cli.ts",
39+
"build:cli": "tsup src/cli/index.ts -d dist/cli --sourcemap",
40+
"build:client": "tsup src/client/index.ts -d dist/client --sourcemap --dts --format esm,cjs",
3541
"format": "prettier --write .",
3642
"format:check": "prettier --write .",
3743
"prepare": "simple-git-hooks"

0 commit comments

Comments
 (0)