wxt 0.18.5 → 0.18.6

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.
@@ -12,7 +12,7 @@ import {
12
12
  } from "./chunk-VBXJIVYU.js";
13
13
 
14
14
  // package.json
15
- var version = "0.18.5";
15
+ var version = "0.18.6";
16
16
 
17
17
  // src/core/utils/paths.ts
18
18
  import systemPath from "node:path";
@@ -1576,7 +1576,14 @@ async function writeMainDeclarationFile(references) {
1576
1576
  `/// <reference types="wxt/vite-builder-env" />`,
1577
1577
  ...references.map(
1578
1578
  (ref) => `/// <reference types="./${normalizePath(relative5(dir, ref))}" />`
1579
- )
1579
+ ),
1580
+ // Add references to modules installed from NPM to the TS project so
1581
+ // their type augmentation can update InlineConfig correctly. Local
1582
+ // modules defined in <root>/modules are already apart of the project, so
1583
+ // we don't need to add them.
1584
+ ...wxt.config.modules.filter(
1585
+ (module) => module.type === "node_module" && module.configKey != null
1586
+ ).map((module) => `/// <reference types="${module.id}" />`)
1580
1587
  ].join("\n") + "\n"
1581
1588
  );
1582
1589
  return filePath;
@@ -1944,7 +1951,11 @@ async function resolveWxtModules(modulesDir, modules = []) {
1944
1951
  if (mod.default == null) {
1945
1952
  throw Error("Module missing default export: " + moduleId);
1946
1953
  }
1947
- return mod.default;
1954
+ return {
1955
+ ...mod.default,
1956
+ type: "node_module",
1957
+ id: moduleId
1958
+ };
1948
1959
  })
1949
1960
  );
1950
1961
  const localModulePaths = await glob3(["*.[tj]s", "*/index.[tj]s"], {
@@ -1953,8 +1964,9 @@ async function resolveWxtModules(modulesDir, modules = []) {
1953
1964
  }).catch(() => []);
1954
1965
  const localModules = await Promise.all(
1955
1966
  localModulePaths.map(async (file) => {
1967
+ const absolutePath = normalizePath(path5.resolve(modulesDir, file));
1956
1968
  const { config } = await loadConfig({
1957
- configFile: path5.resolve(modulesDir, file),
1969
+ configFile: absolutePath,
1958
1970
  globalRc: false,
1959
1971
  rcFile: false,
1960
1972
  packageJson: false,
@@ -1966,7 +1978,11 @@ async function resolveWxtModules(modulesDir, modules = []) {
1966
1978
  `No config found for ${file}. Did you forget to add a default export?`
1967
1979
  );
1968
1980
  config.name ??= file;
1969
- return config;
1981
+ return {
1982
+ ...config,
1983
+ type: "local",
1984
+ id: absolutePath
1985
+ };
1970
1986
  })
1971
1987
  );
1972
1988
  return [...npmModules, ...localModules];
package/dist/cli.js CHANGED
@@ -2089,7 +2089,14 @@ async function writeMainDeclarationFile(references) {
2089
2089
  `/// <reference types="wxt/vite-builder-env" />`,
2090
2090
  ...references.map(
2091
2091
  (ref) => `/// <reference types="./${normalizePath(relative5(dir, ref))}" />`
2092
- )
2092
+ ),
2093
+ // Add references to modules installed from NPM to the TS project so
2094
+ // their type augmentation can update InlineConfig correctly. Local
2095
+ // modules defined in <root>/modules are already apart of the project, so
2096
+ // we don't need to add them.
2097
+ ...wxt.config.modules.filter(
2098
+ (module) => module.type === "node_module" && module.configKey != null
2099
+ ).map((module) => `/// <reference types="${module.id}" />`)
2093
2100
  ].join("\n") + "\n"
2094
2101
  );
2095
2102
  return filePath;
@@ -2457,7 +2464,11 @@ async function resolveWxtModules(modulesDir, modules = []) {
2457
2464
  if (mod.default == null) {
2458
2465
  throw Error("Module missing default export: " + moduleId);
2459
2466
  }
2460
- return mod.default;
2467
+ return {
2468
+ ...mod.default,
2469
+ type: "node_module",
2470
+ id: moduleId
2471
+ };
2461
2472
  })
2462
2473
  );
2463
2474
  const localModulePaths = await glob3(["*.[tj]s", "*/index.[tj]s"], {
@@ -2466,8 +2477,9 @@ async function resolveWxtModules(modulesDir, modules = []) {
2466
2477
  }).catch(() => []);
2467
2478
  const localModules = await Promise.all(
2468
2479
  localModulePaths.map(async (file) => {
2480
+ const absolutePath = normalizePath(path6.resolve(modulesDir, file));
2469
2481
  const { config } = await loadConfig({
2470
- configFile: path6.resolve(modulesDir, file),
2482
+ configFile: absolutePath,
2471
2483
  globalRc: false,
2472
2484
  rcFile: false,
2473
2485
  packageJson: false,
@@ -2479,7 +2491,11 @@ async function resolveWxtModules(modulesDir, modules = []) {
2479
2491
  `No config found for ${file}. Did you forget to add a default export?`
2480
2492
  );
2481
2493
  config.name ??= file;
2482
- return config;
2494
+ return {
2495
+ ...config,
2496
+ type: "local",
2497
+ id: absolutePath
2498
+ };
2483
2499
  })
2484
2500
  );
2485
2501
  return [...npmModules, ...localModules];
@@ -2639,7 +2655,7 @@ function getChunkSortWeight(filename) {
2639
2655
  import pc4 from "picocolors";
2640
2656
 
2641
2657
  // package.json
2642
- var version = "0.18.5";
2658
+ var version = "0.18.6";
2643
2659
 
2644
2660
  // src/core/utils/log/printHeader.ts
2645
2661
  function printHeader() {
@@ -1190,7 +1190,7 @@ interface ResolvedConfig {
1190
1190
  reloadCommand: string | false;
1191
1191
  };
1192
1192
  hooks: NestedHooks<WxtHooks>;
1193
- modules: WxtModule<any>[];
1193
+ modules: WxtModuleWithMetadata<any>[];
1194
1194
  /**
1195
1195
  * An array of string to import plugins from. These paths should be
1196
1196
  * resolvable by vite, and they should `export default defineWxtPlugin(...)`.
@@ -1287,7 +1287,7 @@ interface Dependency {
1287
1287
  version: string;
1288
1288
  }
1289
1289
  type WxtModuleOptions = Record<string, any>;
1290
- type WxtModuleSetup<TOptions extends WxtModuleOptions> = (wxt: Wxt, moduleOptions: TOptions) => void | Promise<void>;
1290
+ type WxtModuleSetup<TOptions extends WxtModuleOptions> = (wxt: Wxt, moduleOptions?: TOptions) => void | Promise<void>;
1291
1291
  interface WxtModule<TOptions extends WxtModuleOptions> {
1292
1292
  name?: string;
1293
1293
  /**
@@ -1309,6 +1309,10 @@ interface WxtModule<TOptions extends WxtModuleOptions> {
1309
1309
  */
1310
1310
  setup?: WxtModuleSetup<TOptions>;
1311
1311
  }
1312
+ interface WxtModuleWithMetadata<TOptions extends WxtModuleOptions> extends WxtModule<TOptions> {
1313
+ type: 'local' | 'node_module';
1314
+ id: string;
1315
+ }
1312
1316
  interface ResolvedPublicFile {
1313
1317
  /**
1314
1318
  * The absolute path to the file that will be copied to the output directory.
@@ -1325,4 +1329,4 @@ interface ResolvedPublicFile {
1325
1329
  }
1326
1330
  type WxtPlugin = () => void;
1327
1331
 
1328
- export type { EslintGlobalsPropValue as $, PerBrowserMap as A, BuildOutput as B, ContentScriptEntrypoint as C, ResolvedPerBrowserOptions as D, ExtensionRunnerConfig as E, UserManifest as F, GenericEntrypoint as G, UserManifestFn as H, InlineConfig as I, ConfigEnv as J, WxtCommand as K, Logger as L, MainWorldContentScriptEntrypointOptions as M, WxtBuilder as N, OutputFile as O, PopupEntrypointOptions as P, WxtBuilderServer as Q, ResolvedConfig as R, SidepanelEntrypointOptions as S, TargetBrowser as T, UserConfig as U, ServerInfo as V, WxtDevServer as W, HookResult as X, Wxt as Y, FsCache as Z, ExtensionRunner as _, WxtViteConfig as a, Eslintrc as a0, ResolvedEslintrc as a1, WxtUnimportOptions as a2, WxtResolvedUnimportOptions as a3, WxtPackageManager as a4, Dependency as a5, WxtModuleOptions as a6, WxtModuleSetup as a7, WxtModule as a8, ResolvedPublicFile as a9, WxtPlugin as aa, WxtHooks as b, OutputChunk as c, OutputAsset as d, BuildStepOutput as e, ReloadContentScriptPayload as f, TargetManifestVersion as g, BaseEntrypointOptions as h, BackgroundEntrypointOptions as i, BaseContentScriptEntrypointOptions as j, IsolatedWorldContentScriptEntrypointOptions as k, OptionsEntrypointOptions as l, BaseEntrypoint as m, BackgroundEntrypoint as n, PopupEntrypoint as o, OptionsEntrypoint as p, SidepanelEntrypoint as q, Entrypoint as r, EntrypointGroup as s, OnContentScriptStopped as t, IsolatedWorldContentScriptDefinition as u, MainWorldContentScriptDefinition as v, ContentScriptDefinition as w, BackgroundDefinition as x, UnlistedScriptDefinition as y, PerBrowserOption as z };
1332
+ export type { EslintGlobalsPropValue as $, PerBrowserMap as A, BuildOutput as B, ContentScriptEntrypoint as C, ResolvedPerBrowserOptions as D, ExtensionRunnerConfig as E, UserManifest as F, GenericEntrypoint as G, UserManifestFn as H, InlineConfig as I, ConfigEnv as J, WxtCommand as K, Logger as L, MainWorldContentScriptEntrypointOptions as M, WxtBuilder as N, OutputFile as O, PopupEntrypointOptions as P, WxtBuilderServer as Q, ResolvedConfig as R, SidepanelEntrypointOptions as S, TargetBrowser as T, UserConfig as U, ServerInfo as V, WxtDevServer as W, HookResult as X, Wxt as Y, FsCache as Z, ExtensionRunner as _, WxtViteConfig as a, Eslintrc as a0, ResolvedEslintrc as a1, WxtUnimportOptions as a2, WxtResolvedUnimportOptions as a3, WxtPackageManager as a4, Dependency as a5, WxtModuleOptions as a6, WxtModuleSetup as a7, WxtModule as a8, WxtModuleWithMetadata as a9, ResolvedPublicFile as aa, WxtPlugin as ab, WxtHooks as b, OutputChunk as c, OutputAsset as d, BuildStepOutput as e, ReloadContentScriptPayload as f, TargetManifestVersion as g, BaseEntrypointOptions as h, BackgroundEntrypointOptions as i, BaseContentScriptEntrypointOptions as j, IsolatedWorldContentScriptEntrypointOptions as k, OptionsEntrypointOptions as l, BaseEntrypoint as m, BackgroundEntrypoint as n, PopupEntrypoint as o, OptionsEntrypoint as p, SidepanelEntrypoint as q, Entrypoint as r, EntrypointGroup as s, OnContentScriptStopped as t, IsolatedWorldContentScriptDefinition as u, MainWorldContentScriptDefinition as v, ContentScriptDefinition as w, BackgroundDefinition as x, UnlistedScriptDefinition as y, PerBrowserOption as z };
@@ -1190,7 +1190,7 @@ interface ResolvedConfig {
1190
1190
  reloadCommand: string | false;
1191
1191
  };
1192
1192
  hooks: NestedHooks<WxtHooks>;
1193
- modules: WxtModule<any>[];
1193
+ modules: WxtModuleWithMetadata<any>[];
1194
1194
  /**
1195
1195
  * An array of string to import plugins from. These paths should be
1196
1196
  * resolvable by vite, and they should `export default defineWxtPlugin(...)`.
@@ -1287,7 +1287,7 @@ interface Dependency {
1287
1287
  version: string;
1288
1288
  }
1289
1289
  type WxtModuleOptions = Record<string, any>;
1290
- type WxtModuleSetup<TOptions extends WxtModuleOptions> = (wxt: Wxt, moduleOptions: TOptions) => void | Promise<void>;
1290
+ type WxtModuleSetup<TOptions extends WxtModuleOptions> = (wxt: Wxt, moduleOptions?: TOptions) => void | Promise<void>;
1291
1291
  interface WxtModule<TOptions extends WxtModuleOptions> {
1292
1292
  name?: string;
1293
1293
  /**
@@ -1309,6 +1309,10 @@ interface WxtModule<TOptions extends WxtModuleOptions> {
1309
1309
  */
1310
1310
  setup?: WxtModuleSetup<TOptions>;
1311
1311
  }
1312
+ interface WxtModuleWithMetadata<TOptions extends WxtModuleOptions> extends WxtModule<TOptions> {
1313
+ type: 'local' | 'node_module';
1314
+ id: string;
1315
+ }
1312
1316
  interface ResolvedPublicFile {
1313
1317
  /**
1314
1318
  * The absolute path to the file that will be copied to the output directory.
@@ -1325,4 +1329,4 @@ interface ResolvedPublicFile {
1325
1329
  }
1326
1330
  type WxtPlugin = () => void;
1327
1331
 
1328
- export type { EslintGlobalsPropValue as $, PerBrowserMap as A, BuildOutput as B, ContentScriptEntrypoint as C, ResolvedPerBrowserOptions as D, ExtensionRunnerConfig as E, UserManifest as F, GenericEntrypoint as G, UserManifestFn as H, InlineConfig as I, ConfigEnv as J, WxtCommand as K, Logger as L, MainWorldContentScriptEntrypointOptions as M, WxtBuilder as N, OutputFile as O, PopupEntrypointOptions as P, WxtBuilderServer as Q, ResolvedConfig as R, SidepanelEntrypointOptions as S, TargetBrowser as T, UserConfig as U, ServerInfo as V, WxtDevServer as W, HookResult as X, Wxt as Y, FsCache as Z, ExtensionRunner as _, WxtViteConfig as a, Eslintrc as a0, ResolvedEslintrc as a1, WxtUnimportOptions as a2, WxtResolvedUnimportOptions as a3, WxtPackageManager as a4, Dependency as a5, WxtModuleOptions as a6, WxtModuleSetup as a7, WxtModule as a8, ResolvedPublicFile as a9, WxtPlugin as aa, WxtHooks as b, OutputChunk as c, OutputAsset as d, BuildStepOutput as e, ReloadContentScriptPayload as f, TargetManifestVersion as g, BaseEntrypointOptions as h, BackgroundEntrypointOptions as i, BaseContentScriptEntrypointOptions as j, IsolatedWorldContentScriptEntrypointOptions as k, OptionsEntrypointOptions as l, BaseEntrypoint as m, BackgroundEntrypoint as n, PopupEntrypoint as o, OptionsEntrypoint as p, SidepanelEntrypoint as q, Entrypoint as r, EntrypointGroup as s, OnContentScriptStopped as t, IsolatedWorldContentScriptDefinition as u, MainWorldContentScriptDefinition as v, ContentScriptDefinition as w, BackgroundDefinition as x, UnlistedScriptDefinition as y, PerBrowserOption as z };
1332
+ export type { EslintGlobalsPropValue as $, PerBrowserMap as A, BuildOutput as B, ContentScriptEntrypoint as C, ResolvedPerBrowserOptions as D, ExtensionRunnerConfig as E, UserManifest as F, GenericEntrypoint as G, UserManifestFn as H, InlineConfig as I, ConfigEnv as J, WxtCommand as K, Logger as L, MainWorldContentScriptEntrypointOptions as M, WxtBuilder as N, OutputFile as O, PopupEntrypointOptions as P, WxtBuilderServer as Q, ResolvedConfig as R, SidepanelEntrypointOptions as S, TargetBrowser as T, UserConfig as U, ServerInfo as V, WxtDevServer as W, HookResult as X, Wxt as Y, FsCache as Z, ExtensionRunner as _, WxtViteConfig as a, Eslintrc as a0, ResolvedEslintrc as a1, WxtUnimportOptions as a2, WxtResolvedUnimportOptions as a3, WxtPackageManager as a4, Dependency as a5, WxtModuleOptions as a6, WxtModuleSetup as a7, WxtModule as a8, WxtModuleWithMetadata as a9, ResolvedPublicFile as aa, WxtPlugin as ab, WxtHooks as b, OutputChunk as c, OutputAsset as d, BuildStepOutput as e, ReloadContentScriptPayload as f, TargetManifestVersion as g, BaseEntrypointOptions as h, BackgroundEntrypointOptions as i, BaseContentScriptEntrypointOptions as j, IsolatedWorldContentScriptEntrypointOptions as k, OptionsEntrypointOptions as l, BaseEntrypoint as m, BackgroundEntrypoint as n, PopupEntrypoint as o, OptionsEntrypoint as p, SidepanelEntrypoint as q, Entrypoint as r, EntrypointGroup as s, OnContentScriptStopped as t, IsolatedWorldContentScriptDefinition as u, MainWorldContentScriptDefinition as v, ContentScriptDefinition as w, BackgroundDefinition as x, UnlistedScriptDefinition as y, PerBrowserOption as z };
package/dist/index.cjs CHANGED
@@ -11068,7 +11068,14 @@ async function writeMainDeclarationFile(references) {
11068
11068
  `/// <reference types="wxt/vite-builder-env" />`,
11069
11069
  ...references.map(
11070
11070
  (ref) => `/// <reference types="./${normalizePath((0, import_path5.relative)(dir, ref))}" />`
11071
- )
11071
+ ),
11072
+ // Add references to modules installed from NPM to the TS project so
11073
+ // their type augmentation can update InlineConfig correctly. Local
11074
+ // modules defined in <root>/modules are already apart of the project, so
11075
+ // we don't need to add them.
11076
+ ...wxt.config.modules.filter(
11077
+ (module2) => module2.type === "node_module" && module2.configKey != null
11078
+ ).map((module2) => `/// <reference types="${module2.id}" />`)
11072
11079
  ].join("\n") + "\n"
11073
11080
  );
11074
11081
  return filePath;
@@ -11447,7 +11454,11 @@ async function resolveWxtModules(modulesDir, modules = []) {
11447
11454
  if (mod.default == null) {
11448
11455
  throw Error("Module missing default export: " + moduleId);
11449
11456
  }
11450
- return mod.default;
11457
+ return {
11458
+ ...mod.default,
11459
+ type: "node_module",
11460
+ id: moduleId
11461
+ };
11451
11462
  })
11452
11463
  );
11453
11464
  const localModulePaths = await (0, import_fast_glob3.default)(["*.[tj]s", "*/index.[tj]s"], {
@@ -11456,8 +11467,9 @@ async function resolveWxtModules(modulesDir, modules = []) {
11456
11467
  }).catch(() => []);
11457
11468
  const localModules = await Promise.all(
11458
11469
  localModulePaths.map(async (file) => {
11470
+ const absolutePath = normalizePath(import_node_path19.default.resolve(modulesDir, file));
11459
11471
  const { config } = await (0, import_c12.loadConfig)({
11460
- configFile: import_node_path19.default.resolve(modulesDir, file),
11472
+ configFile: absolutePath,
11461
11473
  globalRc: false,
11462
11474
  rcFile: false,
11463
11475
  packageJson: false,
@@ -11469,7 +11481,11 @@ async function resolveWxtModules(modulesDir, modules = []) {
11469
11481
  `No config found for ${file}. Did you forget to add a default export?`
11470
11482
  );
11471
11483
  config.name ??= file;
11472
- return config;
11484
+ return {
11485
+ ...config,
11486
+ type: "local",
11487
+ id: absolutePath
11488
+ };
11473
11489
  })
11474
11490
  );
11475
11491
  return [...npmModules, ...localModules];
@@ -11629,7 +11645,7 @@ function getChunkSortWeight(filename) {
11629
11645
  var import_picocolors4 = __toESM(require("picocolors"), 1);
11630
11646
 
11631
11647
  // package.json
11632
- var version = "0.18.5";
11648
+ var version = "0.18.6";
11633
11649
 
11634
11650
  // src/core/utils/building/internal-build.ts
11635
11651
  var import_fast_glob4 = __toESM(require("fast-glob"), 1);
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-q2ZwJBs6.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, a9 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, a4 as WxtPackageManager, aa as WxtPlugin, a3 as WxtResolvedUnimportOptions, a2 as WxtUnimportOptions, a as WxtViteConfig } from './index-q2ZwJBs6.cjs';
1
+ import { I as InlineConfig, B as BuildOutput, U as UserConfig, E as ExtensionRunnerConfig, W as WxtDevServer } from './index-D6lH9OkP.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-D6lH9OkP.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.5";
68
+ var version = "0.18.6";
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-q2ZwJBs6.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, a9 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, a4 as WxtPackageManager, aa as WxtPlugin, a3 as WxtResolvedUnimportOptions, a2 as WxtUnimportOptions, a as WxtViteConfig } from './index-q2ZwJBs6.js';
1
+ import { I as InlineConfig, B as BuildOutput, U as UserConfig, E as ExtensionRunnerConfig, W as WxtDevServer } from './index-D6lH9OkP.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-D6lH9OkP.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.5";
68
+ var version = "0.18.6";
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,7 +19,7 @@ import {
19
19
  unnormalizePath,
20
20
  version,
21
21
  wxt
22
- } from "./chunk-7AOGIMIM.js";
22
+ } from "./chunk-QOYT5J6A.js";
23
23
  import "./chunk-5X3S6AWF.js";
24
24
  import {
25
25
  consola
package/dist/modules.cjs CHANGED
@@ -31,6 +31,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
31
31
  var modules_exports = {};
32
32
  __export(modules_exports, {
33
33
  addEntrypoint: () => addEntrypoint,
34
+ addImportPreset: () => addImportPreset,
34
35
  addPublicAssets: () => addPublicAssets,
35
36
  addViteConfig: () => addViteConfig,
36
37
  addWxtPlugin: () => addWxtPlugin,
@@ -78,9 +79,20 @@ function addWxtPlugin(wxt, plugin) {
78
79
  wxt2.config.plugins.push(plugin);
79
80
  });
80
81
  }
82
+ function addImportPreset(wxt, preset) {
83
+ wxt.hooks.hook("ready", (wxt2) => {
84
+ if (!wxt2.config.imports)
85
+ return;
86
+ wxt2.config.imports.presets ??= [];
87
+ if (wxt2.config.imports.presets.includes(preset))
88
+ return;
89
+ wxt2.config.imports.presets.push(preset);
90
+ });
91
+ }
81
92
  // Annotate the CommonJS export names for ESM import in node:
82
93
  0 && (module.exports = {
83
94
  addEntrypoint,
95
+ addImportPreset,
84
96
  addPublicAssets,
85
97
  addViteConfig,
86
98
  addWxtPlugin,
@@ -1,7 +1,7 @@
1
- import { a6 as WxtModuleOptions, a8 as WxtModule, a7 as WxtModuleSetup, Y as Wxt, r as Entrypoint } from './index-q2ZwJBs6.cjs';
1
+ import { a6 as WxtModuleOptions, a8 as WxtModule, a7 as WxtModuleSetup, Y as Wxt, r as Entrypoint } from './index-D6lH9OkP.cjs';
2
2
  import * as vite from 'vite';
3
+ import { UnimportOptions } from 'unimport';
3
4
  import 'webextension-polyfill';
4
- import 'unimport';
5
5
  import 'consola';
6
6
  import '@aklinker1/rollup-plugin-visualizer';
7
7
  import 'chokidar';
@@ -87,5 +87,33 @@ declare function addViteConfig(wxt: Wxt, viteConfig: (env: vite.ConfigEnv) => vi
87
87
  * });
88
88
  */
89
89
  declare function addWxtPlugin(wxt: Wxt, plugin: string): void;
90
+ /**
91
+ * Add an Unimport preset ([built-in](https://github.com/unjs/unimport?tab=readme-ov-file#built-in-presets),
92
+ * [custom](https://github.com/unjs/unimport?tab=readme-ov-file#custom-presets),
93
+ * or [auto-scanned](https://github.com/unjs/unimport?tab=readme-ov-file#exports-auto-scan)),
94
+ * to the project's list of auto-imported utilities.
95
+ *
96
+ * Some things to note:
97
+ * - This function will only de-duplicate built-in preset names. It will not
98
+ * stop you adding duplicate custom or auto-scanned presets.
99
+ * - If the project has disabled imports, this function has no effect.
100
+ *
101
+ * @param wxt The wxt instance provided by the module's setup function.
102
+ * @param preset The preset to add to the project.
103
+ *
104
+ * @example
105
+ * export default defineWxtModule((wxt) => {
106
+ * // Built-in preset:
107
+ * addImportPreset(wxt, "vue");
108
+ * // Custom preset:
109
+ * addImportPreset(wxt, {
110
+ * from: "vue",
111
+ * imports: ["ref", "reactive", ...],
112
+ * });
113
+ * // Auto-scanned preset:
114
+ * addImportPreset(wxt, { package: "vue" });
115
+ * });
116
+ */
117
+ declare function addImportPreset(wxt: Wxt, preset: UnimportOptions['presets'][0]): void;
90
118
 
91
- export { addEntrypoint, addPublicAssets, addViteConfig, addWxtPlugin, defineWxtModule };
119
+ export { WxtModule, addEntrypoint, addImportPreset, addPublicAssets, addViteConfig, addWxtPlugin, defineWxtModule };
package/dist/modules.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { a6 as WxtModuleOptions, a8 as WxtModule, a7 as WxtModuleSetup, Y as Wxt, r as Entrypoint } from './index-q2ZwJBs6.js';
1
+ import { a6 as WxtModuleOptions, a8 as WxtModule, a7 as WxtModuleSetup, Y as Wxt, r as Entrypoint } from './index-D6lH9OkP.js';
2
2
  import * as vite from 'vite';
3
+ import { UnimportOptions } from 'unimport';
3
4
  import 'webextension-polyfill';
4
- import 'unimport';
5
5
  import 'consola';
6
6
  import '@aklinker1/rollup-plugin-visualizer';
7
7
  import 'chokidar';
@@ -87,5 +87,33 @@ declare function addViteConfig(wxt: Wxt, viteConfig: (env: vite.ConfigEnv) => vi
87
87
  * });
88
88
  */
89
89
  declare function addWxtPlugin(wxt: Wxt, plugin: string): void;
90
+ /**
91
+ * Add an Unimport preset ([built-in](https://github.com/unjs/unimport?tab=readme-ov-file#built-in-presets),
92
+ * [custom](https://github.com/unjs/unimport?tab=readme-ov-file#custom-presets),
93
+ * or [auto-scanned](https://github.com/unjs/unimport?tab=readme-ov-file#exports-auto-scan)),
94
+ * to the project's list of auto-imported utilities.
95
+ *
96
+ * Some things to note:
97
+ * - This function will only de-duplicate built-in preset names. It will not
98
+ * stop you adding duplicate custom or auto-scanned presets.
99
+ * - If the project has disabled imports, this function has no effect.
100
+ *
101
+ * @param wxt The wxt instance provided by the module's setup function.
102
+ * @param preset The preset to add to the project.
103
+ *
104
+ * @example
105
+ * export default defineWxtModule((wxt) => {
106
+ * // Built-in preset:
107
+ * addImportPreset(wxt, "vue");
108
+ * // Custom preset:
109
+ * addImportPreset(wxt, {
110
+ * from: "vue",
111
+ * imports: ["ref", "reactive", ...],
112
+ * });
113
+ * // Auto-scanned preset:
114
+ * addImportPreset(wxt, { package: "vue" });
115
+ * });
116
+ */
117
+ declare function addImportPreset(wxt: Wxt, preset: UnimportOptions['presets'][0]): void;
90
118
 
91
- export { addEntrypoint, addPublicAssets, addViteConfig, addWxtPlugin, defineWxtModule };
119
+ export { WxtModule, addEntrypoint, addImportPreset, addPublicAssets, addViteConfig, addWxtPlugin, defineWxtModule };
package/dist/modules.js CHANGED
@@ -42,8 +42,19 @@ function addWxtPlugin(wxt, plugin) {
42
42
  wxt2.config.plugins.push(plugin);
43
43
  });
44
44
  }
45
+ function addImportPreset(wxt, preset) {
46
+ wxt.hooks.hook("ready", (wxt2) => {
47
+ if (!wxt2.config.imports)
48
+ return;
49
+ wxt2.config.imports.presets ??= [];
50
+ if (wxt2.config.imports.presets.includes(preset))
51
+ return;
52
+ wxt2.config.imports.presets.push(preset);
53
+ });
54
+ }
45
55
  export {
46
56
  addEntrypoint,
57
+ addImportPreset,
47
58
  addPublicAssets,
48
59
  addViteConfig,
49
60
  addWxtPlugin,
package/dist/testing.cjs CHANGED
@@ -2587,7 +2587,11 @@ async function resolveWxtModules(modulesDir, modules = []) {
2587
2587
  if (mod.default == null) {
2588
2588
  throw Error("Module missing default export: " + moduleId);
2589
2589
  }
2590
- return mod.default;
2590
+ return {
2591
+ ...mod.default,
2592
+ type: "node_module",
2593
+ id: moduleId
2594
+ };
2591
2595
  })
2592
2596
  );
2593
2597
  const localModulePaths = await (0, import_fast_glob3.default)(["*.[tj]s", "*/index.[tj]s"], {
@@ -2596,8 +2600,9 @@ async function resolveWxtModules(modulesDir, modules = []) {
2596
2600
  }).catch(() => []);
2597
2601
  const localModules = await Promise.all(
2598
2602
  localModulePaths.map(async (file) => {
2603
+ const absolutePath = normalizePath(import_node_path15.default.resolve(modulesDir, file));
2599
2604
  const { config } = await (0, import_c12.loadConfig)({
2600
- configFile: import_node_path15.default.resolve(modulesDir, file),
2605
+ configFile: absolutePath,
2601
2606
  globalRc: false,
2602
2607
  rcFile: false,
2603
2608
  packageJson: false,
@@ -2609,7 +2614,11 @@ async function resolveWxtModules(modulesDir, modules = []) {
2609
2614
  `No config found for ${file}. Did you forget to add a default export?`
2610
2615
  );
2611
2616
  config.name ??= file;
2612
- return config;
2617
+ return {
2618
+ ...config,
2619
+ type: "local",
2620
+ id: absolutePath
2621
+ };
2613
2622
  })
2614
2623
  );
2615
2624
  return [...npmModules, ...localModules];
@@ -1,6 +1,6 @@
1
1
  export { FakeBrowser, fakeBrowser } from '@webext-core/fake-browser';
2
2
  import * as vite from 'vite';
3
- import { I as InlineConfig } from './index-q2ZwJBs6.cjs';
3
+ import { I as InlineConfig } from './index-D6lH9OkP.cjs';
4
4
  import 'webextension-polyfill';
5
5
  import 'unimport';
6
6
  import 'consola';
package/dist/testing.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { FakeBrowser, fakeBrowser } from '@webext-core/fake-browser';
2
2
  import * as vite from 'vite';
3
- import { I as InlineConfig } from './index-q2ZwJBs6.js';
3
+ import { I as InlineConfig } from './index-D6lH9OkP.js';
4
4
  import 'webextension-polyfill';
5
5
  import 'unimport';
6
6
  import 'consola';
package/dist/testing.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  tsconfigPaths,
6
6
  unimport,
7
7
  webextensionPolyfillMock
8
- } from "./chunk-7AOGIMIM.js";
8
+ } from "./chunk-QOYT5J6A.js";
9
9
  import "./chunk-5X3S6AWF.js";
10
10
  import "./chunk-ZZCTFNQ5.js";
11
11
  import "./chunk-VBXJIVYU.js";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "wxt",
3
3
  "type": "module",
4
- "version": "0.18.5",
4
+ "version": "0.18.6",
5
5
  "description": "Next gen framework for developing web extensions",
6
6
  "repository": {
7
7
  "type": "git",
@@ -147,7 +147,7 @@
147
147
  "publint": "^0.2.6",
148
148
  "tsup": "^8.0.1",
149
149
  "tsx": "^4.11.2",
150
- "typescript": "^5.3.2"
150
+ "typescript": "^5.4.5"
151
151
  },
152
152
  "scripts": {
153
153
  "wxt": "tsx src/cli/index.ts",