wxt 0.18.9 → 0.18.11
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/dist/chunk-6XSIWUWF.js +57 -0
- package/dist/{chunk-UA35R5HN.js → chunk-XNTIBS6O.js} +295 -202
- package/dist/cli.js +350 -238
- package/dist/{execa-D7CMCKO2.js → execa-4UBDUBJZ.js} +566 -478
- package/dist/{execa-ATHZH2Y4.js → execa-QLUM2B3W.js} +566 -478
- package/dist/{index-B0efqfEK.d.ts → index-CER9SLWP.d.cts} +69 -13
- package/dist/{index-B0efqfEK.d.cts → index-CER9SLWP.d.ts} +69 -13
- package/dist/index.cjs +1134 -913
- package/dist/index.d.cts +14 -3
- package/dist/index.d.ts +14 -3
- package/dist/index.js +18 -12
- package/dist/modules.d.cts +1 -1
- package/dist/modules.d.ts +1 -1
- package/dist/modules.js +8 -49
- package/dist/testing.cjs +253 -122
- package/dist/testing.d.cts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +18 -9
- package/dist/virtual/background-entrypoint.js +9 -1
- package/package.json +9 -9
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// src/modules.ts
|
|
2
|
+
import * as vite from "vite";
|
|
3
|
+
import glob from "fast-glob";
|
|
4
|
+
import { resolve } from "node:path";
|
|
5
|
+
function defineWxtModule(module) {
|
|
6
|
+
if (typeof module === "function") return { setup: module };
|
|
7
|
+
return module;
|
|
8
|
+
}
|
|
9
|
+
function addEntrypoint(wxt, entrypoint) {
|
|
10
|
+
wxt.hooks.hook("entrypoints:resolved", (wxt2, entrypoints) => {
|
|
11
|
+
entrypoints.push(entrypoint);
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
function addPublicAssets(wxt, dir) {
|
|
15
|
+
wxt.hooks.hook("build:publicAssets", async (wxt2, files) => {
|
|
16
|
+
const moreFiles = await glob("**/*", { cwd: dir });
|
|
17
|
+
if (moreFiles.length === 0) {
|
|
18
|
+
wxt2.logger.warn("No files to copy in", dir);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
moreFiles.forEach((file) => {
|
|
22
|
+
files.unshift({ absoluteSrc: resolve(dir, file), relativeDest: file });
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
function addViteConfig(wxt, viteConfig) {
|
|
27
|
+
wxt.hooks.hook("ready", (wxt2) => {
|
|
28
|
+
const userVite = wxt2.config.vite;
|
|
29
|
+
wxt2.config.vite = async (env) => {
|
|
30
|
+
const fromUser = await userVite(env);
|
|
31
|
+
const fromModule = viteConfig(env) ?? {};
|
|
32
|
+
return vite.mergeConfig(fromModule, fromUser);
|
|
33
|
+
};
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
function addWxtPlugin(wxt, plugin) {
|
|
37
|
+
wxt.hooks.hook("ready", (wxt2) => {
|
|
38
|
+
wxt2.config.plugins.push(plugin);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
function addImportPreset(wxt, preset) {
|
|
42
|
+
wxt.hooks.hook("ready", (wxt2) => {
|
|
43
|
+
if (!wxt2.config.imports) return;
|
|
44
|
+
wxt2.config.imports.presets ??= [];
|
|
45
|
+
if (wxt2.config.imports.presets.includes(preset)) return;
|
|
46
|
+
wxt2.config.imports.presets.push(preset);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export {
|
|
51
|
+
defineWxtModule,
|
|
52
|
+
addEntrypoint,
|
|
53
|
+
addPublicAssets,
|
|
54
|
+
addViteConfig,
|
|
55
|
+
addWxtPlugin,
|
|
56
|
+
addImportPreset
|
|
57
|
+
};
|