wxt 0.2.5 → 0.3.1

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.ts CHANGED
@@ -15,14 +15,14 @@ interface InlineConfig {
15
15
  * directory.
16
16
  *
17
17
  * @default
18
- * "<root>"
18
+ * "<rootDir>"
19
19
  */
20
20
  srcDir?: string;
21
21
  /**
22
22
  * Directory containing files that will be copied to the output directory as-is.
23
23
  *
24
24
  * @default
25
- * "<srcDir>/publicDir"
25
+ * "<rootDir>/publicDir"
26
26
  */
27
27
  publicDir?: string;
28
28
  /**
@@ -240,7 +240,7 @@ interface BaseEntrypoint {
240
240
  outputDir: string;
241
241
  }
242
242
  interface GenericEntrypoint extends BaseEntrypoint {
243
- type: 'sandbox' | 'bookmarks' | 'history' | 'newtab' | 'sidepanel' | 'devtools' | 'unlisted-page' | 'unlisted-script';
243
+ type: 'sandbox' | 'bookmarks' | 'history' | 'newtab' | 'sidepanel' | 'devtools' | 'unlisted-page' | 'unlisted-script' | 'unlisted-style' | 'content-script-style';
244
244
  }
245
245
  interface BackgroundEntrypoint extends BaseEntrypoint {
246
246
  type: 'background';
@@ -404,7 +404,7 @@ interface ExtensionRunnerConfig {
404
404
 
405
405
  type EntrypointGroup = Entrypoint | Entrypoint[];
406
406
 
407
- var version = "0.2.5";
407
+ var version = "0.3.1";
408
408
 
409
409
  declare function defineConfig(config: UserConfig): UserConfig;
410
410
 
@@ -414,6 +414,10 @@ declare function defineRunnerConfig(config: ExtensionRunnerConfig): ExtensionRun
414
414
  * Bundles the extension for production. Returns a promise of the build result.
415
415
  */
416
416
  declare function build(config: InlineConfig): Promise<BuildOutput>;
417
+ /**
418
+ * Creates a dev server, pre-builds all the files that need to exist to load the extension, and open
419
+ * the browser with the extension installed.
420
+ */
417
421
  declare function createServer(config?: InlineConfig): Promise<WxtDevServer>;
418
422
 
419
423
  export { BackgroundEntrypoint, BackgroundScriptDefintition, BaseEntrypoint, BuildOutput, BuildStepOutput, ConfigEnv, ContentScriptDefinition, ContentScriptEntrypoint, Entrypoint, ExtensionRunnerConfig, GenericEntrypoint, InlineConfig, Logger, OnContentScriptStopped, OptionsEntrypoint, PopupEntrypoint, TargetBrowser, TargetManifestVersion, UserConfig, UserManifest, UserManifestFn, WxtDevServer, WxtInlineViteConfig, build, createServer, defineConfig, defineRunnerConfig, version };
package/dist/index.js CHANGED
@@ -1,20 +1,36 @@
1
1
  // src/core/utils/getInternalConfig.ts
2
2
  import path2, { resolve as resolve6 } from "node:path";
3
- import * as vite from "vite";
3
+ import * as vite2 from "vite";
4
4
  import { consola } from "consola";
5
5
 
6
6
  // src/core/utils/entrypoints.ts
7
7
  import path, { relative, resolve } from "node:path";
8
+
9
+ // src/core/utils/paths.ts
10
+ import nodePath from "node:path";
11
+ import * as vite from "vite";
12
+ function normalizePath2(path5) {
13
+ return vite.normalizePath(path5);
14
+ }
15
+ function unnormalizePath(path5) {
16
+ return nodePath.normalize(path5);
17
+ }
18
+ var CSS_EXTENSIONS = ["css", "scss", "sass", "less", "styl", "stylus"];
19
+ var CSS_EXTENSIONS_PATTERN = `+(${CSS_EXTENSIONS.join("|")})`;
20
+
21
+ // src/core/utils/entrypoints.ts
8
22
  function getEntrypointName(entrypointsDir, inputPath) {
9
23
  const relativePath = path.relative(entrypointsDir, inputPath);
10
- const name = relativePath.split(/[\.\/]/, 2)[0];
24
+ const name = relativePath.split(/[\.\/\\]/, 2)[0];
11
25
  return name;
12
26
  }
13
27
  function getEntrypointOutputFile(entrypoint, ext) {
14
28
  return resolve(entrypoint.outputDir, `${entrypoint.name}${ext}`);
15
29
  }
16
30
  function getEntrypointBundlePath(entrypoint, outDir, ext) {
17
- return relative(outDir, getEntrypointOutputFile(entrypoint, ext));
31
+ return normalizePath2(
32
+ relative(outDir, getEntrypointOutputFile(entrypoint, ext))
33
+ );
18
34
  }
19
35
 
20
36
  // src/core/vite-plugins/devHtmlPrerender.ts
@@ -176,7 +192,7 @@ function multipageMove(entrypoints, config) {
176
192
  async writeBundle(_, bundle) {
177
193
  for (const oldBundlePath in bundle) {
178
194
  const entrypoint = entrypoints.find(
179
- (entry) => !!entry.inputPath.endsWith(oldBundlePath)
195
+ (entry) => !!normalizePath2(entry.inputPath).endsWith(oldBundlePath)
180
196
  );
181
197
  if (entrypoint == null) {
182
198
  config.logger.debug("No entrypoint found for", oldBundlePath);
@@ -217,11 +233,8 @@ import { mergeConfig } from "vite";
217
233
  function getUnimportOptions(config) {
218
234
  const defaultOptions = {
219
235
  debugLog: config.logger.debug,
220
- imports: [
221
- { name: "*", as: "browser", from: "webextension-polyfill" },
222
- { name: "defineConfig", from: "wxt" }
223
- ],
224
- presets: [{ package: "wxt/client" }],
236
+ imports: [{ name: "defineConfig", from: "wxt" }],
237
+ presets: [{ package: "wxt/client" }, { package: "wxt/browser" }],
225
238
  warn: config.logger.warn,
226
239
  dirs: ["./components/*", "./composables/*", "./hooks/*", "./utils/*"]
227
240
  };
@@ -269,7 +282,7 @@ function virtualEntrypoin(type, config) {
269
282
  const index = id.indexOf(virtualId);
270
283
  if (index === -1)
271
284
  return;
272
- const inputPath = id.substring(index + virtualId.length);
285
+ const inputPath = normalizePath2(id.substring(index + virtualId.length));
273
286
  return resolvedVirtualId + inputPath;
274
287
  },
275
288
  async load(id) {
@@ -317,6 +330,30 @@ export default defineBackground(() => void 0)`;
317
330
  }
318
331
  var VIRTUAL_NOOP_BACKGROUND_MODULE_ID = "virtual:user-background";
319
332
 
333
+ // src/core/vite-plugins/cssEntrypoints.ts
334
+ function cssEntrypoints(entrypoint, config) {
335
+ return {
336
+ name: "wxt:css-entrypoint",
337
+ config() {
338
+ return {
339
+ build: {
340
+ rollupOptions: {
341
+ output: {
342
+ assetFileNames: () => getEntrypointBundlePath(entrypoint, config.outDir, ".css")
343
+ }
344
+ }
345
+ }
346
+ };
347
+ },
348
+ generateBundle(_, bundle) {
349
+ Object.keys(bundle).forEach((file) => {
350
+ if (file.endsWith(".js"))
351
+ delete bundle[file];
352
+ });
353
+ }
354
+ };
355
+ }
356
+
320
357
  // src/core/utils/createFsCache.ts
321
358
  import fs3, { ensureDir as ensureDir2 } from "fs-extra";
322
359
  import { dirname as dirname3, resolve as resolve5 } from "path";
@@ -350,7 +387,7 @@ function getGlobals(config) {
350
387
  {
351
388
  name: "__BROWSER__",
352
389
  value: config.browser,
353
- type: `"chromium" | "firefox"`
390
+ type: `string`
354
391
  },
355
392
  {
356
393
  name: "__IS_CHROME__",
@@ -426,7 +463,7 @@ async function getInternalConfig(config, command) {
426
463
  });
427
464
  userConfig = loaded.config ?? {};
428
465
  }
429
- const merged = vite.mergeConfig(
466
+ const merged = vite2.mergeConfig(
430
467
  baseConfig,
431
468
  userConfig
432
469
  );
@@ -435,13 +472,13 @@ async function getInternalConfig(config, command) {
435
472
  srcDir,
436
473
  userConfig.entrypointsDir ?? "entrypoints"
437
474
  );
438
- const publicDir = resolve6(srcDir, userConfig.publicDir ?? "public");
475
+ const publicDir = resolve6(root, userConfig.publicDir ?? "public");
439
476
  const wxtDir = resolve6(srcDir, ".wxt");
440
477
  const typesDir = resolve6(wxtDir, "types");
441
478
  const env = { mode, browser, manifestVersion, command };
442
479
  const userManifest = await resolveManifestConfig(env, userConfig.manifest);
443
480
  const inlineManifest = await resolveManifestConfig(env, config.manifest);
444
- const manifest = vite.mergeConfig(userManifest, inlineManifest);
481
+ const manifest = vite2.mergeConfig(userManifest, inlineManifest);
445
482
  const finalConfig = {
446
483
  ...merged,
447
484
  srcDir,
@@ -503,7 +540,7 @@ async function resolveManifestConfig(env, manifest) {
503
540
 
504
541
  // src/index.ts
505
542
  import pc3 from "picocolors";
506
- import * as vite5 from "vite";
543
+ import * as vite6 from "vite";
507
544
 
508
545
  // src/core/utils/arrays.ts
509
546
  function every(array, predicate) {
@@ -576,11 +613,12 @@ function detectDevChanges(changedFiles, currentOutput) {
576
613
  }
577
614
  function findEffectedSteps(changedFile, currentOutput) {
578
615
  const changes = [];
579
- const changedPath = changedFile[1];
616
+ const changedPath = normalizePath2(changedFile[1]);
580
617
  const isChunkEffected = (chunk) => (
581
618
  // If it's an HTML file with the same path, is is effected because HTML files need to be pre-rendered
582
- // TODO: use bundle path to support `<name>/index.html`?
619
+ // fileName is normalized, relative bundle path
583
620
  chunk.type === "asset" && changedPath.endsWith(chunk.fileName) || // If it's a chunk that depends on the changed file, it is effected
621
+ // moduleIds are absolute, normalized paths
584
622
  chunk.type === "chunk" && chunk.moduleIds.includes(changedPath)
585
623
  );
586
624
  for (const step of currentOutput.steps) {
@@ -602,7 +640,7 @@ import { consola as consola2 } from "consola";
602
640
  import { relative as relative5 } from "node:path";
603
641
 
604
642
  // src/core/build/buildEntrypoints.ts
605
- import * as vite2 from "vite";
643
+ import * as vite3 from "vite";
606
644
 
607
645
  // src/core/utils/removeEmptyDirs.ts
608
646
  import fs4 from "fs-extra";
@@ -623,9 +661,20 @@ async function removeEmptyDirs(dir) {
623
661
  }
624
662
 
625
663
  // src/core/build/buildEntrypoints.ts
626
- import glob from "fast-glob";
627
- import fs5 from "fs-extra";
664
+ import fs6 from "fs-extra";
628
665
  import { dirname as dirname4, resolve as resolve7 } from "path";
666
+
667
+ // src/core/utils/public.ts
668
+ import fs5 from "fs-extra";
669
+ import glob from "fast-glob";
670
+ async function getPublicFiles(config) {
671
+ if (!await fs5.exists(config.publicDir))
672
+ return [];
673
+ const files = await glob("**/*", { cwd: config.publicDir });
674
+ return files.map(unnormalizePath);
675
+ }
676
+
677
+ // src/core/build/buildEntrypoints.ts
629
678
  async function buildEntrypoints(groups, config) {
630
679
  const steps = [];
631
680
  for (const group of groups) {
@@ -639,7 +688,12 @@ async function buildEntrypoints(groups, config) {
639
688
  async function buildSingleEntrypoint(entrypoint, config) {
640
689
  const isVirtual = ["background", "content-script"].includes(entrypoint.type);
641
690
  const entry = isVirtual ? `virtual:wxt-${entrypoint.type}?${entrypoint.inputPath}` : entrypoint.inputPath;
691
+ const plugins = [];
692
+ if (entrypoint.type === "content-script-style" || entrypoint.type === "unlisted-style") {
693
+ plugins.push(cssEntrypoints(entrypoint, config));
694
+ }
642
695
  const libMode = {
696
+ plugins,
643
697
  build: {
644
698
  lib: {
645
699
  entry,
@@ -664,11 +718,11 @@ async function buildSingleEntrypoint(entrypoint, config) {
664
718
  }
665
719
  }
666
720
  };
667
- const entryConfig = vite2.mergeConfig(
721
+ const entryConfig = vite3.mergeConfig(
668
722
  libMode,
669
723
  config.vite
670
724
  );
671
- const result = await vite2.build(entryConfig);
725
+ const result = await vite3.build(entryConfig);
672
726
  return {
673
727
  entrypoints: entrypoint,
674
728
  chunks: getBuildOutputChunks(result)
@@ -694,11 +748,11 @@ async function buildMultipleEntrypoints(entrypoints, config) {
694
748
  }
695
749
  }
696
750
  };
697
- const entryConfig = vite2.mergeConfig(
751
+ const entryConfig = vite3.mergeConfig(
698
752
  multiPage,
699
753
  config.vite
700
754
  );
701
- const result = await vite2.build(entryConfig);
755
+ const result = await vite3.build(entryConfig);
702
756
  return {
703
757
  entrypoints,
704
758
  chunks: getBuildOutputChunks(result)
@@ -712,21 +766,21 @@ function getBuildOutputChunks(result) {
712
766
  return result.output;
713
767
  }
714
768
  async function copyPublicDirectory(config) {
769
+ const files = await getPublicFiles(config);
770
+ if (files.length === 0)
771
+ return [];
715
772
  const publicAssets = [];
716
- if (!await fs5.exists(config.publicDir))
717
- return publicAssets;
718
- const files = await glob("**/*", { cwd: config.publicDir });
719
773
  for (const file of files) {
720
774
  const srcPath = resolve7(config.publicDir, file);
721
775
  const outPath = resolve7(config.outDir, file);
722
- await fs5.ensureDir(dirname4(outPath));
723
- await fs5.copyFile(srcPath, outPath);
776
+ await fs6.ensureDir(dirname4(outPath));
777
+ await fs6.copyFile(srcPath, outPath);
724
778
  publicAssets.push({
725
779
  type: "asset",
726
780
  fileName: file,
727
781
  name: file,
728
782
  needsCodeReference: false,
729
- source: await fs5.readFile(srcPath)
783
+ source: await fs6.readFile(srcPath)
730
784
  });
731
785
  }
732
786
  return publicAssets;
@@ -734,15 +788,15 @@ async function copyPublicDirectory(config) {
734
788
 
735
789
  // src/core/build/findEntrypoints.ts
736
790
  import { relative as relative3, resolve as resolve9 } from "path";
737
- import fs7 from "fs-extra";
738
- import picomatch from "picomatch";
791
+ import fs8 from "fs-extra";
792
+ import { minimatch } from "minimatch";
739
793
  import { parseHTML as parseHTML2 } from "linkedom";
740
794
  import JSON5 from "json5";
741
795
 
742
796
  // src/core/utils/importTsFile.ts
743
797
  import createJITI from "jiti";
744
798
  import { createUnimport as createUnimport2 } from "unimport";
745
- import fs6 from "fs-extra";
799
+ import fs7 from "fs-extra";
746
800
  import { resolve as resolve8 } from "path";
747
801
  import transform from "jiti/dist/babel";
748
802
 
@@ -757,14 +811,14 @@ function removeImportStatements(text) {
757
811
  // src/core/utils/importTsFile.ts
758
812
  async function importTsFile(path5, config) {
759
813
  config.logger.debug("Loading file metadata:", path5);
814
+ const normalPath = normalizePath2(path5);
760
815
  const unimport2 = createUnimport2({
761
816
  ...getUnimportOptions(config),
762
817
  // Only allow specific imports, not all from the project
763
- imports: [{ name: "*", as: "browser", from: "webextension-polyfill" }],
764
818
  dirs: []
765
819
  });
766
820
  await unimport2.init();
767
- const text = await fs6.readFile(path5, "utf-8");
821
+ const text = await fs7.readFile(path5, "utf-8");
768
822
  const textNoImports = removeImportStatements(text);
769
823
  const { code } = await unimport2.injectImports(textNoImports);
770
824
  config.logger.debug(
@@ -781,7 +835,7 @@ async function importTsFile(path5, config) {
781
835
  )
782
836
  },
783
837
  transform(opts) {
784
- if (opts.filename === path5)
838
+ if (opts.filename === normalPath)
785
839
  return transform({ ...opts, source: code });
786
840
  else
787
841
  return transform(opts);
@@ -810,7 +864,7 @@ async function findEntrypoints(config) {
810
864
  relativePaths.map(async (relativePath) => {
811
865
  const path5 = resolve9(config.entrypointsDir, relativePath);
812
866
  const matchingGlob = pathGlobs.find(
813
- (glob3) => picomatch.isMatch(relativePath, glob3)
867
+ (glob3) => minimatch(relativePath, glob3)
814
868
  );
815
869
  if (matchingGlob == null) {
816
870
  return config.logger.warn(
@@ -844,6 +898,14 @@ ${JSON.stringify(
844
898
  path5
845
899
  );
846
900
  break;
901
+ case "content-script-style":
902
+ entrypoint = {
903
+ type,
904
+ name: getEntrypointName(config.entrypointsDir, path5),
905
+ inputPath: path5,
906
+ outputDir: resolve9(config.outDir, CONTENT_SCRIPT_OUT_DIR)
907
+ };
908
+ break;
847
909
  default:
848
910
  entrypoint = {
849
911
  type,
@@ -874,7 +936,7 @@ ${JSON.stringify(
874
936
  }
875
937
  async function getPopupEntrypoint(config, path5) {
876
938
  const options = {};
877
- const content = await fs7.readFile(path5, "utf-8");
939
+ const content = await fs8.readFile(path5, "utf-8");
878
940
  const { document } = parseHTML2(content);
879
941
  const title = document.querySelector("title");
880
942
  if (title != null)
@@ -904,7 +966,7 @@ async function getPopupEntrypoint(config, path5) {
904
966
  }
905
967
  async function getOptionsEntrypoint(config, path5) {
906
968
  const options = {};
907
- const content = await fs7.readFile(path5, "utf-8");
969
+ const content = await fs8.readFile(path5, "utf-8");
908
970
  const { document } = parseHTML2(content);
909
971
  const openInTabContent = document.querySelector("meta[name='manifest.open_in_tab']")?.getAttribute("content");
910
972
  if (openInTabContent) {
@@ -959,7 +1021,7 @@ async function getContentScriptEntrypoint(config, name, path5) {
959
1021
  type: "content-script",
960
1022
  name: getEntrypointName(config.entrypointsDir, path5),
961
1023
  inputPath: path5,
962
- outputDir: resolve9(config.outDir, "content-scripts"),
1024
+ outputDir: resolve9(config.outDir, CONTENT_SCRIPT_OUT_DIR),
963
1025
  options
964
1026
  };
965
1027
  }
@@ -986,6 +1048,10 @@ var PATH_GLOB_TO_TYPE_MAP = {
986
1048
  "content/index.ts?(x)": "content-script",
987
1049
  "*.content.ts?(x)": "content-script",
988
1050
  "*.content/index.ts?(x)": "content-script",
1051
+ [`content.${CSS_EXTENSIONS_PATTERN}`]: "content-script-style",
1052
+ [`*.content.${CSS_EXTENSIONS_PATTERN}`]: "content-script-style",
1053
+ [`content/index.${CSS_EXTENSIONS_PATTERN}`]: "content-script-style",
1054
+ [`*.content/index.${CSS_EXTENSIONS_PATTERN}`]: "content-script-style",
989
1055
  "popup.html": "popup",
990
1056
  "popup/index.html": "popup",
991
1057
  "options.html": "options",
@@ -993,16 +1059,20 @@ var PATH_GLOB_TO_TYPE_MAP = {
993
1059
  "*.html": "unlisted-page",
994
1060
  "*/index.html": "unlisted-page",
995
1061
  "*.ts": "unlisted-script",
1062
+ "*/index.ts": "unlisted-script",
1063
+ [`*.${CSS_EXTENSIONS_PATTERN}`]: "unlisted-style",
1064
+ [`*/index.${CSS_EXTENSIONS_PATTERN}`]: "unlisted-style",
996
1065
  // Don't warn about any files in subdirectories, like CSS or JS entrypoints for HTML files
997
1066
  "*/*": "ignored"
998
1067
  };
1068
+ var CONTENT_SCRIPT_OUT_DIR = "content-scripts";
999
1069
 
1000
1070
  // src/core/build/generateTypesDir.ts
1001
1071
  import { createUnimport as createUnimport3 } from "unimport";
1002
- import fs8 from "fs-extra";
1072
+ import fs9 from "fs-extra";
1003
1073
  import { relative as relative4, resolve as resolve10 } from "path";
1004
1074
  async function generateTypesDir(entrypoints, config) {
1005
- await fs8.ensureDir(config.typesDir);
1075
+ await fs9.ensureDir(config.typesDir);
1006
1076
  const references = [];
1007
1077
  references.push(await writeImportsDeclarationFile(config));
1008
1078
  references.push(await writePathsDeclarationFile(entrypoints, config));
@@ -1014,7 +1084,7 @@ async function writeImportsDeclarationFile(config) {
1014
1084
  const filePath = resolve10(config.typesDir, "imports.d.ts");
1015
1085
  const unimport2 = createUnimport3(getUnimportOptions(config));
1016
1086
  await unimport2.scanImportsFromDir(void 0, { cwd: config.srcDir });
1017
- await fs8.writeFile(
1087
+ await fs9.writeFile(
1018
1088
  filePath,
1019
1089
  ["// Generated by wxt", await unimport2.generateTypeDeclarations()].join(
1020
1090
  "\n"
@@ -1024,28 +1094,34 @@ async function writeImportsDeclarationFile(config) {
1024
1094
  }
1025
1095
  async function writePathsDeclarationFile(entrypoints, config) {
1026
1096
  const filePath = resolve10(config.typesDir, "paths.d.ts");
1027
- const unions = entrypoints.map((entry) => {
1028
- const path5 = getEntrypointBundlePath(
1097
+ const unions = entrypoints.map(
1098
+ (entry) => getEntrypointBundlePath(
1029
1099
  entry,
1030
1100
  config.outDir,
1031
1101
  entry.inputPath.endsWith(".html") ? ".html" : ".js"
1032
- );
1033
- return ` | "/${path5}"`;
1034
- }).sort();
1035
- await fs8.writeFile(
1102
+ )
1103
+ ).concat(await getPublicFiles(config)).map(normalizePath2).map((path5) => ` | "/${path5}"`).sort().join("\n");
1104
+ const template = `// Generated by wxt
1105
+ import "wxt/browser";
1106
+
1107
+ declare module "wxt/browser" {
1108
+ type PublicPath =
1109
+ {{ union }}
1110
+ export interface ProjectRuntime extends Runtime.Static {
1111
+ getURL(path: PublicPath): string;
1112
+ }
1113
+ }
1114
+ `;
1115
+ await fs9.writeFile(
1036
1116
  filePath,
1037
- [
1038
- "// Generated by wxt",
1039
- "type EntrypointPath =",
1040
- ...unions.length === 0 ? [" never"] : unions
1041
- ].join("\n") + "\n"
1117
+ template.replace("{{ union }}", unions || " | never")
1042
1118
  );
1043
1119
  return filePath;
1044
1120
  }
1045
1121
  async function writeGlobalsDeclarationFile(config) {
1046
1122
  const filePath = resolve10(config.typesDir, "globals.d.ts");
1047
1123
  const globals = getGlobals(config);
1048
- await fs8.writeFile(
1124
+ await fs9.writeFile(
1049
1125
  filePath,
1050
1126
  [
1051
1127
  "// Generated by wxt",
@@ -1061,13 +1137,13 @@ async function writeGlobalsDeclarationFile(config) {
1061
1137
  async function writeMainDeclarationFile(references, config) {
1062
1138
  const dir = config.wxtDir;
1063
1139
  const filePath = resolve10(dir, "wxt.d.ts");
1064
- await fs8.writeFile(
1140
+ await fs9.writeFile(
1065
1141
  filePath,
1066
1142
  [
1067
1143
  "// Generated by wxt",
1068
1144
  `/// <reference types="vite/client" />`,
1069
1145
  ...references.map(
1070
- (ref) => `/// <reference types="./${relative4(dir, ref)}" />`
1146
+ (ref) => `/// <reference types="./${normalizePath2(relative4(dir, ref))}" />`
1071
1147
  )
1072
1148
  ].join("\n") + "\n"
1073
1149
  );
@@ -1075,7 +1151,7 @@ async function writeMainDeclarationFile(references, config) {
1075
1151
  }
1076
1152
  async function writeTsConfigFile(mainReference, config) {
1077
1153
  const dir = config.wxtDir;
1078
- await fs8.writeFile(
1154
+ await fs9.writeFile(
1079
1155
  resolve10(dir, "tsconfig.json"),
1080
1156
  `{
1081
1157
  "compilerOptions": {
@@ -1086,37 +1162,32 @@ async function writeTsConfigFile(mainReference, config) {
1086
1162
  "esModuleInterop": true,
1087
1163
  "forceConsistentCasingInFileNames": true,
1088
1164
  "resolveJsonModule": true,
1089
-
1090
- /* Type Checking */
1091
1165
  "strict": true,
1092
-
1093
- /* Completeness */
1166
+ "lib": ["DOM", "WebWorker"],
1094
1167
  "skipLibCheck": true,
1095
-
1096
- /* Aliases */
1097
- "baseUrl": "${relative4(dir, config.root)}",
1168
+ "baseUrl": "${normalizePath2(relative4(dir, config.root))}",
1098
1169
  "paths": {
1099
1170
  "@@": ["."],
1100
1171
  "@@/*": ["./*"],
1101
1172
  "~~": ["."],
1102
1173
  "~~/*": ["./*"],
1103
- "@": ["${relative4(config.root, config.srcDir)}"],
1104
- "@/*": ["${relative4(config.root, config.srcDir)}/*"],
1105
- "~": ["${relative4(config.root, config.srcDir)}"],
1106
- "~/*": ["${relative4(config.root, config.srcDir)}/*"]
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))}/*"]
1107
1178
  }
1108
1179
  },
1109
1180
  "include": [
1110
- "${relative4(dir, config.root)}/**/*",
1111
- "./${relative4(dir, mainReference)}"
1181
+ "${normalizePath2(relative4(dir, config.root))}/**/*",
1182
+ "./${normalizePath2(relative4(dir, mainReference))}"
1112
1183
  ],
1113
- "exclude": ["${relative4(dir, config.outBaseDir)}"]
1184
+ "exclude": ["${normalizePath2(relative4(dir, config.outBaseDir))}"]
1114
1185
  }`
1115
1186
  );
1116
1187
  }
1117
1188
 
1118
1189
  // src/core/utils/manifest.ts
1119
- import fs10 from "fs-extra";
1190
+ import fs11 from "fs-extra";
1120
1191
  import { resolve as resolve12 } from "path";
1121
1192
 
1122
1193
  // src/core/utils/ContentSecurityPolicy.ts
@@ -1202,11 +1273,11 @@ function mapWxtOptionsToContentScript(options) {
1202
1273
 
1203
1274
  // src/core/utils/package.ts
1204
1275
  import { resolve as resolve11 } from "node:path";
1205
- import fs9 from "fs-extra";
1276
+ import fs10 from "fs-extra";
1206
1277
  async function getPackageJson(config) {
1207
1278
  const file = resolve11(config.root, "package.json");
1208
1279
  try {
1209
- return await fs9.readJson(file);
1280
+ return await fs10.readJson(file);
1210
1281
  } catch (err) {
1211
1282
  config.logger.debug(
1212
1283
  `Failed to read package.json at: ${file}. Returning undefined.`
@@ -1218,8 +1289,8 @@ async function getPackageJson(config) {
1218
1289
  // src/core/utils/manifest.ts
1219
1290
  async function writeManifest(manifest, output, config) {
1220
1291
  const str = config.mode === "production" ? JSON.stringify(manifest) : JSON.stringify(manifest, null, 2);
1221
- await fs10.ensureDir(config.outDir);
1222
- await fs10.writeFile(resolve12(config.outDir, "manifest.json"), str, "utf-8");
1292
+ await fs11.ensureDir(config.outDir);
1293
+ await fs11.writeFile(resolve12(config.outDir, "manifest.json"), str, "utf-8");
1223
1294
  output.publicAssets.unshift({
1224
1295
  type: "asset",
1225
1296
  fileName: "manifest.json",
@@ -1249,11 +1320,11 @@ async function generateMainfest(entrypoints, buildOutput, config) {
1249
1320
  addDevModePermissions(manifest, config);
1250
1321
  if (manifest.name == null)
1251
1322
  throw Error(
1252
- "Manifest 'name' is missing. Either:\n1. Set the name in your <root>/package.json\n2. Set a name via the manifest option in your wxt.config.ts"
1323
+ "Manifest 'name' is missing. Either:\n1. Set the name in your <rootDir>/package.json\n2. Set a name via the manifest option in your wxt.config.ts"
1253
1324
  );
1254
1325
  if (manifest.version == null) {
1255
1326
  throw Error(
1256
- "Manifest 'version' is missing. Either:\n1. Add a version in your <root>/package.json\n2. Pass the version via the manifest option in your wxt.config.ts"
1327
+ "Manifest 'version' is missing. Either:\n1. Add a version in your <rootDir>/package.json\n2. Pass the version via the manifest option in your wxt.config.ts"
1257
1328
  );
1258
1329
  }
1259
1330
  return manifest;
@@ -1500,8 +1571,8 @@ function addHostPermission(manifest, hostPermission) {
1500
1571
 
1501
1572
  // src/core/build.ts
1502
1573
  import pc2 from "picocolors";
1503
- import * as vite3 from "vite";
1504
- import fs12 from "fs-extra";
1574
+ import * as vite4 from "vite";
1575
+ import fs13 from "fs-extra";
1505
1576
 
1506
1577
  // src/core/utils/groupEntrypoints.ts
1507
1578
  function groupEntrypoints(entrypoints) {
@@ -1534,7 +1605,9 @@ var ENTRY_TYPE_TO_GROUP_MAP = {
1534
1605
  "unlisted-page": "extension-page",
1535
1606
  background: "no-group",
1536
1607
  "content-script": "no-group",
1537
- "unlisted-script": "no-group"
1608
+ "unlisted-script": "no-group",
1609
+ "unlisted-style": "no-group",
1610
+ "content-script-style": "no-group"
1538
1611
  };
1539
1612
 
1540
1613
  // src/core/utils/formatDuration.ts
@@ -1554,7 +1627,7 @@ import { resolve as resolve13 } from "path";
1554
1627
  // src/core/log/printFileList.ts
1555
1628
  import path4 from "node:path";
1556
1629
  import pc from "picocolors";
1557
- import fs11 from "fs-extra";
1630
+ import fs12 from "fs-extra";
1558
1631
  import { filesize } from "filesize";
1559
1632
 
1560
1633
  // src/core/log/printTable.ts
@@ -1594,7 +1667,7 @@ async function printFileList(log, baseDir, files) {
1594
1667
  ];
1595
1668
  const prefix = i === files.length - 1 ? " \u2514\u2500" : " \u251C\u2500";
1596
1669
  const color = getChunkColor(file);
1597
- const stats = await fs11.lstat(file);
1670
+ const stats = await fs12.lstat(file);
1598
1671
  totalSize += stats.size;
1599
1672
  const size = String(filesize(stats.size));
1600
1673
  return [
@@ -1654,12 +1727,12 @@ async function buildInternal(config) {
1654
1727
  const target = `${config.browser}-mv${config.manifestVersion}`;
1655
1728
  config.logger.info(
1656
1729
  `${verb} ${pc2.cyan(target)} for ${pc2.cyan(config.mode)} with ${pc2.green(
1657
- `Vite ${vite3.version}`
1730
+ `Vite ${vite4.version}`
1658
1731
  )}`
1659
1732
  );
1660
1733
  const startTime = Date.now();
1661
- await fs12.rm(config.outDir, { recursive: true, force: true });
1662
- await fs12.ensureDir(config.outDir);
1734
+ await fs13.rm(config.outDir, { recursive: true, force: true });
1735
+ await fs13.ensureDir(config.outDir);
1663
1736
  const entrypoints = await findEntrypoints(config);
1664
1737
  const groups = groupEntrypoints(entrypoints);
1665
1738
  const { output } = await rebuild(config, groups, void 0);
@@ -1708,7 +1781,7 @@ async function rebuild(config, entrypointGroups, existingOutput = {
1708
1781
  }
1709
1782
 
1710
1783
  // src/core/server.ts
1711
- import * as vite4 from "vite";
1784
+ import * as vite5 from "vite";
1712
1785
 
1713
1786
  // src/core/runners/createWebExtRunner.ts
1714
1787
  function createWebExtRunner() {
@@ -1787,8 +1860,8 @@ async function getServerInfo() {
1787
1860
  }
1788
1861
  async function setupServer(serverInfo, config) {
1789
1862
  const runner = createWebExtRunner();
1790
- const viteServer = await vite4.createServer(
1791
- vite4.mergeConfig(serverInfo, config.vite)
1863
+ const viteServer = await vite5.createServer(
1864
+ vite5.mergeConfig(serverInfo, config.vite)
1792
1865
  );
1793
1866
  const start = async () => {
1794
1867
  await viteServer.listen(server.port);
@@ -1854,7 +1927,7 @@ function reloadHtmlPages(groups, server, config) {
1854
1927
  }
1855
1928
 
1856
1929
  // package.json
1857
- var version2 = "0.2.5";
1930
+ var version2 = "0.3.1";
1858
1931
 
1859
1932
  // src/core/utils/defineConfig.ts
1860
1933
  function defineConfig(config) {
@@ -1874,7 +1947,7 @@ async function build2(config) {
1874
1947
  async function createServer2(config) {
1875
1948
  const serverInfo = await getServerInfo();
1876
1949
  const getLatestInternalConfig = () => {
1877
- const viteConfig = vite5.mergeConfig(
1950
+ const viteConfig = vite6.mergeConfig(
1878
1951
  serverInfo.viteServerConfig,
1879
1952
  config?.vite ?? {}
1880
1953
  );