wxt 0.3.2 → 0.4.0

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,6 +1,7 @@
1
1
  import * as vite from 'vite';
2
2
  import { Manifest, Scripting } from 'webextension-polyfill';
3
3
  import { UnimportOptions } from 'unimport';
4
+ import { LogLevel } from 'consola';
4
5
 
5
6
  interface InlineConfig {
6
7
  /**
@@ -28,11 +29,19 @@ interface InlineConfig {
28
29
  */
29
30
  entrypointsDir?: string;
30
31
  /**
32
+ * > Only available when using the JS API. Not available in `wxt.config.ts` files
33
+ *
31
34
  * Path to `"wxt.config.ts"` file or false to disable config file discovery.
32
35
  *
33
36
  * @default "wxt.config.ts"
34
37
  */
35
38
  configFile?: string | false;
39
+ /**
40
+ * Set to `true` to show debug logs. Overriden by the command line `--debug` option.
41
+ *
42
+ * @default false
43
+ */
44
+ debug?: boolean;
36
45
  /**
37
46
  * ID of the extension for each store. Used for publishing.
38
47
  */
@@ -207,6 +216,7 @@ interface Logger {
207
216
  error(...args: any[]): void;
208
217
  fatal(...args: any[]): void;
209
218
  success(...args: any[]): void;
219
+ level: LogLevel;
210
220
  }
211
221
  interface BaseEntrypoint {
212
222
  /**
@@ -326,7 +336,7 @@ interface BackgroundScriptDefintition {
326
336
  * Manifest customization available in the `wxt.config.ts` file. You cannot configure entrypoints
327
337
  * here, they are configured inline.
328
338
  */
329
- type UserManifest = Partial<Omit<Manifest.WebExtensionManifest, 'action' | 'background' | 'browser_action' | 'chrome_url_overrides' | 'content_scripts' | 'devtools_page' | 'manifest_version' | 'options_page' | 'options_ui' | 'sandbox' | 'page_action' | 'popup' | 'sidepanel' | 'sidebar_action'>>;
339
+ type UserManifest = Partial<Omit<Manifest.WebExtensionManifest, 'action' | 'background' | 'browser_action' | 'chrome_url_overrides' | 'devtools_page' | 'manifest_version' | 'options_page' | 'options_ui' | 'sandbox' | 'page_action' | 'popup' | 'sidepanel' | 'sidebar_action'>>;
330
340
  type UserManifestFn = (env: ConfigEnv) => UserManifest | Promise<UserManifest>;
331
341
  interface ConfigEnv {
332
342
  mode: string;
@@ -401,7 +411,7 @@ interface ExtensionRunnerConfig {
401
411
 
402
412
  type EntrypointGroup = Entrypoint | Entrypoint[];
403
413
 
404
- var version = "0.3.2";
414
+ var version = "0.4.0";
405
415
 
406
416
  declare function defineConfig(config: UserConfig): UserConfig;
407
417
 
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import * as vite from 'vite';
2
2
  import { Manifest, Scripting } from 'webextension-polyfill';
3
3
  import { UnimportOptions } from 'unimport';
4
+ import { LogLevel } from 'consola';
4
5
 
5
6
  interface InlineConfig {
6
7
  /**
@@ -28,11 +29,19 @@ interface InlineConfig {
28
29
  */
29
30
  entrypointsDir?: string;
30
31
  /**
32
+ * > Only available when using the JS API. Not available in `wxt.config.ts` files
33
+ *
31
34
  * Path to `"wxt.config.ts"` file or false to disable config file discovery.
32
35
  *
33
36
  * @default "wxt.config.ts"
34
37
  */
35
38
  configFile?: string | false;
39
+ /**
40
+ * Set to `true` to show debug logs. Overriden by the command line `--debug` option.
41
+ *
42
+ * @default false
43
+ */
44
+ debug?: boolean;
36
45
  /**
37
46
  * ID of the extension for each store. Used for publishing.
38
47
  */
@@ -207,6 +216,7 @@ interface Logger {
207
216
  error(...args: any[]): void;
208
217
  fatal(...args: any[]): void;
209
218
  success(...args: any[]): void;
219
+ level: LogLevel;
210
220
  }
211
221
  interface BaseEntrypoint {
212
222
  /**
@@ -326,7 +336,7 @@ interface BackgroundScriptDefintition {
326
336
  * Manifest customization available in the `wxt.config.ts` file. You cannot configure entrypoints
327
337
  * here, they are configured inline.
328
338
  */
329
- type UserManifest = Partial<Omit<Manifest.WebExtensionManifest, 'action' | 'background' | 'browser_action' | 'chrome_url_overrides' | 'content_scripts' | 'devtools_page' | 'manifest_version' | 'options_page' | 'options_ui' | 'sandbox' | 'page_action' | 'popup' | 'sidepanel' | 'sidebar_action'>>;
339
+ type UserManifest = Partial<Omit<Manifest.WebExtensionManifest, 'action' | 'background' | 'browser_action' | 'chrome_url_overrides' | 'devtools_page' | 'manifest_version' | 'options_page' | 'options_ui' | 'sandbox' | 'page_action' | 'popup' | 'sidepanel' | 'sidebar_action'>>;
330
340
  type UserManifestFn = (env: ConfigEnv) => UserManifest | Promise<UserManifest>;
331
341
  interface ConfigEnv {
332
342
  mode: string;
@@ -401,7 +411,7 @@ interface ExtensionRunnerConfig {
401
411
 
402
412
  type EntrypointGroup = Entrypoint | Entrypoint[];
403
413
 
404
- var version = "0.3.2";
414
+ var version = "0.4.0";
405
415
 
406
416
  declare function defineConfig(config: UserConfig): UserConfig;
407
417
 
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // src/core/utils/getInternalConfig.ts
2
2
  import path2, { resolve as resolve6 } from "node:path";
3
3
  import * as vite2 from "vite";
4
- import { consola } from "consola";
4
+ import { LogLevels, consola } from "consola";
5
5
 
6
6
  // src/core/utils/entrypoints.ts
7
7
  import path, { relative, resolve } from "node:path";
@@ -9,11 +9,11 @@ import path, { relative, resolve } from "node:path";
9
9
  // src/core/utils/paths.ts
10
10
  import nodePath from "node:path";
11
11
  import * as vite from "vite";
12
- function normalizePath2(path5) {
13
- return vite.normalizePath(path5);
12
+ function normalizePath2(path6) {
13
+ return vite.normalizePath(path6);
14
14
  }
15
- function unnormalizePath(path5) {
16
- return nodePath.normalize(path5);
15
+ function unnormalizePath(path6) {
16
+ return nodePath.normalize(path6);
17
17
  }
18
18
  var CSS_EXTENSIONS = ["css", "scss", "sass", "less", "styl", "stylus"];
19
19
  var CSS_EXTENSIONS_PATTERN = `+(${CSS_EXTENSIONS.join("|")})`;
@@ -195,7 +195,9 @@ function multipageMove(entrypoints, config) {
195
195
  (entry) => !!normalizePath2(entry.inputPath).endsWith(oldBundlePath)
196
196
  );
197
197
  if (entrypoint == null) {
198
- config.logger.debug("No entrypoint found for", oldBundlePath);
198
+ config.logger.debug(
199
+ `No entrypoint found for ${oldBundlePath}, leaving in chunks directory`
200
+ );
199
201
  continue;
200
202
  }
201
203
  const newBundlePath = getEntrypointBundlePath(
@@ -302,12 +304,22 @@ function virtualEntrypoin(type, config) {
302
304
  }
303
305
 
304
306
  // src/core/vite-plugins/tsconfigPaths.ts
305
- import paths from "vite-tsconfig-paths";
306
307
  function tsconfigPaths(config) {
307
- const fn = typeof paths === "function" ? paths : paths.default;
308
- return fn({
309
- root: config.root
310
- });
308
+ return {
309
+ name: "wxt:aliases",
310
+ async config() {
311
+ return {
312
+ resolve: {
313
+ alias: {
314
+ "@@": config.root,
315
+ "~~": config.root,
316
+ "@": config.srcDir,
317
+ "~": config.srcDir
318
+ }
319
+ }
320
+ };
321
+ }
322
+ };
311
323
  }
312
324
 
313
325
  // src/core/vite-plugins/noopBackground.ts
@@ -361,14 +373,14 @@ function createFsCache(wxtDir) {
361
373
  const getPath = (key) => resolve5(wxtDir, "cache", encodeURIComponent(key));
362
374
  return {
363
375
  async set(key, value) {
364
- const path5 = getPath(key);
365
- await ensureDir2(dirname3(path5));
366
- await fs3.writeFile(path5, value, "utf-8");
376
+ const path6 = getPath(key);
377
+ await ensureDir2(dirname3(path6));
378
+ await fs3.writeFile(path6, value, "utf-8");
367
379
  },
368
380
  async get(key) {
369
- const path5 = getPath(key);
381
+ const path6 = getPath(key);
370
382
  try {
371
- return await fs3.readFile(path5, "utf-8");
383
+ return await fs3.readFile(path6, "utf-8");
372
384
  } catch {
373
385
  return void 0;
374
386
  }
@@ -432,6 +444,9 @@ async function getInternalConfig(config, command) {
432
444
  const outBaseDir = path2.resolve(root, ".output");
433
445
  const outDir = path2.resolve(outBaseDir, `${browser}-mv${manifestVersion}`);
434
446
  const logger = config.logger ?? consola;
447
+ const debug = !!config.debug;
448
+ if (debug)
449
+ logger.level = LogLevels.debug;
435
450
  const baseConfig = {
436
451
  root,
437
452
  outDir,
@@ -441,6 +456,7 @@ async function getInternalConfig(config, command) {
441
456
  manifestVersion,
442
457
  mode,
443
458
  command,
459
+ debug,
444
460
  logger,
445
461
  vite: config.vite ?? {},
446
462
  imports: config.imports ?? {},
@@ -473,7 +489,7 @@ async function getInternalConfig(config, command) {
473
489
  userConfig.entrypointsDir ?? "entrypoints"
474
490
  );
475
491
  const publicDir = resolve6(root, userConfig.publicDir ?? "public");
476
- const wxtDir = resolve6(srcDir, ".wxt");
492
+ const wxtDir = resolve6(root, ".wxt");
477
493
  const typesDir = resolve6(wxtDir, "types");
478
494
  const env = { mode, browser, manifestVersion, command };
479
495
  const userManifest = await resolveManifestConfig(env, userConfig.manifest);
@@ -809,16 +825,16 @@ function removeImportStatements(text) {
809
825
  }
810
826
 
811
827
  // src/core/utils/importTsFile.ts
812
- async function importTsFile(path5, config) {
813
- config.logger.debug("Loading file metadata:", path5);
814
- const normalPath = normalizePath2(path5);
828
+ async function importTsFile(path6, config) {
829
+ config.logger.debug("Loading file metadata:", path6);
830
+ const normalPath = normalizePath2(path6);
815
831
  const unimport2 = createUnimport2({
816
832
  ...getUnimportOptions(config),
817
833
  // Only allow specific imports, not all from the project
818
834
  dirs: []
819
835
  });
820
836
  await unimport2.init();
821
- const text = await fs7.readFile(path5, "utf-8");
837
+ const text = await fs7.readFile(path6, "utf-8");
822
838
  const textNoImports = removeImportStatements(text);
823
839
  const { code } = await unimport2.injectImports(textNoImports);
824
840
  config.logger.debug(
@@ -842,7 +858,7 @@ async function importTsFile(path5, config) {
842
858
  }
843
859
  });
844
860
  try {
845
- return await jiti(path5);
861
+ return await jiti(path6);
846
862
  } catch (err) {
847
863
  config.logger.error(err);
848
864
  throw err;
@@ -862,7 +878,7 @@ async function findEntrypoints(config) {
862
878
  let hasBackground = false;
863
879
  await Promise.all(
864
880
  relativePaths.map(async (relativePath) => {
865
- const path5 = resolve9(config.entrypointsDir, relativePath);
881
+ const path6 = resolve9(config.entrypointsDir, relativePath);
866
882
  const matchingGlob = pathGlobs.find(
867
883
  (glob3) => minimatch(relativePath, glob3)
868
884
  );
@@ -882,35 +898,35 @@ ${JSON.stringify(
882
898
  let entrypoint;
883
899
  switch (type) {
884
900
  case "popup":
885
- entrypoint = await getPopupEntrypoint(config, path5);
901
+ entrypoint = await getPopupEntrypoint(config, path6);
886
902
  break;
887
903
  case "options":
888
- entrypoint = await getOptionsEntrypoint(config, path5);
904
+ entrypoint = await getOptionsEntrypoint(config, path6);
889
905
  break;
890
906
  case "background":
891
- entrypoint = await getBackgroundEntrypoint(config, path5);
907
+ entrypoint = await getBackgroundEntrypoint(config, path6);
892
908
  hasBackground = true;
893
909
  break;
894
910
  case "content-script":
895
911
  entrypoint = await getContentScriptEntrypoint(
896
912
  config,
897
- getEntrypointName(config.entrypointsDir, path5),
898
- path5
913
+ getEntrypointName(config.entrypointsDir, path6),
914
+ path6
899
915
  );
900
916
  break;
901
917
  case "content-script-style":
902
918
  entrypoint = {
903
919
  type,
904
- name: getEntrypointName(config.entrypointsDir, path5),
905
- inputPath: path5,
920
+ name: getEntrypointName(config.entrypointsDir, path6),
921
+ inputPath: path6,
906
922
  outputDir: resolve9(config.outDir, CONTENT_SCRIPT_OUT_DIR)
907
923
  };
908
924
  break;
909
925
  default:
910
926
  entrypoint = {
911
927
  type,
912
- name: getEntrypointName(config.entrypointsDir, path5),
913
- inputPath: path5,
928
+ name: getEntrypointName(config.entrypointsDir, path6),
929
+ inputPath: path6,
914
930
  outputDir: config.outDir
915
931
  };
916
932
  }
@@ -934,9 +950,9 @@ ${JSON.stringify(
934
950
  }
935
951
  return entrypoints;
936
952
  }
937
- async function getPopupEntrypoint(config, path5) {
953
+ async function getPopupEntrypoint(config, path6) {
938
954
  const options = {};
939
- const content = await fs8.readFile(path5, "utf-8");
955
+ const content = await fs8.readFile(path6, "utf-8");
940
956
  const { document } = parseHTML2(content);
941
957
  const title = document.querySelector("title");
942
958
  if (title != null)
@@ -960,13 +976,13 @@ async function getPopupEntrypoint(config, path5) {
960
976
  type: "popup",
961
977
  name: "popup",
962
978
  options,
963
- inputPath: path5,
979
+ inputPath: path6,
964
980
  outputDir: config.outDir
965
981
  };
966
982
  }
967
- async function getOptionsEntrypoint(config, path5) {
983
+ async function getOptionsEntrypoint(config, path6) {
968
984
  const options = {};
969
- const content = await fs8.readFile(path5, "utf-8");
985
+ const content = await fs8.readFile(path6, "utf-8");
970
986
  const { document } = parseHTML2(content);
971
987
  const openInTabContent = document.querySelector("meta[name='manifest.open_in_tab']")?.getAttribute("content");
972
988
  if (openInTabContent) {
@@ -984,15 +1000,15 @@ async function getOptionsEntrypoint(config, path5) {
984
1000
  type: "options",
985
1001
  name: "options",
986
1002
  options,
987
- inputPath: path5,
1003
+ inputPath: path6,
988
1004
  outputDir: config.outDir
989
1005
  };
990
1006
  }
991
- async function getBackgroundEntrypoint(config, path5) {
1007
+ async function getBackgroundEntrypoint(config, path6) {
992
1008
  let options = {};
993
- if (path5 !== VIRTUAL_NOOP_BACKGROUND_MODULE_ID) {
1009
+ if (path6 !== VIRTUAL_NOOP_BACKGROUND_MODULE_ID) {
994
1010
  const defaultExport = await importTsFile(
995
- path5,
1011
+ path6,
996
1012
  config
997
1013
  );
998
1014
  if (defaultExport == null) {
@@ -1004,14 +1020,14 @@ async function getBackgroundEntrypoint(config, path5) {
1004
1020
  return {
1005
1021
  type: "background",
1006
1022
  name: "background",
1007
- inputPath: path5,
1023
+ inputPath: path6,
1008
1024
  outputDir: config.outDir,
1009
1025
  options
1010
1026
  };
1011
1027
  }
1012
- async function getContentScriptEntrypoint(config, name, path5) {
1028
+ async function getContentScriptEntrypoint(config, name, path6) {
1013
1029
  const { main: _, ...options } = await importTsFile(
1014
- path5,
1030
+ path6,
1015
1031
  config
1016
1032
  );
1017
1033
  if (options == null) {
@@ -1019,8 +1035,8 @@ async function getContentScriptEntrypoint(config, name, path5) {
1019
1035
  }
1020
1036
  return {
1021
1037
  type: "content-script",
1022
- name: getEntrypointName(config.entrypointsDir, path5),
1023
- inputPath: path5,
1038
+ name: getEntrypointName(config.entrypointsDir, path6),
1039
+ inputPath: path6,
1024
1040
  outputDir: resolve9(config.outDir, CONTENT_SCRIPT_OUT_DIR),
1025
1041
  options
1026
1042
  };
@@ -1071,11 +1087,52 @@ var CONTENT_SCRIPT_OUT_DIR = "content-scripts";
1071
1087
  import { createUnimport as createUnimport3 } from "unimport";
1072
1088
  import fs9 from "fs-extra";
1073
1089
  import { relative as relative4, resolve as resolve10 } from "path";
1090
+ import path4 from "node:path";
1091
+
1092
+ // src/core/utils/i18n.ts
1093
+ var predefinedMessages = {
1094
+ "@@extension_id": {
1095
+ message: "<browser.runtime.id>",
1096
+ description: "The extension or app ID; you might use this string to construct URLs for resources inside the extension. Even unlocalized extensions can use this message.\nNote: You can't use this message in a manifest file."
1097
+ },
1098
+ "@@ui_locale": {
1099
+ message: "<browser.i18n.getUiLocale()>",
1100
+ description: ""
1101
+ },
1102
+ "@@bidi_dir": {
1103
+ message: "<ltr|rtl>",
1104
+ description: 'The text direction for the current locale, either "ltr" for left-to-right languages such as English or "rtl" for right-to-left languages such as Japanese.'
1105
+ },
1106
+ "@@bidi_reversed_dir": {
1107
+ message: "<rtl|ltr>",
1108
+ description: `If the @@bidi_dir is "ltr", then this is "rtl"; otherwise, it's "ltr".`
1109
+ },
1110
+ "@@bidi_start_edge": {
1111
+ message: "<left|right>",
1112
+ description: `If the @@bidi_dir is "ltr", then this is "left"; otherwise, it's "right".`
1113
+ },
1114
+ "@@bidi_end_edge": {
1115
+ message: "<right|left>",
1116
+ description: `If the @@bidi_dir is "ltr", then this is "right"; otherwise, it's "left".`
1117
+ }
1118
+ };
1119
+ function parseI18nMessages(messagesJson) {
1120
+ return Object.entries({
1121
+ ...predefinedMessages,
1122
+ ...messagesJson
1123
+ }).map(([name, details]) => ({
1124
+ name,
1125
+ ...details
1126
+ }));
1127
+ }
1128
+
1129
+ // src/core/build/generateTypesDir.ts
1074
1130
  async function generateTypesDir(entrypoints, config) {
1075
1131
  await fs9.ensureDir(config.typesDir);
1076
1132
  const references = [];
1077
1133
  references.push(await writeImportsDeclarationFile(config));
1078
1134
  references.push(await writePathsDeclarationFile(entrypoints, config));
1135
+ references.push(await writeI18nDeclarationFile(config));
1079
1136
  references.push(await writeGlobalsDeclarationFile(config));
1080
1137
  const mainReference = await writeMainDeclarationFile(references, config);
1081
1138
  await writeTsConfigFile(mainReference, config);
@@ -1100,14 +1157,14 @@ async function writePathsDeclarationFile(entrypoints, config) {
1100
1157
  config.outDir,
1101
1158
  entry.inputPath.endsWith(".html") ? ".html" : ".js"
1102
1159
  )
1103
- ).concat(await getPublicFiles(config)).map(normalizePath2).map((path5) => ` | "/${path5}"`).sort().join("\n");
1160
+ ).concat(await getPublicFiles(config)).map(normalizePath2).map((path6) => ` | "/${path6}"`).sort().join("\n");
1104
1161
  const template = `// Generated by wxt
1105
1162
  import "wxt/browser";
1106
1163
 
1107
1164
  declare module "wxt/browser" {
1108
1165
  type PublicPath =
1109
1166
  {{ union }}
1110
- export interface ProjectRuntime extends Runtime.Static {
1167
+ export interface WxtRuntime extends Runtime.Static {
1111
1168
  getURL(path: PublicPath): string;
1112
1169
  }
1113
1170
  }
@@ -1118,6 +1175,59 @@ declare module "wxt/browser" {
1118
1175
  );
1119
1176
  return filePath;
1120
1177
  }
1178
+ async function writeI18nDeclarationFile(config) {
1179
+ const filePath = resolve10(config.typesDir, "i18n.d.ts");
1180
+ const defaultLocale = config.manifest.default_locale;
1181
+ const template = `// Generated by wxt
1182
+ import "wxt/browser";
1183
+
1184
+ declare module "wxt/browser" {
1185
+ /**
1186
+ * See https://developer.chrome.com/docs/extensions/reference/i18n/#method-getMessage
1187
+ */
1188
+ interface GetMessageOptions {
1189
+ /**
1190
+ * See https://developer.chrome.com/docs/extensions/reference/i18n/#method-getMessage
1191
+ */
1192
+ escapeLt?: boolean
1193
+ }
1194
+
1195
+ export interface WxtI18n extends I18n.Static {
1196
+ {{ overrides }}
1197
+ }
1198
+ }
1199
+ `;
1200
+ let messages;
1201
+ if (defaultLocale) {
1202
+ const defaultLocalePath = path4.resolve(
1203
+ config.publicDir,
1204
+ "_locales",
1205
+ defaultLocale,
1206
+ "messages.json"
1207
+ );
1208
+ const content = JSON.parse(await fs9.readFile(defaultLocalePath, "utf-8"));
1209
+ messages = parseI18nMessages(content);
1210
+ } else {
1211
+ messages = parseI18nMessages({});
1212
+ }
1213
+ const overrides = messages.map((message) => {
1214
+ return ` /**
1215
+ * ${message.description ?? "No message description."}
1216
+ *
1217
+ * "${message.message}"
1218
+ */
1219
+ getMessage(
1220
+ messageName: "${message.name}",
1221
+ substitutions?: string | string[],
1222
+ options?: GetMessageOptions,
1223
+ ): string;`;
1224
+ });
1225
+ await fs9.writeFile(
1226
+ filePath,
1227
+ template.replace("{{ overrides }}", overrides.join("\n"))
1228
+ );
1229
+ return filePath;
1230
+ }
1121
1231
  async function writeGlobalsDeclarationFile(config) {
1122
1232
  const filePath = resolve10(config.typesDir, "globals.d.ts");
1123
1233
  const globals = getGlobals(config);
@@ -1151,6 +1261,8 @@ async function writeMainDeclarationFile(references, config) {
1151
1261
  }
1152
1262
  async function writeTsConfigFile(mainReference, config) {
1153
1263
  const dir = config.wxtDir;
1264
+ const rootPath = normalizePath2(relative4(dir, config.root));
1265
+ const srcPath = normalizePath2(relative4(dir, config.srcDir));
1154
1266
  await fs9.writeFile(
1155
1267
  resolve10(dir, "tsconfig.json"),
1156
1268
  `{
@@ -1165,16 +1277,15 @@ async function writeTsConfigFile(mainReference, config) {
1165
1277
  "strict": true,
1166
1278
  "lib": ["DOM", "WebWorker"],
1167
1279
  "skipLibCheck": true,
1168
- "baseUrl": "${normalizePath2(relative4(dir, config.root))}",
1169
1280
  "paths": {
1170
- "@@": ["."],
1171
- "@@/*": ["./*"],
1172
- "~~": ["."],
1173
- "~~/*": ["./*"],
1174
- "@": ["${normalizePath2(relative4(config.root, config.srcDir))}"],
1175
- "@/*": ["${normalizePath2(relative4(config.root, config.srcDir))}/*"],
1176
- "~": ["${normalizePath2(relative4(config.root, config.srcDir))}"],
1177
- "~/*": ["${normalizePath2(relative4(config.root, config.srcDir))}/*"]
1281
+ "@@": ["${rootPath}"],
1282
+ "@@/*": ["${rootPath}/*"],
1283
+ "~~": ["${rootPath}"],
1284
+ "~~/*": ["${rootPath}/*"],
1285
+ "@": ["${srcPath}"],
1286
+ "@/*": ["${srcPath}/*"],
1287
+ "~": ["${srcPath}"],
1288
+ "~/*": ["${srcPath}/*"]
1178
1289
  }
1179
1290
  },
1180
1291
  "include": [
@@ -1500,7 +1611,7 @@ function addEntrypoints(manifest, entrypoints, buildOutput, config) {
1500
1611
  map.set(hash, [script]);
1501
1612
  return map;
1502
1613
  }, /* @__PURE__ */ new Map());
1503
- manifest.content_scripts = Array.from(hashToEntrypointsMap.entries()).map(
1614
+ const newContentScripts = Array.from(hashToEntrypointsMap.entries()).map(
1504
1615
  ([, scripts]) => ({
1505
1616
  ...mapWxtOptionsToContentScript(scripts[0].options),
1506
1617
  // TOOD: Sorting css and js arrays here so we get consistent test results... but we
@@ -1511,6 +1622,10 @@ function addEntrypoints(manifest, entrypoints, buildOutput, config) {
1511
1622
  ).sort()
1512
1623
  })
1513
1624
  );
1625
+ if (newContentScripts.length >= 0) {
1626
+ manifest.content_scripts ??= [];
1627
+ manifest.content_scripts.push(...newContentScripts);
1628
+ }
1514
1629
  }
1515
1630
  }
1516
1631
  }
@@ -1659,7 +1774,7 @@ function formatDuration(duration) {
1659
1774
  import { resolve as resolve13 } from "path";
1660
1775
 
1661
1776
  // src/core/log/printFileList.ts
1662
- import path4 from "node:path";
1777
+ import path5 from "node:path";
1663
1778
  import pc from "picocolors";
1664
1779
  import fs12 from "fs-extra";
1665
1780
  import { filesize } from "filesize";
@@ -1697,8 +1812,8 @@ async function printFileList(log, header, baseDir, files) {
1697
1812
  const fileRows = await Promise.all(
1698
1813
  files.map(async (file, i) => {
1699
1814
  const parts = [
1700
- path4.relative(process.cwd(), baseDir) + path4.sep,
1701
- path4.relative(baseDir, file)
1815
+ path5.relative(process.cwd(), baseDir) + path5.sep,
1816
+ path5.relative(baseDir, file)
1702
1817
  ];
1703
1818
  const prefix = i === files.length - 1 ? " \u2514\u2500" : " \u251C\u2500";
1704
1819
  const color = getChunkColor(file);
@@ -1829,7 +1944,7 @@ function createWebExtRunner() {
1829
1944
  config.logger.warn("Cannot open safari automatically.");
1830
1945
  return;
1831
1946
  }
1832
- const webExtLogger = await import("web-ext/util/logger");
1947
+ const webExtLogger = await import("web-ext-run/util/logger");
1833
1948
  webExtLogger.consoleStream.write = ({ level, msg, name }) => {
1834
1949
  if (level >= ERROR_LOG_LEVEL)
1835
1950
  config.logger.error(name, msg);
@@ -1866,7 +1981,7 @@ function createWebExtRunner() {
1866
1981
  };
1867
1982
  config.logger.debug("web-ext config:", finalConfig);
1868
1983
  config.logger.debug("web-ext options:", options);
1869
- const webExt = await import("web-ext");
1984
+ const webExt = await import("web-ext-run");
1870
1985
  runner = await webExt.default.cmd.run(finalConfig, options);
1871
1986
  },
1872
1987
  async closeBrowser() {
@@ -1911,8 +2026,8 @@ async function setupServer(serverInfo, config) {
1911
2026
  const reloadExtension = () => {
1912
2027
  viteServer.ws.send("wxt:reload-extension");
1913
2028
  };
1914
- const reloadPage = (path5) => {
1915
- viteServer.ws.send("wxt:reload-page", path5);
2029
+ const reloadPage = (path6) => {
2030
+ viteServer.ws.send("wxt:reload-page", path6);
1916
2031
  };
1917
2032
  const reloadContentScript = (contentScript) => {
1918
2033
  viteServer.ws.send("wxt:reload-content-script", contentScript);
@@ -1958,13 +2073,13 @@ function reloadContentScripts(steps, config, server) {
1958
2073
  }
1959
2074
  function reloadHtmlPages(groups, server, config) {
1960
2075
  groups.flat().forEach((entry) => {
1961
- const path5 = getEntrypointBundlePath(entry, config.outDir, ".html");
1962
- server.reloadPage(path5);
2076
+ const path6 = getEntrypointBundlePath(entry, config.outDir, ".html");
2077
+ server.reloadPage(path6);
1963
2078
  });
1964
2079
  }
1965
2080
 
1966
2081
  // package.json
1967
- var version2 = "0.3.2";
2082
+ var version2 = "0.4.0";
1968
2083
 
1969
2084
  // src/core/utils/defineConfig.ts
1970
2085
  function defineConfig(config) {
@@ -1998,10 +2113,10 @@ async function createServer2(config) {
1998
2113
  server.ws.on("wxt:background-initialized", () => {
1999
2114
  reloadContentScripts(server.currentOutput.steps, internalConfig, server);
2000
2115
  });
2001
- server.watcher.on("all", async (event, path5, _stats) => {
2002
- if (path5.startsWith(internalConfig.outBaseDir))
2116
+ server.watcher.on("all", async (event, path6, _stats) => {
2117
+ if (path6.startsWith(internalConfig.outBaseDir))
2003
2118
  return;
2004
- changeQueue.push([event, path5]);
2119
+ changeQueue.push([event, path6]);
2005
2120
  await fileChangedMutex.runExclusive(async () => {
2006
2121
  const fileChanges = changeQueue.splice(0, changeQueue.length);
2007
2122
  if (fileChanges.length === 0)