wxt 0.18.10 → 0.18.12

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-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';
1
+ import { I as InlineConfig, B as BuildOutput, U as UserConfig, E as ExtensionRunnerConfig, W as WxtDevServer } from './index-1N-eQJJh.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-1N-eQJJh.cjs';
3
3
  import 'vite';
4
4
  import 'webextension-polyfill';
5
5
  import 'unimport';
@@ -28,6 +28,17 @@ declare function build(config?: InlineConfig): Promise<BuildOutput>;
28
28
  /**
29
29
  * Remove generated/temp files from the directory.
30
30
  *
31
+ * @param config Optional config that will override your `<root>/wxt.config.ts`.
32
+ *
33
+ * @example
34
+ * await clean();
35
+ */
36
+ declare function clean(config?: InlineConfig): Promise<void>;
37
+ /**
38
+ * Remove generated/temp files from the directory.
39
+ *
40
+ * @deprecated
41
+ *
31
42
  * @param root The directory to look for generated/temp files in. Defaults to `process.cwd()`. Can be relative to `process.cwd()` or absolute.
32
43
  *
33
44
  * @example
@@ -65,6 +76,6 @@ declare function prepare(config: InlineConfig): Promise<void>;
65
76
  */
66
77
  declare function zip(config?: InlineConfig): Promise<string[]>;
67
78
 
68
- var version = "0.18.9";
79
+ var version = "0.18.11";
69
80
 
70
81
  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-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';
1
+ import { I as InlineConfig, B as BuildOutput, U as UserConfig, E as ExtensionRunnerConfig, W as WxtDevServer } from './index-1N-eQJJh.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-1N-eQJJh.js';
3
3
  import 'vite';
4
4
  import 'webextension-polyfill';
5
5
  import 'unimport';
@@ -28,6 +28,17 @@ declare function build(config?: InlineConfig): Promise<BuildOutput>;
28
28
  /**
29
29
  * Remove generated/temp files from the directory.
30
30
  *
31
+ * @param config Optional config that will override your `<root>/wxt.config.ts`.
32
+ *
33
+ * @example
34
+ * await clean();
35
+ */
36
+ declare function clean(config?: InlineConfig): Promise<void>;
37
+ /**
38
+ * Remove generated/temp files from the directory.
39
+ *
40
+ * @deprecated
41
+ *
31
42
  * @param root The directory to look for generated/temp files in. Defaults to `process.cwd()`. Can be relative to `process.cwd()` or absolute.
32
43
  *
33
44
  * @example
@@ -65,6 +76,6 @@ declare function prepare(config: InlineConfig): Promise<void>;
65
76
  */
66
77
  declare function zip(config?: InlineConfig): Promise<string[]>;
67
78
 
68
- var version = "0.18.9";
79
+ var version = "0.18.11";
69
80
 
70
81
  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-2V7XZSZQ.js";
22
+ } from "./chunk-6QN6UXBH.js";
23
23
  import "./chunk-BERPNPEZ.js";
24
24
  import "./chunk-6XSIWUWF.js";
25
25
  import {
@@ -38,32 +38,37 @@ import path from "node:path";
38
38
  import glob from "fast-glob";
39
39
  import fs from "fs-extra";
40
40
  import pc from "picocolors";
41
- async function clean(root = process.cwd()) {
42
- consola.info("Cleaning Project");
41
+ async function clean(config) {
42
+ if (typeof config === "string") {
43
+ config = { root: config };
44
+ }
45
+ await registerWxt("build", config);
46
+ wxt.logger.info("Cleaning Project");
47
+ const root = wxt.config.root;
43
48
  const tempDirs = [
44
49
  "node_modules/.vite",
45
50
  "node_modules/.cache",
46
51
  "**/.wxt",
47
- ".output/*"
52
+ `${path.relative(root, wxt.config.outBaseDir)}/*`
48
53
  ];
49
- consola.debug("Looking for:", tempDirs.map(pc.cyan).join(", "));
54
+ wxt.logger.debug("Looking for:", tempDirs.map(pc.cyan).join(", "));
50
55
  const directories = await glob(tempDirs, {
51
- cwd: path.resolve(root),
56
+ cwd: root,
52
57
  absolute: true,
53
58
  onlyDirectories: true,
54
59
  deep: 2
55
60
  });
56
61
  if (directories.length === 0) {
57
- consola.debug("No generated files found.");
62
+ wxt.logger.debug("No generated files found.");
58
63
  return;
59
64
  }
60
- consola.debug(
65
+ wxt.logger.debug(
61
66
  "Found:",
62
67
  directories.map((dir) => pc.cyan(path.relative(root, dir))).join(", ")
63
68
  );
64
69
  for (const directory of directories) {
65
70
  await fs.rm(directory, { force: true, recursive: true });
66
- consola.debug("Deleted " + pc.cyan(path.relative(root, directory)));
71
+ wxt.logger.debug("Deleted " + pc.cyan(path.relative(root, directory)));
67
72
  }
68
73
  }
69
74
 
@@ -136,6 +141,9 @@ function createWebExtRunner() {
136
141
  ...userConfig,
137
142
  target: wxt.config.browser === "firefox" ? "firefox-desktop" : "chromium",
138
143
  sourceDir: wxt.config.outDir,
144
+ // Don't add a "Reload Manager" extension alongside dev extension, WXT
145
+ // already handles reloads intenrally.
146
+ noReloadManagerExtension: true,
139
147
  // WXT handles reloads, so disable auto-reload behaviors in web-ext
140
148
  noReload: true,
141
149
  noInput: true
@@ -336,19 +344,19 @@ function createFileReloader(server) {
336
344
  switch (changes.type) {
337
345
  case "extension-reload":
338
346
  server.reloadExtension();
339
- consola.success(`Reloaded extension`);
347
+ wxt.logger.success(`Reloaded extension`);
340
348
  break;
341
349
  case "html-reload":
342
350
  const { reloadedNames } = reloadHtmlPages(
343
351
  changes.rebuildGroups,
344
352
  server
345
353
  );
346
- consola.success(`Reloaded: ${getFilenameList(reloadedNames)}`);
354
+ wxt.logger.success(`Reloaded: ${getFilenameList(reloadedNames)}`);
347
355
  break;
348
356
  case "content-script-reload":
349
357
  reloadContentScripts(changes.changedSteps, server);
350
358
  const rebuiltNames = changes.rebuildGroups.flat().map((entry) => entry.name);
351
- consola.success(`Reloaded: ${getFilenameList(rebuiltNames)}`);
359
+ wxt.logger.success(`Reloaded: ${getFilenameList(rebuiltNames)}`);
352
360
  break;
353
361
  }
354
362
  } catch (err) {
@@ -627,14 +635,15 @@ async function zipDir(directory, outputPath, options) {
627
635
  }
628
636
  }
629
637
  await options?.additionalWork?.(archive);
630
- const buffer = await archive.generateAsync({
631
- type: "base64",
632
- ...wxt.config.zip.compressionLevel === 0 ? { compression: "STORE" } : {
633
- compression: "DEFLATE",
634
- compressionOptions: { level: wxt.config.zip.compressionLevel }
635
- }
636
- });
637
- await fs3.writeFile(outputPath, buffer, "base64");
638
+ await new Promise(
639
+ (resolve, reject) => archive.generateNodeStream({
640
+ type: "nodebuffer",
641
+ ...wxt.config.zip.compressionLevel === 0 ? { compression: "STORE" } : {
642
+ compression: "DEFLATE",
643
+ compressionOptions: { level: wxt.config.zip.compressionLevel }
644
+ }
645
+ }).pipe(fs3.createWriteStream(outputPath)).on("error", reject).on("close", resolve)
646
+ );
638
647
  }
639
648
  async function downloadPrivatePackages() {
640
649
  const overrides = {};
@@ -1,4 +1,4 @@
1
- import { a6 as WxtModuleOptions, a8 as WxtModule, a7 as WxtModuleSetup, Y as Wxt, r as Entrypoint } from './index-mz3v4Nde.cjs';
1
+ import { a6 as WxtModuleOptions, a8 as WxtModule, a7 as WxtModuleSetup, Y as Wxt, r as Entrypoint } from './index-1N-eQJJh.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-mz3v4Nde.js';
1
+ import { a6 as WxtModuleOptions, a8 as WxtModule, a7 as WxtModuleSetup, Y as Wxt, r as Entrypoint } from './index-1N-eQJJh.js';
2
2
  import * as vite from 'vite';
3
3
  import { UnimportOptions } from 'unimport';
4
4
  import 'webextension-polyfill';
package/dist/sandbox.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import { U as UnlistedScriptDefinition, B as BackgroundDefinition, C as ContentScriptDefinition, W as WxtPlugin } from './index-Bk-a0SkY.js';
1
+ import { U as UnlistedScriptDefinition, B as BackgroundDefinition, C as ContentScriptDefinition, W as WxtPlugin } from './define-app-config-bg54F_lV.js';
2
+ export { a as WxtAppConfig, d as defineAppConfig } from './define-app-config-bg54F_lV.js';
2
3
  export * from '@webext-core/match-patterns';
3
4
  import 'webextension-polyfill';
4
5
 
package/dist/sandbox.js CHANGED
@@ -20,9 +20,15 @@ function defineWxtPlugin(plugin) {
20
20
  return plugin;
21
21
  }
22
22
 
23
+ // src/sandbox/define-app-config.ts
24
+ function defineAppConfig(config) {
25
+ return config;
26
+ }
27
+
23
28
  // src/sandbox/index.ts
24
29
  export * from "@webext-core/match-patterns";
25
30
  export {
31
+ defineAppConfig,
26
32
  defineBackground,
27
33
  defineContentScript,
28
34
  defineUnlistedScript,
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_path13.sep;
448
+ const cwd = process.cwd() + import_node_path14.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_path13, bracket, BasicReporter;
456
+ var import_node_util, import_node_path14, 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_path13 = require("path");
461
+ import_node_path14 = 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_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;
864
+ var import_node_process, import_node_readline, import_node_tty, import_tty, import_node_util2, import_node_path15, 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_path14 = require("path");
877
+ import_node_path15 = require("path");
878
878
  ESC = "\x1B";
879
879
  CSI = `${ESC}[`;
880
880
  beep = "\x07";
@@ -2108,8 +2108,27 @@ var import_node_path7 = require("path");
2108
2108
  // src/core/builders/vite/plugins/wxtPluginLoader.ts
2109
2109
  var import_linkedom2 = require("linkedom");
2110
2110
 
2111
+ // src/core/builders/vite/plugins/resolveAppConfig.ts
2112
+ var import_fs_extra3 = require("fs-extra");
2113
+ var import_node_path8 = require("path");
2114
+ function resolveAppConfig(config) {
2115
+ const virtualModuleId = "virtual:app-config";
2116
+ const resolvedVirtualModuleId = "\0" + virtualModuleId;
2117
+ const appConfigFile = (0, import_node_path8.resolve)(config.srcDir, "app.config.ts");
2118
+ return {
2119
+ name: "wxt:resolve-app-config",
2120
+ async resolveId(id) {
2121
+ if (id !== virtualModuleId) return;
2122
+ return await (0, import_fs_extra3.exists)(appConfigFile) ? appConfigFile : resolvedVirtualModuleId;
2123
+ },
2124
+ load(id) {
2125
+ if (id === resolvedVirtualModuleId) return `export default {}`;
2126
+ }
2127
+ };
2128
+ }
2129
+
2111
2130
  // src/core/utils/fs.ts
2112
- var import_fs_extra4 = __toESM(require("fs-extra"), 1);
2131
+ var import_fs_extra5 = __toESM(require("fs-extra"), 1);
2113
2132
  var import_fast_glob2 = __toESM(require("fast-glob"), 1);
2114
2133
 
2115
2134
  // src/core/wxt.ts
@@ -2119,8 +2138,8 @@ var import_hookable = require("hookable");
2119
2138
  var import_nypm = require("nypm");
2120
2139
 
2121
2140
  // src/core/package-managers/npm.ts
2122
- var import_node_path8 = __toESM(require("path"), 1);
2123
- var import_fs_extra3 = require("fs-extra");
2141
+ var import_node_path9 = __toESM(require("path"), 1);
2142
+ var import_fs_extra4 = require("fs-extra");
2124
2143
 
2125
2144
  // src/core/builders/vite/index.ts
2126
2145
  var import_server = require("vite-node/server");
@@ -2130,7 +2149,7 @@ var import_source_map = require("vite-node/source-map");
2130
2149
  // src/modules.ts
2131
2150
  var vite = __toESM(require("vite"), 1);
2132
2151
  var import_fast_glob = __toESM(require("fast-glob"), 1);
2133
- var import_node_path9 = require("path");
2152
+ var import_node_path10 = require("path");
2134
2153
  function defineWxtModule(module2) {
2135
2154
  if (typeof module2 === "function") return { setup: module2 };
2136
2155
  return module2;
@@ -2148,7 +2167,7 @@ function addViteConfig(wxt2, viteConfig) {
2148
2167
 
2149
2168
  // src/builtin-modules/unimport.ts
2150
2169
  var import_unimport = require("unimport");
2151
- var import_node_path10 = require("path");
2170
+ var import_node_path11 = require("path");
2152
2171
  var unimport_default = defineWxtModule({
2153
2172
  name: "wxt:built-in:unimport",
2154
2173
  setup(wxt2) {
@@ -2172,8 +2191,10 @@ var unimport_default = defineWxtModule({
2172
2191
  wxt2.hooks.hook("prepare:types", async (_2, entries) => {
2173
2192
  await unimport.init();
2174
2193
  entries.push(await getImportsDeclarationEntry(unimport));
2175
- if (!options.eslintrc.enabled) return;
2176
- entries.push(await getImportsEslintEntry(unimport, options));
2194
+ if (options.eslintrc.enabled === false) return;
2195
+ entries.push(
2196
+ await getEslintConfigEntry(unimport, options.eslintrc.enabled, options)
2197
+ );
2177
2198
  });
2178
2199
  addViteConfig(wxt2, () => ({
2179
2200
  plugins: [vitePlugin(unimport)]
@@ -2193,7 +2214,7 @@ function vitePlugin(unimport) {
2193
2214
  name: "wxt:unimport",
2194
2215
  async transform(code, id) {
2195
2216
  if (id.includes("node_modules")) return;
2196
- if (!ENABLED_EXTENSIONS.has((0, import_node_path10.extname)(id))) return;
2217
+ if (!ENABLED_EXTENSIONS.has((0, import_node_path11.extname)(id))) return;
2197
2218
  const injected = await unimport.injectImports(code, id);
2198
2219
  return {
2199
2220
  code: injected.code,
@@ -2214,15 +2235,33 @@ async function getImportsDeclarationEntry(unimport) {
2214
2235
  tsReference: true
2215
2236
  };
2216
2237
  }
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
- });
2238
+ async function getEslintConfigEntry(unimport, version2, options) {
2239
+ const globals2 = (await unimport.getImports()).map((i) => i.as ?? i.name).filter(Boolean).sort().reduce((globals3, name) => {
2240
+ globals3[name] = options.eslintrc.globalsPropValue;
2241
+ return globals3;
2242
+ }, {});
2243
+ if (version2 <= 8) return getEslint8ConfigEntry(options, globals2);
2244
+ else return getEslint9ConfigEntry(options, globals2);
2245
+ }
2246
+ function getEslint8ConfigEntry(options, globals2) {
2247
+ return {
2248
+ path: options.eslintrc.filePath,
2249
+ text: JSON.stringify({ globals: globals2 }, null, 2) + "\n"
2250
+ };
2251
+ }
2252
+ function getEslint9ConfigEntry(options, globals2) {
2223
2253
  return {
2224
2254
  path: options.eslintrc.filePath,
2225
- text: JSON.stringify(eslintrc, null, 2) + "\n"
2255
+ text: `const globals = ${JSON.stringify(globals2, null, 2)}
2256
+
2257
+ export default {
2258
+ name: "wxt/auto-imports",
2259
+ languageOptions: {
2260
+ globals,
2261
+ sourceType: "module",
2262
+ },
2263
+ };
2264
+ `
2226
2265
  };
2227
2266
  }
2228
2267
 
@@ -2231,18 +2270,18 @@ var builtinModules = [unimport_default];
2231
2270
 
2232
2271
  // src/core/utils/fs.ts
2233
2272
  async function writeFileIfDifferent(file, newContents) {
2234
- const existingContents = await import_fs_extra4.default.readFile(file, "utf-8").catch(() => void 0);
2273
+ const existingContents = await import_fs_extra5.default.readFile(file, "utf-8").catch(() => void 0);
2235
2274
  if (existingContents !== newContents) {
2236
- await import_fs_extra4.default.writeFile(file, newContents);
2275
+ await import_fs_extra5.default.writeFile(file, newContents);
2237
2276
  }
2238
2277
  }
2239
2278
 
2240
2279
  // src/core/utils/building/build-entrypoints.ts
2241
- var import_fs_extra5 = __toESM(require("fs-extra"), 1);
2280
+ var import_fs_extra6 = __toESM(require("fs-extra"), 1);
2242
2281
  var import_picocolors = __toESM(require("picocolors"), 1);
2243
2282
 
2244
2283
  // src/core/utils/building/find-entrypoints.ts
2245
- var import_fs_extra6 = __toESM(require("fs-extra"), 1);
2284
+ var import_fs_extra7 = __toESM(require("fs-extra"), 1);
2246
2285
  var import_minimatch = require("minimatch");
2247
2286
  var import_linkedom3 = require("linkedom");
2248
2287
  var import_json5 = __toESM(require("json5"), 1);
@@ -2289,29 +2328,29 @@ var PATH_GLOB_TO_TYPE_MAP = {
2289
2328
  };
2290
2329
 
2291
2330
  // src/core/utils/building/generate-wxt-dir.ts
2292
- var import_fs_extra7 = __toESM(require("fs-extra"), 1);
2293
- var import_node_path11 = require("path");
2294
- var import_node_path12 = __toESM(require("path"), 1);
2331
+ var import_fs_extra8 = __toESM(require("fs-extra"), 1);
2332
+ var import_node_path12 = require("path");
2333
+ var import_node_path13 = __toESM(require("path"), 1);
2295
2334
 
2296
2335
  // src/core/utils/building/resolve-config.ts
2297
2336
  var import_c12 = require("c12");
2298
2337
  var import_node_path17 = __toESM(require("path"), 1);
2299
2338
 
2300
2339
  // src/core/utils/cache.ts
2301
- var import_fs_extra8 = __toESM(require("fs-extra"), 1);
2340
+ var import_fs_extra9 = __toESM(require("fs-extra"), 1);
2302
2341
  var import_path = require("path");
2303
2342
  function createFsCache(wxtDir) {
2304
2343
  const getPath = (key) => (0, import_path.resolve)(wxtDir, "cache", encodeURIComponent(key));
2305
2344
  return {
2306
2345
  async set(key, value) {
2307
2346
  const path8 = getPath(key);
2308
- await (0, import_fs_extra8.ensureDir)((0, import_path.dirname)(path8));
2347
+ await (0, import_fs_extra9.ensureDir)((0, import_path.dirname)(path8));
2309
2348
  await writeFileIfDifferent(path8, value);
2310
2349
  },
2311
2350
  async get(key) {
2312
2351
  const path8 = getPath(key);
2313
2352
  try {
2314
- return await import_fs_extra8.default.readFile(path8, "utf-8");
2353
+ return await import_fs_extra9.default.readFile(path8, "utf-8");
2315
2354
  } catch {
2316
2355
  return void 0;
2317
2356
  }
@@ -2327,25 +2366,29 @@ var import_node_process3 = require("process");
2327
2366
  init_utils();
2328
2367
  var import_node_tty2 = require("tty");
2329
2368
  var import_node_util3 = require("util");
2330
- var import_node_path15 = require("path");
2369
+ var import_node_path16 = require("path");
2331
2370
 
2332
2371
  // src/core/utils/building/resolve-config.ts
2333
2372
  var import_defu = __toESM(require("defu"), 1);
2373
+ var import_fs_extra10 = __toESM(require("fs-extra"), 1);
2374
+ var import_fast_glob4 = __toESM(require("fast-glob"), 1);
2334
2375
 
2335
- // src/core/utils/package.ts
2336
- var import_node_path16 = require("path");
2337
- var import_fs_extra9 = __toESM(require("fs-extra"), 1);
2338
- function isModuleInstalled(name) {
2339
- return import(
2340
- /* @vite-ignore */
2341
- name
2342
- ).then(() => true).catch(() => false);
2376
+ // src/core/utils/eslint.ts
2377
+ var import_meta = {};
2378
+ async function getEslintVersion() {
2379
+ try {
2380
+ const require2 = (await import("module")).default.createRequire(
2381
+ import_meta.url
2382
+ );
2383
+ const { ESLint } = require2("eslint");
2384
+ return ESLint.version?.split(".") ?? [];
2385
+ } catch (error) {
2386
+ return [];
2387
+ }
2343
2388
  }
2344
2389
 
2345
2390
  // src/core/utils/building/resolve-config.ts
2346
- var import_fs_extra10 = __toESM(require("fs-extra"), 1);
2347
- var import_fast_glob4 = __toESM(require("fast-glob"), 1);
2348
- var import_meta = {};
2391
+ var import_meta2 = {};
2349
2392
  async function resolveConfig(inlineConfig, command) {
2350
2393
  let userConfig = {};
2351
2394
  let userConfigMetadata;
@@ -2459,7 +2502,7 @@ async function resolveConfig(inlineConfig, command) {
2459
2502
  srcDir,
2460
2503
  typesDir,
2461
2504
  wxtDir,
2462
- zip: resolveZipConfig(root, mergedConfig),
2505
+ zip: resolveZipConfig(root, outBaseDir, mergedConfig),
2463
2506
  transformManifest: mergedConfig.transformManifest,
2464
2507
  analysis: resolveAnalysisConfig(root, mergedConfig),
2465
2508
  userConfigMetadata: userConfigMetadata ?? {},
@@ -2504,7 +2547,7 @@ async function mergeInlineConfig(inlineConfig, userConfig) {
2504
2547
  ...builderConfig
2505
2548
  };
2506
2549
  }
2507
- function resolveZipConfig(root, mergedConfig) {
2550
+ function resolveZipConfig(root, outBaseDir, mergedConfig) {
2508
2551
  const downloadedPackagesDir = import_node_path17.default.resolve(root, ".wxt/local_modules");
2509
2552
  return {
2510
2553
  name: void 0,
@@ -2523,6 +2566,8 @@ function resolveZipConfig(root, mergedConfig) {
2523
2566
  // Tests
2524
2567
  "**/__tests__/**",
2525
2568
  "**/*.+(test|spec).?(c|m)+(j|t)s?(x)",
2569
+ // Output directory
2570
+ `${import_node_path17.default.relative(root, outBaseDir)}/**`,
2526
2571
  // From user
2527
2572
  ...mergedConfig.zip?.excludeSources ?? []
2528
2573
  ],
@@ -2549,16 +2594,6 @@ function resolveAnalysisConfig(root, mergedConfig) {
2549
2594
  }
2550
2595
  async function getUnimportOptions(wxtDir, srcDir, logger, config) {
2551
2596
  if (config.imports === false) return false;
2552
- const rawEslintEnabled = config.imports?.eslintrc?.enabled;
2553
- let eslintEnabled;
2554
- switch (rawEslintEnabled) {
2555
- case void 0:
2556
- case "auto":
2557
- eslintEnabled = await isModuleInstalled("eslint");
2558
- break;
2559
- default:
2560
- eslintEnabled = rawEslintEnabled;
2561
- }
2562
2597
  const defaultOptions = {
2563
2598
  debugLog: logger.debug,
2564
2599
  imports: [
@@ -2576,19 +2611,41 @@ async function getUnimportOptions(wxtDir, srcDir, logger, config) {
2576
2611
  dirsScanOptions: {
2577
2612
  cwd: srcDir
2578
2613
  },
2579
- eslintrc: {
2580
- enabled: eslintEnabled,
2581
- filePath: import_node_path17.default.resolve(wxtDir, "eslintrc-auto-import.json"),
2582
- globalsPropValue: true
2583
- }
2614
+ eslintrc: await getUnimportEslintOptions(wxtDir, config.imports?.eslintrc)
2584
2615
  };
2585
2616
  return (0, import_defu.default)(
2586
2617
  config.imports ?? {},
2587
2618
  defaultOptions
2588
2619
  );
2589
2620
  }
2621
+ async function getUnimportEslintOptions(wxtDir, options) {
2622
+ const rawEslintEnabled = options?.enabled ?? "auto";
2623
+ let eslintEnabled;
2624
+ switch (rawEslintEnabled) {
2625
+ case "auto":
2626
+ const version2 = await getEslintVersion();
2627
+ let major = parseInt(version2[0]);
2628
+ if (major <= 8) eslintEnabled = 8;
2629
+ else if (major >= 9) eslintEnabled = 9;
2630
+ else eslintEnabled = 8;
2631
+ break;
2632
+ case true:
2633
+ eslintEnabled = 8;
2634
+ break;
2635
+ default:
2636
+ eslintEnabled = rawEslintEnabled;
2637
+ }
2638
+ return {
2639
+ enabled: eslintEnabled,
2640
+ filePath: import_node_path17.default.resolve(
2641
+ wxtDir,
2642
+ eslintEnabled === 9 ? "eslint-auto-imports.mjs" : "eslintrc-auto-import.json"
2643
+ ),
2644
+ globalsPropValue: true
2645
+ };
2646
+ }
2590
2647
  async function resolveWxtModuleDir() {
2591
- const requireResolve = require?.resolve ?? (await import("module")).default.createRequire(import_meta.url).resolve;
2648
+ const requireResolve = require?.resolve ?? (await import("module")).default.createRequire(import_meta2.url).resolve;
2592
2649
  return import_node_path17.default.resolve(requireResolve("wxt"), "../..");
2593
2650
  }
2594
2651
  async function isDirMissing(dir) {
@@ -2675,7 +2732,7 @@ var import_node_url = require("url");
2675
2732
 
2676
2733
  // src/core/utils/building/internal-build.ts
2677
2734
  var import_picocolors5 = __toESM(require("picocolors"), 1);
2678
- var import_fs_extra14 = __toESM(require("fs-extra"), 1);
2735
+ var import_fs_extra15 = __toESM(require("fs-extra"), 1);
2679
2736
 
2680
2737
  // src/core/utils/log/printFileList.ts
2681
2738
  var import_node_path19 = __toESM(require("path"), 1);
@@ -2702,11 +2759,17 @@ var import_picocolors4 = __toESM(require("picocolors"), 1);
2702
2759
  var import_fast_glob5 = __toESM(require("fast-glob"), 1);
2703
2760
 
2704
2761
  // src/core/utils/manifest.ts
2762
+ var import_fs_extra14 = __toESM(require("fs-extra"), 1);
2763
+
2764
+ // src/core/utils/package.ts
2765
+ var import_node_path20 = require("path");
2705
2766
  var import_fs_extra13 = __toESM(require("fs-extra"), 1);
2767
+
2768
+ // src/core/utils/manifest.ts
2706
2769
  var import_defu2 = __toESM(require("defu"), 1);
2707
2770
 
2708
2771
  // src/core/utils/building/internal-build.ts
2709
- var import_node_path20 = require("path");
2772
+ var import_node_path21 = require("path");
2710
2773
  var import_rollup_plugin_visualizer2 = require("@aklinker1/rollup-plugin-visualizer");
2711
2774
  var import_ci_info = require("ci-info");
2712
2775
 
@@ -2718,7 +2781,8 @@ function WxtVitest(inlineConfig) {
2718
2781
  webextensionPolyfillMock(config),
2719
2782
  globals(config),
2720
2783
  download(config),
2721
- tsconfigPaths(config)
2784
+ tsconfigPaths(config),
2785
+ resolveAppConfig(config)
2722
2786
  ];
2723
2787
  if (config.imports !== false) {
2724
2788
  const unimport = (0, import_unimport5.createUnimport)(config.imports);
@@ -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-mz3v4Nde.cjs';
3
+ import { I as InlineConfig } from './index-1N-eQJJh.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-mz3v4Nde.js';
3
+ import { I as InlineConfig } from './index-1N-eQJJh.js';
4
4
  import 'webextension-polyfill';
5
5
  import 'unimport';
6
6
  import 'consola';
package/dist/testing.js CHANGED
@@ -1,11 +1,12 @@
1
1
  import {
2
2
  download,
3
3
  globals,
4
+ resolveAppConfig,
4
5
  resolveConfig,
5
6
  tsconfigPaths,
6
7
  vitePlugin,
7
8
  webextensionPolyfillMock
8
- } from "./chunk-2V7XZSZQ.js";
9
+ } from "./chunk-6QN6UXBH.js";
9
10
  import "./chunk-BERPNPEZ.js";
10
11
  import "./chunk-6XSIWUWF.js";
11
12
  import "./chunk-BM6QYGAW.js";
@@ -22,7 +23,8 @@ function WxtVitest(inlineConfig) {
22
23
  webextensionPolyfillMock(config),
23
24
  globals(config),
24
25
  download(config),
25
- tsconfigPaths(config)
26
+ tsconfigPaths(config),
27
+ resolveAppConfig(config)
26
28
  ];
27
29
  if (config.imports !== false) {
28
30
  const unimport = createUnimport(config.imports);