wxt 0.16.6 → 0.16.8-alpha1
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-7UFBHZ5F.js → chunk-7WFBUGKG.js} +94 -64
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +109 -65
- package/dist/{index-avHSnR0o.d.cts → index-sl22zA2Z.d.cts} +41 -3
- package/dist/{index-avHSnR0o.d.ts → index-sl22zA2Z.d.ts} +41 -3
- package/dist/index.cjs +128 -84
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +15 -1
- package/dist/testing.cjs +75 -59
- package/dist/testing.d.cts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +1 -1
- package/package.json +3 -3
|
@@ -172,7 +172,7 @@ interface InlineConfig {
|
|
|
172
172
|
* })
|
|
173
173
|
* ```
|
|
174
174
|
*/
|
|
175
|
-
imports?:
|
|
175
|
+
imports?: WxtUnimportOptions | false;
|
|
176
176
|
/**
|
|
177
177
|
* Explicitly set a browser to build for. This will override the default browser for each command,
|
|
178
178
|
* and can be overridden by the command line `--browser` option.
|
|
@@ -899,7 +899,7 @@ interface ResolvedConfig {
|
|
|
899
899
|
manifestVersion: TargetManifestVersion;
|
|
900
900
|
env: ConfigEnv;
|
|
901
901
|
logger: Logger;
|
|
902
|
-
imports: false |
|
|
902
|
+
imports: false | WxtResolvedUnimportOptions;
|
|
903
903
|
manifest: UserManifest;
|
|
904
904
|
fsCache: FsCache;
|
|
905
905
|
server?: WxtDevServer;
|
|
@@ -947,5 +947,43 @@ interface ExtensionRunner {
|
|
|
947
947
|
closeBrowser(): Promise<void>;
|
|
948
948
|
}
|
|
949
949
|
type VirtualEntrypointType = 'content-script-main-world' | 'content-script-isolated-world' | 'background' | 'unlisted-script';
|
|
950
|
+
type EslintGlobalsPropValue = boolean | 'readonly' | 'readable' | 'writable' | 'writeable';
|
|
951
|
+
interface Eslintrc {
|
|
952
|
+
/**
|
|
953
|
+
* When true, generates a file that can be used by ESLint to know which variables are valid globals.
|
|
954
|
+
*
|
|
955
|
+
* - `'auto'`: Check if eslint is installed, and if it is, generate the helper file
|
|
956
|
+
* - `true`: Generate the helper file
|
|
957
|
+
* - `false`: Don't generate the file
|
|
958
|
+
*
|
|
959
|
+
* @default 'auto'
|
|
960
|
+
*/
|
|
961
|
+
enabled?: boolean | 'auto';
|
|
962
|
+
/**
|
|
963
|
+
* File path to save the generated eslint config.
|
|
964
|
+
*
|
|
965
|
+
* @default './.wxt/eslintrc-auto-import.json'
|
|
966
|
+
*/
|
|
967
|
+
filePath?: string;
|
|
968
|
+
/**
|
|
969
|
+
* @default true
|
|
970
|
+
*/
|
|
971
|
+
globalsPropValue?: EslintGlobalsPropValue;
|
|
972
|
+
}
|
|
973
|
+
interface ResolvedEslintrc {
|
|
974
|
+
enabled: boolean;
|
|
975
|
+
/** Absolute path */
|
|
976
|
+
filePath: string;
|
|
977
|
+
globalsPropValue: EslintGlobalsPropValue;
|
|
978
|
+
}
|
|
979
|
+
type WxtUnimportOptions = Partial<UnimportOptions> & {
|
|
980
|
+
/**
|
|
981
|
+
* When eslint is installed,
|
|
982
|
+
*/
|
|
983
|
+
eslintrc?: Eslintrc;
|
|
984
|
+
};
|
|
985
|
+
type WxtResolvedUnimportOptions = Partial<UnimportOptions> & {
|
|
986
|
+
eslintrc: ResolvedEslintrc;
|
|
987
|
+
};
|
|
950
988
|
|
|
951
|
-
export type { Wxt as A, BuildOutput as B, ContentScriptEntrypoint as C, ExtensionRunner as D, ExtensionRunnerConfig as E, FsCache as F, GenericEntrypoint as G, HookResult as H, InlineConfig as I, Logger as L, OutputFile as O, PopupEntrypoint as P, ResolvedConfig as R, ServerInfo as S, TargetBrowser as T, UserConfig as U, VirtualEntrypointType as V, WxtDevServer as W, WxtViteConfig as a, OutputChunk as b, OutputAsset as c, BuildStepOutput as d, TargetManifestVersion as e, BaseEntrypointOptions as f, BaseEntrypoint as g, BackgroundEntrypoint as h, OptionsEntrypoint as i, Entrypoint as j, EntrypointGroup as k, OnContentScriptStopped as l, ContentScriptDefinition as m, ContentScriptIsolatedWorldDefinition as n, ContentScriptMainWorldDefinition as o, ContentScriptBaseDefinition as p, BackgroundDefinition as q, UnlistedScriptDefinition as r, PerBrowserOption as s, ExcludableEntrypoint as t, UserManifest as u, UserManifestFn as v, ConfigEnv as w, WxtBuilder as x, WxtBuilderServer as y, WxtHooks as z };
|
|
989
|
+
export type { Wxt as A, BuildOutput as B, ContentScriptEntrypoint as C, ExtensionRunner as D, ExtensionRunnerConfig as E, FsCache as F, GenericEntrypoint as G, HookResult as H, InlineConfig as I, EslintGlobalsPropValue as J, Eslintrc as K, Logger as L, ResolvedEslintrc as M, WxtUnimportOptions as N, OutputFile as O, PopupEntrypoint as P, WxtResolvedUnimportOptions as Q, ResolvedConfig as R, ServerInfo as S, TargetBrowser as T, UserConfig as U, VirtualEntrypointType as V, WxtDevServer as W, WxtViteConfig as a, OutputChunk as b, OutputAsset as c, BuildStepOutput as d, TargetManifestVersion as e, BaseEntrypointOptions as f, BaseEntrypoint as g, BackgroundEntrypoint as h, OptionsEntrypoint as i, Entrypoint as j, EntrypointGroup as k, OnContentScriptStopped as l, ContentScriptDefinition as m, ContentScriptIsolatedWorldDefinition as n, ContentScriptMainWorldDefinition as o, ContentScriptBaseDefinition as p, BackgroundDefinition as q, UnlistedScriptDefinition as r, PerBrowserOption as s, ExcludableEntrypoint as t, UserManifest as u, UserManifestFn as v, ConfigEnv as w, WxtBuilder as x, WxtBuilderServer as y, WxtHooks as z };
|
|
@@ -172,7 +172,7 @@ interface InlineConfig {
|
|
|
172
172
|
* })
|
|
173
173
|
* ```
|
|
174
174
|
*/
|
|
175
|
-
imports?:
|
|
175
|
+
imports?: WxtUnimportOptions | false;
|
|
176
176
|
/**
|
|
177
177
|
* Explicitly set a browser to build for. This will override the default browser for each command,
|
|
178
178
|
* and can be overridden by the command line `--browser` option.
|
|
@@ -899,7 +899,7 @@ interface ResolvedConfig {
|
|
|
899
899
|
manifestVersion: TargetManifestVersion;
|
|
900
900
|
env: ConfigEnv;
|
|
901
901
|
logger: Logger;
|
|
902
|
-
imports: false |
|
|
902
|
+
imports: false | WxtResolvedUnimportOptions;
|
|
903
903
|
manifest: UserManifest;
|
|
904
904
|
fsCache: FsCache;
|
|
905
905
|
server?: WxtDevServer;
|
|
@@ -947,5 +947,43 @@ interface ExtensionRunner {
|
|
|
947
947
|
closeBrowser(): Promise<void>;
|
|
948
948
|
}
|
|
949
949
|
type VirtualEntrypointType = 'content-script-main-world' | 'content-script-isolated-world' | 'background' | 'unlisted-script';
|
|
950
|
+
type EslintGlobalsPropValue = boolean | 'readonly' | 'readable' | 'writable' | 'writeable';
|
|
951
|
+
interface Eslintrc {
|
|
952
|
+
/**
|
|
953
|
+
* When true, generates a file that can be used by ESLint to know which variables are valid globals.
|
|
954
|
+
*
|
|
955
|
+
* - `'auto'`: Check if eslint is installed, and if it is, generate the helper file
|
|
956
|
+
* - `true`: Generate the helper file
|
|
957
|
+
* - `false`: Don't generate the file
|
|
958
|
+
*
|
|
959
|
+
* @default 'auto'
|
|
960
|
+
*/
|
|
961
|
+
enabled?: boolean | 'auto';
|
|
962
|
+
/**
|
|
963
|
+
* File path to save the generated eslint config.
|
|
964
|
+
*
|
|
965
|
+
* @default './.wxt/eslintrc-auto-import.json'
|
|
966
|
+
*/
|
|
967
|
+
filePath?: string;
|
|
968
|
+
/**
|
|
969
|
+
* @default true
|
|
970
|
+
*/
|
|
971
|
+
globalsPropValue?: EslintGlobalsPropValue;
|
|
972
|
+
}
|
|
973
|
+
interface ResolvedEslintrc {
|
|
974
|
+
enabled: boolean;
|
|
975
|
+
/** Absolute path */
|
|
976
|
+
filePath: string;
|
|
977
|
+
globalsPropValue: EslintGlobalsPropValue;
|
|
978
|
+
}
|
|
979
|
+
type WxtUnimportOptions = Partial<UnimportOptions> & {
|
|
980
|
+
/**
|
|
981
|
+
* When eslint is installed,
|
|
982
|
+
*/
|
|
983
|
+
eslintrc?: Eslintrc;
|
|
984
|
+
};
|
|
985
|
+
type WxtResolvedUnimportOptions = Partial<UnimportOptions> & {
|
|
986
|
+
eslintrc: ResolvedEslintrc;
|
|
987
|
+
};
|
|
950
988
|
|
|
951
|
-
export type { Wxt as A, BuildOutput as B, ContentScriptEntrypoint as C, ExtensionRunner as D, ExtensionRunnerConfig as E, FsCache as F, GenericEntrypoint as G, HookResult as H, InlineConfig as I, Logger as L, OutputFile as O, PopupEntrypoint as P, ResolvedConfig as R, ServerInfo as S, TargetBrowser as T, UserConfig as U, VirtualEntrypointType as V, WxtDevServer as W, WxtViteConfig as a, OutputChunk as b, OutputAsset as c, BuildStepOutput as d, TargetManifestVersion as e, BaseEntrypointOptions as f, BaseEntrypoint as g, BackgroundEntrypoint as h, OptionsEntrypoint as i, Entrypoint as j, EntrypointGroup as k, OnContentScriptStopped as l, ContentScriptDefinition as m, ContentScriptIsolatedWorldDefinition as n, ContentScriptMainWorldDefinition as o, ContentScriptBaseDefinition as p, BackgroundDefinition as q, UnlistedScriptDefinition as r, PerBrowserOption as s, ExcludableEntrypoint as t, UserManifest as u, UserManifestFn as v, ConfigEnv as w, WxtBuilder as x, WxtBuilderServer as y, WxtHooks as z };
|
|
989
|
+
export type { Wxt as A, BuildOutput as B, ContentScriptEntrypoint as C, ExtensionRunner as D, ExtensionRunnerConfig as E, FsCache as F, GenericEntrypoint as G, HookResult as H, InlineConfig as I, EslintGlobalsPropValue as J, Eslintrc as K, Logger as L, ResolvedEslintrc as M, WxtUnimportOptions as N, OutputFile as O, PopupEntrypoint as P, WxtResolvedUnimportOptions as Q, ResolvedConfig as R, ServerInfo as S, TargetBrowser as T, UserConfig as U, VirtualEntrypointType as V, WxtDevServer as W, WxtViteConfig as a, OutputChunk as b, OutputAsset as c, BuildStepOutput as d, TargetManifestVersion as e, BaseEntrypointOptions as f, BaseEntrypoint as g, BackgroundEntrypoint as h, OptionsEntrypoint as i, Entrypoint as j, EntrypointGroup as k, OnContentScriptStopped as l, ContentScriptDefinition as m, ContentScriptIsolatedWorldDefinition as n, ContentScriptMainWorldDefinition as o, ContentScriptBaseDefinition as p, BackgroundDefinition as q, UnlistedScriptDefinition as r, PerBrowserOption as s, ExcludableEntrypoint as t, UserManifest as u, UserManifestFn as v, ConfigEnv as w, WxtBuilder as x, WxtBuilderServer as y, WxtHooks as z };
|
package/dist/index.cjs
CHANGED
|
@@ -3019,29 +3019,6 @@ var import_unimport = require("unimport");
|
|
|
3019
3019
|
var import_fs_extra4 = __toESM(require("fs-extra"), 1);
|
|
3020
3020
|
var import_path3 = require("path");
|
|
3021
3021
|
|
|
3022
|
-
// src/core/utils/unimport.ts
|
|
3023
|
-
var import_defu = require("defu");
|
|
3024
|
-
function getUnimportOptions(config) {
|
|
3025
|
-
if (config.imports === false)
|
|
3026
|
-
return false;
|
|
3027
|
-
const defaultOptions = {
|
|
3028
|
-
debugLog: config.logger.debug,
|
|
3029
|
-
imports: [
|
|
3030
|
-
{ name: "defineConfig", from: "wxt" },
|
|
3031
|
-
{ name: "fakeBrowser", from: "wxt/testing" }
|
|
3032
|
-
],
|
|
3033
|
-
presets: [
|
|
3034
|
-
{ package: "wxt/client" },
|
|
3035
|
-
{ package: "wxt/browser" },
|
|
3036
|
-
{ package: "wxt/sandbox" },
|
|
3037
|
-
{ package: "wxt/storage" }
|
|
3038
|
-
],
|
|
3039
|
-
warn: config.logger.warn,
|
|
3040
|
-
dirs: ["components", "composables", "hooks", "utils"]
|
|
3041
|
-
};
|
|
3042
|
-
return (0, import_defu.defu)(config.imports, defaultOptions);
|
|
3043
|
-
}
|
|
3044
|
-
|
|
3045
3022
|
// src/core/utils/globals.ts
|
|
3046
3023
|
function getGlobals(config) {
|
|
3047
3024
|
return [
|
|
@@ -3141,9 +3118,12 @@ function parseI18nMessages(messagesJson) {
|
|
|
3141
3118
|
async function generateTypesDir(entrypoints) {
|
|
3142
3119
|
await import_fs_extra4.default.ensureDir(wxt.config.typesDir);
|
|
3143
3120
|
const references = [];
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
references.push(await writeImportsDeclarationFile(
|
|
3121
|
+
if (wxt.config.imports !== false) {
|
|
3122
|
+
const unimport2 = (0, import_unimport.createUnimport)(wxt.config.imports);
|
|
3123
|
+
references.push(await writeImportsDeclarationFile(unimport2));
|
|
3124
|
+
if (wxt.config.imports.eslintrc.enabled) {
|
|
3125
|
+
await writeImportsEslintFile(unimport2, wxt.config.imports);
|
|
3126
|
+
}
|
|
3147
3127
|
}
|
|
3148
3128
|
references.push(await writePathsDeclarationFile(entrypoints));
|
|
3149
3129
|
references.push(await writeI18nDeclarationFile());
|
|
@@ -3151,9 +3131,8 @@ async function generateTypesDir(entrypoints) {
|
|
|
3151
3131
|
const mainReference = await writeMainDeclarationFile(references);
|
|
3152
3132
|
await writeTsConfigFile(mainReference);
|
|
3153
3133
|
}
|
|
3154
|
-
async function writeImportsDeclarationFile(
|
|
3134
|
+
async function writeImportsDeclarationFile(unimport2) {
|
|
3155
3135
|
const filePath = (0, import_path3.resolve)(wxt.config.typesDir, "imports.d.ts");
|
|
3156
|
-
const unimport2 = (0, import_unimport.createUnimport)(unimportOptions);
|
|
3157
3136
|
await unimport2.scanImportsFromDir(void 0, { cwd: wxt.config.srcDir });
|
|
3158
3137
|
await writeFileIfDifferent(
|
|
3159
3138
|
filePath,
|
|
@@ -3163,6 +3142,14 @@ async function writeImportsDeclarationFile(unimportOptions) {
|
|
|
3163
3142
|
);
|
|
3164
3143
|
return filePath;
|
|
3165
3144
|
}
|
|
3145
|
+
async function writeImportsEslintFile(unimport2, options) {
|
|
3146
|
+
const globals2 = {};
|
|
3147
|
+
const eslintrc = { globals: globals2 };
|
|
3148
|
+
(await unimport2.getImports()).map((i) => i.as ?? i.name).filter(Boolean).sort().forEach((name) => {
|
|
3149
|
+
eslintrc.globals[name] = options.eslintrc.globalsPropValue;
|
|
3150
|
+
});
|
|
3151
|
+
await import_fs_extra4.default.writeJson(options.eslintrc.filePath, eslintrc, { spaces: 2 });
|
|
3152
|
+
}
|
|
3166
3153
|
async function writePathsDeclarationFile(entrypoints) {
|
|
3167
3154
|
const filePath = (0, import_path3.resolve)(wxt.config.typesDir, "paths.d.ts");
|
|
3168
3155
|
const unions = entrypoints.map(
|
|
@@ -3315,7 +3302,7 @@ ${paths}
|
|
|
3315
3302
|
|
|
3316
3303
|
// src/core/utils/building/resolve-config.ts
|
|
3317
3304
|
var import_c12 = require("c12");
|
|
3318
|
-
var
|
|
3305
|
+
var import_node_path9 = __toESM(require("path"), 1);
|
|
3319
3306
|
|
|
3320
3307
|
// src/core/utils/cache.ts
|
|
3321
3308
|
var import_fs_extra5 = __toESM(require("fs-extra"), 1);
|
|
@@ -3641,7 +3628,7 @@ async function removeEmptyDirs(dir) {
|
|
|
3641
3628
|
}
|
|
3642
3629
|
|
|
3643
3630
|
// src/core/builders/vite/plugins/unimport.ts
|
|
3644
|
-
var
|
|
3631
|
+
var import_unimport2 = require("unimport");
|
|
3645
3632
|
var import_path5 = require("path");
|
|
3646
3633
|
var ENABLED_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
3647
3634
|
".js",
|
|
@@ -3652,10 +3639,10 @@ var ENABLED_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
|
3652
3639
|
".svelte"
|
|
3653
3640
|
]);
|
|
3654
3641
|
function unimport(config) {
|
|
3655
|
-
const options =
|
|
3642
|
+
const options = config.imports;
|
|
3656
3643
|
if (options === false)
|
|
3657
3644
|
return [];
|
|
3658
|
-
const unimport2 = (0,
|
|
3645
|
+
const unimport2 = (0, import_unimport2.createUnimport)(options);
|
|
3659
3646
|
return {
|
|
3660
3647
|
name: "wxt:unimport",
|
|
3661
3648
|
async config() {
|
|
@@ -4068,7 +4055,27 @@ function getRollupEntry(entrypoint) {
|
|
|
4068
4055
|
}
|
|
4069
4056
|
|
|
4070
4057
|
// src/core/utils/building/resolve-config.ts
|
|
4071
|
-
var
|
|
4058
|
+
var import_defu = __toESM(require("defu"), 1);
|
|
4059
|
+
|
|
4060
|
+
// src/core/utils/package.ts
|
|
4061
|
+
var import_node_path8 = require("path");
|
|
4062
|
+
var import_fs_extra8 = __toESM(require("fs-extra"), 1);
|
|
4063
|
+
async function getPackageJson() {
|
|
4064
|
+
const file = (0, import_node_path8.resolve)(wxt.config.root, "package.json");
|
|
4065
|
+
try {
|
|
4066
|
+
return await import_fs_extra8.default.readJson(file);
|
|
4067
|
+
} catch (err) {
|
|
4068
|
+
wxt.logger.debug(
|
|
4069
|
+
`Failed to read package.json at: ${file}. Returning undefined.`
|
|
4070
|
+
);
|
|
4071
|
+
return {};
|
|
4072
|
+
}
|
|
4073
|
+
}
|
|
4074
|
+
function isModuleInstalled(name) {
|
|
4075
|
+
return import(name).then(() => true).catch(() => false);
|
|
4076
|
+
}
|
|
4077
|
+
|
|
4078
|
+
// src/core/utils/building/resolve-config.ts
|
|
4072
4079
|
async function resolveConfig(inlineConfig, command, server) {
|
|
4073
4080
|
let userConfig = {};
|
|
4074
4081
|
let userConfigMetadata;
|
|
@@ -4093,20 +4100,20 @@ async function resolveConfig(inlineConfig, command, server) {
|
|
|
4093
4100
|
const manifestVersion = mergedConfig.manifestVersion ?? (browser === "firefox" || browser === "safari" ? 2 : 3);
|
|
4094
4101
|
const mode = mergedConfig.mode ?? (command === "build" ? "production" : "development");
|
|
4095
4102
|
const env = { browser, command, manifestVersion, mode };
|
|
4096
|
-
const root =
|
|
4103
|
+
const root = import_node_path9.default.resolve(
|
|
4097
4104
|
inlineConfig.root ?? userConfig.root ?? process.cwd()
|
|
4098
4105
|
);
|
|
4099
|
-
const wxtDir =
|
|
4100
|
-
const srcDir =
|
|
4101
|
-
const entrypointsDir =
|
|
4106
|
+
const wxtDir = import_node_path9.default.resolve(root, ".wxt");
|
|
4107
|
+
const srcDir = import_node_path9.default.resolve(root, mergedConfig.srcDir ?? root);
|
|
4108
|
+
const entrypointsDir = import_node_path9.default.resolve(
|
|
4102
4109
|
srcDir,
|
|
4103
4110
|
mergedConfig.entrypointsDir ?? "entrypoints"
|
|
4104
4111
|
);
|
|
4105
4112
|
const filterEntrypoints = !!mergedConfig.filterEntrypoints?.length ? new Set(mergedConfig.filterEntrypoints) : void 0;
|
|
4106
|
-
const publicDir =
|
|
4107
|
-
const typesDir =
|
|
4108
|
-
const outBaseDir =
|
|
4109
|
-
const outDir =
|
|
4113
|
+
const publicDir = import_node_path9.default.resolve(srcDir, mergedConfig.publicDir ?? "public");
|
|
4114
|
+
const typesDir = import_node_path9.default.resolve(wxtDir, "types");
|
|
4115
|
+
const outBaseDir = import_node_path9.default.resolve(root, mergedConfig.outDir ?? ".output");
|
|
4116
|
+
const outDir = import_node_path9.default.resolve(outBaseDir, `${browser}-mv${manifestVersion}`);
|
|
4110
4117
|
const reloadCommand = mergedConfig.dev?.reloadCommand ?? "Alt+R";
|
|
4111
4118
|
const runnerConfig = await (0, import_c12.loadConfig)({
|
|
4112
4119
|
name: "web-ext",
|
|
@@ -4123,14 +4130,14 @@ async function resolveConfig(inlineConfig, command, server) {
|
|
|
4123
4130
|
"~": srcDir,
|
|
4124
4131
|
"@@": root,
|
|
4125
4132
|
"~~": root
|
|
4126
|
-
}).map(([key, value]) => [key,
|
|
4133
|
+
}).map(([key, value]) => [key, import_node_path9.default.resolve(root, value)])
|
|
4127
4134
|
);
|
|
4128
|
-
const analysisOutputFile =
|
|
4135
|
+
const analysisOutputFile = import_node_path9.default.resolve(
|
|
4129
4136
|
root,
|
|
4130
4137
|
mergedConfig.analysis?.outputFile ?? "stats.html"
|
|
4131
4138
|
);
|
|
4132
|
-
const analysisOutputDir =
|
|
4133
|
-
const analysisOutputName =
|
|
4139
|
+
const analysisOutputDir = import_node_path9.default.dirname(analysisOutputFile);
|
|
4140
|
+
const analysisOutputName = import_node_path9.default.parse(analysisOutputFile).name;
|
|
4134
4141
|
const finalConfig = {
|
|
4135
4142
|
browser,
|
|
4136
4143
|
command,
|
|
@@ -4139,7 +4146,7 @@ async function resolveConfig(inlineConfig, command, server) {
|
|
|
4139
4146
|
filterEntrypoints,
|
|
4140
4147
|
env,
|
|
4141
4148
|
fsCache: createFsCache(wxtDir),
|
|
4142
|
-
imports:
|
|
4149
|
+
imports: await getUnimportOptions(wxtDir, logger, mergedConfig),
|
|
4143
4150
|
logger,
|
|
4144
4151
|
manifest: await resolveManifestConfig(env, mergedConfig.manifest),
|
|
4145
4152
|
manifestVersion,
|
|
@@ -4196,22 +4203,22 @@ function mergeInlineConfig(inlineConfig, userConfig) {
|
|
|
4196
4203
|
} else if (userConfig.imports == null && inlineConfig.imports == null) {
|
|
4197
4204
|
imports = void 0;
|
|
4198
4205
|
} else {
|
|
4199
|
-
imports = (0,
|
|
4206
|
+
imports = (0, import_defu.default)(inlineConfig.imports ?? {}, userConfig.imports ?? {});
|
|
4200
4207
|
}
|
|
4201
4208
|
const manifest = async (env) => {
|
|
4202
4209
|
const user = await resolveManifestConfig(env, userConfig.manifest);
|
|
4203
4210
|
const inline = await resolveManifestConfig(env, inlineConfig.manifest);
|
|
4204
|
-
return (0,
|
|
4211
|
+
return (0, import_defu.default)(inline, user);
|
|
4205
4212
|
};
|
|
4206
|
-
const runner = (0,
|
|
4213
|
+
const runner = (0, import_defu.default)(
|
|
4207
4214
|
inlineConfig.runner ?? {},
|
|
4208
4215
|
userConfig.runner ?? {}
|
|
4209
4216
|
);
|
|
4210
|
-
const zip2 = (0,
|
|
4217
|
+
const zip2 = (0, import_defu.default)(
|
|
4211
4218
|
inlineConfig.zip ?? {},
|
|
4212
4219
|
userConfig.zip ?? {}
|
|
4213
4220
|
);
|
|
4214
|
-
const hooks = (0,
|
|
4221
|
+
const hooks = (0, import_defu.default)(
|
|
4215
4222
|
inlineConfig.hooks ?? {},
|
|
4216
4223
|
userConfig.hooks ?? {}
|
|
4217
4224
|
);
|
|
@@ -4275,6 +4282,44 @@ function resolveInternalZipConfig(root, mergedConfig) {
|
|
|
4275
4282
|
]
|
|
4276
4283
|
};
|
|
4277
4284
|
}
|
|
4285
|
+
async function getUnimportOptions(wxtDir, logger, config) {
|
|
4286
|
+
if (config.imports === false)
|
|
4287
|
+
return false;
|
|
4288
|
+
const enabledConfig = config.imports?.eslintrc?.enabled;
|
|
4289
|
+
let enabled;
|
|
4290
|
+
switch (enabledConfig) {
|
|
4291
|
+
case void 0:
|
|
4292
|
+
case "auto":
|
|
4293
|
+
enabled = await isModuleInstalled("eslint");
|
|
4294
|
+
break;
|
|
4295
|
+
default:
|
|
4296
|
+
enabled = enabledConfig;
|
|
4297
|
+
}
|
|
4298
|
+
const defaultOptions = {
|
|
4299
|
+
debugLog: logger.debug,
|
|
4300
|
+
imports: [
|
|
4301
|
+
{ name: "defineConfig", from: "wxt" },
|
|
4302
|
+
{ name: "fakeBrowser", from: "wxt/testing" }
|
|
4303
|
+
],
|
|
4304
|
+
presets: [
|
|
4305
|
+
{ package: "wxt/client" },
|
|
4306
|
+
{ package: "wxt/browser" },
|
|
4307
|
+
{ package: "wxt/sandbox" },
|
|
4308
|
+
{ package: "wxt/storage" }
|
|
4309
|
+
],
|
|
4310
|
+
warn: logger.warn,
|
|
4311
|
+
dirs: ["components", "composables", "hooks", "utils"],
|
|
4312
|
+
eslintrc: {
|
|
4313
|
+
enabled,
|
|
4314
|
+
filePath: import_node_path9.default.resolve(wxtDir, "eslintrc-auto-import.json"),
|
|
4315
|
+
globalsPropValue: true
|
|
4316
|
+
}
|
|
4317
|
+
};
|
|
4318
|
+
return (0, import_defu.default)(
|
|
4319
|
+
config.imports ?? {},
|
|
4320
|
+
defaultOptions
|
|
4321
|
+
);
|
|
4322
|
+
}
|
|
4278
4323
|
|
|
4279
4324
|
// src/core/utils/building/group-entrypoints.ts
|
|
4280
4325
|
function groupEntrypoints(entrypoints) {
|
|
@@ -4317,9 +4362,9 @@ var ENTRY_TYPE_TO_GROUP_MAP = {
|
|
|
4317
4362
|
|
|
4318
4363
|
// src/core/utils/building/import-entrypoint.ts
|
|
4319
4364
|
var import_jiti = __toESM(require("jiti"), 1);
|
|
4320
|
-
var
|
|
4321
|
-
var
|
|
4322
|
-
var
|
|
4365
|
+
var import_unimport3 = require("unimport");
|
|
4366
|
+
var import_fs_extra9 = __toESM(require("fs-extra"), 1);
|
|
4367
|
+
var import_node_path10 = require("path");
|
|
4323
4368
|
|
|
4324
4369
|
// src/core/utils/strings.ts
|
|
4325
4370
|
function kebabCaseAlphanumeric(str) {
|
|
@@ -4345,13 +4390,13 @@ var import_meta = {};
|
|
|
4345
4390
|
async function importEntrypointFile(path11) {
|
|
4346
4391
|
wxt.logger.debug("Loading file metadata:", path11);
|
|
4347
4392
|
const normalPath = normalizePath(path11);
|
|
4348
|
-
const unimport2 = (0,
|
|
4349
|
-
...
|
|
4393
|
+
const unimport2 = (0, import_unimport3.createUnimport)({
|
|
4394
|
+
...wxt.config.imports,
|
|
4350
4395
|
// Only allow specific imports, not all from the project
|
|
4351
4396
|
dirs: []
|
|
4352
4397
|
});
|
|
4353
4398
|
await unimport2.init();
|
|
4354
|
-
const text = await
|
|
4399
|
+
const text = await import_fs_extra9.default.readFile(path11, "utf-8");
|
|
4355
4400
|
const textNoImports = removeProjectImportStatements(text);
|
|
4356
4401
|
const { code } = await unimport2.injectImports(textNoImports);
|
|
4357
4402
|
wxt.logger.debug(
|
|
@@ -4364,7 +4409,7 @@ async function importEntrypointFile(path11) {
|
|
|
4364
4409
|
debug: wxt.config.debug,
|
|
4365
4410
|
esmResolve: true,
|
|
4366
4411
|
alias: {
|
|
4367
|
-
"webextension-polyfill": (0,
|
|
4412
|
+
"webextension-polyfill": (0, import_node_path10.resolve)(
|
|
4368
4413
|
wxt.config.root,
|
|
4369
4414
|
"node_modules/wxt/dist/virtual/mock-browser.js"
|
|
4370
4415
|
)
|
|
@@ -4397,7 +4442,7 @@ async function importEntrypointFile(path11) {
|
|
|
4397
4442
|
const res = await jiti(path11);
|
|
4398
4443
|
return res.default;
|
|
4399
4444
|
} catch (err) {
|
|
4400
|
-
const filePath = (0,
|
|
4445
|
+
const filePath = (0, import_node_path10.relative)(wxt.config.root, path11);
|
|
4401
4446
|
if (err instanceof ReferenceError) {
|
|
4402
4447
|
const variableName = err.message.replace(" is not defined", "");
|
|
4403
4448
|
throw Error(
|
|
@@ -4427,9 +4472,9 @@ var import_fs_extra12 = __toESM(require("fs-extra"), 1);
|
|
|
4427
4472
|
var import_path7 = require("path");
|
|
4428
4473
|
|
|
4429
4474
|
// src/core/utils/log/printFileList.ts
|
|
4430
|
-
var
|
|
4475
|
+
var import_node_path11 = __toESM(require("path"), 1);
|
|
4431
4476
|
var import_picocolors3 = __toESM(require("picocolors"), 1);
|
|
4432
|
-
var
|
|
4477
|
+
var import_fs_extra10 = __toESM(require("fs-extra"), 1);
|
|
4433
4478
|
var import_filesize = require("filesize");
|
|
4434
4479
|
|
|
4435
4480
|
// src/core/utils/log/printTable.ts
|
|
@@ -4465,12 +4510,12 @@ async function printFileList(log, header, baseDir, files) {
|
|
|
4465
4510
|
const fileRows = await Promise.all(
|
|
4466
4511
|
files.map(async (file, i) => {
|
|
4467
4512
|
const parts = [
|
|
4468
|
-
|
|
4469
|
-
|
|
4513
|
+
import_node_path11.default.relative(process.cwd(), baseDir) + import_node_path11.default.sep,
|
|
4514
|
+
import_node_path11.default.relative(baseDir, file)
|
|
4470
4515
|
];
|
|
4471
4516
|
const prefix = i === files.length - 1 ? " \u2514\u2500" : " \u251C\u2500";
|
|
4472
4517
|
const color = getChunkColor(file);
|
|
4473
|
-
const stats = await
|
|
4518
|
+
const stats = await import_fs_extra10.default.lstat(file);
|
|
4474
4519
|
totalSize += stats.size;
|
|
4475
4520
|
const size = String((0, import_filesize.filesize)(stats.size));
|
|
4476
4521
|
return [
|
|
@@ -4534,7 +4579,7 @@ function getChunkSortWeight(filename) {
|
|
|
4534
4579
|
var import_picocolors4 = __toESM(require("picocolors"), 1);
|
|
4535
4580
|
|
|
4536
4581
|
// package.json
|
|
4537
|
-
var version = "0.16.
|
|
4582
|
+
var version = "0.16.8-alpha1";
|
|
4538
4583
|
|
|
4539
4584
|
// src/core/utils/log/printHeader.ts
|
|
4540
4585
|
var import_consola2 = require("consola");
|
|
@@ -4647,23 +4692,8 @@ function mapWxtOptionsToContentScript(options) {
|
|
|
4647
4692
|
};
|
|
4648
4693
|
}
|
|
4649
4694
|
|
|
4650
|
-
// src/core/utils/package.ts
|
|
4651
|
-
var import_node_path11 = require("path");
|
|
4652
|
-
var import_fs_extra10 = __toESM(require("fs-extra"), 1);
|
|
4653
|
-
async function getPackageJson() {
|
|
4654
|
-
const file = (0, import_node_path11.resolve)(wxt.config.root, "package.json");
|
|
4655
|
-
try {
|
|
4656
|
-
return await import_fs_extra10.default.readJson(file);
|
|
4657
|
-
} catch (err) {
|
|
4658
|
-
wxt.logger.debug(
|
|
4659
|
-
`Failed to read package.json at: ${file}. Returning undefined.`
|
|
4660
|
-
);
|
|
4661
|
-
return {};
|
|
4662
|
-
}
|
|
4663
|
-
}
|
|
4664
|
-
|
|
4665
4695
|
// src/core/utils/manifest.ts
|
|
4666
|
-
var
|
|
4696
|
+
var import_defu2 = __toESM(require("defu"), 1);
|
|
4667
4697
|
async function writeManifest(manifest, output) {
|
|
4668
4698
|
const str = wxt.config.mode === "production" ? JSON.stringify(manifest) : JSON.stringify(manifest, null, 2);
|
|
4669
4699
|
await import_fs_extra11.default.ensureDir(wxt.config.outDir);
|
|
@@ -4693,7 +4723,7 @@ async function generateManifest(entrypoints, buildOutput) {
|
|
|
4693
4723
|
icons: discoverIcons(buildOutput)
|
|
4694
4724
|
};
|
|
4695
4725
|
const userManifest = wxt.config.manifest;
|
|
4696
|
-
let manifest = (0,
|
|
4726
|
+
let manifest = (0, import_defu2.default)(
|
|
4697
4727
|
userManifest,
|
|
4698
4728
|
baseManifest
|
|
4699
4729
|
);
|
|
@@ -5388,7 +5418,7 @@ function createWslRunner() {
|
|
|
5388
5418
|
}
|
|
5389
5419
|
|
|
5390
5420
|
// src/core/runners/web-ext.ts
|
|
5391
|
-
var
|
|
5421
|
+
var import_defu3 = __toESM(require("defu"), 1);
|
|
5392
5422
|
function createWebExtRunner() {
|
|
5393
5423
|
let runner;
|
|
5394
5424
|
return {
|
|
@@ -5419,7 +5449,7 @@ function createWebExtRunner() {
|
|
|
5419
5449
|
} : {
|
|
5420
5450
|
chromiumBinary: wxtUserConfig?.binaries?.[wxt.config.browser],
|
|
5421
5451
|
chromiumProfile: wxtUserConfig?.chromiumProfile,
|
|
5422
|
-
chromiumPref: (0,
|
|
5452
|
+
chromiumPref: (0, import_defu3.default)(
|
|
5423
5453
|
wxtUserConfig?.chromiumPref,
|
|
5424
5454
|
DEFAULT_CHROMIUM_PREFS
|
|
5425
5455
|
),
|
|
@@ -5530,6 +5560,20 @@ async function createServer(inlineConfig) {
|
|
|
5530
5560
|
};
|
|
5531
5561
|
const buildAndOpenBrowser = async () => {
|
|
5532
5562
|
server.currentOutput = await internalBuild();
|
|
5563
|
+
const additionalFiles = server.currentOutput.steps.flatMap((step, i) => {
|
|
5564
|
+
if (Array.isArray(step.entrypoints) && i === 0) {
|
|
5565
|
+
return [];
|
|
5566
|
+
}
|
|
5567
|
+
return step.chunks.flatMap((chunk) => {
|
|
5568
|
+
if (chunk.type === "asset")
|
|
5569
|
+
return [];
|
|
5570
|
+
return chunk.moduleIds;
|
|
5571
|
+
});
|
|
5572
|
+
}).filter(
|
|
5573
|
+
(file) => !file.includes("node_modules") && !file.startsWith("\0")
|
|
5574
|
+
);
|
|
5575
|
+
console.log("Adding files:", additionalFiles);
|
|
5576
|
+
server.watcher.add(additionalFiles);
|
|
5533
5577
|
await runner.openBrowser();
|
|
5534
5578
|
};
|
|
5535
5579
|
const closeAndRecreateRunner = async () => {
|
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 './index-
|
|
2
|
-
export { q as BackgroundDefinition, h as BackgroundEntrypoint, g as BaseEntrypoint, f as BaseEntrypointOptions, d as BuildStepOutput, w as ConfigEnv, p as ContentScriptBaseDefinition, m as ContentScriptDefinition, C as ContentScriptEntrypoint, n as ContentScriptIsolatedWorldDefinition, o as ContentScriptMainWorldDefinition, j as Entrypoint, k as EntrypointGroup, t as ExcludableEntrypoint, D as ExtensionRunner, F as FsCache, G as GenericEntrypoint, H as HookResult, L as Logger, l as OnContentScriptStopped, i as OptionsEntrypoint, c as OutputAsset, b as OutputChunk, O as OutputFile, s as PerBrowserOption, P as PopupEntrypoint, R as ResolvedConfig, S as ServerInfo, T as TargetBrowser, e as TargetManifestVersion, r as UnlistedScriptDefinition, u as UserManifest, v as UserManifestFn, V as VirtualEntrypointType, A as Wxt, x as WxtBuilder, y as WxtBuilderServer, z as WxtHooks, a as WxtViteConfig } from './index-
|
|
1
|
+
import { I as InlineConfig, B as BuildOutput, U as UserConfig, E as ExtensionRunnerConfig, W as WxtDevServer } from './index-sl22zA2Z.cjs';
|
|
2
|
+
export { q as BackgroundDefinition, h as BackgroundEntrypoint, g as BaseEntrypoint, f as BaseEntrypointOptions, d as BuildStepOutput, w as ConfigEnv, p as ContentScriptBaseDefinition, m as ContentScriptDefinition, C as ContentScriptEntrypoint, n as ContentScriptIsolatedWorldDefinition, o as ContentScriptMainWorldDefinition, j as Entrypoint, k as EntrypointGroup, J as EslintGlobalsPropValue, K as Eslintrc, t as ExcludableEntrypoint, D as ExtensionRunner, F as FsCache, G as GenericEntrypoint, H as HookResult, L as Logger, l as OnContentScriptStopped, i as OptionsEntrypoint, c as OutputAsset, b as OutputChunk, O as OutputFile, s as PerBrowserOption, P as PopupEntrypoint, R as ResolvedConfig, M as ResolvedEslintrc, S as ServerInfo, T as TargetBrowser, e as TargetManifestVersion, r as UnlistedScriptDefinition, u as UserManifest, v as UserManifestFn, V as VirtualEntrypointType, A as Wxt, x as WxtBuilder, y as WxtBuilderServer, z as WxtHooks, Q as WxtResolvedUnimportOptions, N as WxtUnimportOptions, a as WxtViteConfig } from './index-sl22zA2Z.cjs';
|
|
3
3
|
import 'vite';
|
|
4
4
|
import 'webextension-polyfill';
|
|
5
5
|
import 'unimport';
|
|
@@ -64,6 +64,6 @@ declare function prepare(config: InlineConfig): Promise<void>;
|
|
|
64
64
|
*/
|
|
65
65
|
declare function zip(config?: InlineConfig): Promise<string[]>;
|
|
66
66
|
|
|
67
|
-
var version = "0.16.
|
|
67
|
+
var version = "0.16.8-alpha1";
|
|
68
68
|
|
|
69
69
|
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 './index-
|
|
2
|
-
export { q as BackgroundDefinition, h as BackgroundEntrypoint, g as BaseEntrypoint, f as BaseEntrypointOptions, d as BuildStepOutput, w as ConfigEnv, p as ContentScriptBaseDefinition, m as ContentScriptDefinition, C as ContentScriptEntrypoint, n as ContentScriptIsolatedWorldDefinition, o as ContentScriptMainWorldDefinition, j as Entrypoint, k as EntrypointGroup, t as ExcludableEntrypoint, D as ExtensionRunner, F as FsCache, G as GenericEntrypoint, H as HookResult, L as Logger, l as OnContentScriptStopped, i as OptionsEntrypoint, c as OutputAsset, b as OutputChunk, O as OutputFile, s as PerBrowserOption, P as PopupEntrypoint, R as ResolvedConfig, S as ServerInfo, T as TargetBrowser, e as TargetManifestVersion, r as UnlistedScriptDefinition, u as UserManifest, v as UserManifestFn, V as VirtualEntrypointType, A as Wxt, x as WxtBuilder, y as WxtBuilderServer, z as WxtHooks, a as WxtViteConfig } from './index-
|
|
1
|
+
import { I as InlineConfig, B as BuildOutput, U as UserConfig, E as ExtensionRunnerConfig, W as WxtDevServer } from './index-sl22zA2Z.js';
|
|
2
|
+
export { q as BackgroundDefinition, h as BackgroundEntrypoint, g as BaseEntrypoint, f as BaseEntrypointOptions, d as BuildStepOutput, w as ConfigEnv, p as ContentScriptBaseDefinition, m as ContentScriptDefinition, C as ContentScriptEntrypoint, n as ContentScriptIsolatedWorldDefinition, o as ContentScriptMainWorldDefinition, j as Entrypoint, k as EntrypointGroup, J as EslintGlobalsPropValue, K as Eslintrc, t as ExcludableEntrypoint, D as ExtensionRunner, F as FsCache, G as GenericEntrypoint, H as HookResult, L as Logger, l as OnContentScriptStopped, i as OptionsEntrypoint, c as OutputAsset, b as OutputChunk, O as OutputFile, s as PerBrowserOption, P as PopupEntrypoint, R as ResolvedConfig, M as ResolvedEslintrc, S as ServerInfo, T as TargetBrowser, e as TargetManifestVersion, r as UnlistedScriptDefinition, u as UserManifest, v as UserManifestFn, V as VirtualEntrypointType, A as Wxt, x as WxtBuilder, y as WxtBuilderServer, z as WxtHooks, Q as WxtResolvedUnimportOptions, N as WxtUnimportOptions, a as WxtViteConfig } from './index-sl22zA2Z.js';
|
|
3
3
|
import 'vite';
|
|
4
4
|
import 'webextension-polyfill';
|
|
5
5
|
import 'unimport';
|
|
@@ -64,6 +64,6 @@ declare function prepare(config: InlineConfig): Promise<void>;
|
|
|
64
64
|
*/
|
|
65
65
|
declare function zip(config?: InlineConfig): Promise<string[]>;
|
|
66
66
|
|
|
67
|
-
var version = "0.16.
|
|
67
|
+
var version = "0.16.8-alpha1";
|
|
68
68
|
|
|
69
69
|
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
|
resolvePerBrowserOption,
|
|
16
16
|
version,
|
|
17
17
|
wxt
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-7WFBUGKG.js";
|
|
19
19
|
import "./chunk-VBXJIVYU.js";
|
|
20
20
|
|
|
21
21
|
// src/core/build.ts
|
|
@@ -229,6 +229,20 @@ async function createServer(inlineConfig) {
|
|
|
229
229
|
};
|
|
230
230
|
const buildAndOpenBrowser = async () => {
|
|
231
231
|
server.currentOutput = await internalBuild();
|
|
232
|
+
const additionalFiles = server.currentOutput.steps.flatMap((step, i) => {
|
|
233
|
+
if (Array.isArray(step.entrypoints) && i === 0) {
|
|
234
|
+
return [];
|
|
235
|
+
}
|
|
236
|
+
return step.chunks.flatMap((chunk) => {
|
|
237
|
+
if (chunk.type === "asset")
|
|
238
|
+
return [];
|
|
239
|
+
return chunk.moduleIds;
|
|
240
|
+
});
|
|
241
|
+
}).filter(
|
|
242
|
+
(file) => !file.includes("node_modules") && !file.startsWith("\0")
|
|
243
|
+
);
|
|
244
|
+
console.log("Adding files:", additionalFiles);
|
|
245
|
+
server.watcher.add(additionalFiles);
|
|
232
246
|
await runner.openBrowser();
|
|
233
247
|
};
|
|
234
248
|
const closeAndRecreateRunner = async () => {
|