wxt 0.10.2 → 0.10.4

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.
@@ -1,17 +1,17 @@
1
1
  // package.json
2
- var version = "0.10.2";
2
+ var version = "0.10.4";
3
3
 
4
4
  // src/core/utils/entrypoints.ts
5
5
  import path, { relative, resolve } from "node:path";
6
6
 
7
7
  // src/core/utils/paths.ts
8
- import nodePath from "node:path";
9
- import * as vite from "vite";
10
- function normalizePath2(path7) {
11
- return vite.normalizePath(path7);
8
+ import systemPath from "node:path";
9
+ import normalize from "normalize-path";
10
+ function normalizePath(path7) {
11
+ return normalize(path7);
12
12
  }
13
13
  function unnormalizePath(path7) {
14
- return nodePath.normalize(path7);
14
+ return systemPath.normalize(path7);
15
15
  }
16
16
  var CSS_EXTENSIONS = ["css", "scss", "sass", "less", "styl", "stylus"];
17
17
  var CSS_EXTENSIONS_PATTERN = `+(${CSS_EXTENSIONS.join("|")})`;
@@ -26,7 +26,7 @@ function getEntrypointOutputFile(entrypoint, ext) {
26
26
  return resolve(entrypoint.outputDir, `${entrypoint.name}${ext}`);
27
27
  }
28
28
  function getEntrypointBundlePath(entrypoint, outDir, ext) {
29
- return normalizePath2(
29
+ return normalizePath(
30
30
  relative(outDir, getEntrypointOutputFile(entrypoint, ext))
31
31
  );
32
32
  }
@@ -143,14 +143,14 @@ function getUnimportOptions(config) {
143
143
 
144
144
  // src/core/vite-plugins/unimport.ts
145
145
  import { extname } from "path";
146
- var ENABLED_EXTENSIONS = {
147
- ".js": true,
148
- ".jsx": true,
149
- ".ts": true,
150
- ".tsx": true,
151
- ".vue": true,
152
- ".svelte": true
153
- };
146
+ var ENABLED_EXTENSIONS = /* @__PURE__ */ new Set([
147
+ ".js",
148
+ ".jsx",
149
+ ".ts",
150
+ ".tsx",
151
+ ".vue",
152
+ ".svelte"
153
+ ]);
154
154
  function unimport(config) {
155
155
  const options = getUnimportOptions(config);
156
156
  if (options === false)
@@ -162,9 +162,11 @@ function unimport(config) {
162
162
  await unimport2.scanImportsFromDir(void 0, { cwd: config.srcDir });
163
163
  },
164
164
  async transform(code, id) {
165
- const ext = extname(id);
166
- if (ENABLED_EXTENSIONS[ext])
167
- return unimport2.injectImports(code, id);
165
+ if (id.includes("node_modules"))
166
+ return;
167
+ if (!ENABLED_EXTENSIONS.has(extname(id)))
168
+ return;
169
+ return unimport2.injectImports(code, id);
168
170
  }
169
171
  };
170
172
  }
@@ -443,7 +445,7 @@ function multipageMove(entrypoints, config) {
443
445
  async writeBundle(_, bundle) {
444
446
  for (const oldBundlePath in bundle) {
445
447
  const entrypoint = entrypoints.find(
446
- (entry) => !!normalizePath2(entry.inputPath).endsWith(oldBundlePath)
448
+ (entry) => !!normalizePath(entry.inputPath).endsWith(oldBundlePath)
447
449
  );
448
450
  if (entrypoint == null) {
449
451
  config.logger.debug(
@@ -490,7 +492,7 @@ function virtualEntrypoint(type, config) {
490
492
  const index = id.indexOf(virtualId);
491
493
  if (index === -1)
492
494
  return;
493
- const inputPath = normalizePath2(id.substring(index + virtualId.length));
495
+ const inputPath = normalizePath(id.substring(index + virtualId.length));
494
496
  return resolvedVirtualId + inputPath;
495
497
  },
496
498
  async load(id) {
@@ -659,7 +661,7 @@ function detectDevChanges(changedFiles, currentOutput) {
659
661
  }
660
662
  function findEffectedSteps(changedFile, currentOutput) {
661
663
  const changes = [];
662
- const changedPath = normalizePath2(changedFile[1]);
664
+ const changedPath = normalizePath(changedFile[1]);
663
665
  const isChunkEffected = (chunk) => (
664
666
  // If it's an HTML file with the same path, is is effected because HTML files need to be pre-rendered
665
667
  // fileName is normalized, relative bundle path
@@ -688,7 +690,7 @@ import { parseHTML as parseHTML2 } from "linkedom";
688
690
  import JSON5 from "json5";
689
691
 
690
692
  // src/core/utils/building/build-entrypoints.ts
691
- import * as vite2 from "vite";
693
+ import * as vite from "vite";
692
694
 
693
695
  // src/core/utils/fs.ts
694
696
  import fs3 from "fs-extra";
@@ -787,11 +789,11 @@ async function buildSingleEntrypoint(entrypoint, config) {
787
789
  for (const global of getEntrypointGlobals(config, entrypoint.name)) {
788
790
  libMode.define[global.name] = JSON.stringify(global.value);
789
791
  }
790
- const entryConfig = vite2.mergeConfig(
792
+ const entryConfig = vite.mergeConfig(
791
793
  libMode,
792
794
  await config.vite(config.env)
793
795
  );
794
- const result = await vite2.build(entryConfig);
796
+ const result = await vite.build(entryConfig);
795
797
  return {
796
798
  entrypoints: entrypoint,
797
799
  chunks: getBuildOutputChunks(result)
@@ -822,11 +824,11 @@ async function buildMultipleEntrypoints(entrypoints, config) {
822
824
  for (const global of getEntrypointGlobals(config, "html")) {
823
825
  multiPage.define[global.name] = JSON.stringify(global.value);
824
826
  }
825
- const entryConfig = vite2.mergeConfig(
827
+ const entryConfig = vite.mergeConfig(
826
828
  multiPage,
827
829
  await config.vite(config.env)
828
830
  );
829
- const result = await vite2.build(entryConfig);
831
+ const result = await vite.build(entryConfig);
830
832
  return {
831
833
  entrypoints,
832
834
  chunks: getBuildOutputChunks(result)
@@ -937,7 +939,7 @@ async function writePathsDeclarationFile(entrypoints, config) {
937
939
  config.outDir,
938
940
  entry.inputPath.endsWith(".html") ? ".html" : ".js"
939
941
  )
940
- ).concat(await getPublicFiles(config)).map(normalizePath2).map((path7) => ` | "/${path7}"`).sort().join("\n");
942
+ ).concat(await getPublicFiles(config)).map(normalizePath).map((path7) => ` | "/${path7}"`).sort().join("\n");
941
943
  const template = `// Generated by wxt
942
944
  import "wxt/browser";
943
945
 
@@ -1032,7 +1034,7 @@ async function writeMainDeclarationFile(references, config) {
1032
1034
  "// Generated by wxt",
1033
1035
  `/// <reference types="vite/client" />`,
1034
1036
  ...references.map(
1035
- (ref) => `/// <reference types="./${normalizePath2(relative3(dir, ref))}" />`
1037
+ (ref) => `/// <reference types="./${normalizePath(relative3(dir, ref))}" />`
1036
1038
  )
1037
1039
  ].join("\n") + "\n"
1038
1040
  );
@@ -1040,7 +1042,7 @@ async function writeMainDeclarationFile(references, config) {
1040
1042
  }
1041
1043
  async function writeTsConfigFile(mainReference, config) {
1042
1044
  const dir = config.wxtDir;
1043
- const getTsconfigPath = (path7) => normalizePath2(relative3(dir, path7));
1045
+ const getTsconfigPath = (path7) => normalizePath(relative3(dir, path7));
1044
1046
  const paths = Object.entries(config.alias).flatMap(([alias, absolutePath]) => {
1045
1047
  const aliasPath = getTsconfigPath(absolutePath);
1046
1048
  return [
@@ -1077,7 +1079,7 @@ ${paths}
1077
1079
  // src/core/utils/building/get-internal-config.ts
1078
1080
  import { loadConfig } from "c12";
1079
1081
  import path5 from "node:path";
1080
- import * as vite3 from "vite";
1082
+ import * as vite2 from "vite";
1081
1083
 
1082
1084
  // src/core/utils/cache.ts
1083
1085
  import fs6, { ensureDir as ensureDir2 } from "fs-extra";
@@ -1103,6 +1105,7 @@ function createFsCache(wxtDir) {
1103
1105
 
1104
1106
  // src/core/utils/building/get-internal-config.ts
1105
1107
  import consola, { LogLevels } from "consola";
1108
+ import defu from "defu";
1106
1109
  async function getInternalConfig(inlineConfig, command) {
1107
1110
  let userConfig = {};
1108
1111
  let userConfigMetadata;
@@ -1135,7 +1138,7 @@ async function getInternalConfig(inlineConfig, command) {
1135
1138
  );
1136
1139
  const publicDir = path5.resolve(srcDir, mergedConfig.publicDir ?? "public");
1137
1140
  const typesDir = path5.resolve(wxtDir, "types");
1138
- const outBaseDir = path5.resolve(root, ".output");
1141
+ const outBaseDir = path5.resolve(root, mergedConfig.outDir ?? ".output");
1139
1142
  const outDir = path5.resolve(outBaseDir, `${browser}-mv${manifestVersion}`);
1140
1143
  const runnerConfig = await loadConfig({
1141
1144
  name: "web-ext",
@@ -1204,7 +1207,7 @@ function mergeInlineConfig(inlineConfig, userConfig) {
1204
1207
  } else if (userConfig.imports == null && inlineConfig.imports == null) {
1205
1208
  imports = void 0;
1206
1209
  } else {
1207
- imports = vite3.mergeConfig(
1210
+ imports = vite2.mergeConfig(
1208
1211
  userConfig.imports ?? {},
1209
1212
  inlineConfig.imports ?? {}
1210
1213
  );
@@ -1212,20 +1215,20 @@ function mergeInlineConfig(inlineConfig, userConfig) {
1212
1215
  const manifest = async (env) => {
1213
1216
  const user = await resolveManifestConfig(env, userConfig.manifest);
1214
1217
  const inline = await resolveManifestConfig(env, inlineConfig.manifest);
1215
- return vite3.mergeConfig(user, inline);
1218
+ return vite2.mergeConfig(user, inline);
1216
1219
  };
1217
1220
  const viteConfig = async (env) => {
1218
1221
  const user = await userConfig.vite?.(env);
1219
1222
  const inline = await inlineConfig.vite?.(env);
1220
- return vite3.mergeConfig(user ?? {}, inline ?? {});
1223
+ return vite2.mergeConfig(user ?? {}, inline ?? {});
1221
1224
  };
1222
- const runner = vite3.mergeConfig(
1223
- userConfig.runner ?? {},
1224
- inlineConfig.runner ?? {}
1225
+ const runner = defu(
1226
+ inlineConfig.runner ?? {},
1227
+ userConfig.runner ?? {}
1225
1228
  );
1226
- const zip = vite3.mergeConfig(
1227
- userConfig.zip ?? {},
1228
- inlineConfig.zip ?? {}
1229
+ const zip = defu(
1230
+ inlineConfig.zip ?? {},
1231
+ userConfig.zip ?? {}
1229
1232
  );
1230
1233
  return {
1231
1234
  root: inlineConfig.root ?? userConfig.root,
@@ -1241,6 +1244,7 @@ function mergeInlineConfig(inlineConfig, userConfig) {
1241
1244
  publicDir: inlineConfig.publicDir ?? userConfig.publicDir,
1242
1245
  runner,
1243
1246
  srcDir: inlineConfig.srcDir ?? userConfig.srcDir,
1247
+ outDir: inlineConfig.outDir ?? userConfig.outDir,
1244
1248
  vite: viteConfig,
1245
1249
  zip,
1246
1250
  analysis: {
@@ -1254,11 +1258,13 @@ function mergeInlineConfig(inlineConfig, userConfig) {
1254
1258
  experimental: {
1255
1259
  ...userConfig.experimental,
1256
1260
  ...inlineConfig.experimental
1257
- }
1261
+ },
1262
+ transformManifest: void 0
1258
1263
  };
1259
1264
  }
1260
1265
  function resolveInternalZipConfig(root, mergedConfig) {
1261
1266
  return {
1267
+ name: void 0,
1262
1268
  sourcesTemplate: "{{name}}-{{version}}-sources.zip",
1263
1269
  artifactTemplate: "{{name}}-{{version}}-{{browser}}.zip",
1264
1270
  sourcesRoot: root,
@@ -1374,7 +1380,7 @@ ${noImports}`;
1374
1380
  import { transformSync } from "esbuild";
1375
1381
  async function importEntrypointFile(path7, config) {
1376
1382
  config.logger.debug("Loading file metadata:", path7);
1377
- const normalPath = normalizePath2(path7);
1383
+ const normalPath = normalizePath(path7);
1378
1384
  const unimport2 = createUnimport3({
1379
1385
  ...getUnimportOptions(config),
1380
1386
  // Only allow specific imports, not all from the project
@@ -1430,7 +1436,7 @@ function getEsbuildOptions(opts) {
1430
1436
 
1431
1437
  // src/core/utils/building/internal-build.ts
1432
1438
  import pc4 from "picocolors";
1433
- import * as vite5 from "vite";
1439
+ import * as vite3 from "vite";
1434
1440
  import fs11 from "fs-extra";
1435
1441
 
1436
1442
  // src/core/utils/log/printBuildSummary.ts
@@ -1667,7 +1673,7 @@ async function getPackageJson(config) {
1667
1673
 
1668
1674
  // src/core/utils/manifest.ts
1669
1675
  import { produce } from "immer";
1670
- import * as vite4 from "vite";
1676
+ import defu2 from "defu";
1671
1677
  async function writeManifest(manifest, output, config) {
1672
1678
  const str = config.mode === "production" ? JSON.stringify(manifest) : JSON.stringify(manifest, null, 2);
1673
1679
  await fs10.ensureDir(config.outDir);
@@ -1697,9 +1703,9 @@ async function generateMainfest(entrypoints, buildOutput, config) {
1697
1703
  icons: discoverIcons(buildOutput)
1698
1704
  };
1699
1705
  const userManifest = config.manifest;
1700
- const manifest = vite4.mergeConfig(
1701
- baseManifest,
1702
- userManifest
1706
+ const manifest = defu2(
1707
+ userManifest,
1708
+ baseManifest
1703
1709
  );
1704
1710
  addEntrypoints(manifest, entrypoints, buildOutput, config);
1705
1711
  if (config.command === "serve")
@@ -1958,7 +1964,7 @@ function discoverIcons(buildOutput) {
1958
1964
  }
1959
1965
  if (size == null)
1960
1966
  return;
1961
- icons.push([size, normalizePath2(asset.fileName)]);
1967
+ icons.push([size, normalizePath(asset.fileName)]);
1962
1968
  });
1963
1969
  return icons.length > 0 ? Object.fromEntries(icons) : void 0;
1964
1970
  }
@@ -2098,7 +2104,7 @@ async function internalBuild(config) {
2098
2104
  const target = `${config.browser}-mv${config.manifestVersion}`;
2099
2105
  config.logger.info(
2100
2106
  `${verb} ${pc4.cyan(target)} for ${pc4.cyan(config.mode)} with ${pc4.green(
2101
- `Vite ${vite5.version}`
2107
+ `Vite ${vite3.version}`
2102
2108
  )}`
2103
2109
  );
2104
2110
  const startTime = Date.now();
package/dist/cli.cjs CHANGED
@@ -2316,11 +2316,11 @@ function execaNode(scriptPath, args, options = {}) {
2316
2316
  const stdio = normalizeStdioNode(options);
2317
2317
  const defaultExecArgv = import_node_process4.default.execArgv.filter((arg) => !arg.startsWith("--inspect"));
2318
2318
  const {
2319
- nodePath: nodePath2 = import_node_process4.default.execPath,
2319
+ nodePath = import_node_process4.default.execPath,
2320
2320
  nodeOptions = defaultExecArgv
2321
2321
  } = options;
2322
2322
  return execa(
2323
- nodePath2,
2323
+ nodePath,
2324
2324
  [
2325
2325
  ...nodeOptions,
2326
2326
  scriptPath,
@@ -2415,19 +2415,19 @@ var init_execa = __esm({
2415
2415
  var import_cac = __toESM(require("cac"), 1);
2416
2416
 
2417
2417
  // package.json
2418
- var version = "0.10.2";
2418
+ var version = "0.10.4";
2419
2419
 
2420
2420
  // src/core/utils/building/build-entrypoints.ts
2421
- var vite2 = __toESM(require("vite"), 1);
2421
+ var vite = __toESM(require("vite"), 1);
2422
2422
 
2423
2423
  // src/core/utils/entrypoints.ts
2424
2424
  var import_node_path2 = __toESM(require("path"), 1);
2425
2425
 
2426
2426
  // src/core/utils/paths.ts
2427
2427
  var import_node_path = __toESM(require("path"), 1);
2428
- var vite = __toESM(require("vite"), 1);
2429
- function normalizePath2(path11) {
2430
- return vite.normalizePath(path11);
2428
+ var import_normalize_path = __toESM(require("normalize-path"), 1);
2429
+ function normalizePath(path11) {
2430
+ return (0, import_normalize_path.default)(path11);
2431
2431
  }
2432
2432
  function unnormalizePath(path11) {
2433
2433
  return import_node_path.default.normalize(path11);
@@ -2445,7 +2445,7 @@ function getEntrypointOutputFile(entrypoint, ext) {
2445
2445
  return (0, import_node_path2.resolve)(entrypoint.outputDir, `${entrypoint.name}${ext}`);
2446
2446
  }
2447
2447
  function getEntrypointBundlePath(entrypoint, outDir, ext) {
2448
- return normalizePath2(
2448
+ return normalizePath(
2449
2449
  (0, import_node_path2.relative)(outDir, getEntrypointOutputFile(entrypoint, ext))
2450
2450
  );
2451
2451
  }
@@ -2680,7 +2680,7 @@ function multipageMove(entrypoints, config) {
2680
2680
  async writeBundle(_, bundle) {
2681
2681
  for (const oldBundlePath in bundle) {
2682
2682
  const entrypoint = entrypoints.find(
2683
- (entry) => !!normalizePath2(entry.inputPath).endsWith(oldBundlePath)
2683
+ (entry) => !!normalizePath(entry.inputPath).endsWith(oldBundlePath)
2684
2684
  );
2685
2685
  if (entrypoint == null) {
2686
2686
  config.logger.debug(
@@ -2746,14 +2746,14 @@ function getUnimportOptions(config) {
2746
2746
 
2747
2747
  // src/core/vite-plugins/unimport.ts
2748
2748
  var import_path2 = require("path");
2749
- var ENABLED_EXTENSIONS = {
2750
- ".js": true,
2751
- ".jsx": true,
2752
- ".ts": true,
2753
- ".tsx": true,
2754
- ".vue": true,
2755
- ".svelte": true
2756
- };
2749
+ var ENABLED_EXTENSIONS = /* @__PURE__ */ new Set([
2750
+ ".js",
2751
+ ".jsx",
2752
+ ".ts",
2753
+ ".tsx",
2754
+ ".vue",
2755
+ ".svelte"
2756
+ ]);
2757
2757
  function unimport(config) {
2758
2758
  const options = getUnimportOptions(config);
2759
2759
  if (options === false)
@@ -2765,9 +2765,11 @@ function unimport(config) {
2765
2765
  await unimport2.scanImportsFromDir(void 0, { cwd: config.srcDir });
2766
2766
  },
2767
2767
  async transform(code, id) {
2768
- const ext = (0, import_path2.extname)(id);
2769
- if (ENABLED_EXTENSIONS[ext])
2770
- return unimport2.injectImports(code, id);
2768
+ if (id.includes("node_modules"))
2769
+ return;
2770
+ if (!ENABLED_EXTENSIONS.has((0, import_path2.extname)(id)))
2771
+ return;
2772
+ return unimport2.injectImports(code, id);
2771
2773
  }
2772
2774
  };
2773
2775
  }
@@ -2784,7 +2786,7 @@ function virtualEntrypoint(type, config) {
2784
2786
  const index = id.indexOf(virtualId);
2785
2787
  if (index === -1)
2786
2788
  return;
2787
- const inputPath = normalizePath2(id.substring(index + virtualId.length));
2789
+ const inputPath = normalizePath(id.substring(index + virtualId.length));
2788
2790
  return resolvedVirtualId + inputPath;
2789
2791
  },
2790
2792
  async load(id) {
@@ -3070,11 +3072,11 @@ async function buildSingleEntrypoint(entrypoint, config) {
3070
3072
  for (const global3 of getEntrypointGlobals(config, entrypoint.name)) {
3071
3073
  libMode.define[global3.name] = JSON.stringify(global3.value);
3072
3074
  }
3073
- const entryConfig = vite2.mergeConfig(
3075
+ const entryConfig = vite.mergeConfig(
3074
3076
  libMode,
3075
3077
  await config.vite(config.env)
3076
3078
  );
3077
- const result = await vite2.build(entryConfig);
3079
+ const result = await vite.build(entryConfig);
3078
3080
  return {
3079
3081
  entrypoints: entrypoint,
3080
3082
  chunks: getBuildOutputChunks(result)
@@ -3105,11 +3107,11 @@ async function buildMultipleEntrypoints(entrypoints, config) {
3105
3107
  for (const global3 of getEntrypointGlobals(config, "html")) {
3106
3108
  multiPage.define[global3.name] = JSON.stringify(global3.value);
3107
3109
  }
3108
- const entryConfig = vite2.mergeConfig(
3110
+ const entryConfig = vite.mergeConfig(
3109
3111
  multiPage,
3110
3112
  await config.vite(config.env)
3111
3113
  );
3112
- const result = await vite2.build(entryConfig);
3114
+ const result = await vite.build(entryConfig);
3113
3115
  return {
3114
3116
  entrypoints,
3115
3117
  chunks: getBuildOutputChunks(result)
@@ -3214,7 +3216,7 @@ function detectDevChanges(changedFiles, currentOutput) {
3214
3216
  }
3215
3217
  function findEffectedSteps(changedFile, currentOutput) {
3216
3218
  const changes = [];
3217
- const changedPath = normalizePath2(changedFile[1]);
3219
+ const changedPath = normalizePath(changedFile[1]);
3218
3220
  const isChunkEffected = (chunk) => (
3219
3221
  // If it's an HTML file with the same path, is is effected because HTML files need to be pre-rendered
3220
3222
  // fileName is normalized, relative bundle path
@@ -3615,7 +3617,7 @@ async function writePathsDeclarationFile(entrypoints, config) {
3615
3617
  config.outDir,
3616
3618
  entry.inputPath.endsWith(".html") ? ".html" : ".js"
3617
3619
  )
3618
- ).concat(await getPublicFiles(config)).map(normalizePath2).map((path11) => ` | "/${path11}"`).sort().join("\n");
3620
+ ).concat(await getPublicFiles(config)).map(normalizePath).map((path11) => ` | "/${path11}"`).sort().join("\n");
3619
3621
  const template = `// Generated by wxt
3620
3622
  import "wxt/browser";
3621
3623
 
@@ -3710,7 +3712,7 @@ async function writeMainDeclarationFile(references, config) {
3710
3712
  "// Generated by wxt",
3711
3713
  `/// <reference types="vite/client" />`,
3712
3714
  ...references.map(
3713
- (ref) => `/// <reference types="./${normalizePath2((0, import_path6.relative)(dir, ref))}" />`
3715
+ (ref) => `/// <reference types="./${normalizePath((0, import_path6.relative)(dir, ref))}" />`
3714
3716
  )
3715
3717
  ].join("\n") + "\n"
3716
3718
  );
@@ -3718,7 +3720,7 @@ async function writeMainDeclarationFile(references, config) {
3718
3720
  }
3719
3721
  async function writeTsConfigFile(mainReference, config) {
3720
3722
  const dir = config.wxtDir;
3721
- const getTsconfigPath = (path11) => normalizePath2((0, import_path6.relative)(dir, path11));
3723
+ const getTsconfigPath = (path11) => normalizePath((0, import_path6.relative)(dir, path11));
3722
3724
  const paths = Object.entries(config.alias).flatMap(([alias, absolutePath]) => {
3723
3725
  const aliasPath = getTsconfigPath(absolutePath);
3724
3726
  return [
@@ -3755,7 +3757,7 @@ ${paths}
3755
3757
  // src/core/utils/building/get-internal-config.ts
3756
3758
  var import_c12 = require("c12");
3757
3759
  var import_node_path7 = __toESM(require("path"), 1);
3758
- var vite3 = __toESM(require("vite"), 1);
3760
+ var vite2 = __toESM(require("vite"), 1);
3759
3761
 
3760
3762
  // src/core/utils/cache.ts
3761
3763
  var import_fs_extra7 = __toESM(require("fs-extra"), 1);
@@ -3781,6 +3783,7 @@ function createFsCache(wxtDir) {
3781
3783
 
3782
3784
  // src/core/utils/building/get-internal-config.ts
3783
3785
  var import_consola = __toESM(require("consola"), 1);
3786
+ var import_defu = __toESM(require("defu"), 1);
3784
3787
  async function getInternalConfig(inlineConfig, command) {
3785
3788
  let userConfig = {};
3786
3789
  let userConfigMetadata;
@@ -3813,7 +3816,7 @@ async function getInternalConfig(inlineConfig, command) {
3813
3816
  );
3814
3817
  const publicDir = import_node_path7.default.resolve(srcDir, mergedConfig.publicDir ?? "public");
3815
3818
  const typesDir = import_node_path7.default.resolve(wxtDir, "types");
3816
- const outBaseDir = import_node_path7.default.resolve(root, ".output");
3819
+ const outBaseDir = import_node_path7.default.resolve(root, mergedConfig.outDir ?? ".output");
3817
3820
  const outDir = import_node_path7.default.resolve(outBaseDir, `${browser}-mv${manifestVersion}`);
3818
3821
  const runnerConfig = await (0, import_c12.loadConfig)({
3819
3822
  name: "web-ext",
@@ -3882,7 +3885,7 @@ function mergeInlineConfig(inlineConfig, userConfig) {
3882
3885
  } else if (userConfig.imports == null && inlineConfig.imports == null) {
3883
3886
  imports = void 0;
3884
3887
  } else {
3885
- imports = vite3.mergeConfig(
3888
+ imports = vite2.mergeConfig(
3886
3889
  userConfig.imports ?? {},
3887
3890
  inlineConfig.imports ?? {}
3888
3891
  );
@@ -3890,20 +3893,20 @@ function mergeInlineConfig(inlineConfig, userConfig) {
3890
3893
  const manifest = async (env) => {
3891
3894
  const user = await resolveManifestConfig(env, userConfig.manifest);
3892
3895
  const inline = await resolveManifestConfig(env, inlineConfig.manifest);
3893
- return vite3.mergeConfig(user, inline);
3896
+ return vite2.mergeConfig(user, inline);
3894
3897
  };
3895
3898
  const viteConfig = async (env) => {
3896
3899
  const user = await userConfig.vite?.(env);
3897
3900
  const inline = await inlineConfig.vite?.(env);
3898
- return vite3.mergeConfig(user ?? {}, inline ?? {});
3901
+ return vite2.mergeConfig(user ?? {}, inline ?? {});
3899
3902
  };
3900
- const runner = vite3.mergeConfig(
3901
- userConfig.runner ?? {},
3902
- inlineConfig.runner ?? {}
3903
+ const runner = (0, import_defu.default)(
3904
+ inlineConfig.runner ?? {},
3905
+ userConfig.runner ?? {}
3903
3906
  );
3904
- const zip2 = vite3.mergeConfig(
3905
- userConfig.zip ?? {},
3906
- inlineConfig.zip ?? {}
3907
+ const zip2 = (0, import_defu.default)(
3908
+ inlineConfig.zip ?? {},
3909
+ userConfig.zip ?? {}
3907
3910
  );
3908
3911
  return {
3909
3912
  root: inlineConfig.root ?? userConfig.root,
@@ -3919,6 +3922,7 @@ function mergeInlineConfig(inlineConfig, userConfig) {
3919
3922
  publicDir: inlineConfig.publicDir ?? userConfig.publicDir,
3920
3923
  runner,
3921
3924
  srcDir: inlineConfig.srcDir ?? userConfig.srcDir,
3925
+ outDir: inlineConfig.outDir ?? userConfig.outDir,
3922
3926
  vite: viteConfig,
3923
3927
  zip: zip2,
3924
3928
  analysis: {
@@ -3932,11 +3936,13 @@ function mergeInlineConfig(inlineConfig, userConfig) {
3932
3936
  experimental: {
3933
3937
  ...userConfig.experimental,
3934
3938
  ...inlineConfig.experimental
3935
- }
3939
+ },
3940
+ transformManifest: void 0
3936
3941
  };
3937
3942
  }
3938
3943
  function resolveInternalZipConfig(root, mergedConfig) {
3939
3944
  return {
3945
+ name: void 0,
3940
3946
  sourcesTemplate: "{{name}}-{{version}}-sources.zip",
3941
3947
  artifactTemplate: "{{name}}-{{version}}-{{browser}}.zip",
3942
3948
  sourcesRoot: root,
@@ -4052,7 +4058,7 @@ ${noImports}`;
4052
4058
  var import_esbuild = require("esbuild");
4053
4059
  async function importEntrypointFile(path11, config) {
4054
4060
  config.logger.debug("Loading file metadata:", path11);
4055
- const normalPath = normalizePath2(path11);
4061
+ const normalPath = normalizePath(path11);
4056
4062
  const unimport2 = (0, import_unimport5.createUnimport)({
4057
4063
  ...getUnimportOptions(config),
4058
4064
  // Only allow specific imports, not all from the project
@@ -4108,7 +4114,7 @@ function getEsbuildOptions(opts) {
4108
4114
 
4109
4115
  // src/core/utils/building/internal-build.ts
4110
4116
  var import_picocolors4 = __toESM(require("picocolors"), 1);
4111
- var vite5 = __toESM(require("vite"), 1);
4117
+ var vite3 = __toESM(require("vite"), 1);
4112
4118
  var import_fs_extra12 = __toESM(require("fs-extra"), 1);
4113
4119
 
4114
4120
  // src/core/utils/log/printBuildSummary.ts
@@ -4349,7 +4355,7 @@ async function getPackageJson(config) {
4349
4355
 
4350
4356
  // src/core/utils/manifest.ts
4351
4357
  var import_immer = require("immer");
4352
- var vite4 = __toESM(require("vite"), 1);
4358
+ var import_defu2 = __toESM(require("defu"), 1);
4353
4359
  async function writeManifest(manifest, output, config) {
4354
4360
  const str = config.mode === "production" ? JSON.stringify(manifest) : JSON.stringify(manifest, null, 2);
4355
4361
  await import_fs_extra11.default.ensureDir(config.outDir);
@@ -4379,9 +4385,9 @@ async function generateMainfest(entrypoints, buildOutput, config) {
4379
4385
  icons: discoverIcons(buildOutput)
4380
4386
  };
4381
4387
  const userManifest = config.manifest;
4382
- const manifest = vite4.mergeConfig(
4383
- baseManifest,
4384
- userManifest
4388
+ const manifest = (0, import_defu2.default)(
4389
+ userManifest,
4390
+ baseManifest
4385
4391
  );
4386
4392
  addEntrypoints(manifest, entrypoints, buildOutput, config);
4387
4393
  if (config.command === "serve")
@@ -4640,7 +4646,7 @@ function discoverIcons(buildOutput) {
4640
4646
  }
4641
4647
  if (size == null)
4642
4648
  return;
4643
- icons.push([size, normalizePath2(asset.fileName)]);
4649
+ icons.push([size, normalizePath(asset.fileName)]);
4644
4650
  });
4645
4651
  return icons.length > 0 ? Object.fromEntries(icons) : void 0;
4646
4652
  }
@@ -4780,7 +4786,7 @@ async function internalBuild(config) {
4780
4786
  const target = `${config.browser}-mv${config.manifestVersion}`;
4781
4787
  config.logger.info(
4782
4788
  `${verb} ${import_picocolors4.default.cyan(target)} for ${import_picocolors4.default.cyan(config.mode)} with ${import_picocolors4.default.green(
4783
- `Vite ${vite5.version}`
4789
+ `Vite ${vite3.version}`
4784
4790
  )}`
4785
4791
  );
4786
4792
  const startTime = Date.now();
@@ -4860,7 +4866,7 @@ async function clean(root = process.cwd()) {
4860
4866
  }
4861
4867
 
4862
4868
  // src/core/create-server.ts
4863
- var vite6 = __toESM(require("vite"), 1);
4869
+ var vite4 = __toESM(require("vite"), 1);
4864
4870
 
4865
4871
  // src/core/runners/wsl.ts
4866
4872
  var import_node_path13 = require("path");
@@ -5077,8 +5083,8 @@ async function getServerInfo() {
5077
5083
  }
5078
5084
  async function setupServer(serverInfo, config) {
5079
5085
  const runner = await createExtensionRunner(config);
5080
- const viteServer = await vite6.createServer(
5081
- vite6.mergeConfig(serverInfo, await config.vite(config.env))
5086
+ const viteServer = await vite4.createServer(
5087
+ vite4.mergeConfig(serverInfo, await config.vite(config.env))
5082
5088
  );
5083
5089
  const start = async () => {
5084
5090
  await viteServer.listen(server.port);
@@ -109,6 +109,12 @@ interface InlineConfig {
109
109
  * @default "${config.srcDir}/entrypoints"
110
110
  */
111
111
  entrypointsDir?: string;
112
+ /**
113
+ * Output directory that stored build folders and ZIPs.
114
+ *
115
+ * @default ".output"
116
+ */
117
+ outDir?: string;
112
118
  /**
113
119
  * > Only available when using the JS API. Not available in `wxt.config.ts` files
114
120
  *
@@ -393,7 +399,7 @@ interface BaseEntrypoint {
393
399
  * - `named.sandbox.html` &rarr; `named`
394
400
  * - `named.sandbox/index.html` &rarr; `named`
395
401
  * - `sandbox.html` &rarr; `sandbox`
396
- * - `sandbox.index.html` &rarr; `sandbox`
402
+ * - `sandbox/index.html` &rarr; `sandbox`
397
403
  * - `overlay.content.ts` &rarr; `overlay`
398
404
  * - `overlay.content/index.ts` &rarr; `overlay`
399
405
  *
package/dist/index.cjs CHANGED
@@ -2317,11 +2317,11 @@ function execaNode(scriptPath, args, options = {}) {
2317
2317
  const stdio = normalizeStdioNode(options);
2318
2318
  const defaultExecArgv = import_node_process4.default.execArgv.filter((arg) => !arg.startsWith("--inspect"));
2319
2319
  const {
2320
- nodePath: nodePath2 = import_node_process4.default.execPath,
2320
+ nodePath = import_node_process4.default.execPath,
2321
2321
  nodeOptions = defaultExecArgv
2322
2322
  } = options;
2323
2323
  return execa(
2324
- nodePath2,
2324
+ nodePath,
2325
2325
  [
2326
2326
  ...nodeOptions,
2327
2327
  scriptPath,
@@ -2428,16 +2428,16 @@ __export(src_exports, {
2428
2428
  module.exports = __toCommonJS(src_exports);
2429
2429
 
2430
2430
  // src/core/utils/building/build-entrypoints.ts
2431
- var vite2 = __toESM(require("vite"), 1);
2431
+ var vite = __toESM(require("vite"), 1);
2432
2432
 
2433
2433
  // src/core/utils/entrypoints.ts
2434
2434
  var import_node_path2 = __toESM(require("path"), 1);
2435
2435
 
2436
2436
  // src/core/utils/paths.ts
2437
2437
  var import_node_path = __toESM(require("path"), 1);
2438
- var vite = __toESM(require("vite"), 1);
2439
- function normalizePath2(path11) {
2440
- return vite.normalizePath(path11);
2438
+ var import_normalize_path = __toESM(require("normalize-path"), 1);
2439
+ function normalizePath(path11) {
2440
+ return (0, import_normalize_path.default)(path11);
2441
2441
  }
2442
2442
  function unnormalizePath(path11) {
2443
2443
  return import_node_path.default.normalize(path11);
@@ -2455,7 +2455,7 @@ function getEntrypointOutputFile(entrypoint, ext) {
2455
2455
  return (0, import_node_path2.resolve)(entrypoint.outputDir, `${entrypoint.name}${ext}`);
2456
2456
  }
2457
2457
  function getEntrypointBundlePath(entrypoint, outDir, ext) {
2458
- return normalizePath2(
2458
+ return normalizePath(
2459
2459
  (0, import_node_path2.relative)(outDir, getEntrypointOutputFile(entrypoint, ext))
2460
2460
  );
2461
2461
  }
@@ -2690,7 +2690,7 @@ function multipageMove(entrypoints, config) {
2690
2690
  async writeBundle(_, bundle) {
2691
2691
  for (const oldBundlePath in bundle) {
2692
2692
  const entrypoint = entrypoints.find(
2693
- (entry) => !!normalizePath2(entry.inputPath).endsWith(oldBundlePath)
2693
+ (entry) => !!normalizePath(entry.inputPath).endsWith(oldBundlePath)
2694
2694
  );
2695
2695
  if (entrypoint == null) {
2696
2696
  config.logger.debug(
@@ -2756,14 +2756,14 @@ function getUnimportOptions(config) {
2756
2756
 
2757
2757
  // src/core/vite-plugins/unimport.ts
2758
2758
  var import_path2 = require("path");
2759
- var ENABLED_EXTENSIONS = {
2760
- ".js": true,
2761
- ".jsx": true,
2762
- ".ts": true,
2763
- ".tsx": true,
2764
- ".vue": true,
2765
- ".svelte": true
2766
- };
2759
+ var ENABLED_EXTENSIONS = /* @__PURE__ */ new Set([
2760
+ ".js",
2761
+ ".jsx",
2762
+ ".ts",
2763
+ ".tsx",
2764
+ ".vue",
2765
+ ".svelte"
2766
+ ]);
2767
2767
  function unimport(config) {
2768
2768
  const options = getUnimportOptions(config);
2769
2769
  if (options === false)
@@ -2775,9 +2775,11 @@ function unimport(config) {
2775
2775
  await unimport2.scanImportsFromDir(void 0, { cwd: config.srcDir });
2776
2776
  },
2777
2777
  async transform(code, id) {
2778
- const ext = (0, import_path2.extname)(id);
2779
- if (ENABLED_EXTENSIONS[ext])
2780
- return unimport2.injectImports(code, id);
2778
+ if (id.includes("node_modules"))
2779
+ return;
2780
+ if (!ENABLED_EXTENSIONS.has((0, import_path2.extname)(id)))
2781
+ return;
2782
+ return unimport2.injectImports(code, id);
2781
2783
  }
2782
2784
  };
2783
2785
  }
@@ -2794,7 +2796,7 @@ function virtualEntrypoint(type, config) {
2794
2796
  const index = id.indexOf(virtualId);
2795
2797
  if (index === -1)
2796
2798
  return;
2797
- const inputPath = normalizePath2(id.substring(index + virtualId.length));
2799
+ const inputPath = normalizePath(id.substring(index + virtualId.length));
2798
2800
  return resolvedVirtualId + inputPath;
2799
2801
  },
2800
2802
  async load(id) {
@@ -3080,11 +3082,11 @@ async function buildSingleEntrypoint(entrypoint, config) {
3080
3082
  for (const global3 of getEntrypointGlobals(config, entrypoint.name)) {
3081
3083
  libMode.define[global3.name] = JSON.stringify(global3.value);
3082
3084
  }
3083
- const entryConfig = vite2.mergeConfig(
3085
+ const entryConfig = vite.mergeConfig(
3084
3086
  libMode,
3085
3087
  await config.vite(config.env)
3086
3088
  );
3087
- const result = await vite2.build(entryConfig);
3089
+ const result = await vite.build(entryConfig);
3088
3090
  return {
3089
3091
  entrypoints: entrypoint,
3090
3092
  chunks: getBuildOutputChunks(result)
@@ -3115,11 +3117,11 @@ async function buildMultipleEntrypoints(entrypoints, config) {
3115
3117
  for (const global3 of getEntrypointGlobals(config, "html")) {
3116
3118
  multiPage.define[global3.name] = JSON.stringify(global3.value);
3117
3119
  }
3118
- const entryConfig = vite2.mergeConfig(
3120
+ const entryConfig = vite.mergeConfig(
3119
3121
  multiPage,
3120
3122
  await config.vite(config.env)
3121
3123
  );
3122
- const result = await vite2.build(entryConfig);
3124
+ const result = await vite.build(entryConfig);
3123
3125
  return {
3124
3126
  entrypoints,
3125
3127
  chunks: getBuildOutputChunks(result)
@@ -3224,7 +3226,7 @@ function detectDevChanges(changedFiles, currentOutput) {
3224
3226
  }
3225
3227
  function findEffectedSteps(changedFile, currentOutput) {
3226
3228
  const changes = [];
3227
- const changedPath = normalizePath2(changedFile[1]);
3229
+ const changedPath = normalizePath(changedFile[1]);
3228
3230
  const isChunkEffected = (chunk) => (
3229
3231
  // If it's an HTML file with the same path, is is effected because HTML files need to be pre-rendered
3230
3232
  // fileName is normalized, relative bundle path
@@ -3625,7 +3627,7 @@ async function writePathsDeclarationFile(entrypoints, config) {
3625
3627
  config.outDir,
3626
3628
  entry.inputPath.endsWith(".html") ? ".html" : ".js"
3627
3629
  )
3628
- ).concat(await getPublicFiles(config)).map(normalizePath2).map((path11) => ` | "/${path11}"`).sort().join("\n");
3630
+ ).concat(await getPublicFiles(config)).map(normalizePath).map((path11) => ` | "/${path11}"`).sort().join("\n");
3629
3631
  const template = `// Generated by wxt
3630
3632
  import "wxt/browser";
3631
3633
 
@@ -3720,7 +3722,7 @@ async function writeMainDeclarationFile(references, config) {
3720
3722
  "// Generated by wxt",
3721
3723
  `/// <reference types="vite/client" />`,
3722
3724
  ...references.map(
3723
- (ref) => `/// <reference types="./${normalizePath2((0, import_path6.relative)(dir, ref))}" />`
3725
+ (ref) => `/// <reference types="./${normalizePath((0, import_path6.relative)(dir, ref))}" />`
3724
3726
  )
3725
3727
  ].join("\n") + "\n"
3726
3728
  );
@@ -3728,7 +3730,7 @@ async function writeMainDeclarationFile(references, config) {
3728
3730
  }
3729
3731
  async function writeTsConfigFile(mainReference, config) {
3730
3732
  const dir = config.wxtDir;
3731
- const getTsconfigPath = (path11) => normalizePath2((0, import_path6.relative)(dir, path11));
3733
+ const getTsconfigPath = (path11) => normalizePath((0, import_path6.relative)(dir, path11));
3732
3734
  const paths = Object.entries(config.alias).flatMap(([alias, absolutePath]) => {
3733
3735
  const aliasPath = getTsconfigPath(absolutePath);
3734
3736
  return [
@@ -3765,7 +3767,7 @@ ${paths}
3765
3767
  // src/core/utils/building/get-internal-config.ts
3766
3768
  var import_c12 = require("c12");
3767
3769
  var import_node_path7 = __toESM(require("path"), 1);
3768
- var vite3 = __toESM(require("vite"), 1);
3770
+ var vite2 = __toESM(require("vite"), 1);
3769
3771
 
3770
3772
  // src/core/utils/cache.ts
3771
3773
  var import_fs_extra7 = __toESM(require("fs-extra"), 1);
@@ -3791,6 +3793,7 @@ function createFsCache(wxtDir) {
3791
3793
 
3792
3794
  // src/core/utils/building/get-internal-config.ts
3793
3795
  var import_consola = __toESM(require("consola"), 1);
3796
+ var import_defu = __toESM(require("defu"), 1);
3794
3797
  async function getInternalConfig(inlineConfig, command) {
3795
3798
  let userConfig = {};
3796
3799
  let userConfigMetadata;
@@ -3823,7 +3826,7 @@ async function getInternalConfig(inlineConfig, command) {
3823
3826
  );
3824
3827
  const publicDir = import_node_path7.default.resolve(srcDir, mergedConfig.publicDir ?? "public");
3825
3828
  const typesDir = import_node_path7.default.resolve(wxtDir, "types");
3826
- const outBaseDir = import_node_path7.default.resolve(root, ".output");
3829
+ const outBaseDir = import_node_path7.default.resolve(root, mergedConfig.outDir ?? ".output");
3827
3830
  const outDir = import_node_path7.default.resolve(outBaseDir, `${browser}-mv${manifestVersion}`);
3828
3831
  const runnerConfig = await (0, import_c12.loadConfig)({
3829
3832
  name: "web-ext",
@@ -3892,7 +3895,7 @@ function mergeInlineConfig(inlineConfig, userConfig) {
3892
3895
  } else if (userConfig.imports == null && inlineConfig.imports == null) {
3893
3896
  imports = void 0;
3894
3897
  } else {
3895
- imports = vite3.mergeConfig(
3898
+ imports = vite2.mergeConfig(
3896
3899
  userConfig.imports ?? {},
3897
3900
  inlineConfig.imports ?? {}
3898
3901
  );
@@ -3900,20 +3903,20 @@ function mergeInlineConfig(inlineConfig, userConfig) {
3900
3903
  const manifest = async (env) => {
3901
3904
  const user = await resolveManifestConfig(env, userConfig.manifest);
3902
3905
  const inline = await resolveManifestConfig(env, inlineConfig.manifest);
3903
- return vite3.mergeConfig(user, inline);
3906
+ return vite2.mergeConfig(user, inline);
3904
3907
  };
3905
3908
  const viteConfig = async (env) => {
3906
3909
  const user = await userConfig.vite?.(env);
3907
3910
  const inline = await inlineConfig.vite?.(env);
3908
- return vite3.mergeConfig(user ?? {}, inline ?? {});
3911
+ return vite2.mergeConfig(user ?? {}, inline ?? {});
3909
3912
  };
3910
- const runner = vite3.mergeConfig(
3911
- userConfig.runner ?? {},
3912
- inlineConfig.runner ?? {}
3913
+ const runner = (0, import_defu.default)(
3914
+ inlineConfig.runner ?? {},
3915
+ userConfig.runner ?? {}
3913
3916
  );
3914
- const zip2 = vite3.mergeConfig(
3915
- userConfig.zip ?? {},
3916
- inlineConfig.zip ?? {}
3917
+ const zip2 = (0, import_defu.default)(
3918
+ inlineConfig.zip ?? {},
3919
+ userConfig.zip ?? {}
3917
3920
  );
3918
3921
  return {
3919
3922
  root: inlineConfig.root ?? userConfig.root,
@@ -3929,6 +3932,7 @@ function mergeInlineConfig(inlineConfig, userConfig) {
3929
3932
  publicDir: inlineConfig.publicDir ?? userConfig.publicDir,
3930
3933
  runner,
3931
3934
  srcDir: inlineConfig.srcDir ?? userConfig.srcDir,
3935
+ outDir: inlineConfig.outDir ?? userConfig.outDir,
3932
3936
  vite: viteConfig,
3933
3937
  zip: zip2,
3934
3938
  analysis: {
@@ -3942,11 +3946,13 @@ function mergeInlineConfig(inlineConfig, userConfig) {
3942
3946
  experimental: {
3943
3947
  ...userConfig.experimental,
3944
3948
  ...inlineConfig.experimental
3945
- }
3949
+ },
3950
+ transformManifest: void 0
3946
3951
  };
3947
3952
  }
3948
3953
  function resolveInternalZipConfig(root, mergedConfig) {
3949
3954
  return {
3955
+ name: void 0,
3950
3956
  sourcesTemplate: "{{name}}-{{version}}-sources.zip",
3951
3957
  artifactTemplate: "{{name}}-{{version}}-{{browser}}.zip",
3952
3958
  sourcesRoot: root,
@@ -4062,7 +4068,7 @@ ${noImports}`;
4062
4068
  var import_esbuild = require("esbuild");
4063
4069
  async function importEntrypointFile(path11, config) {
4064
4070
  config.logger.debug("Loading file metadata:", path11);
4065
- const normalPath = normalizePath2(path11);
4071
+ const normalPath = normalizePath(path11);
4066
4072
  const unimport2 = (0, import_unimport5.createUnimport)({
4067
4073
  ...getUnimportOptions(config),
4068
4074
  // Only allow specific imports, not all from the project
@@ -4118,7 +4124,7 @@ function getEsbuildOptions(opts) {
4118
4124
 
4119
4125
  // src/core/utils/building/internal-build.ts
4120
4126
  var import_picocolors4 = __toESM(require("picocolors"), 1);
4121
- var vite5 = __toESM(require("vite"), 1);
4127
+ var vite3 = __toESM(require("vite"), 1);
4122
4128
  var import_fs_extra12 = __toESM(require("fs-extra"), 1);
4123
4129
 
4124
4130
  // src/core/utils/log/printBuildSummary.ts
@@ -4230,7 +4236,7 @@ function getChunkSortWeight(filename) {
4230
4236
  var import_picocolors3 = __toESM(require("picocolors"), 1);
4231
4237
 
4232
4238
  // package.json
4233
- var version = "0.10.2";
4239
+ var version = "0.10.4";
4234
4240
 
4235
4241
  // src/core/utils/log/printHeader.ts
4236
4242
  var import_consola2 = require("consola");
@@ -4360,7 +4366,7 @@ async function getPackageJson(config) {
4360
4366
 
4361
4367
  // src/core/utils/manifest.ts
4362
4368
  var import_immer = require("immer");
4363
- var vite4 = __toESM(require("vite"), 1);
4369
+ var import_defu2 = __toESM(require("defu"), 1);
4364
4370
  async function writeManifest(manifest, output, config) {
4365
4371
  const str = config.mode === "production" ? JSON.stringify(manifest) : JSON.stringify(manifest, null, 2);
4366
4372
  await import_fs_extra11.default.ensureDir(config.outDir);
@@ -4390,9 +4396,9 @@ async function generateMainfest(entrypoints, buildOutput, config) {
4390
4396
  icons: discoverIcons(buildOutput)
4391
4397
  };
4392
4398
  const userManifest = config.manifest;
4393
- const manifest = vite4.mergeConfig(
4394
- baseManifest,
4395
- userManifest
4399
+ const manifest = (0, import_defu2.default)(
4400
+ userManifest,
4401
+ baseManifest
4396
4402
  );
4397
4403
  addEntrypoints(manifest, entrypoints, buildOutput, config);
4398
4404
  if (config.command === "serve")
@@ -4651,7 +4657,7 @@ function discoverIcons(buildOutput) {
4651
4657
  }
4652
4658
  if (size == null)
4653
4659
  return;
4654
- icons.push([size, normalizePath2(asset.fileName)]);
4660
+ icons.push([size, normalizePath(asset.fileName)]);
4655
4661
  });
4656
4662
  return icons.length > 0 ? Object.fromEntries(icons) : void 0;
4657
4663
  }
@@ -4791,7 +4797,7 @@ async function internalBuild(config) {
4791
4797
  const target = `${config.browser}-mv${config.manifestVersion}`;
4792
4798
  config.logger.info(
4793
4799
  `${verb} ${import_picocolors4.default.cyan(target)} for ${import_picocolors4.default.cyan(config.mode)} with ${import_picocolors4.default.green(
4794
- `Vite ${vite5.version}`
4800
+ `Vite ${vite3.version}`
4795
4801
  )}`
4796
4802
  );
4797
4803
  const startTime = Date.now();
@@ -4881,7 +4887,7 @@ function defineRunnerConfig(config) {
4881
4887
  }
4882
4888
 
4883
4889
  // src/core/create-server.ts
4884
- var vite6 = __toESM(require("vite"), 1);
4890
+ var vite4 = __toESM(require("vite"), 1);
4885
4891
 
4886
4892
  // src/core/runners/wsl.ts
4887
4893
  var import_node_path13 = require("path");
@@ -5098,8 +5104,8 @@ async function getServerInfo() {
5098
5104
  }
5099
5105
  async function setupServer(serverInfo, config) {
5100
5106
  const runner = await createExtensionRunner(config);
5101
- const viteServer = await vite6.createServer(
5102
- vite6.mergeConfig(serverInfo, await config.vite(config.env))
5107
+ const viteServer = await vite4.createServer(
5108
+ vite4.mergeConfig(serverInfo, await config.vite(config.env))
5103
5109
  );
5104
5110
  const start = async () => {
5105
5111
  await viteServer.listen(server.port);
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 './external-9115d0fb.js';
2
- export { k as BackgroundDefinition, f as BackgroundEntrypoint, e as BaseEntrypoint, d as BaseEntrypointOptions, b as BuildStepOutput, q as ConfigEnv, j as ContentScriptDefinition, C as ContentScriptEntrypoint, g as Entrypoint, h as EntrypointGroup, n as ExcludableEntrypoint, G as GenericEntrypoint, L as Logger, i as OnContentScriptStopped, O as OptionsEntrypoint, m as PerBrowserOption, P as PopupEntrypoint, T as TargetBrowser, c as TargetManifestVersion, l as UnlistedScriptDefinition, o as UserManifest, p as UserManifestFn, a as WxtInlineViteConfig, r as WxtViteConfig } from './external-9115d0fb.js';
1
+ import { I as InlineConfig, B as BuildOutput, U as UserConfig, E as ExtensionRunnerConfig, W as WxtDevServer } from './external-32209cff.js';
2
+ export { k as BackgroundDefinition, f as BackgroundEntrypoint, e as BaseEntrypoint, d as BaseEntrypointOptions, b as BuildStepOutput, q as ConfigEnv, j as ContentScriptDefinition, C as ContentScriptEntrypoint, g as Entrypoint, h as EntrypointGroup, n as ExcludableEntrypoint, G as GenericEntrypoint, L as Logger, i as OnContentScriptStopped, O as OptionsEntrypoint, m as PerBrowserOption, P as PopupEntrypoint, T as TargetBrowser, c as TargetManifestVersion, l as UnlistedScriptDefinition, o as UserManifest, p as UserManifestFn, a as WxtInlineViteConfig, r as WxtViteConfig } from './external-32209cff.js';
3
3
  import 'vite';
4
4
  import 'webextension-polyfill';
5
5
  import 'unimport';
@@ -61,6 +61,6 @@ declare function prepare(config: InlineConfig): Promise<void>;
61
61
  */
62
62
  declare function zip(config?: InlineConfig): Promise<string[]>;
63
63
 
64
- var version = "0.10.2";
64
+ var version = "0.10.4";
65
65
 
66
66
  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 './external-9115d0fb.js';
2
- export { k as BackgroundDefinition, f as BackgroundEntrypoint, e as BaseEntrypoint, d as BaseEntrypointOptions, b as BuildStepOutput, q as ConfigEnv, j as ContentScriptDefinition, C as ContentScriptEntrypoint, g as Entrypoint, h as EntrypointGroup, n as ExcludableEntrypoint, G as GenericEntrypoint, L as Logger, i as OnContentScriptStopped, O as OptionsEntrypoint, m as PerBrowserOption, P as PopupEntrypoint, T as TargetBrowser, c as TargetManifestVersion, l as UnlistedScriptDefinition, o as UserManifest, p as UserManifestFn, a as WxtInlineViteConfig, r as WxtViteConfig } from './external-9115d0fb.js';
1
+ import { I as InlineConfig, B as BuildOutput, U as UserConfig, E as ExtensionRunnerConfig, W as WxtDevServer } from './external-32209cff.js';
2
+ export { k as BackgroundDefinition, f as BackgroundEntrypoint, e as BaseEntrypoint, d as BaseEntrypointOptions, b as BuildStepOutput, q as ConfigEnv, j as ContentScriptDefinition, C as ContentScriptEntrypoint, g as Entrypoint, h as EntrypointGroup, n as ExcludableEntrypoint, G as GenericEntrypoint, L as Logger, i as OnContentScriptStopped, O as OptionsEntrypoint, m as PerBrowserOption, P as PopupEntrypoint, T as TargetBrowser, c as TargetManifestVersion, l as UnlistedScriptDefinition, o as UserManifest, p as UserManifestFn, a as WxtInlineViteConfig, r as WxtViteConfig } from './external-32209cff.js';
3
3
  import 'vite';
4
4
  import 'webextension-polyfill';
5
5
  import 'unimport';
@@ -61,6 +61,6 @@ declare function prepare(config: InlineConfig): Promise<void>;
61
61
  */
62
62
  declare function zip(config?: InlineConfig): Promise<string[]>;
63
63
 
64
- var version = "0.10.2";
64
+ var version = "0.10.4";
65
65
 
66
66
  export { BuildOutput, ExtensionRunnerConfig, InlineConfig, UserConfig, WxtDevServer, build, clean, createServer, defineConfig, defineRunnerConfig, initialize, prepare, version, zip };
package/dist/index.js CHANGED
@@ -15,7 +15,7 @@ import {
15
15
  rebuild,
16
16
  resolvePerBrowserOption,
17
17
  version
18
- } from "./chunk-6APJQ3J3.js";
18
+ } from "./chunk-RSHXTUF4.js";
19
19
  import "./chunk-YUG22S6W.js";
20
20
 
21
21
  // src/core/build.ts
package/dist/testing.cjs CHANGED
@@ -43,9 +43,9 @@ var import_node_path2 = __toESM(require("path"), 1);
43
43
 
44
44
  // src/core/utils/paths.ts
45
45
  var import_node_path = __toESM(require("path"), 1);
46
- var vite = __toESM(require("vite"), 1);
47
- function normalizePath2(path7) {
48
- return vite.normalizePath(path7);
46
+ var import_normalize_path = __toESM(require("normalize-path"), 1);
47
+ function normalizePath(path7) {
48
+ return (0, import_normalize_path.default)(path7);
49
49
  }
50
50
  var CSS_EXTENSIONS = ["css", "scss", "sass", "less", "styl", "stylus"];
51
51
  var CSS_EXTENSIONS_PATTERN = `+(${CSS_EXTENSIONS.join("|")})`;
@@ -299,14 +299,14 @@ function getUnimportOptions(config) {
299
299
 
300
300
  // src/core/vite-plugins/unimport.ts
301
301
  var import_path2 = require("path");
302
- var ENABLED_EXTENSIONS = {
303
- ".js": true,
304
- ".jsx": true,
305
- ".ts": true,
306
- ".tsx": true,
307
- ".vue": true,
308
- ".svelte": true
309
- };
302
+ var ENABLED_EXTENSIONS = /* @__PURE__ */ new Set([
303
+ ".js",
304
+ ".jsx",
305
+ ".ts",
306
+ ".tsx",
307
+ ".vue",
308
+ ".svelte"
309
+ ]);
310
310
  function unimport(config) {
311
311
  const options = getUnimportOptions(config);
312
312
  if (options === false)
@@ -318,9 +318,11 @@ function unimport(config) {
318
318
  await unimport2.scanImportsFromDir(void 0, { cwd: config.srcDir });
319
319
  },
320
320
  async transform(code, id) {
321
- const ext = (0, import_path2.extname)(id);
322
- if (ENABLED_EXTENSIONS[ext])
323
- return unimport2.injectImports(code, id);
321
+ if (id.includes("node_modules"))
322
+ return;
323
+ if (!ENABLED_EXTENSIONS.has((0, import_path2.extname)(id)))
324
+ return;
325
+ return unimport2.injectImports(code, id);
324
326
  }
325
327
  };
326
328
  }
@@ -337,7 +339,7 @@ function virtualEntrypoint(type, config) {
337
339
  const index = id.indexOf(virtualId);
338
340
  if (index === -1)
339
341
  return;
340
- const inputPath = normalizePath2(id.substring(index + virtualId.length));
342
+ const inputPath = normalizePath(id.substring(index + virtualId.length));
341
343
  return resolvedVirtualId + inputPath;
342
344
  },
343
345
  async load(id) {
@@ -530,7 +532,7 @@ function excludeBrowserPolyfill(config) {
530
532
  }
531
533
 
532
534
  // src/core/utils/building/build-entrypoints.ts
533
- var vite2 = __toESM(require("vite"), 1);
535
+ var vite = __toESM(require("vite"), 1);
534
536
 
535
537
  // src/core/utils/fs.ts
536
538
  var import_fs_extra3 = __toESM(require("fs-extra"), 1);
@@ -603,7 +605,7 @@ var import_node_path6 = __toESM(require("path"), 1);
603
605
  // src/core/utils/building/get-internal-config.ts
604
606
  var import_c12 = require("c12");
605
607
  var import_node_path7 = __toESM(require("path"), 1);
606
- var vite3 = __toESM(require("vite"), 1);
608
+ var vite2 = __toESM(require("vite"), 1);
607
609
 
608
610
  // src/core/utils/cache.ts
609
611
  var import_fs_extra7 = __toESM(require("fs-extra"), 1);
@@ -629,6 +631,7 @@ function createFsCache(wxtDir) {
629
631
 
630
632
  // src/core/utils/building/get-internal-config.ts
631
633
  var import_consola = __toESM(require("consola"), 1);
634
+ var import_defu = __toESM(require("defu"), 1);
632
635
  async function getInternalConfig(inlineConfig, command) {
633
636
  let userConfig = {};
634
637
  let userConfigMetadata;
@@ -661,7 +664,7 @@ async function getInternalConfig(inlineConfig, command) {
661
664
  );
662
665
  const publicDir = import_node_path7.default.resolve(srcDir, mergedConfig.publicDir ?? "public");
663
666
  const typesDir = import_node_path7.default.resolve(wxtDir, "types");
664
- const outBaseDir = import_node_path7.default.resolve(root, ".output");
667
+ const outBaseDir = import_node_path7.default.resolve(root, mergedConfig.outDir ?? ".output");
665
668
  const outDir = import_node_path7.default.resolve(outBaseDir, `${browser}-mv${manifestVersion}`);
666
669
  const runnerConfig = await (0, import_c12.loadConfig)({
667
670
  name: "web-ext",
@@ -730,7 +733,7 @@ function mergeInlineConfig(inlineConfig, userConfig) {
730
733
  } else if (userConfig.imports == null && inlineConfig.imports == null) {
731
734
  imports = void 0;
732
735
  } else {
733
- imports = vite3.mergeConfig(
736
+ imports = vite2.mergeConfig(
734
737
  userConfig.imports ?? {},
735
738
  inlineConfig.imports ?? {}
736
739
  );
@@ -738,20 +741,20 @@ function mergeInlineConfig(inlineConfig, userConfig) {
738
741
  const manifest = async (env) => {
739
742
  const user = await resolveManifestConfig(env, userConfig.manifest);
740
743
  const inline = await resolveManifestConfig(env, inlineConfig.manifest);
741
- return vite3.mergeConfig(user, inline);
744
+ return vite2.mergeConfig(user, inline);
742
745
  };
743
746
  const viteConfig = async (env) => {
744
747
  const user = await userConfig.vite?.(env);
745
748
  const inline = await inlineConfig.vite?.(env);
746
- return vite3.mergeConfig(user ?? {}, inline ?? {});
749
+ return vite2.mergeConfig(user ?? {}, inline ?? {});
747
750
  };
748
- const runner = vite3.mergeConfig(
749
- userConfig.runner ?? {},
750
- inlineConfig.runner ?? {}
751
+ const runner = (0, import_defu.default)(
752
+ inlineConfig.runner ?? {},
753
+ userConfig.runner ?? {}
751
754
  );
752
- const zip = vite3.mergeConfig(
753
- userConfig.zip ?? {},
754
- inlineConfig.zip ?? {}
755
+ const zip = (0, import_defu.default)(
756
+ inlineConfig.zip ?? {},
757
+ userConfig.zip ?? {}
755
758
  );
756
759
  return {
757
760
  root: inlineConfig.root ?? userConfig.root,
@@ -767,6 +770,7 @@ function mergeInlineConfig(inlineConfig, userConfig) {
767
770
  publicDir: inlineConfig.publicDir ?? userConfig.publicDir,
768
771
  runner,
769
772
  srcDir: inlineConfig.srcDir ?? userConfig.srcDir,
773
+ outDir: inlineConfig.outDir ?? userConfig.outDir,
770
774
  vite: viteConfig,
771
775
  zip,
772
776
  analysis: {
@@ -780,11 +784,13 @@ function mergeInlineConfig(inlineConfig, userConfig) {
780
784
  experimental: {
781
785
  ...userConfig.experimental,
782
786
  ...inlineConfig.experimental
783
- }
787
+ },
788
+ transformManifest: void 0
784
789
  };
785
790
  }
786
791
  function resolveInternalZipConfig(root, mergedConfig) {
787
792
  return {
793
+ name: void 0,
788
794
  sourcesTemplate: "{{name}}-{{version}}-sources.zip",
789
795
  artifactTemplate: "{{name}}-{{version}}-{{browser}}.zip",
790
796
  sourcesRoot: root,
@@ -844,7 +850,7 @@ var import_esbuild = require("esbuild");
844
850
 
845
851
  // src/core/utils/building/internal-build.ts
846
852
  var import_picocolors4 = __toESM(require("picocolors"), 1);
847
- var vite5 = __toESM(require("vite"), 1);
853
+ var vite3 = __toESM(require("vite"), 1);
848
854
  var import_fs_extra12 = __toESM(require("fs-extra"), 1);
849
855
 
850
856
  // src/core/utils/log/printFileList.ts
@@ -881,7 +887,7 @@ var import_fs_extra10 = __toESM(require("fs-extra"), 1);
881
887
 
882
888
  // src/core/utils/manifest.ts
883
889
  var import_immer = require("immer");
884
- var vite4 = __toESM(require("vite"), 1);
890
+ var import_defu2 = __toESM(require("defu"), 1);
885
891
 
886
892
  // src/testing/wxt-vitest-plugin.ts
887
893
  function WxtVitest(inlineConfig) {
@@ -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 './external-9115d0fb.js';
3
+ import { I as InlineConfig } from './external-32209cff.js';
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 './external-9115d0fb.js';
3
+ import { I as InlineConfig } from './external-32209cff.js';
4
4
  import 'webextension-polyfill';
5
5
  import 'unimport';
6
6
  import 'consola';
package/dist/testing.js CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  unimport,
7
7
  webextensionPolyfillAlias,
8
8
  webextensionPolyfillInlineDeps
9
- } from "./chunk-6APJQ3J3.js";
9
+ } from "./chunk-RSHXTUF4.js";
10
10
  import "./chunk-YUG22S6W.js";
11
11
 
12
12
  // src/testing/fake-browser.ts
@@ -2,7 +2,7 @@
2
2
  import { fakeBrowser } from "@webext-core/fake-browser";
3
3
 
4
4
  // src/core/utils/paths.ts
5
- import * as vite from "vite";
5
+ import normalize from "normalize-path";
6
6
  var CSS_EXTENSIONS = ["css", "scss", "sass", "less", "styl", "stylus"];
7
7
  var CSS_EXTENSIONS_PATTERN = `+(${CSS_EXTENSIONS.join("|")})`;
8
8
 
@@ -28,7 +28,7 @@ var VIRTUAL_NOOP_BACKGROUND_MODULE_ID = "virtual:user-background";
28
28
  import { visualizer } from "rollup-plugin-visualizer";
29
29
 
30
30
  // src/core/utils/building/build-entrypoints.ts
31
- import * as vite2 from "vite";
31
+ import * as vite from "vite";
32
32
 
33
33
  // src/core/utils/fs.ts
34
34
  import fs3 from "fs-extra";
@@ -92,13 +92,14 @@ import fs6 from "fs-extra";
92
92
 
93
93
  // src/core/utils/building/get-internal-config.ts
94
94
  import { loadConfig } from "c12";
95
- import * as vite3 from "vite";
95
+ import * as vite2 from "vite";
96
96
 
97
97
  // src/core/utils/cache.ts
98
98
  import fs7, { ensureDir as ensureDir2 } from "fs-extra";
99
99
 
100
100
  // src/core/utils/building/get-internal-config.ts
101
101
  import consola, { LogLevels } from "consola";
102
+ import defu from "defu";
102
103
 
103
104
  // src/core/utils/building/import-entrypoint.ts
104
105
  import createJITI from "jiti";
@@ -108,7 +109,7 @@ import { transformSync } from "esbuild";
108
109
 
109
110
  // src/core/utils/building/internal-build.ts
110
111
  import pc4 from "picocolors";
111
- import * as vite5 from "vite";
112
+ import * as vite3 from "vite";
112
113
  import fs12 from "fs-extra";
113
114
 
114
115
  // src/core/utils/log/printFileList.ts
@@ -143,7 +144,7 @@ import fs10 from "fs-extra";
143
144
 
144
145
  // src/core/utils/manifest.ts
145
146
  import { produce } from "immer";
146
- import * as vite4 from "vite";
147
+ import defu2 from "defu";
147
148
 
148
149
  // src/virtual/mock-browser.ts
149
150
  var mock_browser_default = fakeBrowser;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "wxt",
3
3
  "type": "module",
4
- "version": "0.10.2",
4
+ "version": "0.10.4",
5
5
  "description": "Next gen framework for developing web extensions",
6
6
  "engines": {
7
7
  "node": ">=18",
@@ -72,6 +72,7 @@
72
72
  "c12": "^1.5.1",
73
73
  "cac": "^6.7.14",
74
74
  "consola": "^3.2.3",
75
+ "defu": "^6.1.3",
75
76
  "esbuild": "^0.19.5",
76
77
  "fast-glob": "^3.3.1",
77
78
  "filesize": "^10.0.8",
@@ -84,6 +85,7 @@
84
85
  "json5": "^2.2.3",
85
86
  "linkedom": "^0.16.1",
86
87
  "minimatch": "^9.0.3",
88
+ "normalize-path": "^3.0.0",
87
89
  "ora": "^7.0.1",
88
90
  "picocolors": "^1.0.0",
89
91
  "prompts": "^2.4.2",
@@ -100,6 +102,7 @@
100
102
  "@types/fs-extra": "^11.0.3",
101
103
  "@types/lodash.merge": "^4.6.8",
102
104
  "@types/node": "^20.8.10",
105
+ "@types/normalize-path": "^3.0.2",
103
106
  "@types/prompts": "^2.4.7",
104
107
  "@vitest/coverage-v8": "^0.34.6",
105
108
  "execa": "^8.0.1",
@@ -111,11 +114,11 @@
111
114
  "prettier": "^3.0.1",
112
115
  "simple-git-hooks": "^2.9.0",
113
116
  "tsup": "^7.2.0",
114
- "tsx": "^3.12.7",
115
- "typedoc": "^0.25.3",
117
+ "tsx": "^4.6.1",
118
+ "typedoc": "^0.25.4",
116
119
  "typedoc-plugin-markdown": "4.0.0-next.23",
117
120
  "typedoc-vitepress-theme": "1.0.0-next.3",
118
- "typescript": "^5.2.2",
121
+ "typescript": "^5.3.2",
119
122
  "vitepress": "1.0.0-rc.24",
120
123
  "vitest": "^0.34.6",
121
124
  "vitest-mock-extended": "^1.3.1",