wxt 0.19.22 → 0.20.0-beta1

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.
Files changed (103) hide show
  1. package/README.md +6 -0
  2. package/dist/browser.d.ts +28 -0
  3. package/dist/builtin-modules/unimport.d.ts +1 -1
  4. package/dist/builtin-modules/unimport.mjs +36 -12
  5. package/dist/cli/index.mjs +0 -1
  6. package/dist/core/builders/vite/index.mjs +21 -38
  7. package/dist/core/builders/vite/plugins/extensionApiMock.d.ts +1 -6
  8. package/dist/core/builders/vite/plugins/extensionApiMock.mjs +2 -4
  9. package/dist/core/builders/vite/plugins/index.d.ts +0 -1
  10. package/dist/core/builders/vite/plugins/index.mjs +0 -1
  11. package/dist/core/builders/vite/plugins/noopBackground.mjs +1 -1
  12. package/dist/core/create-server.mjs +1 -0
  13. package/dist/core/define-web-ext-config.d.ts +9 -0
  14. package/dist/core/define-web-ext-config.mjs +10 -0
  15. package/dist/core/generate-wxt-dir.mjs +4 -6
  16. package/dist/core/index.d.ts +1 -1
  17. package/dist/core/index.mjs +1 -1
  18. package/dist/core/initialize.mjs +2 -5
  19. package/dist/core/keyboard-shortcuts.mjs +3 -9
  20. package/dist/core/resolve-config.mjs +152 -55
  21. package/dist/core/runners/web-ext.mjs +1 -1
  22. package/dist/core/utils/building/find-entrypoints.mjs +2 -1
  23. package/dist/core/utils/building/index.d.ts +0 -1
  24. package/dist/core/utils/building/index.mjs +0 -1
  25. package/dist/core/utils/building/rebuild.d.ts +1 -2
  26. package/dist/core/utils/content-scripts.d.ts +3 -3
  27. package/dist/core/utils/content-scripts.mjs +2 -0
  28. package/dist/core/utils/eslint.mjs +3 -5
  29. package/dist/core/utils/manifest.d.ts +3 -8
  30. package/dist/core/utils/manifest.mjs +4 -7
  31. package/dist/core/utils/strings.d.ts +0 -4
  32. package/dist/core/utils/strings.mjs +0 -6
  33. package/dist/core/utils/testing/fake-objects.d.ts +3416 -991
  34. package/dist/core/utils/testing/fake-objects.mjs +19 -22
  35. package/dist/core/utils/transform.d.ts +1 -1
  36. package/dist/core/utils/types.d.ts +2 -0
  37. package/dist/core/utils/validation.mjs +2 -2
  38. package/dist/index.d.ts +5 -0
  39. package/dist/modules.d.ts +1 -1
  40. package/dist/testing/index.d.ts +1 -0
  41. package/dist/testing/wxt-vitest-plugin.mjs +3 -5
  42. package/dist/types.d.ts +48 -70
  43. package/dist/utils/app-config.d.ts +2 -0
  44. package/dist/{client/content-scripts → utils}/content-script-context.d.ts +4 -3
  45. package/dist/{client/content-scripts → utils}/content-script-context.mjs +5 -3
  46. package/dist/utils/content-script-ui/iframe.d.ts +32 -0
  47. package/dist/utils/content-script-ui/iframe.mjs +30 -0
  48. package/dist/utils/content-script-ui/integrated.d.ts +34 -0
  49. package/dist/utils/content-script-ui/integrated.mjs +32 -0
  50. package/dist/utils/content-script-ui/shadow-root.d.ts +76 -0
  51. package/dist/utils/content-script-ui/shadow-root.mjs +73 -0
  52. package/dist/utils/content-script-ui/shared.d.ts +5 -0
  53. package/dist/{client/content-scripts/ui/index.mjs → utils/content-script-ui/shared.mjs} +5 -138
  54. package/dist/{client/content-scripts/ui → utils/content-script-ui}/types.d.ts +0 -96
  55. package/dist/{sandbox → utils}/define-app-config.d.ts +3 -2
  56. package/dist/{sandbox → utils}/define-background.d.ts +1 -0
  57. package/dist/{sandbox → utils}/define-content-script.d.ts +1 -0
  58. package/dist/{sandbox → utils}/define-unlisted-script.d.ts +1 -0
  59. package/dist/{sandbox → utils}/define-wxt-plugin.d.ts +1 -0
  60. package/dist/{sandbox → utils/internal}/dev-server-websocket.mjs +1 -1
  61. package/dist/{client/content-scripts → utils/internal}/location-watcher.d.ts +1 -1
  62. package/dist/utils/match-patterns.d.ts +5 -0
  63. package/dist/utils/match-patterns.mjs +1 -0
  64. package/dist/utils/storage.d.ts +5 -0
  65. package/dist/version.mjs +1 -1
  66. package/dist/virtual/background-entrypoint.mjs +1 -1
  67. package/dist/virtual/content-script-isolated-world-entrypoint.mjs +1 -1
  68. package/package.json +108 -71
  69. package/dist/browser/chrome.d.ts +0 -13
  70. package/dist/browser/index.d.ts +0 -26
  71. package/dist/browser/index.mjs +0 -2
  72. package/dist/client/app-config.d.ts +0 -2
  73. package/dist/client/content-scripts/index.d.ts +0 -2
  74. package/dist/client/content-scripts/index.mjs +0 -2
  75. package/dist/client/content-scripts/ui/index.d.ts +0 -23
  76. package/dist/client/index.d.ts +0 -8
  77. package/dist/client/index.mjs +0 -3
  78. package/dist/core/builders/vite/plugins/resolveExtensionApi.d.ts +0 -10
  79. package/dist/core/builders/vite/plugins/resolveExtensionApi.mjs +0 -15
  80. package/dist/core/define-runner-config.d.ts +0 -2
  81. package/dist/core/define-runner-config.mjs +0 -3
  82. package/dist/core/utils/building/import-entrypoint.d.ts +0 -16
  83. package/dist/core/utils/building/import-entrypoint.mjs +0 -100
  84. package/dist/sandbox/index.d.ts +0 -11
  85. package/dist/sandbox/index.mjs +0 -6
  86. package/dist/storage.d.ts +0 -4
  87. /package/dist/{browser/chrome.mjs → browser.mjs} +0 -0
  88. /package/dist/{client → utils}/app-config.mjs +0 -0
  89. /package/dist/{client/content-scripts/ui → utils/content-script-ui}/types.mjs +0 -0
  90. /package/dist/{sandbox → utils}/define-app-config.mjs +0 -0
  91. /package/dist/{sandbox → utils}/define-background.mjs +0 -0
  92. /package/dist/{sandbox → utils}/define-content-script.mjs +0 -0
  93. /package/dist/{sandbox → utils}/define-unlisted-script.mjs +0 -0
  94. /package/dist/{sandbox → utils}/define-wxt-plugin.mjs +0 -0
  95. /package/dist/{client → utils}/inject-script.d.ts +0 -0
  96. /package/dist/{client → utils}/inject-script.mjs +0 -0
  97. /package/dist/{client/content-scripts → utils/internal}/custom-events.d.ts +0 -0
  98. /package/dist/{client/content-scripts → utils/internal}/custom-events.mjs +0 -0
  99. /package/dist/{sandbox → utils/internal}/dev-server-websocket.d.ts +0 -0
  100. /package/dist/{client/content-scripts → utils/internal}/location-watcher.mjs +0 -0
  101. /package/dist/{sandbox/utils → utils/internal}/logger.d.ts +0 -0
  102. /package/dist/{sandbox/utils → utils/internal}/logger.mjs +0 -0
  103. /package/dist/{storage.mjs → utils/storage.mjs} +0 -0
@@ -11,6 +11,7 @@ import { getEslintVersion } from "./utils/eslint.mjs";
11
11
  import { safeStringToNumber } from "./utils/number.mjs";
12
12
  import { loadEnv } from "./utils/env.mjs";
13
13
  import { getPort } from "get-port-please";
14
+ import { fileURLToPath } from "node:url";
14
15
  export async function resolveConfig(inlineConfig, command) {
15
16
  let userConfig = {};
16
17
  let userConfigMetadata;
@@ -19,10 +20,7 @@ export async function resolveConfig(inlineConfig, command) {
19
20
  configFile: inlineConfig.configFile,
20
21
  name: "wxt",
21
22
  cwd: inlineConfig.root ?? process.cwd(),
22
- rcFile: false,
23
- jitiOptions: {
24
- esmResolve: true
25
- }
23
+ rcFile: false
26
24
  });
27
25
  if (inlineConfig.configFile && metadata.layers?.length === 0) {
28
26
  throw Error(`Config file "${inlineConfig.configFile}" not found`);
@@ -49,28 +47,34 @@ export async function resolveConfig(inlineConfig, command) {
49
47
  srcDir,
50
48
  mergedConfig.entrypointsDir ?? "entrypoints"
51
49
  );
52
- const modulesDir = path.resolve(srcDir, mergedConfig.modulesDir ?? "modules");
53
50
  if (await isDirMissing(entrypointsDir)) {
54
51
  logMissingDir(logger, "Entrypoints", entrypointsDir);
55
52
  }
53
+ const modulesDir = path.resolve(root, mergedConfig.modulesDir ?? "modules");
56
54
  const filterEntrypoints = mergedConfig.filterEntrypoints?.length ? new Set(mergedConfig.filterEntrypoints) : void 0;
57
- const publicDir = path.resolve(srcDir, mergedConfig.publicDir ?? "public");
55
+ const publicDir = path.resolve(root, mergedConfig.publicDir ?? "public");
58
56
  const typesDir = path.resolve(wxtDir, "types");
59
57
  const outBaseDir = path.resolve(root, mergedConfig.outDir ?? ".output");
60
58
  const modeSuffixes = {
61
59
  production: "",
62
60
  development: "-dev"
63
61
  };
64
- const outDirTemplate = (mergedConfig.outDirTemplate ?? `${browser}-mv${manifestVersion}`).replaceAll("{{browser}}", browser).replaceAll("{{manifestVersion}}", manifestVersion.toString()).replaceAll("{{modeSuffix}}", modeSuffixes[mode] ?? `-${mode}`).replaceAll("{{mode}}", mode).replaceAll("{{command}}", command);
62
+ const modeSuffix = modeSuffixes[mode] ?? `-${mode}`;
63
+ const outDirTemplate = (mergedConfig.outDirTemplate ?? `${browser}-mv${manifestVersion}${modeSuffix}`).replaceAll("{{browser}}", browser).replaceAll("{{manifestVersion}}", manifestVersion.toString()).replaceAll("{{modeSuffix}}", modeSuffix).replaceAll("{{mode}}", mode).replaceAll("{{command}}", command);
65
64
  const outDir = path.resolve(outBaseDir, outDirTemplate);
66
65
  const reloadCommand = mergedConfig.dev?.reloadCommand ?? "Alt+R";
66
+ if (inlineConfig.runner != null || userConfig.runner != null) {
67
+ logger.warn(
68
+ "`InlineConfig#runner` is deprecated, use `InlineConfig#webExt` instead. See https://wxt.dev/guide/resources/upgrading.html#v0-19-0-rarr-v0-20-0"
69
+ );
70
+ }
67
71
  const runnerConfig = await loadConfig({
68
72
  name: "web-ext",
69
73
  cwd: root,
70
74
  globalRc: true,
71
75
  rcFile: ".webextrc",
72
- overrides: inlineConfig.runner,
73
- defaults: userConfig.runner
76
+ overrides: inlineConfig.webExt ?? inlineConfig.runner,
77
+ defaults: userConfig.webExt ?? userConfig.runner
74
78
  });
75
79
  const alias = Object.fromEntries(
76
80
  Object.entries({
@@ -113,7 +117,6 @@ export async function resolveConfig(inlineConfig, command) {
113
117
  },
114
118
  {}
115
119
  );
116
- const extensionApi = mergedConfig.extensionApi ?? "webextension-polyfill";
117
120
  return {
118
121
  browser,
119
122
  command,
@@ -123,13 +126,7 @@ export async function resolveConfig(inlineConfig, command) {
123
126
  filterEntrypoints,
124
127
  env,
125
128
  fsCache: createFsCache(wxtDir),
126
- imports: await getUnimportOptions(
127
- wxtDir,
128
- srcDir,
129
- logger,
130
- extensionApi,
131
- mergedConfig
132
- ),
129
+ imports: await getUnimportOptions(wxtDir, srcDir, logger, mergedConfig),
133
130
  logger,
134
131
  manifest: await resolveManifestConfig(env, mergedConfig.manifest),
135
132
  manifestVersion,
@@ -144,12 +141,9 @@ export async function resolveConfig(inlineConfig, command) {
144
141
  typesDir,
145
142
  wxtDir,
146
143
  zip: resolveZipConfig(root, browser, outBaseDir, mergedConfig),
147
- transformManifest: mergedConfig.transformManifest,
148
144
  analysis: resolveAnalysisConfig(root, mergedConfig),
149
145
  userConfigMetadata: userConfigMetadata ?? {},
150
146
  alias,
151
- extensionApi,
152
- entrypointLoader: mergedConfig.entrypointLoader ?? "vite-node",
153
147
  experimental: defu(mergedConfig.experimental, {}),
154
148
  dev: {
155
149
  server: devServerConfig,
@@ -173,10 +167,6 @@ async function mergeInlineConfig(inlineConfig, userConfig) {
173
167
  const inline = await resolveManifestConfig(env, inlineConfig.manifest);
174
168
  return defu(inline, user);
175
169
  };
176
- const transformManifest = (manifest2) => {
177
- userConfig.transformManifest?.(manifest2);
178
- inlineConfig.transformManifest?.(manifest2);
179
- };
180
170
  const merged = defu(inlineConfig, userConfig);
181
171
  const builderConfig = await mergeBuilderConfig(
182
172
  merged.logger ?? consola,
@@ -186,7 +176,6 @@ async function mergeInlineConfig(inlineConfig, userConfig) {
186
176
  return {
187
177
  ...merged,
188
178
  // Custom merge values
189
- transformManifest,
190
179
  imports,
191
180
  manifest,
192
181
  ...builderConfig
@@ -239,34 +228,136 @@ function resolveAnalysisConfig(root, mergedConfig) {
239
228
  keepArtifacts: mergedConfig.analysis?.keepArtifacts ?? false
240
229
  };
241
230
  }
242
- async function getUnimportOptions(wxtDir, srcDir, logger, extensionApi, config) {
243
- if (config.imports === false) return false;
231
+ async function getUnimportOptions(wxtDir, srcDir, logger, config) {
232
+ const disabled = config.imports === false;
233
+ const eslintrc = await getUnimportEslintOptions(wxtDir, config.imports);
234
+ const invalidExports = ["options"];
235
+ const defineImportsAndTypes = (imports, typeImports) => [
236
+ ...imports,
237
+ ...typeImports.map((name) => ({ name, type: true }))
238
+ ];
244
239
  const defaultOptions = {
245
- debugLog: logger.debug,
246
- imports: [
247
- { name: "defineConfig", from: "wxt" },
248
- { name: "fakeBrowser", from: "wxt/testing" }
249
- ],
240
+ imports: [{ name: "fakeBrowser", from: "wxt/testing" }],
250
241
  presets: [
251
242
  {
252
- package: "wxt/client",
253
- // There seems to be a bug in unimport that thinks "options" is an
254
- // export from wxt/client, but it doesn't actually exist... so it's
255
- // ignored.
256
- ignore: ["options"]
243
+ from: "wxt/browser",
244
+ imports: defineImportsAndTypes(["browser"], [])
245
+ },
246
+ {
247
+ from: "wxt/utils/storage",
248
+ imports: defineImportsAndTypes(
249
+ ["storage"],
250
+ [
251
+ "StorageArea",
252
+ "WxtStorage",
253
+ "WxtStorageItem",
254
+ "StorageArea",
255
+ "StorageItemKey",
256
+ "StorageAreaChanges",
257
+ "MigrationError"
258
+ ]
259
+ )
260
+ },
261
+ {
262
+ from: "wxt/utils/app-config",
263
+ imports: defineImportsAndTypes(["useAppConfig"], [])
264
+ },
265
+ {
266
+ from: "wxt/utils/content-script-context",
267
+ imports: defineImportsAndTypes(
268
+ ["ContentScriptContext"],
269
+ ["WxtWindowEventMap"]
270
+ )
271
+ },
272
+ {
273
+ from: "wxt/utils/content-script-ui/iframe",
274
+ imports: defineImportsAndTypes(
275
+ ["createIframeUi"],
276
+ ["IframeContentScriptUi", "IframeContentScriptUiOptions"]
277
+ ),
278
+ ignore: invalidExports
279
+ },
280
+ {
281
+ from: "wxt/utils/content-script-ui/integrated",
282
+ imports: defineImportsAndTypes(
283
+ ["createIntegratedUi"],
284
+ ["IntegratedContentScriptUi", "IntegratedContentScriptUiOptions"]
285
+ ),
286
+ ignore: invalidExports
287
+ },
288
+ {
289
+ from: "wxt/utils/content-script-ui/shadow-root",
290
+ imports: defineImportsAndTypes(
291
+ ["createShadowRootUi"],
292
+ ["ShadowRootContentScriptUi", "ShadowRootContentScriptUiOptions"]
293
+ ),
294
+ ignore: invalidExports
295
+ },
296
+ {
297
+ from: "wxt/utils/content-script-ui/types",
298
+ imports: defineImportsAndTypes(
299
+ [],
300
+ [
301
+ "ContentScriptUi",
302
+ "ContentScriptUiOptions",
303
+ "ContentScriptOverlayAlignment",
304
+ "ContentScriptAppendMode",
305
+ "ContentScriptInlinePositioningOptions",
306
+ "ContentScriptOverlayPositioningOptions",
307
+ "ContentScriptModalPositioningOptions",
308
+ "ContentScriptPositioningOptions",
309
+ "ContentScriptAnchoredOptions",
310
+ "AutoMountOptions",
311
+ "StopAutoMount",
312
+ "AutoMount"
313
+ ]
314
+ )
315
+ },
316
+ {
317
+ from: "wxt/utils/define-app-config",
318
+ imports: defineImportsAndTypes(["defineAppConfig"], ["WxtAppConfig"])
319
+ },
320
+ {
321
+ from: "wxt/utils/define-background",
322
+ imports: defineImportsAndTypes(["defineBackground"], [])
323
+ },
324
+ {
325
+ from: "wxt/utils/define-content-script",
326
+ imports: defineImportsAndTypes(["defineContentScript"], [])
257
327
  },
258
328
  {
259
- package: extensionApi === "chrome" ? "wxt/browser/chrome" : "wxt/browser"
329
+ from: "wxt/utils/define-unlisted-script",
330
+ imports: defineImportsAndTypes(["defineUnlistedScript"], [])
260
331
  },
261
- { package: "wxt/sandbox" },
262
- { package: "wxt/storage" }
332
+ {
333
+ from: "wxt/utils/define-wxt-plugin",
334
+ imports: defineImportsAndTypes(["defineWxtPlugin"], [])
335
+ },
336
+ {
337
+ from: "wxt/utils/inject-script",
338
+ imports: defineImportsAndTypes(
339
+ ["injectScript"],
340
+ ["ScriptPublicPath", "InjectScriptOptions"]
341
+ ),
342
+ ignore: invalidExports
343
+ },
344
+ {
345
+ from: "wxt/utils/match-patterns",
346
+ imports: defineImportsAndTypes(
347
+ ["InvalidMatchPattern", "MatchPattern"],
348
+ []
349
+ )
350
+ }
263
351
  ],
352
+ virtualImports: ["#imports"],
353
+ debugLog: logger.debug,
264
354
  warn: logger.warn,
265
- dirs: ["components", "composables", "hooks", "utils"],
266
355
  dirsScanOptions: {
267
356
  cwd: srcDir
268
357
  },
269
- eslintrc: await getUnimportEslintOptions(wxtDir, config.imports?.eslintrc)
358
+ eslintrc,
359
+ dirs: disabled ? [] : ["components", "composables", "hooks", "utils"],
360
+ disabled
270
361
  };
271
362
  return defu(
272
363
  config.imports ?? {},
@@ -274,35 +365,35 @@ async function getUnimportOptions(wxtDir, srcDir, logger, extensionApi, config)
274
365
  );
275
366
  }
276
367
  async function getUnimportEslintOptions(wxtDir, options) {
277
- const rawEslintEnabled = options?.enabled ?? "auto";
278
- let eslintEnabled;
279
- switch (rawEslintEnabled) {
368
+ const inlineEnabled = options === false ? false : options?.eslintrc?.enabled ?? "auto";
369
+ let enabled;
370
+ switch (inlineEnabled) {
280
371
  case "auto":
281
372
  const version = await getEslintVersion();
282
373
  let major = parseInt(version[0]);
283
- if (isNaN(major)) eslintEnabled = false;
284
- if (major <= 8) eslintEnabled = 8;
285
- else if (major >= 9) eslintEnabled = 9;
286
- else eslintEnabled = false;
374
+ if (isNaN(major)) enabled = false;
375
+ if (major <= 8) enabled = 8;
376
+ else if (major >= 9) enabled = 9;
377
+ else enabled = false;
287
378
  break;
288
379
  case true:
289
- eslintEnabled = 8;
380
+ enabled = 8;
290
381
  break;
291
382
  default:
292
- eslintEnabled = rawEslintEnabled;
383
+ enabled = inlineEnabled;
293
384
  }
294
385
  return {
295
- enabled: eslintEnabled,
386
+ enabled,
296
387
  filePath: path.resolve(
297
388
  wxtDir,
298
- eslintEnabled === 9 ? "eslint-auto-imports.mjs" : "eslintrc-auto-import.json"
389
+ enabled === 9 ? "eslint-auto-imports.mjs" : "eslintrc-auto-import.json"
299
390
  ),
300
391
  globalsPropValue: true
301
392
  };
302
393
  }
303
394
  async function resolveWxtModuleDir() {
304
- const requireResolve = globalThis.require?.resolve ?? (await import("node:module")).default.createRequire(import.meta.url).resolve;
305
- return path.resolve(requireResolve("wxt"), "../..");
395
+ const url = import.meta.resolve("wxt", import.meta.url);
396
+ return path.resolve(fileURLToPath(url), "../..");
306
397
  }
307
398
  async function isDirMissing(dir) {
308
399
  return !await fs.exists(dir);
@@ -380,3 +471,9 @@ export async function resolveWxtUserModules(modulesDir, modules = []) {
380
471
  );
381
472
  return [...npmModules, ...localModules];
382
473
  }
474
+ if (false) {
475
+ (void 0).resolve = (path2) => (
476
+ // @ts-expect-error: vitestCreateRequire defined in vitest.setup.ts
477
+ "file://" + vitestCreateRequire(import.meta.url).resolve(path2)
478
+ );
479
+ }
@@ -21,7 +21,7 @@ export function createWebExtRunner() {
21
21
  };
22
22
  const wxtUserConfig = wxt.config.runnerConfig.config;
23
23
  const userConfig = {
24
- console: wxtUserConfig?.openConsole,
24
+ browserConsole: wxtUserConfig?.openConsole,
25
25
  devtools: wxtUserConfig?.openDevtools,
26
26
  startUrl: wxtUserConfig?.startUrls,
27
27
  keepProfileChanges: wxtUserConfig?.keepProfileChanges,
@@ -45,6 +45,7 @@ export async function findEntrypoints() {
45
45
  }
46
46
  return results;
47
47
  }, []);
48
+ await wxt.hooks.callHook("entrypoints:found", wxt, entrypointInfos);
48
49
  preventNoEntrypoints(entrypointInfos);
49
50
  preventDuplicateEntrypointNames(entrypointInfos);
50
51
  let hasBackground = false;
@@ -108,6 +109,7 @@ export async function findEntrypoints() {
108
109
  ...entry,
109
110
  skipped: isEntrypointSkipped(entry)
110
111
  }));
112
+ await wxt.hooks.callHook("entrypoints:resolved", wxt, entrypoints);
111
113
  wxt.logger.debug("All entrypoints:", entrypoints);
112
114
  const skippedEntrypointNames = entrypoints.filter((item) => item.skipped).map((item) => item.name);
113
115
  if (skippedEntrypointNames.length) {
@@ -120,7 +122,6 @@ export async function findEntrypoints() {
120
122
  ].join("\n")
121
123
  );
122
124
  }
123
- await wxt.hooks.callHook("entrypoints:resolved", wxt, entrypoints);
124
125
  return entrypoints;
125
126
  }
126
127
  async function importEntrypoints(infos) {
@@ -2,6 +2,5 @@ export * from './build-entrypoints';
2
2
  export * from './detect-dev-changes';
3
3
  export * from './find-entrypoints';
4
4
  export * from './group-entrypoints';
5
- export * from './import-entrypoint';
6
5
  export * from './internal-build';
7
6
  export * from './rebuild';
@@ -2,6 +2,5 @@ export * from "./build-entrypoints.mjs";
2
2
  export * from "./detect-dev-changes.mjs";
3
3
  export * from "./find-entrypoints.mjs";
4
4
  export * from "./group-entrypoints.mjs";
5
- export * from "./import-entrypoint.mjs";
6
5
  export * from "./internal-build.mjs";
7
6
  export * from "./rebuild.mjs";
@@ -1,4 +1,3 @@
1
- import type { Manifest } from 'wxt/browser';
2
1
  import { BuildOutput, Entrypoint, EntrypointGroup } from '../../../types';
3
2
  /**
4
3
  * Given a configuration, list of entrypoints, and an existing, partial output, build the
@@ -18,6 +17,6 @@ import { BuildOutput, Entrypoint, EntrypointGroup } from '../../../types';
18
17
  */
19
18
  export declare function rebuild(allEntrypoints: Entrypoint[], entrypointGroups: EntrypointGroup[], existingOutput?: Omit<BuildOutput, 'manifest'>): Promise<{
20
19
  output: BuildOutput;
21
- manifest: Manifest.WebExtensionManifest;
20
+ manifest: chrome.runtime.Manifest;
22
21
  warnings: any[][];
23
22
  }>;
@@ -1,11 +1,11 @@
1
- import type { Manifest, Scripting } from 'wxt/browser';
2
1
  import { ContentScriptEntrypoint, ResolvedConfig } from '../../types';
2
+ import { ManifestContentScript } from './types';
3
3
  /**
4
4
  * Returns a unique and consistent string hash based on a content scripts options.
5
5
  *
6
6
  * It is able to recognize default values,
7
7
  */
8
8
  export declare function hashContentScriptOptions(options: ContentScriptEntrypoint['options']): string;
9
- export declare function mapWxtOptionsToContentScript(options: ContentScriptEntrypoint['options'], js: string[] | undefined, css: string[] | undefined): Manifest.ContentScript;
10
- export declare function mapWxtOptionsToRegisteredContentScript(options: ContentScriptEntrypoint['options'], js: string[] | undefined, css: string[] | undefined): Omit<Scripting.RegisteredContentScript, 'id'>;
9
+ export declare function mapWxtOptionsToContentScript(options: ContentScriptEntrypoint['options'], js: string[] | undefined, css: string[] | undefined): ManifestContentScript;
10
+ export declare function mapWxtOptionsToRegisteredContentScript(options: ContentScriptEntrypoint['options'], js: string[] | undefined, css: string[] | undefined): Omit<chrome.scripting.RegisteredContentScript, 'id'>;
11
11
  export declare function getContentScriptJs(config: ResolvedConfig, entrypoint: ContentScriptEntrypoint): string[];
@@ -15,6 +15,7 @@ export function hashContentScriptOptions(options) {
15
15
  match_about_blank: false,
16
16
  run_at: "document_idle",
17
17
  all_frames: false,
18
+ // @ts-expect-error: Untyped
18
19
  match_origin_as_fallback: false,
19
20
  world: "ISOLATED",
20
21
  ...simplifiedOptions
@@ -37,6 +38,7 @@ export function mapWxtOptionsToContentScript(options, js, css) {
37
38
  run_at: options.runAt,
38
39
  css,
39
40
  js,
41
+ // @ts-expect-error: Untyped
40
42
  match_origin_as_fallback: options.matchOriginAsFallback,
41
43
  world: options.world
42
44
  };
@@ -1,10 +1,8 @@
1
+ const ESLINT_PACKAGE_NAME = "eslint";
1
2
  export async function getEslintVersion() {
2
3
  try {
3
- const require = (await import("node:module")).default.createRequire(
4
- import.meta.url
5
- );
6
- const { ESLint } = require("eslint");
7
- return ESLint.version?.split(".") ?? [];
4
+ const { version } = await import(ESLINT_PACKAGE_NAME);
5
+ return version.split(".") ?? [];
8
6
  } catch {
9
7
  return [];
10
8
  }
@@ -1,14 +1,13 @@
1
- import type { Manifest } from 'wxt/browser';
2
1
  import { Entrypoint, BuildOutput, ContentScriptEntrypoint } from '../../types';
3
2
  /**
4
3
  * Writes the manifest to the output directory and the build output.
5
4
  */
6
- export declare function writeManifest(manifest: Manifest.WebExtensionManifest, output: BuildOutput): Promise<void>;
5
+ export declare function writeManifest(manifest: chrome.runtime.Manifest, output: BuildOutput): Promise<void>;
7
6
  /**
8
7
  * Generates the manifest based on the config and entrypoints.
9
8
  */
10
9
  export declare function generateManifest(allEntrypoints: Entrypoint[], buildOutput: Omit<BuildOutput, 'manifest'>): Promise<{
11
- manifest: Manifest.WebExtensionManifest;
10
+ manifest: chrome.runtime.Manifest;
12
11
  warnings: any[][];
13
12
  }>;
14
13
  /**
@@ -37,8 +36,4 @@ export declare function stripPathFromMatchPattern(pattern: string): string;
37
36
  * generated in this file, and may be defined by the user in their manifest. In both cases, when
38
37
  * targeting MV2, automatically convert their definitions down to the basic MV2 array.
39
38
  */
40
- export declare function convertWebAccessibleResourcesToMv2(manifest: Manifest.WebExtensionManifest): void;
41
- /**
42
- * Make sure all resources are in MV3 format. If not, add a wanring
43
- */
44
- export declare function validateMv3WebAccessibleResources(manifest: Manifest.WebExtensionManifest): void;
39
+ export declare function convertWebAccessibleResourcesToMv2(manifest: chrome.runtime.Manifest): void;
@@ -41,10 +41,7 @@ export async function generateManifest(allEntrypoints, buildOutput) {
41
41
  icons: discoverIcons(buildOutput)
42
42
  };
43
43
  const userManifest = wxt.config.manifest;
44
- let manifest = defu(
45
- userManifest,
46
- baseManifest
47
- );
44
+ let manifest = defu(userManifest, baseManifest);
48
45
  if (wxt.config.command === "serve" && wxt.config.dev.reloadCommand) {
49
46
  if (manifest.commands && // If the following limit is exceeded, Chrome will fail to load the extension.
50
47
  // Error: "Too many commands specified for 'commands': The maximum is 4."
@@ -70,7 +67,6 @@ export async function generateManifest(allEntrypoints, buildOutput) {
70
67
  addEntrypoints(manifest, entrypoints, buildOutput);
71
68
  if (wxt.config.command === "serve") addDevModeCsp(manifest);
72
69
  if (wxt.config.command === "serve") addDevModePermissions(manifest);
73
- wxt.config.transformManifest?.(manifest);
74
70
  await wxt.hooks.callHook("build:manifestGenerated", wxt, manifest);
75
71
  if (wxt.config.manifestVersion === 2) {
76
72
  convertWebAccessibleResourcesToMv2(manifest);
@@ -220,6 +216,7 @@ function addEntrypoints(manifest, entrypoints, buildOutput) {
220
216
  const page = getEntrypointBundlePath(options, wxt.config.outDir, ".html");
221
217
  manifest.options_ui = {
222
218
  open_in_tab: options.options.openInTab,
219
+ // @ts-expect-error: Not typed by @types/chrome, but supported by Firefox
223
220
  browser_style: wxt.config.browser === "firefox" ? options.options.browserStyle : void 0,
224
221
  chrome_style: wxt.config.browser !== "firefox" ? options.options.chromeStyle : void 0,
225
222
  page
@@ -400,7 +397,7 @@ export function getContentScriptCssWebAccessibleResources(contentScripts, conten
400
397
  resources: [cssFile],
401
398
  matches: script.options.matches?.map(
402
399
  (matchPattern) => stripPathFromMatchPattern(matchPattern)
403
- )
400
+ ) ?? []
404
401
  });
405
402
  });
406
403
  return resources;
@@ -460,7 +457,7 @@ function convertCspToMv2(manifest) {
460
457
  return;
461
458
  manifest.content_security_policy = manifest.content_security_policy.extension_pages;
462
459
  }
463
- export function validateMv3WebAccessibleResources(manifest) {
460
+ function validateMv3WebAccessibleResources(manifest) {
464
461
  if (manifest.web_accessible_resources == null) return;
465
462
  const stringResources = manifest.web_accessible_resources.filter(
466
463
  (item) => typeof item === "string"
@@ -12,7 +12,3 @@ export declare function safeFilename(str: string): string;
12
12
  * calls.
13
13
  */
14
14
  export declare function removeImportStatements(text: string): string;
15
- /**
16
- * Removes imports, ensuring that some of WXT's client imports are present, so that entrypoints can be parsed if auto-imports are disabled.
17
- */
18
- export declare function removeProjectImportStatements(text: string): string;
@@ -16,9 +16,3 @@ export function removeImportStatements(text) {
16
16
  ""
17
17
  );
18
18
  }
19
- export function removeProjectImportStatements(text) {
20
- const noImports = removeImportStatements(text);
21
- return `import { defineUnlistedScript, defineContentScript, defineBackground } from 'wxt/sandbox';
22
-
23
- ${noImports}`;
24
- }