wxt 0.9.1-alpha1 → 0.9.2
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-QV4KO4GO.js → chunk-OKMB7FJI.js} +67 -22
- package/dist/cli.cjs +72 -22
- package/dist/{external-cb0967d6.d.ts → external-9115d0fb.d.ts} +41 -0
- package/dist/index.cjs +72 -22
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +6 -1
- package/dist/testing.cjs +48 -7
- package/dist/testing.d.cts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +1 -1
- package/package.json +5 -8
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// package.json
|
|
2
|
-
var version = "0.9.
|
|
2
|
+
var version = "0.9.2";
|
|
3
3
|
|
|
4
4
|
// src/core/utils/entrypoints.ts
|
|
5
5
|
import path, { relative, resolve } from "node:path";
|
|
@@ -175,12 +175,7 @@ function tsconfigPaths(config) {
|
|
|
175
175
|
async config() {
|
|
176
176
|
return {
|
|
177
177
|
resolve: {
|
|
178
|
-
alias:
|
|
179
|
-
"@@": config.root,
|
|
180
|
-
"~~": config.root,
|
|
181
|
-
"@": config.srcDir,
|
|
182
|
-
"~": config.srcDir
|
|
183
|
-
}
|
|
178
|
+
alias: config.alias
|
|
184
179
|
}
|
|
185
180
|
};
|
|
186
181
|
}
|
|
@@ -568,6 +563,30 @@ function bundleAnalysis() {
|
|
|
568
563
|
});
|
|
569
564
|
}
|
|
570
565
|
|
|
566
|
+
// src/core/vite-plugins/excludeBrowserPolyfill.ts
|
|
567
|
+
function excludeBrowserPolyfill(config) {
|
|
568
|
+
const virtualId = "virtual:wxt-webextension-polyfill-disabled";
|
|
569
|
+
return {
|
|
570
|
+
name: "wxt:exclude-browser-polyfill",
|
|
571
|
+
config() {
|
|
572
|
+
if (config.experimental.includeBrowserPolyfill)
|
|
573
|
+
return;
|
|
574
|
+
return {
|
|
575
|
+
resolve: {
|
|
576
|
+
alias: {
|
|
577
|
+
"webextension-polyfill": virtualId
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
};
|
|
581
|
+
},
|
|
582
|
+
load(id) {
|
|
583
|
+
if (id === virtualId) {
|
|
584
|
+
return "export default chrome";
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
};
|
|
588
|
+
}
|
|
589
|
+
|
|
571
590
|
// src/core/utils/arrays.ts
|
|
572
591
|
function every(array, predicate) {
|
|
573
592
|
for (let i = 0; i < array.length; i++)
|
|
@@ -1018,8 +1037,14 @@ async function writeMainDeclarationFile(references, config) {
|
|
|
1018
1037
|
}
|
|
1019
1038
|
async function writeTsConfigFile(mainReference, config) {
|
|
1020
1039
|
const dir = config.wxtDir;
|
|
1021
|
-
const
|
|
1022
|
-
const
|
|
1040
|
+
const getTsconfigPath = (path7) => normalizePath2(relative3(dir, path7));
|
|
1041
|
+
const paths = Object.entries(config.alias).flatMap(([alias, absolutePath]) => {
|
|
1042
|
+
const aliasPath = getTsconfigPath(absolutePath);
|
|
1043
|
+
return [
|
|
1044
|
+
` "${alias}": ["${aliasPath}"]`,
|
|
1045
|
+
` "${alias}/*": ["${aliasPath}/*"]`
|
|
1046
|
+
];
|
|
1047
|
+
}).join(",\n");
|
|
1023
1048
|
await writeFileIfDifferent(
|
|
1024
1049
|
resolve6(dir, "tsconfig.json"),
|
|
1025
1050
|
`{
|
|
@@ -1034,21 +1059,14 @@ async function writeTsConfigFile(mainReference, config) {
|
|
|
1034
1059
|
"strict": true,
|
|
1035
1060
|
"skipLibCheck": true,
|
|
1036
1061
|
"paths": {
|
|
1037
|
-
|
|
1038
|
-
"@/*": ["${srcPath}/*"],
|
|
1039
|
-
"~": ["${srcPath}"],
|
|
1040
|
-
"~/*": ["${srcPath}/*"],
|
|
1041
|
-
"@@": ["${rootPath}"],
|
|
1042
|
-
"@@/*": ["${rootPath}/*"],
|
|
1043
|
-
"~~": ["${rootPath}"],
|
|
1044
|
-
"~~/*": ["${rootPath}/*"]
|
|
1062
|
+
${paths}
|
|
1045
1063
|
}
|
|
1046
1064
|
},
|
|
1047
1065
|
"include": [
|
|
1048
|
-
"${
|
|
1049
|
-
"./${
|
|
1066
|
+
"${getTsconfigPath(config.root)}/**/*",
|
|
1067
|
+
"./${getTsconfigPath(mainReference)}"
|
|
1050
1068
|
],
|
|
1051
|
-
"exclude": ["${
|
|
1069
|
+
"exclude": ["${getTsconfigPath(config.outBaseDir)}"]
|
|
1052
1070
|
}`
|
|
1053
1071
|
);
|
|
1054
1072
|
}
|
|
@@ -1124,6 +1142,15 @@ async function getInternalConfig(inlineConfig, command) {
|
|
|
1124
1142
|
overrides: inlineConfig.runner,
|
|
1125
1143
|
defaults: userConfig.runner
|
|
1126
1144
|
});
|
|
1145
|
+
const alias = Object.fromEntries(
|
|
1146
|
+
Object.entries({
|
|
1147
|
+
...mergedConfig.alias,
|
|
1148
|
+
"@": srcDir,
|
|
1149
|
+
"~": srcDir,
|
|
1150
|
+
"@@": root,
|
|
1151
|
+
"~~": root
|
|
1152
|
+
}).map(([key, value]) => [key, path5.resolve(root, value)])
|
|
1153
|
+
);
|
|
1127
1154
|
const finalConfig = {
|
|
1128
1155
|
browser,
|
|
1129
1156
|
command,
|
|
@@ -1155,7 +1182,11 @@ async function getInternalConfig(inlineConfig, command) {
|
|
|
1155
1182
|
enabled: mergedConfig.analysis?.enabled ?? false,
|
|
1156
1183
|
template: mergedConfig.analysis?.template ?? "treemap"
|
|
1157
1184
|
},
|
|
1158
|
-
userConfigMetadata: userConfigMetadata ?? {}
|
|
1185
|
+
userConfigMetadata: userConfigMetadata ?? {},
|
|
1186
|
+
alias,
|
|
1187
|
+
experimental: {
|
|
1188
|
+
includeBrowserPolyfill: mergedConfig.experimental?.includeBrowserPolyfill ?? true
|
|
1189
|
+
}
|
|
1159
1190
|
};
|
|
1160
1191
|
finalConfig.vite = (env2) => resolveInternalViteConfig(env2, mergedConfig, finalConfig);
|
|
1161
1192
|
return finalConfig;
|
|
@@ -1212,6 +1243,14 @@ function mergeInlineConfig(inlineConfig, userConfig) {
|
|
|
1212
1243
|
analysis: {
|
|
1213
1244
|
enabled: inlineConfig.analysis?.enabled ?? userConfig.analysis?.enabled,
|
|
1214
1245
|
template: inlineConfig.analysis?.template ?? userConfig.analysis?.template
|
|
1246
|
+
},
|
|
1247
|
+
alias: {
|
|
1248
|
+
...userConfig.alias,
|
|
1249
|
+
...inlineConfig.alias
|
|
1250
|
+
},
|
|
1251
|
+
experimental: {
|
|
1252
|
+
...userConfig.experimental,
|
|
1253
|
+
...inlineConfig.experimental
|
|
1215
1254
|
}
|
|
1216
1255
|
};
|
|
1217
1256
|
}
|
|
@@ -1264,6 +1303,7 @@ async function resolveInternalViteConfig(env, mergedConfig, finalConfig) {
|
|
|
1264
1303
|
internalVite.plugins.push(bundleAnalysis());
|
|
1265
1304
|
}
|
|
1266
1305
|
internalVite.plugins.push(globals(finalConfig));
|
|
1306
|
+
internalVite.plugins.push(excludeBrowserPolyfill(finalConfig));
|
|
1267
1307
|
return internalVite;
|
|
1268
1308
|
}
|
|
1269
1309
|
|
|
@@ -1700,7 +1740,12 @@ function addEntrypoints(manifest, entrypoints, buildOutput, config) {
|
|
|
1700
1740
|
const sidepanels = entriesByType["sidepanel"];
|
|
1701
1741
|
if (background) {
|
|
1702
1742
|
const script = getEntrypointBundlePath(background, config.outDir, ".js");
|
|
1703
|
-
if (
|
|
1743
|
+
if (config.browser === "firefox" && config.manifestVersion === 3) {
|
|
1744
|
+
manifest.background = {
|
|
1745
|
+
type: background.options.type,
|
|
1746
|
+
scripts: [script]
|
|
1747
|
+
};
|
|
1748
|
+
} else if (config.manifestVersion === 3) {
|
|
1704
1749
|
manifest.background = {
|
|
1705
1750
|
type: background.options.type,
|
|
1706
1751
|
service_worker: script
|
package/dist/cli.cjs
CHANGED
|
@@ -2415,7 +2415,7 @@ var init_execa = __esm({
|
|
|
2415
2415
|
var import_cac = __toESM(require("cac"), 1);
|
|
2416
2416
|
|
|
2417
2417
|
// package.json
|
|
2418
|
-
var version = "0.9.
|
|
2418
|
+
var version = "0.9.2";
|
|
2419
2419
|
|
|
2420
2420
|
// src/core/utils/building/build-entrypoints.ts
|
|
2421
2421
|
var vite2 = __toESM(require("vite"), 1);
|
|
@@ -2809,12 +2809,7 @@ function tsconfigPaths(config) {
|
|
|
2809
2809
|
async config() {
|
|
2810
2810
|
return {
|
|
2811
2811
|
resolve: {
|
|
2812
|
-
alias:
|
|
2813
|
-
"@@": config.root,
|
|
2814
|
-
"~~": config.root,
|
|
2815
|
-
"@": config.srcDir,
|
|
2816
|
-
"~": config.srcDir
|
|
2817
|
-
}
|
|
2812
|
+
alias: config.alias
|
|
2818
2813
|
}
|
|
2819
2814
|
};
|
|
2820
2815
|
}
|
|
@@ -2953,6 +2948,30 @@ function globals(config) {
|
|
|
2953
2948
|
// src/core/vite-plugins/webextensionPolyfillAlias.ts
|
|
2954
2949
|
var import_node_path4 = __toESM(require("path"), 1);
|
|
2955
2950
|
|
|
2951
|
+
// src/core/vite-plugins/excludeBrowserPolyfill.ts
|
|
2952
|
+
function excludeBrowserPolyfill(config) {
|
|
2953
|
+
const virtualId = "virtual:wxt-webextension-polyfill-disabled";
|
|
2954
|
+
return {
|
|
2955
|
+
name: "wxt:exclude-browser-polyfill",
|
|
2956
|
+
config() {
|
|
2957
|
+
if (config.experimental.includeBrowserPolyfill)
|
|
2958
|
+
return;
|
|
2959
|
+
return {
|
|
2960
|
+
resolve: {
|
|
2961
|
+
alias: {
|
|
2962
|
+
"webextension-polyfill": virtualId
|
|
2963
|
+
}
|
|
2964
|
+
}
|
|
2965
|
+
};
|
|
2966
|
+
},
|
|
2967
|
+
load(id) {
|
|
2968
|
+
if (id === virtualId) {
|
|
2969
|
+
return "export default chrome";
|
|
2970
|
+
}
|
|
2971
|
+
}
|
|
2972
|
+
};
|
|
2973
|
+
}
|
|
2974
|
+
|
|
2956
2975
|
// src/core/utils/fs.ts
|
|
2957
2976
|
var import_fs_extra3 = __toESM(require("fs-extra"), 1);
|
|
2958
2977
|
var import_fast_glob = __toESM(require("fast-glob"), 1);
|
|
@@ -3696,8 +3715,14 @@ async function writeMainDeclarationFile(references, config) {
|
|
|
3696
3715
|
}
|
|
3697
3716
|
async function writeTsConfigFile(mainReference, config) {
|
|
3698
3717
|
const dir = config.wxtDir;
|
|
3699
|
-
const
|
|
3700
|
-
const
|
|
3718
|
+
const getTsconfigPath = (path11) => normalizePath2((0, import_path6.relative)(dir, path11));
|
|
3719
|
+
const paths = Object.entries(config.alias).flatMap(([alias, absolutePath]) => {
|
|
3720
|
+
const aliasPath = getTsconfigPath(absolutePath);
|
|
3721
|
+
return [
|
|
3722
|
+
` "${alias}": ["${aliasPath}"]`,
|
|
3723
|
+
` "${alias}/*": ["${aliasPath}/*"]`
|
|
3724
|
+
];
|
|
3725
|
+
}).join(",\n");
|
|
3701
3726
|
await writeFileIfDifferent(
|
|
3702
3727
|
(0, import_path6.resolve)(dir, "tsconfig.json"),
|
|
3703
3728
|
`{
|
|
@@ -3712,21 +3737,14 @@ async function writeTsConfigFile(mainReference, config) {
|
|
|
3712
3737
|
"strict": true,
|
|
3713
3738
|
"skipLibCheck": true,
|
|
3714
3739
|
"paths": {
|
|
3715
|
-
|
|
3716
|
-
"@/*": ["${srcPath}/*"],
|
|
3717
|
-
"~": ["${srcPath}"],
|
|
3718
|
-
"~/*": ["${srcPath}/*"],
|
|
3719
|
-
"@@": ["${rootPath}"],
|
|
3720
|
-
"@@/*": ["${rootPath}/*"],
|
|
3721
|
-
"~~": ["${rootPath}"],
|
|
3722
|
-
"~~/*": ["${rootPath}/*"]
|
|
3740
|
+
${paths}
|
|
3723
3741
|
}
|
|
3724
3742
|
},
|
|
3725
3743
|
"include": [
|
|
3726
|
-
"${
|
|
3727
|
-
"./${
|
|
3744
|
+
"${getTsconfigPath(config.root)}/**/*",
|
|
3745
|
+
"./${getTsconfigPath(mainReference)}"
|
|
3728
3746
|
],
|
|
3729
|
-
"exclude": ["${
|
|
3747
|
+
"exclude": ["${getTsconfigPath(config.outBaseDir)}"]
|
|
3730
3748
|
}`
|
|
3731
3749
|
);
|
|
3732
3750
|
}
|
|
@@ -3802,6 +3820,15 @@ async function getInternalConfig(inlineConfig, command) {
|
|
|
3802
3820
|
overrides: inlineConfig.runner,
|
|
3803
3821
|
defaults: userConfig.runner
|
|
3804
3822
|
});
|
|
3823
|
+
const alias = Object.fromEntries(
|
|
3824
|
+
Object.entries({
|
|
3825
|
+
...mergedConfig.alias,
|
|
3826
|
+
"@": srcDir,
|
|
3827
|
+
"~": srcDir,
|
|
3828
|
+
"@@": root,
|
|
3829
|
+
"~~": root
|
|
3830
|
+
}).map(([key, value]) => [key, import_node_path7.default.resolve(root, value)])
|
|
3831
|
+
);
|
|
3805
3832
|
const finalConfig = {
|
|
3806
3833
|
browser,
|
|
3807
3834
|
command,
|
|
@@ -3833,7 +3860,11 @@ async function getInternalConfig(inlineConfig, command) {
|
|
|
3833
3860
|
enabled: mergedConfig.analysis?.enabled ?? false,
|
|
3834
3861
|
template: mergedConfig.analysis?.template ?? "treemap"
|
|
3835
3862
|
},
|
|
3836
|
-
userConfigMetadata: userConfigMetadata ?? {}
|
|
3863
|
+
userConfigMetadata: userConfigMetadata ?? {},
|
|
3864
|
+
alias,
|
|
3865
|
+
experimental: {
|
|
3866
|
+
includeBrowserPolyfill: mergedConfig.experimental?.includeBrowserPolyfill ?? true
|
|
3867
|
+
}
|
|
3837
3868
|
};
|
|
3838
3869
|
finalConfig.vite = (env2) => resolveInternalViteConfig(env2, mergedConfig, finalConfig);
|
|
3839
3870
|
return finalConfig;
|
|
@@ -3890,6 +3921,14 @@ function mergeInlineConfig(inlineConfig, userConfig) {
|
|
|
3890
3921
|
analysis: {
|
|
3891
3922
|
enabled: inlineConfig.analysis?.enabled ?? userConfig.analysis?.enabled,
|
|
3892
3923
|
template: inlineConfig.analysis?.template ?? userConfig.analysis?.template
|
|
3924
|
+
},
|
|
3925
|
+
alias: {
|
|
3926
|
+
...userConfig.alias,
|
|
3927
|
+
...inlineConfig.alias
|
|
3928
|
+
},
|
|
3929
|
+
experimental: {
|
|
3930
|
+
...userConfig.experimental,
|
|
3931
|
+
...inlineConfig.experimental
|
|
3893
3932
|
}
|
|
3894
3933
|
};
|
|
3895
3934
|
}
|
|
@@ -3942,6 +3981,7 @@ async function resolveInternalViteConfig(env, mergedConfig, finalConfig) {
|
|
|
3942
3981
|
internalVite.plugins.push(bundleAnalysis());
|
|
3943
3982
|
}
|
|
3944
3983
|
internalVite.plugins.push(globals(finalConfig));
|
|
3984
|
+
internalVite.plugins.push(excludeBrowserPolyfill(finalConfig));
|
|
3945
3985
|
return internalVite;
|
|
3946
3986
|
}
|
|
3947
3987
|
|
|
@@ -4382,7 +4422,12 @@ function addEntrypoints(manifest, entrypoints, buildOutput, config) {
|
|
|
4382
4422
|
const sidepanels = entriesByType["sidepanel"];
|
|
4383
4423
|
if (background) {
|
|
4384
4424
|
const script = getEntrypointBundlePath(background, config.outDir, ".js");
|
|
4385
|
-
if (
|
|
4425
|
+
if (config.browser === "firefox" && config.manifestVersion === 3) {
|
|
4426
|
+
manifest.background = {
|
|
4427
|
+
type: background.options.type,
|
|
4428
|
+
scripts: [script]
|
|
4429
|
+
};
|
|
4430
|
+
} else if (config.manifestVersion === 3) {
|
|
4386
4431
|
manifest.background = {
|
|
4387
4432
|
type: background.options.type,
|
|
4388
4433
|
service_worker: script
|
|
@@ -4834,6 +4879,11 @@ function createWebExtRunner() {
|
|
|
4834
4879
|
return {
|
|
4835
4880
|
async openBrowser(config) {
|
|
4836
4881
|
config.logger.info("Opening browser...");
|
|
4882
|
+
if (config.browser === "firefox" && config.manifestVersion === 3) {
|
|
4883
|
+
throw Error(
|
|
4884
|
+
"Dev mode does not support Firefox MV3. For alternatives, see https://github.com/wxt-dev/wxt/issues/230#issuecomment-1806881653"
|
|
4885
|
+
);
|
|
4886
|
+
}
|
|
4837
4887
|
const webExtLogger = await import("web-ext-run/util/logger");
|
|
4838
4888
|
webExtLogger.consoleStream.write = ({ level, msg, name }) => {
|
|
4839
4889
|
if (level >= ERROR_LOG_LEVEL)
|
|
@@ -268,6 +268,47 @@ interface InlineConfig {
|
|
|
268
268
|
*/
|
|
269
269
|
template?: PluginVisualizerOptions['template'];
|
|
270
270
|
};
|
|
271
|
+
/**
|
|
272
|
+
* Add additional paths to the `.wxt/tsconfig.json`. Use this instead of overwriting the `paths`
|
|
273
|
+
* in the root `tsconfig.json` if you want to add new paths.
|
|
274
|
+
*
|
|
275
|
+
* Passed into Vite's
|
|
276
|
+
* [`resolve.alias`](https://vitejs.dev/config/shared-options.html#resolve-alias) option and used
|
|
277
|
+
* to generate the `.wxt/tsconfig.json`.
|
|
278
|
+
*
|
|
279
|
+
* The key is the import alias and the value is either a relative path to the root directory or an absolute path.
|
|
280
|
+
*
|
|
281
|
+
* @example
|
|
282
|
+
* {
|
|
283
|
+
* "testing": "src/utils/testing.ts"
|
|
284
|
+
* }
|
|
285
|
+
*/
|
|
286
|
+
alias?: Record<string, string>;
|
|
287
|
+
/**
|
|
288
|
+
* Experimental settings - use with caution.
|
|
289
|
+
*/
|
|
290
|
+
experimental?: {
|
|
291
|
+
/**
|
|
292
|
+
* Whether to use [`webextension-polyfill`](https://www.npmjs.com/package/webextension-polyfill)
|
|
293
|
+
* when importing `browser` from `wxt/browser`.
|
|
294
|
+
*
|
|
295
|
+
* When set to `false`, WXT will export the chrome global instead of the polyfill from
|
|
296
|
+
* `wxt/browser`.
|
|
297
|
+
*
|
|
298
|
+
* You should use `browser` to access the web extension APIs.
|
|
299
|
+
*
|
|
300
|
+
* @experimental This option will remain experimental until Manifest V2 is dead.
|
|
301
|
+
*
|
|
302
|
+
* @default true
|
|
303
|
+
* @example
|
|
304
|
+
* export default defineConfig({
|
|
305
|
+
* experimental: {
|
|
306
|
+
* includeBrowserPolyfill: false
|
|
307
|
+
* }
|
|
308
|
+
* })
|
|
309
|
+
*/
|
|
310
|
+
includeBrowserPolyfill?: boolean;
|
|
311
|
+
};
|
|
271
312
|
}
|
|
272
313
|
interface WxtInlineViteConfig extends Omit<vite.InlineConfig, 'root' | 'configFile' | 'mode' | 'build'> {
|
|
273
314
|
build?: Omit<vite.BuildOptions, 'outDir'>;
|
package/dist/index.cjs
CHANGED
|
@@ -2819,12 +2819,7 @@ function tsconfigPaths(config) {
|
|
|
2819
2819
|
async config() {
|
|
2820
2820
|
return {
|
|
2821
2821
|
resolve: {
|
|
2822
|
-
alias:
|
|
2823
|
-
"@@": config.root,
|
|
2824
|
-
"~~": config.root,
|
|
2825
|
-
"@": config.srcDir,
|
|
2826
|
-
"~": config.srcDir
|
|
2827
|
-
}
|
|
2822
|
+
alias: config.alias
|
|
2828
2823
|
}
|
|
2829
2824
|
};
|
|
2830
2825
|
}
|
|
@@ -2963,6 +2958,30 @@ function globals(config) {
|
|
|
2963
2958
|
// src/core/vite-plugins/webextensionPolyfillAlias.ts
|
|
2964
2959
|
var import_node_path4 = __toESM(require("path"), 1);
|
|
2965
2960
|
|
|
2961
|
+
// src/core/vite-plugins/excludeBrowserPolyfill.ts
|
|
2962
|
+
function excludeBrowserPolyfill(config) {
|
|
2963
|
+
const virtualId = "virtual:wxt-webextension-polyfill-disabled";
|
|
2964
|
+
return {
|
|
2965
|
+
name: "wxt:exclude-browser-polyfill",
|
|
2966
|
+
config() {
|
|
2967
|
+
if (config.experimental.includeBrowserPolyfill)
|
|
2968
|
+
return;
|
|
2969
|
+
return {
|
|
2970
|
+
resolve: {
|
|
2971
|
+
alias: {
|
|
2972
|
+
"webextension-polyfill": virtualId
|
|
2973
|
+
}
|
|
2974
|
+
}
|
|
2975
|
+
};
|
|
2976
|
+
},
|
|
2977
|
+
load(id) {
|
|
2978
|
+
if (id === virtualId) {
|
|
2979
|
+
return "export default chrome";
|
|
2980
|
+
}
|
|
2981
|
+
}
|
|
2982
|
+
};
|
|
2983
|
+
}
|
|
2984
|
+
|
|
2966
2985
|
// src/core/utils/fs.ts
|
|
2967
2986
|
var import_fs_extra3 = __toESM(require("fs-extra"), 1);
|
|
2968
2987
|
var import_fast_glob = __toESM(require("fast-glob"), 1);
|
|
@@ -3706,8 +3725,14 @@ async function writeMainDeclarationFile(references, config) {
|
|
|
3706
3725
|
}
|
|
3707
3726
|
async function writeTsConfigFile(mainReference, config) {
|
|
3708
3727
|
const dir = config.wxtDir;
|
|
3709
|
-
const
|
|
3710
|
-
const
|
|
3728
|
+
const getTsconfigPath = (path11) => normalizePath2((0, import_path6.relative)(dir, path11));
|
|
3729
|
+
const paths = Object.entries(config.alias).flatMap(([alias, absolutePath]) => {
|
|
3730
|
+
const aliasPath = getTsconfigPath(absolutePath);
|
|
3731
|
+
return [
|
|
3732
|
+
` "${alias}": ["${aliasPath}"]`,
|
|
3733
|
+
` "${alias}/*": ["${aliasPath}/*"]`
|
|
3734
|
+
];
|
|
3735
|
+
}).join(",\n");
|
|
3711
3736
|
await writeFileIfDifferent(
|
|
3712
3737
|
(0, import_path6.resolve)(dir, "tsconfig.json"),
|
|
3713
3738
|
`{
|
|
@@ -3722,21 +3747,14 @@ async function writeTsConfigFile(mainReference, config) {
|
|
|
3722
3747
|
"strict": true,
|
|
3723
3748
|
"skipLibCheck": true,
|
|
3724
3749
|
"paths": {
|
|
3725
|
-
|
|
3726
|
-
"@/*": ["${srcPath}/*"],
|
|
3727
|
-
"~": ["${srcPath}"],
|
|
3728
|
-
"~/*": ["${srcPath}/*"],
|
|
3729
|
-
"@@": ["${rootPath}"],
|
|
3730
|
-
"@@/*": ["${rootPath}/*"],
|
|
3731
|
-
"~~": ["${rootPath}"],
|
|
3732
|
-
"~~/*": ["${rootPath}/*"]
|
|
3750
|
+
${paths}
|
|
3733
3751
|
}
|
|
3734
3752
|
},
|
|
3735
3753
|
"include": [
|
|
3736
|
-
"${
|
|
3737
|
-
"./${
|
|
3754
|
+
"${getTsconfigPath(config.root)}/**/*",
|
|
3755
|
+
"./${getTsconfigPath(mainReference)}"
|
|
3738
3756
|
],
|
|
3739
|
-
"exclude": ["${
|
|
3757
|
+
"exclude": ["${getTsconfigPath(config.outBaseDir)}"]
|
|
3740
3758
|
}`
|
|
3741
3759
|
);
|
|
3742
3760
|
}
|
|
@@ -3812,6 +3830,15 @@ async function getInternalConfig(inlineConfig, command) {
|
|
|
3812
3830
|
overrides: inlineConfig.runner,
|
|
3813
3831
|
defaults: userConfig.runner
|
|
3814
3832
|
});
|
|
3833
|
+
const alias = Object.fromEntries(
|
|
3834
|
+
Object.entries({
|
|
3835
|
+
...mergedConfig.alias,
|
|
3836
|
+
"@": srcDir,
|
|
3837
|
+
"~": srcDir,
|
|
3838
|
+
"@@": root,
|
|
3839
|
+
"~~": root
|
|
3840
|
+
}).map(([key, value]) => [key, import_node_path7.default.resolve(root, value)])
|
|
3841
|
+
);
|
|
3815
3842
|
const finalConfig = {
|
|
3816
3843
|
browser,
|
|
3817
3844
|
command,
|
|
@@ -3843,7 +3870,11 @@ async function getInternalConfig(inlineConfig, command) {
|
|
|
3843
3870
|
enabled: mergedConfig.analysis?.enabled ?? false,
|
|
3844
3871
|
template: mergedConfig.analysis?.template ?? "treemap"
|
|
3845
3872
|
},
|
|
3846
|
-
userConfigMetadata: userConfigMetadata ?? {}
|
|
3873
|
+
userConfigMetadata: userConfigMetadata ?? {},
|
|
3874
|
+
alias,
|
|
3875
|
+
experimental: {
|
|
3876
|
+
includeBrowserPolyfill: mergedConfig.experimental?.includeBrowserPolyfill ?? true
|
|
3877
|
+
}
|
|
3847
3878
|
};
|
|
3848
3879
|
finalConfig.vite = (env2) => resolveInternalViteConfig(env2, mergedConfig, finalConfig);
|
|
3849
3880
|
return finalConfig;
|
|
@@ -3900,6 +3931,14 @@ function mergeInlineConfig(inlineConfig, userConfig) {
|
|
|
3900
3931
|
analysis: {
|
|
3901
3932
|
enabled: inlineConfig.analysis?.enabled ?? userConfig.analysis?.enabled,
|
|
3902
3933
|
template: inlineConfig.analysis?.template ?? userConfig.analysis?.template
|
|
3934
|
+
},
|
|
3935
|
+
alias: {
|
|
3936
|
+
...userConfig.alias,
|
|
3937
|
+
...inlineConfig.alias
|
|
3938
|
+
},
|
|
3939
|
+
experimental: {
|
|
3940
|
+
...userConfig.experimental,
|
|
3941
|
+
...inlineConfig.experimental
|
|
3903
3942
|
}
|
|
3904
3943
|
};
|
|
3905
3944
|
}
|
|
@@ -3952,6 +3991,7 @@ async function resolveInternalViteConfig(env, mergedConfig, finalConfig) {
|
|
|
3952
3991
|
internalVite.plugins.push(bundleAnalysis());
|
|
3953
3992
|
}
|
|
3954
3993
|
internalVite.plugins.push(globals(finalConfig));
|
|
3994
|
+
internalVite.plugins.push(excludeBrowserPolyfill(finalConfig));
|
|
3955
3995
|
return internalVite;
|
|
3956
3996
|
}
|
|
3957
3997
|
|
|
@@ -4184,7 +4224,7 @@ function getChunkSortWeight(filename) {
|
|
|
4184
4224
|
var import_picocolors3 = __toESM(require("picocolors"), 1);
|
|
4185
4225
|
|
|
4186
4226
|
// package.json
|
|
4187
|
-
var version = "0.9.
|
|
4227
|
+
var version = "0.9.2";
|
|
4188
4228
|
|
|
4189
4229
|
// src/core/utils/log/printHeader.ts
|
|
4190
4230
|
var import_consola2 = require("consola");
|
|
@@ -4393,7 +4433,12 @@ function addEntrypoints(manifest, entrypoints, buildOutput, config) {
|
|
|
4393
4433
|
const sidepanels = entriesByType["sidepanel"];
|
|
4394
4434
|
if (background) {
|
|
4395
4435
|
const script = getEntrypointBundlePath(background, config.outDir, ".js");
|
|
4396
|
-
if (
|
|
4436
|
+
if (config.browser === "firefox" && config.manifestVersion === 3) {
|
|
4437
|
+
manifest.background = {
|
|
4438
|
+
type: background.options.type,
|
|
4439
|
+
scripts: [script]
|
|
4440
|
+
};
|
|
4441
|
+
} else if (config.manifestVersion === 3) {
|
|
4397
4442
|
manifest.background = {
|
|
4398
4443
|
type: background.options.type,
|
|
4399
4444
|
service_worker: script
|
|
@@ -4855,6 +4900,11 @@ function createWebExtRunner() {
|
|
|
4855
4900
|
return {
|
|
4856
4901
|
async openBrowser(config) {
|
|
4857
4902
|
config.logger.info("Opening browser...");
|
|
4903
|
+
if (config.browser === "firefox" && config.manifestVersion === 3) {
|
|
4904
|
+
throw Error(
|
|
4905
|
+
"Dev mode does not support Firefox MV3. For alternatives, see https://github.com/wxt-dev/wxt/issues/230#issuecomment-1806881653"
|
|
4906
|
+
);
|
|
4907
|
+
}
|
|
4858
4908
|
const webExtLogger = await import("web-ext-run/util/logger");
|
|
4859
4909
|
webExtLogger.consoleStream.write = ({ level, msg, name }) => {
|
|
4860
4910
|
if (level >= ERROR_LOG_LEVEL)
|
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-
|
|
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-
|
|
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';
|
|
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.9.
|
|
64
|
+
var version = "0.9.2";
|
|
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-
|
|
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-
|
|
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';
|
|
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.9.
|
|
64
|
+
var version = "0.9.2";
|
|
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-
|
|
18
|
+
} from "./chunk-OKMB7FJI.js";
|
|
19
19
|
import "./chunk-YUG22S6W.js";
|
|
20
20
|
|
|
21
21
|
// src/core/build.ts
|
|
@@ -95,6 +95,11 @@ function createWebExtRunner() {
|
|
|
95
95
|
return {
|
|
96
96
|
async openBrowser(config) {
|
|
97
97
|
config.logger.info("Opening browser...");
|
|
98
|
+
if (config.browser === "firefox" && config.manifestVersion === 3) {
|
|
99
|
+
throw Error(
|
|
100
|
+
"Dev mode does not support Firefox MV3. For alternatives, see https://github.com/wxt-dev/wxt/issues/230#issuecomment-1806881653"
|
|
101
|
+
);
|
|
102
|
+
}
|
|
98
103
|
const webExtLogger = await import("web-ext-run/util/logger");
|
|
99
104
|
webExtLogger.consoleStream.write = ({ level, msg, name }) => {
|
|
100
105
|
if (level >= ERROR_LOG_LEVEL)
|
package/dist/testing.cjs
CHANGED
|
@@ -362,12 +362,7 @@ function tsconfigPaths(config) {
|
|
|
362
362
|
async config() {
|
|
363
363
|
return {
|
|
364
364
|
resolve: {
|
|
365
|
-
alias:
|
|
366
|
-
"@@": config.root,
|
|
367
|
-
"~~": config.root,
|
|
368
|
-
"@": config.srcDir,
|
|
369
|
-
"~": config.srcDir
|
|
370
|
-
}
|
|
365
|
+
alias: config.alias
|
|
371
366
|
}
|
|
372
367
|
};
|
|
373
368
|
}
|
|
@@ -509,6 +504,30 @@ function webextensionPolyfillInlineDeps() {
|
|
|
509
504
|
};
|
|
510
505
|
}
|
|
511
506
|
|
|
507
|
+
// src/core/vite-plugins/excludeBrowserPolyfill.ts
|
|
508
|
+
function excludeBrowserPolyfill(config) {
|
|
509
|
+
const virtualId = "virtual:wxt-webextension-polyfill-disabled";
|
|
510
|
+
return {
|
|
511
|
+
name: "wxt:exclude-browser-polyfill",
|
|
512
|
+
config() {
|
|
513
|
+
if (config.experimental.includeBrowserPolyfill)
|
|
514
|
+
return;
|
|
515
|
+
return {
|
|
516
|
+
resolve: {
|
|
517
|
+
alias: {
|
|
518
|
+
"webextension-polyfill": virtualId
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
};
|
|
522
|
+
},
|
|
523
|
+
load(id) {
|
|
524
|
+
if (id === virtualId) {
|
|
525
|
+
return "export default chrome";
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
};
|
|
529
|
+
}
|
|
530
|
+
|
|
512
531
|
// src/core/utils/building/build-entrypoints.ts
|
|
513
532
|
var vite2 = __toESM(require("vite"), 1);
|
|
514
533
|
|
|
@@ -651,6 +670,15 @@ async function getInternalConfig(inlineConfig, command) {
|
|
|
651
670
|
overrides: inlineConfig.runner,
|
|
652
671
|
defaults: userConfig.runner
|
|
653
672
|
});
|
|
673
|
+
const alias = Object.fromEntries(
|
|
674
|
+
Object.entries({
|
|
675
|
+
...mergedConfig.alias,
|
|
676
|
+
"@": srcDir,
|
|
677
|
+
"~": srcDir,
|
|
678
|
+
"@@": root,
|
|
679
|
+
"~~": root
|
|
680
|
+
}).map(([key, value]) => [key, import_node_path7.default.resolve(root, value)])
|
|
681
|
+
);
|
|
654
682
|
const finalConfig = {
|
|
655
683
|
browser,
|
|
656
684
|
command,
|
|
@@ -682,7 +710,11 @@ async function getInternalConfig(inlineConfig, command) {
|
|
|
682
710
|
enabled: mergedConfig.analysis?.enabled ?? false,
|
|
683
711
|
template: mergedConfig.analysis?.template ?? "treemap"
|
|
684
712
|
},
|
|
685
|
-
userConfigMetadata: userConfigMetadata ?? {}
|
|
713
|
+
userConfigMetadata: userConfigMetadata ?? {},
|
|
714
|
+
alias,
|
|
715
|
+
experimental: {
|
|
716
|
+
includeBrowserPolyfill: mergedConfig.experimental?.includeBrowserPolyfill ?? true
|
|
717
|
+
}
|
|
686
718
|
};
|
|
687
719
|
finalConfig.vite = (env2) => resolveInternalViteConfig(env2, mergedConfig, finalConfig);
|
|
688
720
|
return finalConfig;
|
|
@@ -739,6 +771,14 @@ function mergeInlineConfig(inlineConfig, userConfig) {
|
|
|
739
771
|
analysis: {
|
|
740
772
|
enabled: inlineConfig.analysis?.enabled ?? userConfig.analysis?.enabled,
|
|
741
773
|
template: inlineConfig.analysis?.template ?? userConfig.analysis?.template
|
|
774
|
+
},
|
|
775
|
+
alias: {
|
|
776
|
+
...userConfig.alias,
|
|
777
|
+
...inlineConfig.alias
|
|
778
|
+
},
|
|
779
|
+
experimental: {
|
|
780
|
+
...userConfig.experimental,
|
|
781
|
+
...inlineConfig.experimental
|
|
742
782
|
}
|
|
743
783
|
};
|
|
744
784
|
}
|
|
@@ -791,6 +831,7 @@ async function resolveInternalViteConfig(env, mergedConfig, finalConfig) {
|
|
|
791
831
|
internalVite.plugins.push(bundleAnalysis());
|
|
792
832
|
}
|
|
793
833
|
internalVite.plugins.push(globals(finalConfig));
|
|
834
|
+
internalVite.plugins.push(excludeBrowserPolyfill(finalConfig));
|
|
794
835
|
return internalVite;
|
|
795
836
|
}
|
|
796
837
|
|
package/dist/testing.d.cts
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-
|
|
3
|
+
import { I as InlineConfig } from './external-9115d0fb.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-
|
|
3
|
+
import { I as InlineConfig } from './external-9115d0fb.js';
|
|
4
4
|
import 'webextension-polyfill';
|
|
5
5
|
import 'unimport';
|
|
6
6
|
import 'consola';
|
package/dist/testing.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wxt",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.9.
|
|
4
|
+
"version": "0.9.2",
|
|
5
5
|
"description": "Next gen framework for developing web extensions",
|
|
6
6
|
"engines": {
|
|
7
7
|
"node": ">=18",
|
|
@@ -59,6 +59,7 @@
|
|
|
59
59
|
}
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
|
+
"@types/webextension-polyfill": "^0.10.5",
|
|
62
63
|
"@webext-core/fake-browser": "^1.2.2",
|
|
63
64
|
"@webext-core/isolated-element": "^1.0.4",
|
|
64
65
|
"@webext-core/match-patterns": "^1.0.2",
|
|
@@ -83,8 +84,9 @@
|
|
|
83
84
|
"prompts": "^2.4.2",
|
|
84
85
|
"rollup-plugin-visualizer": "^5.9.2",
|
|
85
86
|
"unimport": "^3.4.0",
|
|
86
|
-
"vite": "^4.5.0",
|
|
87
|
+
"vite": "^4.0.0 || ^5.0.0-0",
|
|
87
88
|
"web-ext-run": "^0.1.0",
|
|
89
|
+
"webextension-polyfill": "^0.10.0",
|
|
88
90
|
"zip-dir": "^2.0.0"
|
|
89
91
|
},
|
|
90
92
|
"devDependencies": {
|
|
@@ -93,7 +95,6 @@
|
|
|
93
95
|
"@types/lodash.merge": "^4.6.8",
|
|
94
96
|
"@types/node": "^20.8.10",
|
|
95
97
|
"@types/prompts": "^2.4.7",
|
|
96
|
-
"@types/webextension-polyfill": "^0.10.5",
|
|
97
98
|
"@vitest/coverage-v8": "^0.34.6",
|
|
98
99
|
"execa": "^8.0.1",
|
|
99
100
|
"happy-dom": "^12.4.0",
|
|
@@ -112,11 +113,7 @@
|
|
|
112
113
|
"vitepress": "1.0.0-rc.24",
|
|
113
114
|
"vitest": "^0.34.6",
|
|
114
115
|
"vitest-mock-extended": "^1.3.1",
|
|
115
|
-
"vue": "^3.3.7"
|
|
116
|
-
"webextension-polyfill": "^0.10.0"
|
|
117
|
-
},
|
|
118
|
-
"peerDependencies": {
|
|
119
|
-
"webextension-polyfill": "^0.10.0"
|
|
116
|
+
"vue": "^3.3.7"
|
|
120
117
|
},
|
|
121
118
|
"packageManager": "pnpm@8.6.3",
|
|
122
119
|
"simple-git-hooks": {
|