wxt 0.18.9 → 0.18.10

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/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { I as InlineConfig, B as BuildOutput, U as UserConfig, E as ExtensionRunnerConfig, W as WxtDevServer } from './index-B0efqfEK.cjs';
2
- export { x as BackgroundDefinition, n as BackgroundEntrypoint, i as BackgroundEntrypointOptions, j as BaseContentScriptEntrypointOptions, m as BaseEntrypoint, h as BaseEntrypointOptions, e as BuildStepOutput, J as ConfigEnv, w as ContentScriptDefinition, C as ContentScriptEntrypoint, a5 as Dependency, r as Entrypoint, s as EntrypointGroup, $ as EslintGlobalsPropValue, a0 as Eslintrc, _ as ExtensionRunner, Z as FsCache, G as GenericEntrypoint, X as HookResult, u as IsolatedWorldContentScriptDefinition, k as IsolatedWorldContentScriptEntrypointOptions, L as Logger, v as MainWorldContentScriptDefinition, M as MainWorldContentScriptEntrypointOptions, t as OnContentScriptStopped, p as OptionsEntrypoint, l as OptionsEntrypointOptions, d as OutputAsset, c as OutputChunk, O as OutputFile, A as PerBrowserMap, z as PerBrowserOption, o as PopupEntrypoint, P as PopupEntrypointOptions, f as ReloadContentScriptPayload, R as ResolvedConfig, a1 as ResolvedEslintrc, D as ResolvedPerBrowserOptions, aa as ResolvedPublicFile, V as ServerInfo, q as SidepanelEntrypoint, S as SidepanelEntrypointOptions, T as TargetBrowser, g as TargetManifestVersion, y as UnlistedScriptDefinition, F as UserManifest, H as UserManifestFn, Y as Wxt, N as WxtBuilder, Q as WxtBuilderServer, K as WxtCommand, b as WxtHooks, a8 as WxtModule, a6 as WxtModuleOptions, a7 as WxtModuleSetup, a9 as WxtModuleWithMetadata, a4 as WxtPackageManager, ab as WxtPlugin, a3 as WxtResolvedUnimportOptions, a2 as WxtUnimportOptions, a as WxtViteConfig } from './index-B0efqfEK.cjs';
1
+ import { I as InlineConfig, B as BuildOutput, U as UserConfig, E as ExtensionRunnerConfig, W as WxtDevServer } from './index-mz3v4Nde.cjs';
2
+ export { x as BackgroundDefinition, n as BackgroundEntrypoint, i as BackgroundEntrypointOptions, j as BaseContentScriptEntrypointOptions, m as BaseEntrypoint, h as BaseEntrypointOptions, e as BuildStepOutput, J as ConfigEnv, w as ContentScriptDefinition, C as ContentScriptEntrypoint, ac as CopiedPublicFile, a5 as Dependency, r as Entrypoint, s as EntrypointGroup, $ as EslintGlobalsPropValue, a0 as Eslintrc, _ as ExtensionRunner, Z as FsCache, ad as GeneratedPublicFile, G as GenericEntrypoint, X as HookResult, u as IsolatedWorldContentScriptDefinition, k as IsolatedWorldContentScriptEntrypointOptions, L as Logger, v as MainWorldContentScriptDefinition, M as MainWorldContentScriptEntrypointOptions, t as OnContentScriptStopped, p as OptionsEntrypoint, l as OptionsEntrypointOptions, d as OutputAsset, c as OutputChunk, O as OutputFile, A as PerBrowserMap, z as PerBrowserOption, o as PopupEntrypoint, P as PopupEntrypointOptions, f as ReloadContentScriptPayload, ab as ResolvedBasePublicFile, R as ResolvedConfig, a1 as ResolvedEslintrc, D as ResolvedPerBrowserOptions, aa as ResolvedPublicFile, V as ServerInfo, q as SidepanelEntrypoint, S as SidepanelEntrypointOptions, T as TargetBrowser, g as TargetManifestVersion, y as UnlistedScriptDefinition, F as UserManifest, H as UserManifestFn, Y as Wxt, N as WxtBuilder, Q as WxtBuilderServer, K as WxtCommand, af as WxtDirEntry, ah as WxtDirFileEntry, ag as WxtDirTypeReferenceEntry, b as WxtHooks, a8 as WxtModule, a6 as WxtModuleOptions, a7 as WxtModuleSetup, a9 as WxtModuleWithMetadata, a4 as WxtPackageManager, ae as WxtPlugin, a3 as WxtResolvedUnimportOptions, a2 as WxtUnimportOptions, a as WxtViteConfig } from './index-mz3v4Nde.cjs';
3
3
  import 'vite';
4
4
  import 'webextension-polyfill';
5
5
  import 'unimport';
@@ -65,6 +65,6 @@ declare function prepare(config: InlineConfig): Promise<void>;
65
65
  */
66
66
  declare function zip(config?: InlineConfig): Promise<string[]>;
67
67
 
68
- var version = "0.18.8";
68
+ var version = "0.18.9";
69
69
 
70
70
  export { BuildOutput, ExtensionRunnerConfig, InlineConfig, UserConfig, WxtDevServer, build, clean, createServer, defineConfig, defineRunnerConfig, initialize, prepare, version, zip };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { I as InlineConfig, B as BuildOutput, U as UserConfig, E as ExtensionRunnerConfig, W as WxtDevServer } from './index-B0efqfEK.js';
2
- export { x as BackgroundDefinition, n as BackgroundEntrypoint, i as BackgroundEntrypointOptions, j as BaseContentScriptEntrypointOptions, m as BaseEntrypoint, h as BaseEntrypointOptions, e as BuildStepOutput, J as ConfigEnv, w as ContentScriptDefinition, C as ContentScriptEntrypoint, a5 as Dependency, r as Entrypoint, s as EntrypointGroup, $ as EslintGlobalsPropValue, a0 as Eslintrc, _ as ExtensionRunner, Z as FsCache, G as GenericEntrypoint, X as HookResult, u as IsolatedWorldContentScriptDefinition, k as IsolatedWorldContentScriptEntrypointOptions, L as Logger, v as MainWorldContentScriptDefinition, M as MainWorldContentScriptEntrypointOptions, t as OnContentScriptStopped, p as OptionsEntrypoint, l as OptionsEntrypointOptions, d as OutputAsset, c as OutputChunk, O as OutputFile, A as PerBrowserMap, z as PerBrowserOption, o as PopupEntrypoint, P as PopupEntrypointOptions, f as ReloadContentScriptPayload, R as ResolvedConfig, a1 as ResolvedEslintrc, D as ResolvedPerBrowserOptions, aa as ResolvedPublicFile, V as ServerInfo, q as SidepanelEntrypoint, S as SidepanelEntrypointOptions, T as TargetBrowser, g as TargetManifestVersion, y as UnlistedScriptDefinition, F as UserManifest, H as UserManifestFn, Y as Wxt, N as WxtBuilder, Q as WxtBuilderServer, K as WxtCommand, b as WxtHooks, a8 as WxtModule, a6 as WxtModuleOptions, a7 as WxtModuleSetup, a9 as WxtModuleWithMetadata, a4 as WxtPackageManager, ab as WxtPlugin, a3 as WxtResolvedUnimportOptions, a2 as WxtUnimportOptions, a as WxtViteConfig } from './index-B0efqfEK.js';
1
+ import { I as InlineConfig, B as BuildOutput, U as UserConfig, E as ExtensionRunnerConfig, W as WxtDevServer } from './index-mz3v4Nde.js';
2
+ export { x as BackgroundDefinition, n as BackgroundEntrypoint, i as BackgroundEntrypointOptions, j as BaseContentScriptEntrypointOptions, m as BaseEntrypoint, h as BaseEntrypointOptions, e as BuildStepOutput, J as ConfigEnv, w as ContentScriptDefinition, C as ContentScriptEntrypoint, ac as CopiedPublicFile, a5 as Dependency, r as Entrypoint, s as EntrypointGroup, $ as EslintGlobalsPropValue, a0 as Eslintrc, _ as ExtensionRunner, Z as FsCache, ad as GeneratedPublicFile, G as GenericEntrypoint, X as HookResult, u as IsolatedWorldContentScriptDefinition, k as IsolatedWorldContentScriptEntrypointOptions, L as Logger, v as MainWorldContentScriptDefinition, M as MainWorldContentScriptEntrypointOptions, t as OnContentScriptStopped, p as OptionsEntrypoint, l as OptionsEntrypointOptions, d as OutputAsset, c as OutputChunk, O as OutputFile, A as PerBrowserMap, z as PerBrowserOption, o as PopupEntrypoint, P as PopupEntrypointOptions, f as ReloadContentScriptPayload, ab as ResolvedBasePublicFile, R as ResolvedConfig, a1 as ResolvedEslintrc, D as ResolvedPerBrowserOptions, aa as ResolvedPublicFile, V as ServerInfo, q as SidepanelEntrypoint, S as SidepanelEntrypointOptions, T as TargetBrowser, g as TargetManifestVersion, y as UnlistedScriptDefinition, F as UserManifest, H as UserManifestFn, Y as Wxt, N as WxtBuilder, Q as WxtBuilderServer, K as WxtCommand, af as WxtDirEntry, ah as WxtDirFileEntry, ag as WxtDirTypeReferenceEntry, b as WxtHooks, a8 as WxtModule, a6 as WxtModuleOptions, a7 as WxtModuleSetup, a9 as WxtModuleWithMetadata, a4 as WxtPackageManager, ae as WxtPlugin, a3 as WxtResolvedUnimportOptions, a2 as WxtUnimportOptions, a as WxtViteConfig } from './index-mz3v4Nde.js';
3
3
  import 'vite';
4
4
  import 'webextension-polyfill';
5
5
  import 'unimport';
@@ -65,6 +65,6 @@ declare function prepare(config: InlineConfig): Promise<void>;
65
65
  */
66
66
  declare function zip(config?: InlineConfig): Promise<string[]>;
67
67
 
68
- var version = "0.18.8";
68
+ var version = "0.18.9";
69
69
 
70
70
  export { BuildOutput, ExtensionRunnerConfig, InlineConfig, UserConfig, WxtDevServer, build, clean, createServer, defineConfig, defineRunnerConfig, initialize, prepare, version, zip };
package/dist/index.js CHANGED
@@ -19,8 +19,9 @@ import {
19
19
  unnormalizePath,
20
20
  version,
21
21
  wxt
22
- } from "./chunk-UA35R5HN.js";
22
+ } from "./chunk-2V7XZSZQ.js";
23
23
  import "./chunk-BERPNPEZ.js";
24
+ import "./chunk-6XSIWUWF.js";
24
25
  import {
25
26
  consola
26
27
  } from "./chunk-BM6QYGAW.js";
@@ -1,4 +1,4 @@
1
- import { a6 as WxtModuleOptions, a8 as WxtModule, a7 as WxtModuleSetup, Y as Wxt, r as Entrypoint } from './index-B0efqfEK.cjs';
1
+ import { a6 as WxtModuleOptions, a8 as WxtModule, a7 as WxtModuleSetup, Y as Wxt, r as Entrypoint } from './index-mz3v4Nde.cjs';
2
2
  import * as vite from 'vite';
3
3
  import { UnimportOptions } from 'unimport';
4
4
  import 'webextension-polyfill';
package/dist/modules.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { a6 as WxtModuleOptions, a8 as WxtModule, a7 as WxtModuleSetup, Y as Wxt, r as Entrypoint } from './index-B0efqfEK.js';
1
+ import { a6 as WxtModuleOptions, a8 as WxtModule, a7 as WxtModuleSetup, Y as Wxt, r as Entrypoint } from './index-mz3v4Nde.js';
2
2
  import * as vite from 'vite';
3
3
  import { UnimportOptions } from 'unimport';
4
4
  import 'webextension-polyfill';
package/dist/modules.js CHANGED
@@ -1,53 +1,12 @@
1
+ import {
2
+ addEntrypoint,
3
+ addImportPreset,
4
+ addPublicAssets,
5
+ addViteConfig,
6
+ addWxtPlugin,
7
+ defineWxtModule
8
+ } from "./chunk-6XSIWUWF.js";
1
9
  import "./chunk-QGM4M3NI.js";
2
-
3
- // src/modules.ts
4
- import * as vite from "vite";
5
- import glob from "fast-glob";
6
- import { resolve } from "node:path";
7
- function defineWxtModule(module) {
8
- if (typeof module === "function") return { setup: module };
9
- return module;
10
- }
11
- function addEntrypoint(wxt, entrypoint) {
12
- wxt.hooks.hook("entrypoints:resolved", (wxt2, entrypoints) => {
13
- entrypoints.push(entrypoint);
14
- });
15
- }
16
- function addPublicAssets(wxt, dir) {
17
- wxt.hooks.hook("build:publicAssets", async (wxt2, files) => {
18
- const moreFiles = await glob("**/*", { cwd: dir });
19
- if (moreFiles.length === 0) {
20
- wxt2.logger.warn("No files to copy in", dir);
21
- return;
22
- }
23
- moreFiles.forEach((file) => {
24
- files.unshift({ absoluteSrc: resolve(dir, file), relativeDest: file });
25
- });
26
- });
27
- }
28
- function addViteConfig(wxt, viteConfig) {
29
- wxt.hooks.hook("ready", (wxt2) => {
30
- const userVite = wxt2.config.vite;
31
- wxt2.config.vite = async (env) => {
32
- const fromUser = await userVite(env);
33
- const fromModule = viteConfig(env) ?? {};
34
- return vite.mergeConfig(fromModule, fromUser);
35
- };
36
- });
37
- }
38
- function addWxtPlugin(wxt, plugin) {
39
- wxt.hooks.hook("ready", (wxt2) => {
40
- wxt2.config.plugins.push(plugin);
41
- });
42
- }
43
- function addImportPreset(wxt, preset) {
44
- wxt.hooks.hook("ready", (wxt2) => {
45
- if (!wxt2.config.imports) return;
46
- wxt2.config.imports.presets ??= [];
47
- if (wxt2.config.imports.presets.includes(preset)) return;
48
- wxt2.config.imports.presets.push(preset);
49
- });
50
- }
51
10
  export {
52
11
  addEntrypoint,
53
12
  addImportPreset,
package/dist/testing.cjs CHANGED
@@ -445,7 +445,7 @@ var init_core = __esm({
445
445
 
446
446
  // ../../node_modules/.pnpm/consola@3.2.3/node_modules/consola/dist/shared/consola.06ad8a64.mjs
447
447
  function parseStack(stack) {
448
- const cwd = process.cwd() + import_node_path10.sep;
448
+ const cwd = process.cwd() + import_node_path13.sep;
449
449
  const lines = stack.split("\n").splice(1).map((l2) => l2.trim().replace("file://", "").replace(cwd, ""));
450
450
  return lines;
451
451
  }
@@ -453,12 +453,12 @@ function writeStream(data, stream) {
453
453
  const write = stream.__write || stream.write;
454
454
  return write.call(stream, data);
455
455
  }
456
- var import_node_util, import_node_path10, bracket, BasicReporter;
456
+ var import_node_util, import_node_path13, bracket, BasicReporter;
457
457
  var init_consola_06ad8a64 = __esm({
458
458
  "../../node_modules/.pnpm/consola@3.2.3/node_modules/consola/dist/shared/consola.06ad8a64.mjs"() {
459
459
  "use strict";
460
460
  import_node_util = require("util");
461
- import_node_path10 = require("path");
461
+ import_node_path13 = require("path");
462
462
  bracket = (x) => x ? `[${x}]` : "";
463
463
  BasicReporter = class {
464
464
  formatStack(stack, opts) {
@@ -861,7 +861,7 @@ async function prompt(message, opts = {}) {
861
861
  }
862
862
  throw new Error(`Unknown prompt type: ${opts.type}`);
863
863
  }
864
- var import_node_process, import_node_readline, import_node_tty, import_tty, import_node_util2, import_node_path11, ESC, CSI, beep, cursor, scroll, erase, src, picocolors, tty2, isColorSupported2, formatter, replaceClose2, createColors2, picocolorsExports, l, m, G, K, Y, v, L, M, T, r, Z, H, q, p, J, b, W, Q, I, w, N, j, X, _, DD, uD, R, V, tD, h, sD, iD, ED, oD, unicode, s, S_STEP_ACTIVE, S_STEP_CANCEL, S_STEP_ERROR, S_STEP_SUBMIT, S_BAR, S_BAR_END, S_RADIO_ACTIVE, S_RADIO_INACTIVE, S_CHECKBOX_ACTIVE, S_CHECKBOX_SELECTED, S_CHECKBOX_INACTIVE, symbol, text, confirm, select, multiselect;
864
+ var import_node_process, import_node_readline, import_node_tty, import_tty, import_node_util2, import_node_path14, ESC, CSI, beep, cursor, scroll, erase, src, picocolors, tty2, isColorSupported2, formatter, replaceClose2, createColors2, picocolorsExports, l, m, G, K, Y, v, L, M, T, r, Z, H, q, p, J, b, W, Q, I, w, N, j, X, _, DD, uD, R, V, tD, h, sD, iD, ED, oD, unicode, s, S_STEP_ACTIVE, S_STEP_CANCEL, S_STEP_ERROR, S_STEP_SUBMIT, S_BAR, S_BAR_END, S_RADIO_ACTIVE, S_RADIO_INACTIVE, S_CHECKBOX_ACTIVE, S_CHECKBOX_SELECTED, S_CHECKBOX_INACTIVE, symbol, text, confirm, select, multiselect;
865
865
  var init_prompt = __esm({
866
866
  "../../node_modules/.pnpm/consola@3.2.3/node_modules/consola/dist/chunks/prompt.mjs"() {
867
867
  "use strict";
@@ -874,7 +874,7 @@ var init_prompt = __esm({
874
874
  init_core();
875
875
  init_consola_06ad8a64();
876
876
  import_node_util2 = require("util");
877
- import_node_path11 = require("path");
877
+ import_node_path14 = require("path");
878
878
  ESC = "\x1B";
879
879
  CSI = `${ESC}[`;
880
880
  beep = "\x07";
@@ -1972,38 +1972,6 @@ function download(config) {
1972
1972
  var import_node_path4 = require("path");
1973
1973
  var import_fs_extra = __toESM(require("fs-extra"), 1);
1974
1974
 
1975
- // src/core/builders/vite/plugins/unimport.ts
1976
- var import_unimport = require("unimport");
1977
- var import_path = require("path");
1978
- var ENABLED_EXTENSIONS = /* @__PURE__ */ new Set([
1979
- ".js",
1980
- ".jsx",
1981
- ".ts",
1982
- ".tsx",
1983
- ".vue",
1984
- ".svelte"
1985
- ]);
1986
- function unimport(config) {
1987
- const options = config.imports;
1988
- if (options === false) return [];
1989
- const unimport2 = (0, import_unimport.createUnimport)(options);
1990
- return {
1991
- name: "wxt:unimport",
1992
- async config() {
1993
- await unimport2.scanImportsFromDir(void 0, { cwd: config.srcDir });
1994
- },
1995
- async transform(code, id) {
1996
- if (id.includes("node_modules")) return;
1997
- if (!ENABLED_EXTENSIONS.has((0, import_path.extname)(id))) return;
1998
- const injected = await unimport2.injectImports(code, id);
1999
- return {
2000
- code: injected.code,
2001
- map: injected.s.generateMap({ hires: "boundary", source: id })
2002
- };
2003
- }
2004
- };
2005
- }
2006
-
2007
1975
  // src/core/utils/virtual-modules.ts
2008
1976
  var virtualEntrypointTypes = [
2009
1977
  "content-script-main-world",
@@ -2142,7 +2110,7 @@ var import_linkedom2 = require("linkedom");
2142
2110
 
2143
2111
  // src/core/utils/fs.ts
2144
2112
  var import_fs_extra4 = __toESM(require("fs-extra"), 1);
2145
- var import_fast_glob = __toESM(require("fast-glob"), 1);
2113
+ var import_fast_glob2 = __toESM(require("fast-glob"), 1);
2146
2114
 
2147
2115
  // src/core/wxt.ts
2148
2116
  var import_hookable = require("hookable");
@@ -2159,6 +2127,108 @@ var import_server = require("vite-node/server");
2159
2127
  var import_client = require("vite-node/client");
2160
2128
  var import_source_map = require("vite-node/source-map");
2161
2129
 
2130
+ // src/modules.ts
2131
+ var vite = __toESM(require("vite"), 1);
2132
+ var import_fast_glob = __toESM(require("fast-glob"), 1);
2133
+ var import_node_path9 = require("path");
2134
+ function defineWxtModule(module2) {
2135
+ if (typeof module2 === "function") return { setup: module2 };
2136
+ return module2;
2137
+ }
2138
+ function addViteConfig(wxt2, viteConfig) {
2139
+ wxt2.hooks.hook("ready", (wxt3) => {
2140
+ const userVite = wxt3.config.vite;
2141
+ wxt3.config.vite = async (env2) => {
2142
+ const fromUser = await userVite(env2);
2143
+ const fromModule = viteConfig(env2) ?? {};
2144
+ return vite.mergeConfig(fromModule, fromUser);
2145
+ };
2146
+ });
2147
+ }
2148
+
2149
+ // src/builtin-modules/unimport.ts
2150
+ var import_unimport = require("unimport");
2151
+ var import_node_path10 = require("path");
2152
+ var unimport_default = defineWxtModule({
2153
+ name: "wxt:built-in:unimport",
2154
+ setup(wxt2) {
2155
+ const options = wxt2.config.imports;
2156
+ if (options === false) return;
2157
+ let unimport;
2158
+ wxt2.hooks.hook("ready", () => {
2159
+ const addModuleImports = (module2) => {
2160
+ if (!module2.imports) return;
2161
+ options.imports ??= [];
2162
+ options.imports.push(...module2.imports);
2163
+ };
2164
+ wxt2.config.builtinModules.forEach(addModuleImports);
2165
+ wxt2.config.userModules.forEach(addModuleImports);
2166
+ });
2167
+ wxt2.hooks.afterEach((event) => {
2168
+ if (event.name === "ready") {
2169
+ unimport = (0, import_unimport.createUnimport)(options);
2170
+ }
2171
+ });
2172
+ wxt2.hooks.hook("prepare:types", async (_2, entries) => {
2173
+ await unimport.init();
2174
+ entries.push(await getImportsDeclarationEntry(unimport));
2175
+ if (!options.eslintrc.enabled) return;
2176
+ entries.push(await getImportsEslintEntry(unimport, options));
2177
+ });
2178
+ addViteConfig(wxt2, () => ({
2179
+ plugins: [vitePlugin(unimport)]
2180
+ }));
2181
+ }
2182
+ });
2183
+ function vitePlugin(unimport) {
2184
+ const ENABLED_EXTENSIONS = /* @__PURE__ */ new Set([
2185
+ ".js",
2186
+ ".jsx",
2187
+ ".ts",
2188
+ ".tsx",
2189
+ ".vue",
2190
+ ".svelte"
2191
+ ]);
2192
+ return {
2193
+ name: "wxt:unimport",
2194
+ async transform(code, id) {
2195
+ if (id.includes("node_modules")) return;
2196
+ if (!ENABLED_EXTENSIONS.has((0, import_node_path10.extname)(id))) return;
2197
+ const injected = await unimport.injectImports(code, id);
2198
+ return {
2199
+ code: injected.code,
2200
+ map: injected.s.generateMap({ hires: "boundary", source: id })
2201
+ };
2202
+ }
2203
+ };
2204
+ }
2205
+ async function getImportsDeclarationEntry(unimport) {
2206
+ await unimport.init();
2207
+ return {
2208
+ path: "types/imports.d.ts",
2209
+ text: [
2210
+ "// Generated by wxt",
2211
+ await unimport.generateTypeDeclarations(),
2212
+ ""
2213
+ ].join("\n"),
2214
+ tsReference: true
2215
+ };
2216
+ }
2217
+ async function getImportsEslintEntry(unimport, options) {
2218
+ const globals2 = {};
2219
+ const eslintrc = { globals: globals2 };
2220
+ (await unimport.getImports()).map((i) => i.as ?? i.name).filter(Boolean).sort().forEach((name) => {
2221
+ eslintrc.globals[name] = options.eslintrc.globalsPropValue;
2222
+ });
2223
+ return {
2224
+ path: options.eslintrc.filePath,
2225
+ text: JSON.stringify(eslintrc, null, 2) + "\n"
2226
+ };
2227
+ }
2228
+
2229
+ // src/builtin-modules/index.ts
2230
+ var builtinModules = [unimport_default];
2231
+
2162
2232
  // src/core/utils/fs.ts
2163
2233
  async function writeFileIfDifferent(file, newContents) {
2164
2234
  const existingContents = await import_fs_extra4.default.readFile(file, "utf-8").catch(() => void 0);
@@ -2176,7 +2246,7 @@ var import_fs_extra6 = __toESM(require("fs-extra"), 1);
2176
2246
  var import_minimatch = require("minimatch");
2177
2247
  var import_linkedom3 = require("linkedom");
2178
2248
  var import_json5 = __toESM(require("json5"), 1);
2179
- var import_fast_glob2 = __toESM(require("fast-glob"), 1);
2249
+ var import_fast_glob3 = __toESM(require("fast-glob"), 1);
2180
2250
  var import_picocolors2 = __toESM(require("picocolors"), 1);
2181
2251
  var PATH_GLOB_TO_TYPE_MAP = {
2182
2252
  "sandbox.html": "sandbox",
@@ -2219,23 +2289,23 @@ var PATH_GLOB_TO_TYPE_MAP = {
2219
2289
  };
2220
2290
 
2221
2291
  // src/core/utils/building/generate-wxt-dir.ts
2222
- var import_unimport2 = require("unimport");
2223
2292
  var import_fs_extra7 = __toESM(require("fs-extra"), 1);
2224
- var import_node_path9 = __toESM(require("path"), 1);
2293
+ var import_node_path11 = require("path");
2294
+ var import_node_path12 = __toESM(require("path"), 1);
2225
2295
 
2226
2296
  // src/core/utils/building/resolve-config.ts
2227
2297
  var import_c12 = require("c12");
2228
- var import_node_path14 = __toESM(require("path"), 1);
2298
+ var import_node_path17 = __toESM(require("path"), 1);
2229
2299
 
2230
2300
  // src/core/utils/cache.ts
2231
2301
  var import_fs_extra8 = __toESM(require("fs-extra"), 1);
2232
- var import_path2 = require("path");
2302
+ var import_path = require("path");
2233
2303
  function createFsCache(wxtDir) {
2234
- const getPath = (key) => (0, import_path2.resolve)(wxtDir, "cache", encodeURIComponent(key));
2304
+ const getPath = (key) => (0, import_path.resolve)(wxtDir, "cache", encodeURIComponent(key));
2235
2305
  return {
2236
2306
  async set(key, value) {
2237
2307
  const path8 = getPath(key);
2238
- await (0, import_fs_extra8.ensureDir)((0, import_path2.dirname)(path8));
2308
+ await (0, import_fs_extra8.ensureDir)((0, import_path.dirname)(path8));
2239
2309
  await writeFileIfDifferent(path8, value);
2240
2310
  },
2241
2311
  async get(key) {
@@ -2257,13 +2327,13 @@ var import_node_process3 = require("process");
2257
2327
  init_utils();
2258
2328
  var import_node_tty2 = require("tty");
2259
2329
  var import_node_util3 = require("util");
2260
- var import_node_path12 = require("path");
2330
+ var import_node_path15 = require("path");
2261
2331
 
2262
2332
  // src/core/utils/building/resolve-config.ts
2263
2333
  var import_defu = __toESM(require("defu"), 1);
2264
2334
 
2265
2335
  // src/core/utils/package.ts
2266
- var import_node_path13 = require("path");
2336
+ var import_node_path16 = require("path");
2267
2337
  var import_fs_extra9 = __toESM(require("fs-extra"), 1);
2268
2338
  function isModuleInstalled(name) {
2269
2339
  return import(
@@ -2274,7 +2344,7 @@ function isModuleInstalled(name) {
2274
2344
 
2275
2345
  // src/core/utils/building/resolve-config.ts
2276
2346
  var import_fs_extra10 = __toESM(require("fs-extra"), 1);
2277
- var import_fast_glob3 = __toESM(require("fast-glob"), 1);
2347
+ var import_fast_glob4 = __toESM(require("fast-glob"), 1);
2278
2348
  var import_meta = {};
2279
2349
  async function resolveConfig(inlineConfig, command) {
2280
2350
  let userConfig = {};
@@ -2300,28 +2370,28 @@ async function resolveConfig(inlineConfig, command) {
2300
2370
  const manifestVersion = mergedConfig.manifestVersion ?? (browser === "firefox" || browser === "safari" ? 2 : 3);
2301
2371
  const mode = mergedConfig.mode ?? COMMAND_MODES[command];
2302
2372
  const env2 = { browser, command, manifestVersion, mode };
2303
- const root = import_node_path14.default.resolve(
2373
+ const root = import_node_path17.default.resolve(
2304
2374
  inlineConfig.root ?? userConfig.root ?? process.cwd()
2305
2375
  );
2306
- const wxtDir = import_node_path14.default.resolve(root, ".wxt");
2376
+ const wxtDir = import_node_path17.default.resolve(root, ".wxt");
2307
2377
  const wxtModuleDir = await resolveWxtModuleDir();
2308
- const srcDir = import_node_path14.default.resolve(root, mergedConfig.srcDir ?? root);
2309
- const entrypointsDir = import_node_path14.default.resolve(
2378
+ const srcDir = import_node_path17.default.resolve(root, mergedConfig.srcDir ?? root);
2379
+ const entrypointsDir = import_node_path17.default.resolve(
2310
2380
  srcDir,
2311
2381
  mergedConfig.entrypointsDir ?? "entrypoints"
2312
2382
  );
2313
- const modulesDir = import_node_path14.default.resolve(srcDir, mergedConfig.modulesDir ?? "modules");
2383
+ const modulesDir = import_node_path17.default.resolve(srcDir, mergedConfig.modulesDir ?? "modules");
2314
2384
  if (await isDirMissing(entrypointsDir)) {
2315
2385
  logMissingDir(logger, "Entrypoints", entrypointsDir);
2316
2386
  }
2317
2387
  const filterEntrypoints = !!mergedConfig.filterEntrypoints?.length ? new Set(mergedConfig.filterEntrypoints) : void 0;
2318
- const publicDir = import_node_path14.default.resolve(srcDir, mergedConfig.publicDir ?? "public");
2388
+ const publicDir = import_node_path17.default.resolve(srcDir, mergedConfig.publicDir ?? "public");
2319
2389
  if (await isDirMissing(publicDir)) {
2320
2390
  logMissingDir(logger, "Public", publicDir);
2321
2391
  }
2322
- const typesDir = import_node_path14.default.resolve(wxtDir, "types");
2323
- const outBaseDir = import_node_path14.default.resolve(root, mergedConfig.outDir ?? ".output");
2324
- const outDir = import_node_path14.default.resolve(outBaseDir, `${browser}-mv${manifestVersion}`);
2392
+ const typesDir = import_node_path17.default.resolve(wxtDir, "types");
2393
+ const outBaseDir = import_node_path17.default.resolve(root, mergedConfig.outDir ?? ".output");
2394
+ const outDir = import_node_path17.default.resolve(outBaseDir, `${browser}-mv${manifestVersion}`);
2325
2395
  const reloadCommand = mergedConfig.dev?.reloadCommand ?? "Alt+R";
2326
2396
  const runnerConfig = await (0, import_c12.loadConfig)({
2327
2397
  name: "web-ext",
@@ -2338,7 +2408,7 @@ async function resolveConfig(inlineConfig, command) {
2338
2408
  "~": srcDir,
2339
2409
  "@@": root,
2340
2410
  "~~": root
2341
- }).map(([key, value]) => [key, import_node_path14.default.resolve(root, value)])
2411
+ }).map(([key, value]) => [key, import_node_path17.default.resolve(root, value)])
2342
2412
  );
2343
2413
  let devServerConfig;
2344
2414
  if (command === "serve") {
@@ -2352,14 +2422,20 @@ async function resolveConfig(inlineConfig, command) {
2352
2422
  hostname: "localhost"
2353
2423
  };
2354
2424
  }
2355
- const modules = await resolveWxtModules(modulesDir, mergedConfig.modules);
2356
- const moduleOptions = modules.reduce((map, module2) => {
2357
- if (module2.configKey) {
2358
- map[module2.configKey] = // @ts-expect-error
2359
- mergedConfig[module2.configKey];
2360
- }
2361
- return map;
2362
- }, {});
2425
+ const userModules = await resolveWxtUserModules(
2426
+ modulesDir,
2427
+ mergedConfig.modules
2428
+ );
2429
+ const moduleOptions = userModules.reduce(
2430
+ (map, module2) => {
2431
+ if (module2.configKey) {
2432
+ map[module2.configKey] = // @ts-expect-error
2433
+ mergedConfig[module2.configKey];
2434
+ }
2435
+ return map;
2436
+ },
2437
+ {}
2438
+ );
2363
2439
  return {
2364
2440
  browser,
2365
2441
  command,
@@ -2369,7 +2445,7 @@ async function resolveConfig(inlineConfig, command) {
2369
2445
  filterEntrypoints,
2370
2446
  env: env2,
2371
2447
  fsCache: createFsCache(wxtDir),
2372
- imports: await getUnimportOptions(wxtDir, logger, mergedConfig),
2448
+ imports: await getUnimportOptions(wxtDir, srcDir, logger, mergedConfig),
2373
2449
  logger,
2374
2450
  manifest: await resolveManifestConfig(env2, mergedConfig.manifest),
2375
2451
  manifestVersion,
@@ -2398,7 +2474,8 @@ async function resolveConfig(inlineConfig, command) {
2398
2474
  },
2399
2475
  hooks: mergedConfig.hooks ?? {},
2400
2476
  vite: mergedConfig.vite ?? (() => ({})),
2401
- modules,
2477
+ builtinModules,
2478
+ userModules,
2402
2479
  plugins: [],
2403
2480
  ...moduleOptions
2404
2481
  };
@@ -2428,7 +2505,7 @@ async function mergeInlineConfig(inlineConfig, userConfig) {
2428
2505
  };
2429
2506
  }
2430
2507
  function resolveZipConfig(root, mergedConfig) {
2431
- const downloadedPackagesDir = import_node_path14.default.resolve(root, ".wxt/local_modules");
2508
+ const downloadedPackagesDir = import_node_path17.default.resolve(root, ".wxt/local_modules");
2432
2509
  return {
2433
2510
  name: void 0,
2434
2511
  sourcesTemplate: "{{name}}-{{version}}-sources.zip",
@@ -2454,12 +2531,12 @@ function resolveZipConfig(root, mergedConfig) {
2454
2531
  };
2455
2532
  }
2456
2533
  function resolveAnalysisConfig(root, mergedConfig) {
2457
- const analysisOutputFile = import_node_path14.default.resolve(
2534
+ const analysisOutputFile = import_node_path17.default.resolve(
2458
2535
  root,
2459
2536
  mergedConfig.analysis?.outputFile ?? "stats.html"
2460
2537
  );
2461
- const analysisOutputDir = import_node_path14.default.dirname(analysisOutputFile);
2462
- const analysisOutputName = import_node_path14.default.parse(analysisOutputFile).name;
2538
+ const analysisOutputDir = import_node_path17.default.dirname(analysisOutputFile);
2539
+ const analysisOutputName = import_node_path17.default.parse(analysisOutputFile).name;
2463
2540
  return {
2464
2541
  enabled: mergedConfig.analysis?.enabled ?? false,
2465
2542
  open: mergedConfig.analysis?.open ?? false,
@@ -2470,17 +2547,17 @@ function resolveAnalysisConfig(root, mergedConfig) {
2470
2547
  keepArtifacts: mergedConfig.analysis?.keepArtifacts ?? false
2471
2548
  };
2472
2549
  }
2473
- async function getUnimportOptions(wxtDir, logger, config) {
2550
+ async function getUnimportOptions(wxtDir, srcDir, logger, config) {
2474
2551
  if (config.imports === false) return false;
2475
- const enabledConfig = config.imports?.eslintrc?.enabled;
2476
- let enabled;
2477
- switch (enabledConfig) {
2552
+ const rawEslintEnabled = config.imports?.eslintrc?.enabled;
2553
+ let eslintEnabled;
2554
+ switch (rawEslintEnabled) {
2478
2555
  case void 0:
2479
2556
  case "auto":
2480
- enabled = await isModuleInstalled("eslint");
2557
+ eslintEnabled = await isModuleInstalled("eslint");
2481
2558
  break;
2482
2559
  default:
2483
- enabled = enabledConfig;
2560
+ eslintEnabled = rawEslintEnabled;
2484
2561
  }
2485
2562
  const defaultOptions = {
2486
2563
  debugLog: logger.debug,
@@ -2496,9 +2573,12 @@ async function getUnimportOptions(wxtDir, logger, config) {
2496
2573
  ],
2497
2574
  warn: logger.warn,
2498
2575
  dirs: ["components", "composables", "hooks", "utils"],
2576
+ dirsScanOptions: {
2577
+ cwd: srcDir
2578
+ },
2499
2579
  eslintrc: {
2500
- enabled,
2501
- filePath: import_node_path14.default.resolve(wxtDir, "eslintrc-auto-import.json"),
2580
+ enabled: eslintEnabled,
2581
+ filePath: import_node_path17.default.resolve(wxtDir, "eslintrc-auto-import.json"),
2502
2582
  globalsPropValue: true
2503
2583
  }
2504
2584
  };
@@ -2509,7 +2589,7 @@ async function getUnimportOptions(wxtDir, logger, config) {
2509
2589
  }
2510
2590
  async function resolveWxtModuleDir() {
2511
2591
  const requireResolve = require?.resolve ?? (await import("module")).default.createRequire(import_meta.url).resolve;
2512
- return import_node_path14.default.resolve(requireResolve("wxt"), "../..");
2592
+ return import_node_path17.default.resolve(requireResolve("wxt"), "../..");
2513
2593
  }
2514
2594
  async function isDirMissing(dir) {
2515
2595
  return !await import_fs_extra10.default.exists(dir);
@@ -2517,7 +2597,7 @@ async function isDirMissing(dir) {
2517
2597
  function logMissingDir(logger, name, expected) {
2518
2598
  logger.warn(
2519
2599
  `${name} directory not found: ./${normalizePath(
2520
- import_node_path14.default.relative(process.cwd(), expected)
2600
+ import_node_path17.default.relative(process.cwd(), expected)
2521
2601
  )}`
2522
2602
  );
2523
2603
  }
@@ -2526,19 +2606,19 @@ var COMMAND_MODES = {
2526
2606
  serve: "development"
2527
2607
  };
2528
2608
  async function mergeBuilderConfig(inlineConfig, userConfig) {
2529
- const vite = await import("vite").catch(() => void 0);
2530
- if (vite) {
2609
+ const vite2 = await import("vite").catch(() => void 0);
2610
+ if (vite2) {
2531
2611
  return {
2532
2612
  vite: async (env2) => {
2533
2613
  const resolvedInlineConfig = await inlineConfig.vite?.(env2) ?? {};
2534
2614
  const resolvedUserConfig = await userConfig.vite?.(env2) ?? {};
2535
- return vite.mergeConfig(resolvedUserConfig, resolvedInlineConfig);
2615
+ return vite2.mergeConfig(resolvedUserConfig, resolvedInlineConfig);
2536
2616
  }
2537
2617
  };
2538
2618
  }
2539
2619
  throw Error("Builder not found. Make sure vite is installed.");
2540
2620
  }
2541
- async function resolveWxtModules(modulesDir, modules = []) {
2621
+ async function resolveWxtUserModules(modulesDir, modules = []) {
2542
2622
  const npmModules = await Promise.all(
2543
2623
  modules.map(async (moduleId) => {
2544
2624
  const mod = await import(
@@ -2555,13 +2635,13 @@ async function resolveWxtModules(modulesDir, modules = []) {
2555
2635
  };
2556
2636
  })
2557
2637
  );
2558
- const localModulePaths = await (0, import_fast_glob3.default)(["*.[tj]s", "*/index.[tj]s"], {
2638
+ const localModulePaths = await (0, import_fast_glob4.default)(["*.[tj]s", "*/index.[tj]s"], {
2559
2639
  cwd: modulesDir,
2560
2640
  onlyFiles: true
2561
2641
  }).catch(() => []);
2562
2642
  const localModules = await Promise.all(
2563
2643
  localModulePaths.map(async (file) => {
2564
- const absolutePath = normalizePath(import_node_path14.default.resolve(modulesDir, file));
2644
+ const absolutePath = normalizePath(import_node_path17.default.resolve(modulesDir, file));
2565
2645
  const { config } = await (0, import_c12.loadConfig)({
2566
2646
  configFile: absolutePath,
2567
2647
  globalRc: false,
@@ -2589,7 +2669,7 @@ async function resolveWxtModules(modulesDir, modules = []) {
2589
2669
  var import_jiti = __toESM(require("jiti"), 1);
2590
2670
  var import_unimport3 = require("unimport");
2591
2671
  var import_fs_extra11 = __toESM(require("fs-extra"), 1);
2592
- var import_node_path15 = require("path");
2672
+ var import_node_path18 = require("path");
2593
2673
  var import_esbuild = require("esbuild");
2594
2674
  var import_node_url = require("url");
2595
2675
 
@@ -2598,7 +2678,7 @@ var import_picocolors5 = __toESM(require("picocolors"), 1);
2598
2678
  var import_fs_extra14 = __toESM(require("fs-extra"), 1);
2599
2679
 
2600
2680
  // src/core/utils/log/printFileList.ts
2601
- var import_node_path16 = __toESM(require("path"), 1);
2681
+ var import_node_path19 = __toESM(require("path"), 1);
2602
2682
  var import_picocolors3 = __toESM(require("picocolors"), 1);
2603
2683
  var import_fs_extra12 = __toESM(require("fs-extra"), 1);
2604
2684
  var import_filesize = require("filesize");
@@ -2619,26 +2699,34 @@ var CHUNK_COLORS = {
2619
2699
  var import_picocolors4 = __toESM(require("picocolors"), 1);
2620
2700
 
2621
2701
  // src/core/utils/building/internal-build.ts
2622
- var import_fast_glob4 = __toESM(require("fast-glob"), 1);
2702
+ var import_fast_glob5 = __toESM(require("fast-glob"), 1);
2623
2703
 
2624
2704
  // src/core/utils/manifest.ts
2625
2705
  var import_fs_extra13 = __toESM(require("fs-extra"), 1);
2626
2706
  var import_defu2 = __toESM(require("defu"), 1);
2627
2707
 
2628
2708
  // src/core/utils/building/internal-build.ts
2629
- var import_node_path17 = require("path");
2709
+ var import_node_path20 = require("path");
2630
2710
  var import_rollup_plugin_visualizer2 = require("@aklinker1/rollup-plugin-visualizer");
2631
2711
  var import_ci_info = require("ci-info");
2632
2712
 
2633
2713
  // src/testing/wxt-vitest-plugin.ts
2714
+ var import_unimport5 = require("unimport");
2634
2715
  function WxtVitest(inlineConfig) {
2635
- return resolveConfig(inlineConfig ?? {}, "serve").then((config) => [
2636
- webextensionPolyfillMock(config),
2637
- unimport(config),
2638
- globals(config),
2639
- download(config),
2640
- tsconfigPaths(config)
2641
- ]);
2716
+ return resolveConfig(inlineConfig ?? {}, "serve").then(async (config) => {
2717
+ const plugins = [
2718
+ webextensionPolyfillMock(config),
2719
+ globals(config),
2720
+ download(config),
2721
+ tsconfigPaths(config)
2722
+ ];
2723
+ if (config.imports !== false) {
2724
+ const unimport = (0, import_unimport5.createUnimport)(config.imports);
2725
+ await unimport.init();
2726
+ plugins.push(vitePlugin(unimport));
2727
+ }
2728
+ return plugins;
2729
+ });
2642
2730
  }
2643
2731
  // Annotate the CommonJS export names for ESM import in node:
2644
2732
  0 && (module.exports = {