@multiplatform.one/vite-plugin-webext 6.4.3 → 6.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.cjs +7 -1
- package/lib/index.mjs +7 -2
- package/package.json +7 -3
- package/src/index.ts +15 -1
- package/types/index.d.ts.map +1 -1
package/lib/index.cjs
CHANGED
|
@@ -31,6 +31,8 @@ node_fs = __toESM(node_fs, 1);
|
|
|
31
31
|
let node_path = require("node:path");
|
|
32
32
|
node_path = __toESM(node_path, 1);
|
|
33
33
|
let _multiplatform_one_utils_dev = require("@multiplatform.one/utils/dev");
|
|
34
|
+
let _rolldown_plugin_babel = require("@rolldown/plugin-babel");
|
|
35
|
+
_rolldown_plugin_babel = __toESM(_rolldown_plugin_babel, 1);
|
|
34
36
|
let _vitejs_plugin_react = require("@vitejs/plugin-react");
|
|
35
37
|
_vitejs_plugin_react = __toESM(_vitejs_plugin_react, 1);
|
|
36
38
|
|
|
@@ -145,6 +147,7 @@ async function createWebextViewsConfig(options) {
|
|
|
145
147
|
(0, _multiplatform_one_utils_dev.stubExpoTypeDeclarations)(),
|
|
146
148
|
(0, _multiplatform_one_utils_dev.oneServerOnlyBrowserStub)(workspaceRoot),
|
|
147
149
|
(0, _vitejs_plugin_react.default)({ jsxRuntime: "automatic" }),
|
|
150
|
+
(0, _rolldown_plugin_babel.default)({ presets: [(0, _vitejs_plugin_react.reactCompilerPreset)()] }),
|
|
148
151
|
tamaguiPlugin({
|
|
149
152
|
components: (0, _multiplatform_one_utils_dev.lookupTamaguiModules)([options.targetDir]),
|
|
150
153
|
config: options.tamaguiConfig,
|
|
@@ -222,6 +225,8 @@ async function createWebextContentConfig(options) {
|
|
|
222
225
|
(0, _multiplatform_one_utils_dev.stubExpoTypeDeclarations)(),
|
|
223
226
|
(0, _multiplatform_one_utils_dev.oneServerOnlyBrowserStub)(workspaceRoot),
|
|
224
227
|
shikiStubPlugin(),
|
|
228
|
+
(0, _vitejs_plugin_react.default)({ jsxRuntime: "automatic" }),
|
|
229
|
+
(0, _rolldown_plugin_babel.default)({ presets: [(0, _vitejs_plugin_react.reactCompilerPreset)()] }),
|
|
225
230
|
tamaguiPlugin({
|
|
226
231
|
components: (0, _multiplatform_one_utils_dev.lookupTamaguiModules)([options.targetDir]),
|
|
227
232
|
config: options.tamaguiConfig,
|
|
@@ -247,7 +252,8 @@ async function createWebextContentConfig(options) {
|
|
|
247
252
|
lib: {
|
|
248
253
|
entry: node_path.default.join(options.targetDir, "content_scripts/index.tsx"),
|
|
249
254
|
name: options.packageInfo.name,
|
|
250
|
-
formats: ["iife"]
|
|
255
|
+
formats: ["iife"],
|
|
256
|
+
cssFileName: "webext"
|
|
251
257
|
},
|
|
252
258
|
rollupOptions: { output: {
|
|
253
259
|
entryFileNames: "index.global.js",
|
package/lib/index.mjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { lookupProjectRoot, lookupTamaguiModules, oneServerOnlyBrowserStub, stubExpoTypeDeclarations, workspaceSourceAliases } from "@multiplatform.one/utils/dev";
|
|
4
|
-
import
|
|
4
|
+
import babel from "@rolldown/plugin-babel";
|
|
5
|
+
import react, { reactCompilerPreset } from "@vitejs/plugin-react";
|
|
5
6
|
|
|
6
7
|
//#region src/index.ts
|
|
7
8
|
const WEBEXT_EXTENSIONS = [
|
|
@@ -114,6 +115,7 @@ async function createWebextViewsConfig(options) {
|
|
|
114
115
|
stubExpoTypeDeclarations(),
|
|
115
116
|
oneServerOnlyBrowserStub(workspaceRoot),
|
|
116
117
|
react({ jsxRuntime: "automatic" }),
|
|
118
|
+
babel({ presets: [reactCompilerPreset()] }),
|
|
117
119
|
tamaguiPlugin({
|
|
118
120
|
components: lookupTamaguiModules([options.targetDir]),
|
|
119
121
|
config: options.tamaguiConfig,
|
|
@@ -191,6 +193,8 @@ async function createWebextContentConfig(options) {
|
|
|
191
193
|
stubExpoTypeDeclarations(),
|
|
192
194
|
oneServerOnlyBrowserStub(workspaceRoot),
|
|
193
195
|
shikiStubPlugin(),
|
|
196
|
+
react({ jsxRuntime: "automatic" }),
|
|
197
|
+
babel({ presets: [reactCompilerPreset()] }),
|
|
194
198
|
tamaguiPlugin({
|
|
195
199
|
components: lookupTamaguiModules([options.targetDir]),
|
|
196
200
|
config: options.tamaguiConfig,
|
|
@@ -216,7 +220,8 @@ async function createWebextContentConfig(options) {
|
|
|
216
220
|
lib: {
|
|
217
221
|
entry: path.join(options.targetDir, "content_scripts/index.tsx"),
|
|
218
222
|
name: options.packageInfo.name,
|
|
219
|
-
formats: ["iife"]
|
|
223
|
+
formats: ["iife"],
|
|
224
|
+
cssFileName: "webext"
|
|
220
225
|
},
|
|
221
226
|
rollupOptions: { output: {
|
|
222
227
|
entryFileNames: "index.global.js",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@multiplatform.one/vite-plugin-webext",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.7.0",
|
|
4
4
|
"description": "Vite config factories for building a browser web extension (MV3 views, background service worker, content scripts) as a target of a multiplatform.one One app — workspace source aliases, the one-server-only browser stub, Tamagui wiring, and the manifest/dev-reload prepare pipeline.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"browser-extension",
|
|
@@ -46,11 +46,15 @@
|
|
|
46
46
|
"access": "public"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
+
"@babel/core": "^7.26.0",
|
|
50
|
+
"@rolldown/plugin-babel": "^0.2.3",
|
|
51
|
+
"babel-plugin-react-compiler": "^1.0.0",
|
|
49
52
|
"chokidar": "^5.0.0",
|
|
50
|
-
"@multiplatform.one/utils": "6.
|
|
53
|
+
"@multiplatform.one/utils": "6.7.0"
|
|
51
54
|
},
|
|
52
55
|
"devDependencies": {
|
|
53
56
|
"@tamagui/vite-plugin": "2.0.0-rc.41",
|
|
57
|
+
"@types/babel__core": "^7.20.5",
|
|
54
58
|
"@types/node": "^25.6.0",
|
|
55
59
|
"@vitejs/plugin-react": "^6.0.1",
|
|
56
60
|
"typescript": "~5.9.3",
|
|
@@ -62,7 +66,7 @@
|
|
|
62
66
|
"vite": ">=5"
|
|
63
67
|
},
|
|
64
68
|
"scripts": {
|
|
65
|
-
"typecheck": "
|
|
69
|
+
"typecheck": "tsgo --noEmit",
|
|
66
70
|
"build": "rm -rf lib types 2>/dev/null && tsc -b --emitDeclarationOnly && tsdown"
|
|
67
71
|
}
|
|
68
72
|
}
|
package/src/index.ts
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
// <stagingDir>/dist/views/<view>/index.html (popup/options/sidepanel/…)
|
|
9
9
|
// <stagingDir>/dist/background/index.mjs (service worker / bg script)
|
|
10
10
|
// <stagingDir>/dist/contentScripts/index.global.js
|
|
11
|
+
// <stagingDir>/dist/contentScripts/webext.css (web-accessible resource)
|
|
11
12
|
//
|
|
12
13
|
// Three vite builds cover the three JS worlds (DOM views, worker, injected
|
|
13
14
|
// content script); `runWebextPrepare` writes the manifest and the dev-mode
|
|
@@ -24,7 +25,8 @@ import {
|
|
|
24
25
|
workspaceSourceAliases,
|
|
25
26
|
lookupProjectRoot,
|
|
26
27
|
} from "@multiplatform.one/utils/dev";
|
|
27
|
-
import
|
|
28
|
+
import babel from "@rolldown/plugin-babel";
|
|
29
|
+
import react, { reactCompilerPreset } from "@vitejs/plugin-react";
|
|
28
30
|
import type { Alias, Plugin, UserConfig } from "vite";
|
|
29
31
|
|
|
30
32
|
export interface WebextPackageInfo {
|
|
@@ -168,6 +170,9 @@ export async function createWebextViewsConfig(options: WebextTargetOptions): Pro
|
|
|
168
170
|
stubExpoTypeDeclarations(),
|
|
169
171
|
oneServerOnlyBrowserStub(workspaceRoot),
|
|
170
172
|
react({ jsxRuntime: "automatic" }),
|
|
173
|
+
// Same React Compiler pass the One app runs (react 19 built-in
|
|
174
|
+
// runtime) — extension views get the memoization for free.
|
|
175
|
+
babel({ presets: [reactCompilerPreset()] }),
|
|
171
176
|
tamaguiPlugin({
|
|
172
177
|
components: lookupTamaguiModules([options.targetDir]),
|
|
173
178
|
config: options.tamaguiConfig,
|
|
@@ -257,6 +262,10 @@ export async function createWebextContentConfig(options: WebextTargetOptions): P
|
|
|
257
262
|
stubExpoTypeDeclarations(),
|
|
258
263
|
oneServerOnlyBrowserStub(workspaceRoot),
|
|
259
264
|
shikiStubPlugin(),
|
|
265
|
+
// The react plugin transforms JSX (the esbuild jsx setting below
|
|
266
|
+
// stays for non-plugin paths); the babel pass adds the compiler.
|
|
267
|
+
react({ jsxRuntime: "automatic" }),
|
|
268
|
+
babel({ presets: [reactCompilerPreset()] }),
|
|
260
269
|
tamaguiPlugin({
|
|
261
270
|
components: lookupTamaguiModules([options.targetDir]),
|
|
262
271
|
config: options.tamaguiConfig,
|
|
@@ -287,6 +296,11 @@ export async function createWebextContentConfig(options: WebextTargetOptions): P
|
|
|
287
296
|
entry: path.join(options.targetDir, "content_scripts/index.tsx"),
|
|
288
297
|
name: options.packageInfo.name,
|
|
289
298
|
formats: ["iife"],
|
|
299
|
+
// Without this, Vite names the extracted stylesheet after the nearest
|
|
300
|
+
// package.json — so the file tracked whichever app hosts the target
|
|
301
|
+
// (`one.css` since webext folded into apps/one) while the manifest
|
|
302
|
+
// declares a stable target-owned name.
|
|
303
|
+
cssFileName: "webext",
|
|
290
304
|
},
|
|
291
305
|
rollupOptions: {
|
|
292
306
|
output: {
|
package/types/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AA6BA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAEtD,MAAM,WAAW,iBAAiB;IAChC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