wxt 0.18.8 → 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.
@@ -434,14 +434,17 @@ interface InlineConfig {
434
434
  */
435
435
  includeBrowserPolyfill?: boolean;
436
436
  /**
437
- * When set to `true`, use the Vite Runtime API to load entrypoint options instead of the default, `jiti`.
437
+ * Method used to import entrypoint files during the build process to extract their options.
438
438
  *
439
- * Lets you use imported variables and leverage your Vite config to add support for non-standard APIs/syntax.
439
+ * - "jiti": Simplest and fastest, but doesn't allow using any imported variables outside the entrypoint's main function
440
+ * - "vite-runtime" (unstable): Uses Vite 5.3's new runtime API to import the entrypoints. Automatically includes vite config based on your wxt.config.ts file
441
+ * - "vite-node" (unstable): Uses `vite-node` to import the entrypoints. Automatically includes vite config based on your wxt.config.ts file
440
442
  *
441
- * @experimental Early access to try out the feature before it becomes the default.
442
- * @default false
443
+ * @see {@link https://wxt.dev/guide/go-further/entrypoint-side-effects.html|Entrypoint Side-effect Docs}
444
+ *
445
+ * @default "jiti"
443
446
  */
444
- viteRuntime?: boolean;
447
+ entrypointImporter?: 'jiti' | 'vite-runtime' | 'vite-node';
445
448
  };
446
449
  /**
447
450
  * Config effecting dev mode only.
@@ -1038,6 +1041,23 @@ interface WxtHooks {
1038
1041
  * @returns Promise
1039
1042
  */
1040
1043
  ready: (wxt: Wxt) => HookResult;
1044
+ /**
1045
+ * Called before WXT writes .wxt/tsconfig.json and .wxt/wxt.d.ts, allowing
1046
+ * addition of custom references and declarations in wxt.d.ts, or directly
1047
+ * modifying the options in `tsconfig.json`.
1048
+ *
1049
+ * @example
1050
+ * wxt.hooks.hook("prepare:types", (wxt, entries) => {
1051
+ * // Add a file, ".wxt/types/example.d.ts", that defines a global
1052
+ * // variable called "example" in the TS project.
1053
+ * entries.push({
1054
+ * path: "types/example.d.ts",
1055
+ * textContent: "declare const a: string;",
1056
+ * tsReference: true,
1057
+ * });
1058
+ * })
1059
+ */
1060
+ 'prepare:types': (wxt: Wxt, entries: WxtDirEntry[]) => HookResult;
1041
1061
  /**
1042
1062
  * Called before the build is started in both dev mode and build mode.
1043
1063
  *
@@ -1179,7 +1199,7 @@ interface ResolvedConfig {
1179
1199
  alias: Record<string, string>;
1180
1200
  experimental: {
1181
1201
  includeBrowserPolyfill: boolean;
1182
- viteRuntime: boolean;
1202
+ entrypointImporter: 'jiti' | 'vite-runtime' | 'vite-node';
1183
1203
  };
1184
1204
  dev: {
1185
1205
  /** Only defined during dev command */
@@ -1190,7 +1210,8 @@ interface ResolvedConfig {
1190
1210
  reloadCommand: string | false;
1191
1211
  };
1192
1212
  hooks: NestedHooks<WxtHooks>;
1193
- modules: WxtModuleWithMetadata<any>[];
1213
+ builtinModules: WxtModule<any>[];
1214
+ userModules: WxtModuleWithMetadata<any>[];
1194
1215
  /**
1195
1216
  * An array of string to import plugins from. These paths should be
1196
1217
  * resolvable by vite, and they should `export default defineWxtPlugin(...)`.
@@ -1313,20 +1334,53 @@ interface WxtModuleWithMetadata<TOptions extends WxtModuleOptions> extends WxtMo
1313
1334
  type: 'local' | 'node_module';
1314
1335
  id: string;
1315
1336
  }
1316
- interface ResolvedPublicFile {
1337
+ type ResolvedPublicFile = CopiedPublicFile | GeneratedPublicFile;
1338
+ interface ResolvedBasePublicFile {
1339
+ /**
1340
+ * The relative path in the output directory to copy the file to.
1341
+ * @example
1342
+ * "content-scripts/base-styles.css"
1343
+ */
1344
+ relativeDest: string;
1345
+ }
1346
+ interface CopiedPublicFile extends ResolvedBasePublicFile {
1317
1347
  /**
1318
1348
  * The absolute path to the file that will be copied to the output directory.
1319
1349
  * @example
1320
1350
  * "/path/to/any/file.css"
1321
1351
  */
1322
1352
  absoluteSrc: string;
1353
+ }
1354
+ interface GeneratedPublicFile extends ResolvedBasePublicFile {
1323
1355
  /**
1324
- * The relative path in the output directory to copy the file to.
1325
- * @example
1326
- * "content-scripts/base-styles.css"
1356
+ * Text to write to the file.
1327
1357
  */
1328
- relativeDest: string;
1358
+ contents: string;
1329
1359
  }
1330
1360
  type WxtPlugin = () => void;
1361
+ type WxtDirEntry = WxtDirTypeReferenceEntry | WxtDirFileEntry;
1362
+ /**
1363
+ * Represents type reference to a node module to be added to `.wxt/wxt.d.ts` file
1364
+ */
1365
+ interface WxtDirTypeReferenceEntry {
1366
+ module: string;
1367
+ }
1368
+ /**
1369
+ * Represents a file to be written to the project's `.wxt/` directory.
1370
+ */
1371
+ interface WxtDirFileEntry {
1372
+ /**
1373
+ * Path relative to the `.wxt/` directory. So "tsconfig.json" would resolve to ".wxt/tsconfig.json".
1374
+ */
1375
+ path: string;
1376
+ /**
1377
+ * The text that will be written to the file.
1378
+ */
1379
+ text: string;
1380
+ /**
1381
+ * Set to `true` to add a reference to this file in `.wxt/wxt.d.ts`.
1382
+ */
1383
+ tsReference?: boolean;
1384
+ }
1331
1385
 
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 };
1386
+ 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, ResolvedBasePublicFile as ab, CopiedPublicFile as ac, GeneratedPublicFile as ad, WxtPlugin as ae, WxtDirEntry as af, WxtDirTypeReferenceEntry as ag, WxtDirFileEntry as ah, 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 };
@@ -434,14 +434,17 @@ interface InlineConfig {
434
434
  */
435
435
  includeBrowserPolyfill?: boolean;
436
436
  /**
437
- * When set to `true`, use the Vite Runtime API to load entrypoint options instead of the default, `jiti`.
437
+ * Method used to import entrypoint files during the build process to extract their options.
438
438
  *
439
- * Lets you use imported variables and leverage your Vite config to add support for non-standard APIs/syntax.
439
+ * - "jiti": Simplest and fastest, but doesn't allow using any imported variables outside the entrypoint's main function
440
+ * - "vite-runtime" (unstable): Uses Vite 5.3's new runtime API to import the entrypoints. Automatically includes vite config based on your wxt.config.ts file
441
+ * - "vite-node" (unstable): Uses `vite-node` to import the entrypoints. Automatically includes vite config based on your wxt.config.ts file
440
442
  *
441
- * @experimental Early access to try out the feature before it becomes the default.
442
- * @default false
443
+ * @see {@link https://wxt.dev/guide/go-further/entrypoint-side-effects.html|Entrypoint Side-effect Docs}
444
+ *
445
+ * @default "jiti"
443
446
  */
444
- viteRuntime?: boolean;
447
+ entrypointImporter?: 'jiti' | 'vite-runtime' | 'vite-node';
445
448
  };
446
449
  /**
447
450
  * Config effecting dev mode only.
@@ -1038,6 +1041,23 @@ interface WxtHooks {
1038
1041
  * @returns Promise
1039
1042
  */
1040
1043
  ready: (wxt: Wxt) => HookResult;
1044
+ /**
1045
+ * Called before WXT writes .wxt/tsconfig.json and .wxt/wxt.d.ts, allowing
1046
+ * addition of custom references and declarations in wxt.d.ts, or directly
1047
+ * modifying the options in `tsconfig.json`.
1048
+ *
1049
+ * @example
1050
+ * wxt.hooks.hook("prepare:types", (wxt, entries) => {
1051
+ * // Add a file, ".wxt/types/example.d.ts", that defines a global
1052
+ * // variable called "example" in the TS project.
1053
+ * entries.push({
1054
+ * path: "types/example.d.ts",
1055
+ * textContent: "declare const a: string;",
1056
+ * tsReference: true,
1057
+ * });
1058
+ * })
1059
+ */
1060
+ 'prepare:types': (wxt: Wxt, entries: WxtDirEntry[]) => HookResult;
1041
1061
  /**
1042
1062
  * Called before the build is started in both dev mode and build mode.
1043
1063
  *
@@ -1179,7 +1199,7 @@ interface ResolvedConfig {
1179
1199
  alias: Record<string, string>;
1180
1200
  experimental: {
1181
1201
  includeBrowserPolyfill: boolean;
1182
- viteRuntime: boolean;
1202
+ entrypointImporter: 'jiti' | 'vite-runtime' | 'vite-node';
1183
1203
  };
1184
1204
  dev: {
1185
1205
  /** Only defined during dev command */
@@ -1190,7 +1210,8 @@ interface ResolvedConfig {
1190
1210
  reloadCommand: string | false;
1191
1211
  };
1192
1212
  hooks: NestedHooks<WxtHooks>;
1193
- modules: WxtModuleWithMetadata<any>[];
1213
+ builtinModules: WxtModule<any>[];
1214
+ userModules: WxtModuleWithMetadata<any>[];
1194
1215
  /**
1195
1216
  * An array of string to import plugins from. These paths should be
1196
1217
  * resolvable by vite, and they should `export default defineWxtPlugin(...)`.
@@ -1313,20 +1334,53 @@ interface WxtModuleWithMetadata<TOptions extends WxtModuleOptions> extends WxtMo
1313
1334
  type: 'local' | 'node_module';
1314
1335
  id: string;
1315
1336
  }
1316
- interface ResolvedPublicFile {
1337
+ type ResolvedPublicFile = CopiedPublicFile | GeneratedPublicFile;
1338
+ interface ResolvedBasePublicFile {
1339
+ /**
1340
+ * The relative path in the output directory to copy the file to.
1341
+ * @example
1342
+ * "content-scripts/base-styles.css"
1343
+ */
1344
+ relativeDest: string;
1345
+ }
1346
+ interface CopiedPublicFile extends ResolvedBasePublicFile {
1317
1347
  /**
1318
1348
  * The absolute path to the file that will be copied to the output directory.
1319
1349
  * @example
1320
1350
  * "/path/to/any/file.css"
1321
1351
  */
1322
1352
  absoluteSrc: string;
1353
+ }
1354
+ interface GeneratedPublicFile extends ResolvedBasePublicFile {
1323
1355
  /**
1324
- * The relative path in the output directory to copy the file to.
1325
- * @example
1326
- * "content-scripts/base-styles.css"
1356
+ * Text to write to the file.
1327
1357
  */
1328
- relativeDest: string;
1358
+ contents: string;
1329
1359
  }
1330
1360
  type WxtPlugin = () => void;
1361
+ type WxtDirEntry = WxtDirTypeReferenceEntry | WxtDirFileEntry;
1362
+ /**
1363
+ * Represents type reference to a node module to be added to `.wxt/wxt.d.ts` file
1364
+ */
1365
+ interface WxtDirTypeReferenceEntry {
1366
+ module: string;
1367
+ }
1368
+ /**
1369
+ * Represents a file to be written to the project's `.wxt/` directory.
1370
+ */
1371
+ interface WxtDirFileEntry {
1372
+ /**
1373
+ * Path relative to the `.wxt/` directory. So "tsconfig.json" would resolve to ".wxt/tsconfig.json".
1374
+ */
1375
+ path: string;
1376
+ /**
1377
+ * The text that will be written to the file.
1378
+ */
1379
+ text: string;
1380
+ /**
1381
+ * Set to `true` to add a reference to this file in `.wxt/wxt.d.ts`.
1382
+ */
1383
+ tsReference?: boolean;
1384
+ }
1331
1385
 
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 };
1386
+ 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, ResolvedBasePublicFile as ab, CopiedPublicFile as ac, GeneratedPublicFile as ad, WxtPlugin as ae, WxtDirEntry as af, WxtDirTypeReferenceEntry as ag, WxtDirFileEntry as ah, 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 };