wxt 0.18.10 → 0.18.11
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/{chunk-2V7XZSZQ.js → chunk-XNTIBS6O.js} +109 -68
- package/dist/cli.js +124 -76
- package/dist/{execa-D7CMCKO2.js → execa-4UBDUBJZ.js} +566 -478
- package/dist/{execa-ATHZH2Y4.js → execa-QLUM2B3W.js} +566 -478
- package/dist/{index-mz3v4Nde.d.ts → index-CER9SLWP.d.cts} +11 -6
- package/dist/{index-mz3v4Nde.d.cts → index-CER9SLWP.d.ts} +11 -6
- package/dist/index.cjs +851 -695
- package/dist/index.d.cts +14 -3
- package/dist/index.d.ts +14 -3
- package/dist/index.js +17 -12
- package/dist/modules.d.cts +1 -1
- package/dist/modules.d.ts +1 -1
- package/dist/testing.cjs +104 -61
- package/dist/testing.d.cts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +1 -1
- package/dist/virtual/background-entrypoint.js +9 -1
- package/package.json +9 -9
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
} from "./chunk-QGM4M3NI.js";
|
|
17
17
|
|
|
18
18
|
// package.json
|
|
19
|
-
var version = "0.18.
|
|
19
|
+
var version = "0.18.10";
|
|
20
20
|
|
|
21
21
|
// src/core/utils/paths.ts
|
|
22
22
|
import systemPath from "node:path";
|
|
@@ -749,8 +749,10 @@ var unimport_default = defineWxtModule({
|
|
|
749
749
|
wxt2.hooks.hook("prepare:types", async (_, entries) => {
|
|
750
750
|
await unimport.init();
|
|
751
751
|
entries.push(await getImportsDeclarationEntry(unimport));
|
|
752
|
-
if (
|
|
753
|
-
entries.push(
|
|
752
|
+
if (options.eslintrc.enabled === false) return;
|
|
753
|
+
entries.push(
|
|
754
|
+
await getEslintConfigEntry(unimport, options.eslintrc.enabled, options)
|
|
755
|
+
);
|
|
754
756
|
});
|
|
755
757
|
addViteConfig(wxt2, () => ({
|
|
756
758
|
plugins: [vitePlugin(unimport)]
|
|
@@ -791,15 +793,32 @@ async function getImportsDeclarationEntry(unimport) {
|
|
|
791
793
|
tsReference: true
|
|
792
794
|
};
|
|
793
795
|
}
|
|
794
|
-
async function
|
|
795
|
-
const globals2 = {
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
796
|
+
async function getEslintConfigEntry(unimport, version2, options) {
|
|
797
|
+
const globals2 = (await unimport.getImports()).map((i) => i.as ?? i.name).filter(Boolean).sort().reduce((globals3, name) => {
|
|
798
|
+
globals3[name] = options.eslintrc.globalsPropValue;
|
|
799
|
+
return globals3;
|
|
800
|
+
}, {});
|
|
801
|
+
if (version2 <= 8) return getEslint8ConfigEntry(options, globals2);
|
|
802
|
+
else return getEslint9ConfigEntry(options, globals2);
|
|
803
|
+
}
|
|
804
|
+
function getEslint8ConfigEntry(options, globals2) {
|
|
800
805
|
return {
|
|
801
806
|
path: options.eslintrc.filePath,
|
|
802
|
-
text: JSON.stringify(
|
|
807
|
+
text: JSON.stringify({ globals: globals2 }, null, 2) + "\n"
|
|
808
|
+
};
|
|
809
|
+
}
|
|
810
|
+
function getEslint9ConfigEntry(options, globals2) {
|
|
811
|
+
return {
|
|
812
|
+
path: options.eslintrc.filePath,
|
|
813
|
+
text: `const globals = ${JSON.stringify(globals2, null, 2)}
|
|
814
|
+
|
|
815
|
+
export default {
|
|
816
|
+
languageOptions: {
|
|
817
|
+
globals,
|
|
818
|
+
sourceType: "module",
|
|
819
|
+
},
|
|
820
|
+
};
|
|
821
|
+
`
|
|
803
822
|
};
|
|
804
823
|
}
|
|
805
824
|
|
|
@@ -1584,35 +1603,25 @@ function createFsCache(wxtDir) {
|
|
|
1584
1603
|
|
|
1585
1604
|
// src/core/utils/building/resolve-config.ts
|
|
1586
1605
|
import defu from "defu";
|
|
1587
|
-
|
|
1588
|
-
// src/core/utils/package.ts
|
|
1589
|
-
import { resolve as resolve10 } from "node:path";
|
|
1590
1606
|
import fs8 from "fs-extra";
|
|
1591
|
-
async function getPackageJson() {
|
|
1592
|
-
const file = resolve10(wxt.config.root, "package.json");
|
|
1593
|
-
try {
|
|
1594
|
-
return await fs8.readJson(file);
|
|
1595
|
-
} catch (err) {
|
|
1596
|
-
wxt.logger.debug(
|
|
1597
|
-
`Failed to read package.json at: ${file}. Returning undefined.`
|
|
1598
|
-
);
|
|
1599
|
-
return {};
|
|
1600
|
-
}
|
|
1601
|
-
}
|
|
1602
|
-
function isModuleInstalled(name) {
|
|
1603
|
-
return import(
|
|
1604
|
-
/* @vite-ignore */
|
|
1605
|
-
name
|
|
1606
|
-
).then(() => true).catch(() => false);
|
|
1607
|
-
}
|
|
1608
|
-
|
|
1609
|
-
// src/core/utils/building/resolve-config.ts
|
|
1610
|
-
import fs9 from "fs-extra";
|
|
1611
1607
|
import glob3 from "fast-glob";
|
|
1612
1608
|
|
|
1613
1609
|
// src/builtin-modules/index.ts
|
|
1614
1610
|
var builtinModules = [unimport_default];
|
|
1615
1611
|
|
|
1612
|
+
// src/core/utils/eslint.ts
|
|
1613
|
+
async function getEslintVersion() {
|
|
1614
|
+
try {
|
|
1615
|
+
const require2 = (await import("node:module")).default.createRequire(
|
|
1616
|
+
import.meta.url
|
|
1617
|
+
);
|
|
1618
|
+
const { ESLint } = require2("eslint");
|
|
1619
|
+
return ESLint.version?.split(".") ?? [];
|
|
1620
|
+
} catch (error) {
|
|
1621
|
+
return [];
|
|
1622
|
+
}
|
|
1623
|
+
}
|
|
1624
|
+
|
|
1616
1625
|
// src/core/utils/building/resolve-config.ts
|
|
1617
1626
|
async function resolveConfig(inlineConfig, command) {
|
|
1618
1627
|
let userConfig = {};
|
|
@@ -1727,7 +1736,7 @@ async function resolveConfig(inlineConfig, command) {
|
|
|
1727
1736
|
srcDir,
|
|
1728
1737
|
typesDir,
|
|
1729
1738
|
wxtDir,
|
|
1730
|
-
zip: resolveZipConfig(root, mergedConfig),
|
|
1739
|
+
zip: resolveZipConfig(root, outBaseDir, mergedConfig),
|
|
1731
1740
|
transformManifest: mergedConfig.transformManifest,
|
|
1732
1741
|
analysis: resolveAnalysisConfig(root, mergedConfig),
|
|
1733
1742
|
userConfigMetadata: userConfigMetadata ?? {},
|
|
@@ -1772,7 +1781,7 @@ async function mergeInlineConfig(inlineConfig, userConfig) {
|
|
|
1772
1781
|
...builderConfig
|
|
1773
1782
|
};
|
|
1774
1783
|
}
|
|
1775
|
-
function resolveZipConfig(root, mergedConfig) {
|
|
1784
|
+
function resolveZipConfig(root, outBaseDir, mergedConfig) {
|
|
1776
1785
|
const downloadedPackagesDir = path5.resolve(root, ".wxt/local_modules");
|
|
1777
1786
|
return {
|
|
1778
1787
|
name: void 0,
|
|
@@ -1791,6 +1800,8 @@ function resolveZipConfig(root, mergedConfig) {
|
|
|
1791
1800
|
// Tests
|
|
1792
1801
|
"**/__tests__/**",
|
|
1793
1802
|
"**/*.+(test|spec).?(c|m)+(j|t)s?(x)",
|
|
1803
|
+
// Output directory
|
|
1804
|
+
`${path5.relative(root, outBaseDir)}/**`,
|
|
1794
1805
|
// From user
|
|
1795
1806
|
...mergedConfig.zip?.excludeSources ?? []
|
|
1796
1807
|
],
|
|
@@ -1817,16 +1828,6 @@ function resolveAnalysisConfig(root, mergedConfig) {
|
|
|
1817
1828
|
}
|
|
1818
1829
|
async function getUnimportOptions(wxtDir, srcDir, logger, config) {
|
|
1819
1830
|
if (config.imports === false) return false;
|
|
1820
|
-
const rawEslintEnabled = config.imports?.eslintrc?.enabled;
|
|
1821
|
-
let eslintEnabled;
|
|
1822
|
-
switch (rawEslintEnabled) {
|
|
1823
|
-
case void 0:
|
|
1824
|
-
case "auto":
|
|
1825
|
-
eslintEnabled = await isModuleInstalled("eslint");
|
|
1826
|
-
break;
|
|
1827
|
-
default:
|
|
1828
|
-
eslintEnabled = rawEslintEnabled;
|
|
1829
|
-
}
|
|
1830
1831
|
const defaultOptions = {
|
|
1831
1832
|
debugLog: logger.debug,
|
|
1832
1833
|
imports: [
|
|
@@ -1844,23 +1845,45 @@ async function getUnimportOptions(wxtDir, srcDir, logger, config) {
|
|
|
1844
1845
|
dirsScanOptions: {
|
|
1845
1846
|
cwd: srcDir
|
|
1846
1847
|
},
|
|
1847
|
-
eslintrc:
|
|
1848
|
-
enabled: eslintEnabled,
|
|
1849
|
-
filePath: path5.resolve(wxtDir, "eslintrc-auto-import.json"),
|
|
1850
|
-
globalsPropValue: true
|
|
1851
|
-
}
|
|
1848
|
+
eslintrc: await getUnimportEslintOptions(wxtDir, config.imports?.eslintrc)
|
|
1852
1849
|
};
|
|
1853
1850
|
return defu(
|
|
1854
1851
|
config.imports ?? {},
|
|
1855
1852
|
defaultOptions
|
|
1856
1853
|
);
|
|
1857
1854
|
}
|
|
1855
|
+
async function getUnimportEslintOptions(wxtDir, options) {
|
|
1856
|
+
const rawEslintEnabled = options?.enabled ?? "auto";
|
|
1857
|
+
let eslintEnabled;
|
|
1858
|
+
switch (rawEslintEnabled) {
|
|
1859
|
+
case "auto":
|
|
1860
|
+
const version2 = await getEslintVersion();
|
|
1861
|
+
let major = parseInt(version2[0]);
|
|
1862
|
+
if (major <= 8) eslintEnabled = 8;
|
|
1863
|
+
else if (major >= 9) eslintEnabled = 9;
|
|
1864
|
+
else eslintEnabled = 8;
|
|
1865
|
+
break;
|
|
1866
|
+
case true:
|
|
1867
|
+
eslintEnabled = 8;
|
|
1868
|
+
break;
|
|
1869
|
+
default:
|
|
1870
|
+
eslintEnabled = rawEslintEnabled;
|
|
1871
|
+
}
|
|
1872
|
+
return {
|
|
1873
|
+
enabled: eslintEnabled,
|
|
1874
|
+
filePath: path5.resolve(
|
|
1875
|
+
wxtDir,
|
|
1876
|
+
eslintEnabled === 9 ? "eslint-auto-imports.mjs" : "eslintrc-auto-import.json"
|
|
1877
|
+
),
|
|
1878
|
+
globalsPropValue: true
|
|
1879
|
+
};
|
|
1880
|
+
}
|
|
1858
1881
|
async function resolveWxtModuleDir() {
|
|
1859
1882
|
const requireResolve = __require?.resolve ?? (await import("node:module")).default.createRequire(import.meta.url).resolve;
|
|
1860
1883
|
return path5.resolve(requireResolve("wxt"), "../..");
|
|
1861
1884
|
}
|
|
1862
1885
|
async function isDirMissing(dir) {
|
|
1863
|
-
return !await
|
|
1886
|
+
return !await fs8.exists(dir);
|
|
1864
1887
|
}
|
|
1865
1888
|
function logMissingDir(logger, name, expected) {
|
|
1866
1889
|
logger.warn(
|
|
@@ -1975,8 +1998,8 @@ var ENTRY_TYPE_TO_GROUP_MAP = {
|
|
|
1975
1998
|
// src/core/utils/building/import-entrypoint.ts
|
|
1976
1999
|
import createJITI from "jiti";
|
|
1977
2000
|
import { createUnimport as createUnimport2 } from "unimport";
|
|
1978
|
-
import
|
|
1979
|
-
import { relative as relative5, resolve as
|
|
2001
|
+
import fs9 from "fs-extra";
|
|
2002
|
+
import { relative as relative5, resolve as resolve10 } from "node:path";
|
|
1980
2003
|
import { transformSync } from "esbuild";
|
|
1981
2004
|
import { fileURLToPath } from "node:url";
|
|
1982
2005
|
async function importEntrypointFile(path8) {
|
|
@@ -1988,7 +2011,7 @@ async function importEntrypointFile(path8) {
|
|
|
1988
2011
|
dirs: []
|
|
1989
2012
|
});
|
|
1990
2013
|
await unimport.init();
|
|
1991
|
-
const text = await
|
|
2014
|
+
const text = await fs9.readFile(path8, "utf-8");
|
|
1992
2015
|
const textNoImports = removeProjectImportStatements(text);
|
|
1993
2016
|
const { code } = await unimport.injectImports(textNoImports);
|
|
1994
2017
|
wxt.logger.debug(
|
|
@@ -2001,7 +2024,7 @@ async function importEntrypointFile(path8) {
|
|
|
2001
2024
|
debug: wxt.config.debug,
|
|
2002
2025
|
esmResolve: true,
|
|
2003
2026
|
alias: {
|
|
2004
|
-
"webextension-polyfill":
|
|
2027
|
+
"webextension-polyfill": resolve10(
|
|
2005
2028
|
wxt.config.wxtModuleDir,
|
|
2006
2029
|
"dist/virtual/mock-browser.js"
|
|
2007
2030
|
)
|
|
@@ -2066,12 +2089,12 @@ import pc5 from "picocolors";
|
|
|
2066
2089
|
import fs13 from "fs-extra";
|
|
2067
2090
|
|
|
2068
2091
|
// src/core/utils/log/printBuildSummary.ts
|
|
2069
|
-
import { resolve as
|
|
2092
|
+
import { resolve as resolve11 } from "path";
|
|
2070
2093
|
|
|
2071
2094
|
// src/core/utils/log/printFileList.ts
|
|
2072
2095
|
import path6 from "node:path";
|
|
2073
2096
|
import pc3 from "picocolors";
|
|
2074
|
-
import
|
|
2097
|
+
import fs10 from "fs-extra";
|
|
2075
2098
|
import { filesize } from "filesize";
|
|
2076
2099
|
|
|
2077
2100
|
// src/core/utils/log/printTable.ts
|
|
@@ -2109,7 +2132,7 @@ async function printFileList(log, header, baseDir, files) {
|
|
|
2109
2132
|
];
|
|
2110
2133
|
const prefix = i === files.length - 1 ? " \u2514\u2500" : " \u251C\u2500";
|
|
2111
2134
|
const color = getChunkColor(file);
|
|
2112
|
-
const stats = await
|
|
2135
|
+
const stats = await fs10.lstat(file);
|
|
2113
2136
|
totalSize += stats.size;
|
|
2114
2137
|
const size = String(filesize(stats.size));
|
|
2115
2138
|
return [
|
|
@@ -2150,7 +2173,7 @@ async function printBuildSummary(log, header, output) {
|
|
|
2150
2173
|
return l.fileName.localeCompare(r.fileName);
|
|
2151
2174
|
});
|
|
2152
2175
|
const files = chunks.map(
|
|
2153
|
-
(chunk) =>
|
|
2176
|
+
(chunk) => resolve11(wxt.config.outDir, chunk.fileName)
|
|
2154
2177
|
);
|
|
2155
2178
|
await printFileList(log, header, wxt.config.outDir, files);
|
|
2156
2179
|
}
|
|
@@ -2280,6 +2303,21 @@ function getContentScriptJs(config, entrypoint) {
|
|
|
2280
2303
|
return [getEntrypointBundlePath(entrypoint, config.outDir, ".js")];
|
|
2281
2304
|
}
|
|
2282
2305
|
|
|
2306
|
+
// src/core/utils/package.ts
|
|
2307
|
+
import { resolve as resolve12 } from "node:path";
|
|
2308
|
+
import fs11 from "fs-extra";
|
|
2309
|
+
async function getPackageJson() {
|
|
2310
|
+
const file = resolve12(wxt.config.root, "package.json");
|
|
2311
|
+
try {
|
|
2312
|
+
return await fs11.readJson(file);
|
|
2313
|
+
} catch (err) {
|
|
2314
|
+
wxt.logger.debug(
|
|
2315
|
+
`Failed to read package.json at: ${file}. Returning undefined.`
|
|
2316
|
+
);
|
|
2317
|
+
return {};
|
|
2318
|
+
}
|
|
2319
|
+
}
|
|
2320
|
+
|
|
2283
2321
|
// src/core/utils/manifest.ts
|
|
2284
2322
|
import defu2 from "defu";
|
|
2285
2323
|
async function writeManifest(manifest, output) {
|
|
@@ -2967,12 +3005,12 @@ function printValidationResults({
|
|
|
2967
3005
|
return map;
|
|
2968
3006
|
}, /* @__PURE__ */ new Map());
|
|
2969
3007
|
Array.from(entrypointErrors.entries()).forEach(([entrypoint, errors2]) => {
|
|
2970
|
-
|
|
3008
|
+
wxt.logger.log(relative6(cwd, entrypoint.inputPath));
|
|
2971
3009
|
console.log();
|
|
2972
3010
|
errors2.forEach((err) => {
|
|
2973
3011
|
const type = err.type === "error" ? pc5.red("ERROR") : pc5.yellow("WARN");
|
|
2974
3012
|
const recieved = pc5.dim(`(recieved: ${JSON.stringify(err.value)})`);
|
|
2975
|
-
|
|
3013
|
+
wxt.logger.log(` - ${type} ${err.message} ${recieved}`);
|
|
2976
3014
|
});
|
|
2977
3015
|
console.log();
|
|
2978
3016
|
});
|
|
@@ -2998,7 +3036,7 @@ var npm = {
|
|
|
2998
3036
|
overridesKey: "overrides",
|
|
2999
3037
|
async downloadDependency(id, downloadDir) {
|
|
3000
3038
|
await ensureDir3(downloadDir);
|
|
3001
|
-
const { execa } = await import("./execa-
|
|
3039
|
+
const { execa } = await import("./execa-4UBDUBJZ.js");
|
|
3002
3040
|
const res = await execa("npm", ["pack", id, "--json"], {
|
|
3003
3041
|
cwd: downloadDir
|
|
3004
3042
|
});
|
|
@@ -3010,7 +3048,7 @@ var npm = {
|
|
|
3010
3048
|
if (options?.all) {
|
|
3011
3049
|
args.push("--depth", "Infinity");
|
|
3012
3050
|
}
|
|
3013
|
-
const { execa } = await import("./execa-
|
|
3051
|
+
const { execa } = await import("./execa-4UBDUBJZ.js");
|
|
3014
3052
|
const res = await execa("npm", args, { cwd: options?.cwd });
|
|
3015
3053
|
const project = JSON.parse(res.stdout);
|
|
3016
3054
|
return flattenNpmListOutput([project]);
|
|
@@ -3063,7 +3101,7 @@ var bun = {
|
|
|
3063
3101
|
if (options?.all) {
|
|
3064
3102
|
args.push("--all");
|
|
3065
3103
|
}
|
|
3066
|
-
const { execa } = await import("./execa-
|
|
3104
|
+
const { execa } = await import("./execa-4UBDUBJZ.js");
|
|
3067
3105
|
const res = await execa("bun", args, { cwd: options?.cwd });
|
|
3068
3106
|
return dedupeDependencies(
|
|
3069
3107
|
res.stdout.split("\n").slice(1).map((line) => line.trim()).map((line) => /.* (@?\S+)@(\S+)$/.exec(line)).filter((match) => !!match).map(([_, name, version2]) => ({ name, version: version2 }))
|
|
@@ -3082,7 +3120,7 @@ var yarn = {
|
|
|
3082
3120
|
if (options?.all) {
|
|
3083
3121
|
args.push("--depth", "Infinity");
|
|
3084
3122
|
}
|
|
3085
|
-
const { execa } = await import("./execa-
|
|
3123
|
+
const { execa } = await import("./execa-4UBDUBJZ.js");
|
|
3086
3124
|
const res = await execa("yarn", args, { cwd: options?.cwd });
|
|
3087
3125
|
const tree = res.stdout.split("\n").map((line) => JSON.parse(line)).find((line) => line.type === "tree")?.data;
|
|
3088
3126
|
if (tree == null) throw Error("'yarn list --json' did not output a tree");
|
|
@@ -3118,7 +3156,7 @@ var pnpm = {
|
|
|
3118
3156
|
if (typeof process !== "undefined" && process.env.WXT_PNPM_IGNORE_WORKSPACE === "true") {
|
|
3119
3157
|
args.push("--ignore-workspace");
|
|
3120
3158
|
}
|
|
3121
|
-
const { execa } = await import("./execa-
|
|
3159
|
+
const { execa } = await import("./execa-4UBDUBJZ.js");
|
|
3122
3160
|
const res = await execa("pnpm", args, { cwd: options?.cwd });
|
|
3123
3161
|
const projects = JSON.parse(res.stdout);
|
|
3124
3162
|
return flattenNpmListOutput(projects);
|
|
@@ -3366,7 +3404,10 @@ async function createViteBuilder(wxtConfig, hooks, server) {
|
|
|
3366
3404
|
const config = vite.mergeConfig(baseConfig, envConfig);
|
|
3367
3405
|
const server2 = await vite.createServer(config);
|
|
3368
3406
|
await server2.pluginContainer.buildStart({});
|
|
3369
|
-
const node = new ViteNodeServer(
|
|
3407
|
+
const node = new ViteNodeServer(
|
|
3408
|
+
// @ts-ignore: Some weird type error...
|
|
3409
|
+
server2
|
|
3410
|
+
);
|
|
3370
3411
|
installSourcemapsSupport({
|
|
3371
3412
|
getSourceMap: (source) => node.getSourceMap(source)
|
|
3372
3413
|
});
|
|
@@ -3519,12 +3560,12 @@ export {
|
|
|
3519
3560
|
detectDevChanges,
|
|
3520
3561
|
findEntrypoints,
|
|
3521
3562
|
generateTypesDir,
|
|
3522
|
-
getPackageJson,
|
|
3523
3563
|
resolveConfig,
|
|
3524
3564
|
printFileList,
|
|
3525
3565
|
version,
|
|
3526
3566
|
mapWxtOptionsToRegisteredContentScript,
|
|
3527
3567
|
getContentScriptJs,
|
|
3568
|
+
getPackageJson,
|
|
3528
3569
|
getContentScriptCssFiles,
|
|
3529
3570
|
getContentScriptsCssMap,
|
|
3530
3571
|
rebuild,
|