wxt 0.16.5 → 0.16.7

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/testing.cjs CHANGED
@@ -356,31 +356,6 @@ async function removeEmptyDirs(dir) {
356
356
 
357
357
  // src/core/builders/vite/plugins/unimport.ts
358
358
  var import_unimport = require("unimport");
359
-
360
- // src/core/utils/unimport.ts
361
- var import_defu = require("defu");
362
- function getUnimportOptions(config) {
363
- if (config.imports === false)
364
- return false;
365
- const defaultOptions = {
366
- debugLog: config.logger.debug,
367
- imports: [
368
- { name: "defineConfig", from: "wxt" },
369
- { name: "fakeBrowser", from: "wxt/testing" }
370
- ],
371
- presets: [
372
- { package: "wxt/client" },
373
- { package: "wxt/browser" },
374
- { package: "wxt/sandbox" },
375
- { package: "wxt/storage" }
376
- ],
377
- warn: config.logger.warn,
378
- dirs: ["components", "composables", "hooks", "utils"]
379
- };
380
- return (0, import_defu.defu)(config.imports, defaultOptions);
381
- }
382
-
383
- // src/core/builders/vite/plugins/unimport.ts
384
359
  var import_path = require("path");
385
360
  var ENABLED_EXTENSIONS = /* @__PURE__ */ new Set([
386
361
  ".js",
@@ -391,7 +366,7 @@ var ENABLED_EXTENSIONS = /* @__PURE__ */ new Set([
391
366
  ".svelte"
392
367
  ]);
393
368
  function unimport(config) {
394
- const options = getUnimportOptions(config);
369
+ const options = config.imports;
395
370
  if (options === false)
396
371
  return [];
397
372
  const unimport2 = (0, import_unimport.createUnimport)(options);
@@ -512,7 +487,10 @@ var increment = 0;
512
487
  function bundleAnalysis(config) {
513
488
  return (0, import_rollup_plugin_visualizer.visualizer)({
514
489
  template: "raw-data",
515
- filename: import_node_path5.default.resolve(config.outDir, `stats-${increment++}.json`)
490
+ filename: import_node_path5.default.resolve(
491
+ config.analysis.outputDir,
492
+ `${config.analysis.outputName}-${increment++}.json`
493
+ )
516
494
  });
517
495
  }
518
496
 
@@ -735,13 +713,13 @@ var PATH_GLOB_TO_TYPE_MAP = {
735
713
  };
736
714
 
737
715
  // src/core/utils/building/generate-wxt-dir.ts
738
- var import_unimport3 = require("unimport");
716
+ var import_unimport2 = require("unimport");
739
717
  var import_fs_extra6 = __toESM(require("fs-extra"), 1);
740
718
  var import_node_path7 = __toESM(require("path"), 1);
741
719
 
742
720
  // src/core/utils/building/resolve-config.ts
743
721
  var import_c12 = require("c12");
744
- var import_node_path8 = __toESM(require("path"), 1);
722
+ var import_node_path9 = __toESM(require("path"), 1);
745
723
 
746
724
  // src/core/utils/cache.ts
747
725
  var import_fs_extra7 = __toESM(require("fs-extra"), 1);
@@ -984,7 +962,16 @@ function getRollupEntry(entrypoint) {
984
962
  }
985
963
 
986
964
  // src/core/utils/building/resolve-config.ts
987
- var import_defu2 = __toESM(require("defu"), 1);
965
+ var import_defu = __toESM(require("defu"), 1);
966
+
967
+ // src/core/utils/package.ts
968
+ var import_node_path8 = require("path");
969
+ var import_fs_extra8 = __toESM(require("fs-extra"), 1);
970
+ function isModuleInstalled(name) {
971
+ return import(name).then(() => true).catch(() => false);
972
+ }
973
+
974
+ // src/core/utils/building/resolve-config.ts
988
975
  async function resolveConfig(inlineConfig, command, server) {
989
976
  let userConfig = {};
990
977
  let userConfigMetadata;
@@ -1009,20 +996,20 @@ async function resolveConfig(inlineConfig, command, server) {
1009
996
  const manifestVersion = mergedConfig.manifestVersion ?? (browser === "firefox" || browser === "safari" ? 2 : 3);
1010
997
  const mode = mergedConfig.mode ?? (command === "build" ? "production" : "development");
1011
998
  const env = { browser, command, manifestVersion, mode };
1012
- const root = import_node_path8.default.resolve(
999
+ const root = import_node_path9.default.resolve(
1013
1000
  inlineConfig.root ?? userConfig.root ?? process.cwd()
1014
1001
  );
1015
- const wxtDir = import_node_path8.default.resolve(root, ".wxt");
1016
- const srcDir = import_node_path8.default.resolve(root, mergedConfig.srcDir ?? root);
1017
- const entrypointsDir = import_node_path8.default.resolve(
1002
+ const wxtDir = import_node_path9.default.resolve(root, ".wxt");
1003
+ const srcDir = import_node_path9.default.resolve(root, mergedConfig.srcDir ?? root);
1004
+ const entrypointsDir = import_node_path9.default.resolve(
1018
1005
  srcDir,
1019
1006
  mergedConfig.entrypointsDir ?? "entrypoints"
1020
1007
  );
1021
1008
  const filterEntrypoints = !!mergedConfig.filterEntrypoints?.length ? new Set(mergedConfig.filterEntrypoints) : void 0;
1022
- const publicDir = import_node_path8.default.resolve(srcDir, mergedConfig.publicDir ?? "public");
1023
- const typesDir = import_node_path8.default.resolve(wxtDir, "types");
1024
- const outBaseDir = import_node_path8.default.resolve(root, mergedConfig.outDir ?? ".output");
1025
- const outDir = import_node_path8.default.resolve(outBaseDir, `${browser}-mv${manifestVersion}`);
1009
+ const publicDir = import_node_path9.default.resolve(srcDir, mergedConfig.publicDir ?? "public");
1010
+ const typesDir = import_node_path9.default.resolve(wxtDir, "types");
1011
+ const outBaseDir = import_node_path9.default.resolve(root, mergedConfig.outDir ?? ".output");
1012
+ const outDir = import_node_path9.default.resolve(outBaseDir, `${browser}-mv${manifestVersion}`);
1026
1013
  const reloadCommand = mergedConfig.dev?.reloadCommand ?? "Alt+R";
1027
1014
  const runnerConfig = await (0, import_c12.loadConfig)({
1028
1015
  name: "web-ext",
@@ -1039,8 +1026,14 @@ async function resolveConfig(inlineConfig, command, server) {
1039
1026
  "~": srcDir,
1040
1027
  "@@": root,
1041
1028
  "~~": root
1042
- }).map(([key, value]) => [key, import_node_path8.default.resolve(root, value)])
1029
+ }).map(([key, value]) => [key, import_node_path9.default.resolve(root, value)])
1043
1030
  );
1031
+ const analysisOutputFile = import_node_path9.default.resolve(
1032
+ root,
1033
+ mergedConfig.analysis?.outputFile ?? "stats.html"
1034
+ );
1035
+ const analysisOutputDir = import_node_path9.default.dirname(analysisOutputFile);
1036
+ const analysisOutputName = import_node_path9.default.parse(analysisOutputFile).name;
1044
1037
  const finalConfig = {
1045
1038
  browser,
1046
1039
  command,
@@ -1049,7 +1042,7 @@ async function resolveConfig(inlineConfig, command, server) {
1049
1042
  filterEntrypoints,
1050
1043
  env,
1051
1044
  fsCache: createFsCache(wxtDir),
1052
- imports: mergedConfig.imports ?? {},
1045
+ imports: await getUnimportOptions(wxtDir, logger, mergedConfig),
1053
1046
  logger,
1054
1047
  manifest: await resolveManifestConfig(env, mergedConfig.manifest),
1055
1048
  manifestVersion,
@@ -1070,10 +1063,10 @@ async function resolveConfig(inlineConfig, command, server) {
1070
1063
  analysis: {
1071
1064
  enabled: mergedConfig.analysis?.enabled ?? false,
1072
1065
  template: mergedConfig.analysis?.template ?? "treemap",
1073
- outputFile: import_node_path8.default.resolve(
1074
- root,
1075
- mergedConfig.analysis?.outputFile ?? "stats.html"
1076
- )
1066
+ outputFile: analysisOutputFile,
1067
+ outputDir: analysisOutputDir,
1068
+ outputName: analysisOutputName,
1069
+ keepArtifacts: mergedConfig.analysis?.keepArtifacts ?? false
1077
1070
  },
1078
1071
  userConfigMetadata: userConfigMetadata ?? {},
1079
1072
  alias,
@@ -1106,22 +1099,22 @@ function mergeInlineConfig(inlineConfig, userConfig) {
1106
1099
  } else if (userConfig.imports == null && inlineConfig.imports == null) {
1107
1100
  imports = void 0;
1108
1101
  } else {
1109
- imports = (0, import_defu2.default)(inlineConfig.imports ?? {}, userConfig.imports ?? {});
1102
+ imports = (0, import_defu.default)(inlineConfig.imports ?? {}, userConfig.imports ?? {});
1110
1103
  }
1111
1104
  const manifest = async (env) => {
1112
1105
  const user = await resolveManifestConfig(env, userConfig.manifest);
1113
1106
  const inline = await resolveManifestConfig(env, inlineConfig.manifest);
1114
- return (0, import_defu2.default)(inline, user);
1107
+ return (0, import_defu.default)(inline, user);
1115
1108
  };
1116
- const runner = (0, import_defu2.default)(
1109
+ const runner = (0, import_defu.default)(
1117
1110
  inlineConfig.runner ?? {},
1118
1111
  userConfig.runner ?? {}
1119
1112
  );
1120
- const zip = (0, import_defu2.default)(
1113
+ const zip = (0, import_defu.default)(
1121
1114
  inlineConfig.zip ?? {},
1122
1115
  userConfig.zip ?? {}
1123
1116
  );
1124
- const hooks = (0, import_defu2.default)(
1117
+ const hooks = (0, import_defu.default)(
1125
1118
  inlineConfig.hooks ?? {},
1126
1119
  userConfig.hooks ?? {}
1127
1120
  );
@@ -1185,12 +1178,50 @@ function resolveInternalZipConfig(root, mergedConfig) {
1185
1178
  ]
1186
1179
  };
1187
1180
  }
1181
+ async function getUnimportOptions(wxtDir, logger, config) {
1182
+ if (config.imports === false)
1183
+ return false;
1184
+ const enabledConfig = config.imports?.eslintrc?.enabled;
1185
+ let enabled;
1186
+ switch (enabledConfig) {
1187
+ case void 0:
1188
+ case "auto":
1189
+ enabled = await isModuleInstalled("eslint");
1190
+ break;
1191
+ default:
1192
+ enabled = enabledConfig;
1193
+ }
1194
+ const defaultOptions = {
1195
+ debugLog: logger.debug,
1196
+ imports: [
1197
+ { name: "defineConfig", from: "wxt" },
1198
+ { name: "fakeBrowser", from: "wxt/testing" }
1199
+ ],
1200
+ presets: [
1201
+ { package: "wxt/client" },
1202
+ { package: "wxt/browser" },
1203
+ { package: "wxt/sandbox" },
1204
+ { package: "wxt/storage" }
1205
+ ],
1206
+ warn: logger.warn,
1207
+ dirs: ["components", "composables", "hooks", "utils"],
1208
+ eslintrc: {
1209
+ enabled,
1210
+ filePath: import_node_path9.default.resolve(wxtDir, "eslintrc-auto-import.json"),
1211
+ globalsPropValue: true
1212
+ }
1213
+ };
1214
+ return (0, import_defu.default)(
1215
+ config.imports ?? {},
1216
+ defaultOptions
1217
+ );
1218
+ }
1188
1219
 
1189
1220
  // src/core/utils/building/import-entrypoint.ts
1190
1221
  var import_jiti = __toESM(require("jiti"), 1);
1191
- var import_unimport5 = require("unimport");
1192
- var import_fs_extra8 = __toESM(require("fs-extra"), 1);
1193
- var import_node_path9 = require("path");
1222
+ var import_unimport3 = require("unimport");
1223
+ var import_fs_extra9 = __toESM(require("fs-extra"), 1);
1224
+ var import_node_path10 = require("path");
1194
1225
  var import_esbuild = require("esbuild");
1195
1226
  var import_node_url = require("url");
1196
1227
 
@@ -1199,9 +1230,9 @@ var import_picocolors5 = __toESM(require("picocolors"), 1);
1199
1230
  var import_fs_extra12 = __toESM(require("fs-extra"), 1);
1200
1231
 
1201
1232
  // src/core/utils/log/printFileList.ts
1202
- var import_node_path10 = __toESM(require("path"), 1);
1233
+ var import_node_path11 = __toESM(require("path"), 1);
1203
1234
  var import_picocolors3 = __toESM(require("picocolors"), 1);
1204
- var import_fs_extra9 = __toESM(require("fs-extra"), 1);
1235
+ var import_fs_extra10 = __toESM(require("fs-extra"), 1);
1205
1236
  var import_filesize = require("filesize");
1206
1237
  var DEFAULT_COLOR = import_picocolors3.default.blue;
1207
1238
  var CHUNK_COLORS = {
@@ -1225,13 +1256,7 @@ var import_fast_glob3 = __toESM(require("fast-glob"), 1);
1225
1256
 
1226
1257
  // src/core/utils/manifest.ts
1227
1258
  var import_fs_extra11 = __toESM(require("fs-extra"), 1);
1228
-
1229
- // src/core/utils/package.ts
1230
- var import_node_path11 = require("path");
1231
- var import_fs_extra10 = __toESM(require("fs-extra"), 1);
1232
-
1233
- // src/core/utils/manifest.ts
1234
- var import_defu3 = __toESM(require("defu"), 1);
1259
+ var import_defu2 = __toESM(require("defu"), 1);
1235
1260
 
1236
1261
  // src/core/utils/building/internal-build.ts
1237
1262
  var import_node_path13 = require("path");
@@ -1,6 +1,6 @@
1
1
  export { FakeBrowser, fakeBrowser } from '@webext-core/fake-browser';
2
2
  import * as vite from 'vite';
3
- import { I as InlineConfig } from './index-znx-ff-l.cjs';
3
+ import { I as InlineConfig } from './index-sl22zA2Z.cjs';
4
4
  import 'webextension-polyfill';
5
5
  import 'unimport';
6
6
  import 'consola';
package/dist/testing.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { FakeBrowser, fakeBrowser } from '@webext-core/fake-browser';
2
2
  import * as vite from 'vite';
3
- import { I as InlineConfig } from './index-znx-ff-l.js';
3
+ import { I as InlineConfig } from './index-sl22zA2Z.js';
4
4
  import 'webextension-polyfill';
5
5
  import 'unimport';
6
6
  import 'consola';
package/dist/testing.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  tsconfigPaths,
6
6
  unimport,
7
7
  webextensionPolyfillMock
8
- } from "./chunk-N5MSLHHE.js";
8
+ } from "./chunk-KKL6XTRP.js";
9
9
  import "./chunk-VBXJIVYU.js";
10
10
 
11
11
  // src/testing/fake-browser.ts
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "wxt",
3
3
  "type": "module",
4
- "version": "0.16.5",
4
+ "version": "0.16.7",
5
5
  "description": "Next gen framework for developing web extensions",
6
6
  "engines": {
7
7
  "node": ">=18",
@@ -114,7 +114,7 @@
114
114
  "publish-browser-extension": "^2.1.2",
115
115
  "rollup-plugin-visualizer": "^5.9.2",
116
116
  "unimport": "^3.4.0",
117
- "vite": "^5.0.12",
117
+ "vite": "^5.1.3",
118
118
  "web-ext-run": "^0.2.0",
119
119
  "webextension-polyfill": "^0.10.0",
120
120
  "zip-dir": "^2.0.0"
@@ -144,7 +144,7 @@
144
144
  "typedoc-vitepress-theme": "1.0.0-next.3",
145
145
  "typescript": "^5.3.2",
146
146
  "vitepress": "1.0.0-rc.34",
147
- "vitest": "^1.1.0",
147
+ "vitest": "^1.2.2",
148
148
  "vitest-mock-extended": "^1.3.1",
149
149
  "vue": "^3.3.10"
150
150
  },