wxt 0.17.7 → 0.17.9
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/README.md +2 -2
- package/dist/{chunk-QFL6IFHC.js → chunk-ONUEB57P.js} +52 -79
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +97 -107
- package/dist/client.d.ts +1 -1
- package/dist/{index-l43sonfW.d.cts → index-mZodC81T.d.cts} +25 -12
- package/dist/{index-l43sonfW.d.ts → index-mZodC81T.d.ts} +25 -12
- package/dist/index.cjs +92 -105
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +41 -27
- package/dist/testing.cjs +40 -77
- package/dist/testing.d.cts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +1 -1
- package/package.json +4 -1
|
@@ -235,10 +235,11 @@ interface InlineConfig {
|
|
|
235
235
|
*
|
|
236
236
|
* Available template variables:
|
|
237
237
|
*
|
|
238
|
-
* -
|
|
239
|
-
* -
|
|
240
|
-
* -
|
|
241
|
-
* -
|
|
238
|
+
* - <span v-pre>`{{name}}`</span> - The project's name converted to kebab-case
|
|
239
|
+
* - <span v-pre>`{{version}}`</span> - The version_name or version from the manifest
|
|
240
|
+
* - <span v-pre>`{{browser}}`</span> - The target browser from the `--browser` CLI flag
|
|
241
|
+
* - <span v-pre>`{{mode}}`</span> - The current mode
|
|
242
|
+
* - <span v-pre>`{{manifestVersion}}`</span> - Either "2" or "3"
|
|
242
243
|
*
|
|
243
244
|
* @default "{{name}}-{{version}}-{{browser}}.zip"
|
|
244
245
|
*/
|
|
@@ -248,10 +249,11 @@ interface InlineConfig {
|
|
|
248
249
|
*
|
|
249
250
|
* Available template variables:
|
|
250
251
|
*
|
|
251
|
-
* -
|
|
252
|
-
* -
|
|
253
|
-
* -
|
|
254
|
-
* -
|
|
252
|
+
* - <span v-pre>`{{name}}`</span> - The project's name converted to kebab-case
|
|
253
|
+
* - <span v-pre>`{{version}}`</span> - The version_name or version from the manifest
|
|
254
|
+
* - <span v-pre>`{{browser}}`</span> - The target browser from the `--browser` CLI flag
|
|
255
|
+
* - <span v-pre>`{{mode}}`</span> - The current mode
|
|
256
|
+
* - <span v-pre>`{{manifestVersion}}`</span> - Either "2" or "3"
|
|
255
257
|
*
|
|
256
258
|
* @default "{{name}}-{{version}}-sources.zip"
|
|
257
259
|
*/
|
|
@@ -346,6 +348,12 @@ interface InlineConfig {
|
|
|
346
348
|
* @default false
|
|
347
349
|
*/
|
|
348
350
|
enabled?: boolean;
|
|
351
|
+
/**
|
|
352
|
+
* Set to true to automatically open the `stats.html` file when the build is finished. When building in CI, the browser will never open.
|
|
353
|
+
*
|
|
354
|
+
* @default false
|
|
355
|
+
*/
|
|
356
|
+
open?: boolean;
|
|
349
357
|
/**
|
|
350
358
|
* When running `wxt build --analyze` or setting `analysis.enabled` to true, customize how the
|
|
351
359
|
* bundle will be visualized. See
|
|
@@ -794,7 +802,7 @@ interface ConfigEnv {
|
|
|
794
802
|
/**
|
|
795
803
|
* The command used to run WXT. `"serve"` during development and `"build"` for any other command.
|
|
796
804
|
*/
|
|
797
|
-
command:
|
|
805
|
+
command: WxtCommand;
|
|
798
806
|
/**
|
|
799
807
|
* Browser passed in from the CLI via the `-b` or `--browser` flag. Defaults to `"chrome"` when not passed.
|
|
800
808
|
*/
|
|
@@ -806,6 +814,7 @@ interface ConfigEnv {
|
|
|
806
814
|
*/
|
|
807
815
|
manifestVersion: 2 | 3;
|
|
808
816
|
}
|
|
817
|
+
type WxtCommand = 'build' | 'serve';
|
|
809
818
|
/**
|
|
810
819
|
* Configure how the browser starts up.
|
|
811
820
|
*/
|
|
@@ -1023,7 +1032,7 @@ interface ResolvedConfig {
|
|
|
1023
1032
|
*/
|
|
1024
1033
|
wxtModuleDir: string;
|
|
1025
1034
|
mode: string;
|
|
1026
|
-
command:
|
|
1035
|
+
command: WxtCommand;
|
|
1027
1036
|
browser: TargetBrowser;
|
|
1028
1037
|
manifestVersion: TargetManifestVersion;
|
|
1029
1038
|
env: ConfigEnv;
|
|
@@ -1043,9 +1052,13 @@ interface ResolvedConfig {
|
|
|
1043
1052
|
downloadedPackagesDir: string;
|
|
1044
1053
|
downloadPackages: string[];
|
|
1045
1054
|
};
|
|
1046
|
-
|
|
1055
|
+
/**
|
|
1056
|
+
* @deprecated Use `build:manifestGenerated` hook instead.
|
|
1057
|
+
*/
|
|
1058
|
+
transformManifest?: (manifest: Manifest.WebExtensionManifest) => void;
|
|
1047
1059
|
analysis: {
|
|
1048
1060
|
enabled: boolean;
|
|
1061
|
+
open: boolean;
|
|
1049
1062
|
template: NonNullable<PluginVisualizerOptions['template']>;
|
|
1050
1063
|
/** Absolute file path to the `stats.html` file */
|
|
1051
1064
|
outputFile: string;
|
|
@@ -1153,4 +1166,4 @@ interface Dependency {
|
|
|
1153
1166
|
version: string;
|
|
1154
1167
|
}
|
|
1155
1168
|
|
|
1156
|
-
export type {
|
|
1169
|
+
export type { VirtualEntrypointType as $, UserManifest as A, BuildOutput as B, ContentScriptEntrypoint as C, UserManifestFn as D, ExtensionRunnerConfig as E, ConfigEnv as F, GenericEntrypoint as G, WxtCommand as H, InlineConfig as I, WxtBuilder as J, WxtBuilderServer as K, Logger as L, MainWorldContentScriptEntrypointOptions as M, ServerInfo as N, OutputFile as O, PopupEntrypointOptions as P, HookResult as Q, ReloadContentScriptPayload as R, SidepanelEntrypointOptions as S, TargetBrowser as T, UserConfig as U, WxtHooks as V, WxtDevServer as W, Wxt as X, ResolvedConfig as Y, FsCache as Z, ExtensionRunner as _, WxtViteConfig as a, EslintGlobalsPropValue as a0, Eslintrc as a1, ResolvedEslintrc as a2, WxtUnimportOptions as a3, WxtResolvedUnimportOptions as a4, WxtPackageManager as a5, Dependency as a6, OutputChunk as b, OutputAsset as c, BuildStepOutput as d, TargetManifestVersion as e, BaseEntrypointOptions as f, BackgroundEntrypointOptions as g, BaseContentScriptEntrypointOptions as h, IsolatedWorldContentScriptEntrypointOptions as i, OptionsEntrypointOptions as j, BaseEntrypoint as k, BackgroundEntrypoint as l, PopupEntrypoint as m, OptionsEntrypoint as n, SidepanelEntrypoint as o, Entrypoint as p, EntrypointGroup as q, OnContentScriptStopped as r, IsolatedWorldContentScriptDefinition as s, MainWorldContentScriptDefinition as t, ContentScriptDefinition as u, BackgroundDefinition as v, UnlistedScriptDefinition as w, PerBrowserOption as x, PerBrowserMap as y, ResolvedPerBrowserOptions as z };
|
package/dist/index.cjs
CHANGED
|
@@ -2693,6 +2693,7 @@ async function buildEntrypoints(groups, spinner) {
|
|
|
2693
2693
|
try {
|
|
2694
2694
|
steps.push(await wxt.config.builder.build(group));
|
|
2695
2695
|
} catch (err) {
|
|
2696
|
+
spinner.stop().clear();
|
|
2696
2697
|
wxt.logger.error(err);
|
|
2697
2698
|
throw Error(`Failed to build ${groupNames.join(", ")}`, { cause: err });
|
|
2698
2699
|
}
|
|
@@ -4323,7 +4324,7 @@ async function resolveConfig(inlineConfig, command, server) {
|
|
|
4323
4324
|
logger.level = import_consola.LogLevels.debug;
|
|
4324
4325
|
const browser = mergedConfig.browser ?? "chrome";
|
|
4325
4326
|
const manifestVersion = mergedConfig.manifestVersion ?? (browser === "firefox" || browser === "safari" ? 2 : 3);
|
|
4326
|
-
const mode = mergedConfig.mode ??
|
|
4327
|
+
const mode = mergedConfig.mode ?? COMMAND_MODES[command];
|
|
4327
4328
|
const env = { browser, command, manifestVersion, mode };
|
|
4328
4329
|
const root = import_node_path12.default.resolve(
|
|
4329
4330
|
inlineConfig.root ?? userConfig.root ?? process.cwd()
|
|
@@ -4364,12 +4365,6 @@ async function resolveConfig(inlineConfig, command, server) {
|
|
|
4364
4365
|
"~~": root
|
|
4365
4366
|
}).map(([key, value]) => [key, import_node_path12.default.resolve(root, value)])
|
|
4366
4367
|
);
|
|
4367
|
-
const analysisOutputFile = import_node_path12.default.resolve(
|
|
4368
|
-
root,
|
|
4369
|
-
mergedConfig.analysis?.outputFile ?? "stats.html"
|
|
4370
|
-
);
|
|
4371
|
-
const analysisOutputDir = import_node_path12.default.dirname(analysisOutputFile);
|
|
4372
|
-
const analysisOutputName = import_node_path12.default.parse(analysisOutputFile).name;
|
|
4373
4368
|
const finalConfig = {
|
|
4374
4369
|
browser,
|
|
4375
4370
|
command,
|
|
@@ -4392,24 +4387,14 @@ async function resolveConfig(inlineConfig, command, server) {
|
|
|
4392
4387
|
srcDir,
|
|
4393
4388
|
typesDir,
|
|
4394
4389
|
wxtDir,
|
|
4395
|
-
zip:
|
|
4396
|
-
transformManifest
|
|
4397
|
-
|
|
4398
|
-
inlineConfig.transformManifest?.(manifest);
|
|
4399
|
-
},
|
|
4400
|
-
analysis: {
|
|
4401
|
-
enabled: mergedConfig.analysis?.enabled ?? false,
|
|
4402
|
-
template: mergedConfig.analysis?.template ?? "treemap",
|
|
4403
|
-
outputFile: analysisOutputFile,
|
|
4404
|
-
outputDir: analysisOutputDir,
|
|
4405
|
-
outputName: analysisOutputName,
|
|
4406
|
-
keepArtifacts: mergedConfig.analysis?.keepArtifacts ?? false
|
|
4407
|
-
},
|
|
4390
|
+
zip: resolveZipConfig(root, mergedConfig),
|
|
4391
|
+
transformManifest: mergedConfig.transformManifest,
|
|
4392
|
+
analysis: resolveAnalysisConfig(root, mergedConfig),
|
|
4408
4393
|
userConfigMetadata: userConfigMetadata ?? {},
|
|
4409
4394
|
alias,
|
|
4410
|
-
experimental: {
|
|
4411
|
-
includeBrowserPolyfill:
|
|
4412
|
-
},
|
|
4395
|
+
experimental: (0, import_defu.default)(mergedConfig.experimental, {
|
|
4396
|
+
includeBrowserPolyfill: true
|
|
4397
|
+
}),
|
|
4413
4398
|
server,
|
|
4414
4399
|
dev: {
|
|
4415
4400
|
reloadCommand
|
|
@@ -4430,70 +4415,27 @@ async function resolveManifestConfig(env, manifest) {
|
|
|
4430
4415
|
return await (typeof manifest === "function" ? manifest(env) : manifest ?? {});
|
|
4431
4416
|
}
|
|
4432
4417
|
function mergeInlineConfig(inlineConfig, userConfig) {
|
|
4433
|
-
|
|
4434
|
-
if (inlineConfig.imports === false || userConfig.imports === false) {
|
|
4435
|
-
imports = false;
|
|
4436
|
-
} else if (userConfig.imports == null && inlineConfig.imports == null) {
|
|
4437
|
-
imports = void 0;
|
|
4438
|
-
} else {
|
|
4439
|
-
imports = (0, import_defu.default)(inlineConfig.imports ?? {}, userConfig.imports ?? {});
|
|
4440
|
-
}
|
|
4418
|
+
const imports = inlineConfig.imports === false || userConfig.imports === false ? false : userConfig.imports == null && inlineConfig.imports == null ? void 0 : (0, import_defu.default)(inlineConfig.imports ?? {}, userConfig.imports ?? {});
|
|
4441
4419
|
const manifest = async (env) => {
|
|
4442
4420
|
const user = await resolveManifestConfig(env, userConfig.manifest);
|
|
4443
4421
|
const inline = await resolveManifestConfig(env, inlineConfig.manifest);
|
|
4444
4422
|
return (0, import_defu.default)(inline, user);
|
|
4445
4423
|
};
|
|
4446
|
-
const
|
|
4447
|
-
|
|
4448
|
-
|
|
4449
|
-
|
|
4450
|
-
const zip2 = (0, import_defu.default)(
|
|
4451
|
-
inlineConfig.zip ?? {},
|
|
4452
|
-
userConfig.zip ?? {}
|
|
4453
|
-
);
|
|
4454
|
-
const hooks = (0, import_defu.default)(
|
|
4455
|
-
inlineConfig.hooks ?? {},
|
|
4456
|
-
userConfig.hooks ?? {}
|
|
4457
|
-
);
|
|
4424
|
+
const transformManifest = (manifest2) => {
|
|
4425
|
+
userConfig.transformManifest?.(manifest2);
|
|
4426
|
+
inlineConfig.transformManifest?.(manifest2);
|
|
4427
|
+
};
|
|
4458
4428
|
return {
|
|
4459
|
-
|
|
4460
|
-
|
|
4461
|
-
|
|
4462
|
-
configFile: inlineConfig.configFile,
|
|
4463
|
-
debug: inlineConfig.debug ?? userConfig.debug,
|
|
4464
|
-
entrypointsDir: inlineConfig.entrypointsDir ?? userConfig.entrypointsDir,
|
|
4465
|
-
filterEntrypoints: inlineConfig.filterEntrypoints ?? userConfig.filterEntrypoints,
|
|
4429
|
+
...(0, import_defu.default)(inlineConfig, userConfig),
|
|
4430
|
+
// Custom merge values
|
|
4431
|
+
transformManifest,
|
|
4466
4432
|
imports,
|
|
4467
|
-
logger: inlineConfig.logger ?? userConfig.logger,
|
|
4468
4433
|
manifest,
|
|
4469
|
-
|
|
4470
|
-
|
|
4471
|
-
runner,
|
|
4472
|
-
srcDir: inlineConfig.srcDir ?? userConfig.srcDir,
|
|
4473
|
-
outDir: inlineConfig.outDir ?? userConfig.outDir,
|
|
4474
|
-
zip: zip2,
|
|
4475
|
-
analysis: {
|
|
4476
|
-
...userConfig.analysis,
|
|
4477
|
-
...inlineConfig.analysis
|
|
4478
|
-
},
|
|
4479
|
-
alias: {
|
|
4480
|
-
...userConfig.alias,
|
|
4481
|
-
...inlineConfig.alias
|
|
4482
|
-
},
|
|
4483
|
-
experimental: {
|
|
4484
|
-
...userConfig.experimental,
|
|
4485
|
-
...inlineConfig.experimental
|
|
4486
|
-
},
|
|
4487
|
-
vite: void 0,
|
|
4488
|
-
transformManifest: void 0,
|
|
4489
|
-
dev: {
|
|
4490
|
-
...userConfig.dev,
|
|
4491
|
-
...inlineConfig.dev
|
|
4492
|
-
},
|
|
4493
|
-
hooks
|
|
4434
|
+
// Vite builder handles merging vite config internally
|
|
4435
|
+
vite: void 0
|
|
4494
4436
|
};
|
|
4495
4437
|
}
|
|
4496
|
-
function
|
|
4438
|
+
function resolveZipConfig(root, mergedConfig) {
|
|
4497
4439
|
const downloadedPackagesDir = import_node_path12.default.resolve(root, ".wxt/local_modules");
|
|
4498
4440
|
return {
|
|
4499
4441
|
name: void 0,
|
|
@@ -4518,6 +4460,23 @@ function resolveInternalZipConfig(root, mergedConfig) {
|
|
|
4518
4460
|
downloadedPackagesDir
|
|
4519
4461
|
};
|
|
4520
4462
|
}
|
|
4463
|
+
function resolveAnalysisConfig(root, mergedConfig) {
|
|
4464
|
+
const analysisOutputFile = import_node_path12.default.resolve(
|
|
4465
|
+
root,
|
|
4466
|
+
mergedConfig.analysis?.outputFile ?? "stats.html"
|
|
4467
|
+
);
|
|
4468
|
+
const analysisOutputDir = import_node_path12.default.dirname(analysisOutputFile);
|
|
4469
|
+
const analysisOutputName = import_node_path12.default.parse(analysisOutputFile).name;
|
|
4470
|
+
return {
|
|
4471
|
+
enabled: mergedConfig.analysis?.enabled ?? false,
|
|
4472
|
+
open: mergedConfig.analysis?.open ?? false,
|
|
4473
|
+
template: mergedConfig.analysis?.template ?? "treemap",
|
|
4474
|
+
outputFile: analysisOutputFile,
|
|
4475
|
+
outputDir: analysisOutputDir,
|
|
4476
|
+
outputName: analysisOutputName,
|
|
4477
|
+
keepArtifacts: mergedConfig.analysis?.keepArtifacts ?? false
|
|
4478
|
+
};
|
|
4479
|
+
}
|
|
4521
4480
|
async function getUnimportOptions(wxtDir, logger, config) {
|
|
4522
4481
|
if (config.imports === false)
|
|
4523
4482
|
return false;
|
|
@@ -4570,6 +4529,10 @@ function logMissingDir(logger, name, expected) {
|
|
|
4570
4529
|
)}`
|
|
4571
4530
|
);
|
|
4572
4531
|
}
|
|
4532
|
+
var COMMAND_MODES = {
|
|
4533
|
+
build: "production",
|
|
4534
|
+
serve: "development"
|
|
4535
|
+
};
|
|
4573
4536
|
|
|
4574
4537
|
// src/core/utils/building/group-entrypoints.ts
|
|
4575
4538
|
function groupEntrypoints(entrypoints) {
|
|
@@ -4834,7 +4797,7 @@ function getChunkSortWeight(filename) {
|
|
|
4834
4797
|
var import_picocolors4 = __toESM(require("picocolors"), 1);
|
|
4835
4798
|
|
|
4836
4799
|
// package.json
|
|
4837
|
-
var version = "0.17.
|
|
4800
|
+
var version = "0.17.9";
|
|
4838
4801
|
|
|
4839
4802
|
// src/core/utils/log/printHeader.ts
|
|
4840
4803
|
var import_consola2 = require("consola");
|
|
@@ -5008,7 +4971,7 @@ async function generateManifest(entrypoints, buildOutput) {
|
|
|
5008
4971
|
addDevModeCsp(manifest);
|
|
5009
4972
|
if (wxt.config.command === "serve")
|
|
5010
4973
|
addDevModePermissions(manifest);
|
|
5011
|
-
wxt.config.transformManifest(manifest);
|
|
4974
|
+
wxt.config.transformManifest?.(manifest);
|
|
5012
4975
|
await wxt.hooks.callHook("build:manifestGenerated", wxt, manifest);
|
|
5013
4976
|
if (wxt.config.manifestVersion === 2) {
|
|
5014
4977
|
convertWebAccessibleResourcesToMv2(manifest);
|
|
@@ -5556,6 +5519,7 @@ var ValidationError = class extends Error {
|
|
|
5556
5519
|
// src/core/utils/building/internal-build.ts
|
|
5557
5520
|
var import_consola3 = __toESM(require("consola"), 1);
|
|
5558
5521
|
var import_rollup_plugin_visualizer2 = require("@aklinker1/rollup-plugin-visualizer");
|
|
5522
|
+
var import_ci_info = require("ci-info");
|
|
5559
5523
|
async function internalBuild() {
|
|
5560
5524
|
await wxt.hooks.callHook("build:before", wxt);
|
|
5561
5525
|
const verb = wxt.config.command === "serve" ? "Pre-rendering" : "Building";
|
|
@@ -5598,6 +5562,15 @@ async function internalBuild() {
|
|
|
5598
5562
|
`Analysis complete:
|
|
5599
5563
|
${import_picocolors5.default.gray("\u2514\u2500")} ${import_picocolors5.default.yellow(statsPath)}`
|
|
5600
5564
|
);
|
|
5565
|
+
if (wxt.config.analysis.open) {
|
|
5566
|
+
if (import_ci_info.isCI) {
|
|
5567
|
+
wxt.logger.debug(`Skipped opening ${import_picocolors5.default.yellow(statsPath)} in CI`);
|
|
5568
|
+
} else {
|
|
5569
|
+
wxt.logger.info(`Opening ${import_picocolors5.default.yellow(statsPath)} in browser...`);
|
|
5570
|
+
const { default: open } = await import("open");
|
|
5571
|
+
open(wxt.config.analysis.outputFile);
|
|
5572
|
+
}
|
|
5573
|
+
}
|
|
5601
5574
|
}
|
|
5602
5575
|
return output;
|
|
5603
5576
|
}
|
|
@@ -5954,30 +5927,33 @@ function createFileReloader(server) {
|
|
|
5954
5927
|
`Changed: ${Array.from(new Set(fileChanges)).map((file) => import_picocolors7.default.dim((0, import_node_path20.relative)(wxt.config.root, file))).join(", ")}`
|
|
5955
5928
|
);
|
|
5956
5929
|
const allEntrypoints = await findEntrypoints();
|
|
5957
|
-
|
|
5958
|
-
|
|
5959
|
-
|
|
5960
|
-
|
|
5961
|
-
|
|
5962
|
-
|
|
5963
|
-
|
|
5964
|
-
|
|
5965
|
-
|
|
5966
|
-
|
|
5967
|
-
|
|
5968
|
-
|
|
5969
|
-
|
|
5970
|
-
|
|
5971
|
-
|
|
5972
|
-
|
|
5973
|
-
|
|
5974
|
-
|
|
5975
|
-
|
|
5976
|
-
|
|
5977
|
-
|
|
5978
|
-
|
|
5979
|
-
|
|
5980
|
-
|
|
5930
|
+
try {
|
|
5931
|
+
const { output: newOutput } = await rebuild(
|
|
5932
|
+
allEntrypoints,
|
|
5933
|
+
// TODO: this excludes new entrypoints, so they're not built until the dev command is restarted
|
|
5934
|
+
changes.rebuildGroups,
|
|
5935
|
+
changes.cachedOutput
|
|
5936
|
+
);
|
|
5937
|
+
server.currentOutput = newOutput;
|
|
5938
|
+
switch (changes.type) {
|
|
5939
|
+
case "extension-reload":
|
|
5940
|
+
server.reloadExtension();
|
|
5941
|
+
import_consola5.consola.success(`Reloaded extension`);
|
|
5942
|
+
break;
|
|
5943
|
+
case "html-reload":
|
|
5944
|
+
const { reloadedNames } = reloadHtmlPages(
|
|
5945
|
+
changes.rebuildGroups,
|
|
5946
|
+
server
|
|
5947
|
+
);
|
|
5948
|
+
import_consola5.consola.success(`Reloaded: ${getFilenameList(reloadedNames)}`);
|
|
5949
|
+
break;
|
|
5950
|
+
case "content-script-reload":
|
|
5951
|
+
reloadContentScripts(changes.changedSteps, server);
|
|
5952
|
+
const rebuiltNames = changes.rebuildGroups.flat().map((entry) => entry.name);
|
|
5953
|
+
import_consola5.consola.success(`Reloaded: ${getFilenameList(rebuiltNames)}`);
|
|
5954
|
+
break;
|
|
5955
|
+
}
|
|
5956
|
+
} catch (err) {
|
|
5981
5957
|
}
|
|
5982
5958
|
});
|
|
5983
5959
|
};
|
|
@@ -6088,6 +6064,16 @@ async function initialize(options) {
|
|
|
6088
6064
|
input.directory ??= options.directory;
|
|
6089
6065
|
input.template ??= defaultTemplate;
|
|
6090
6066
|
input.packageManager ??= options.packageManager;
|
|
6067
|
+
const isExists = await import_fs_extra16.default.pathExists(input.directory);
|
|
6068
|
+
if (isExists) {
|
|
6069
|
+
const isEmpty = (await import_fs_extra16.default.readdir(input.directory)).length === 0;
|
|
6070
|
+
if (!isEmpty) {
|
|
6071
|
+
import_consola6.consola.error(
|
|
6072
|
+
`The directory ${import_node_path21.default.resolve(input.directory)} is not empty. Aborted.`
|
|
6073
|
+
);
|
|
6074
|
+
process.exit(1);
|
|
6075
|
+
}
|
|
6076
|
+
}
|
|
6091
6077
|
await cloneProject(input);
|
|
6092
6078
|
const cdPath = import_node_path21.default.relative(process.cwd(), import_node_path21.default.resolve(input.directory));
|
|
6093
6079
|
console.log();
|
|
@@ -6117,7 +6103,8 @@ async function listTemplates() {
|
|
|
6117
6103
|
return l.name.localeCompare(r.name);
|
|
6118
6104
|
});
|
|
6119
6105
|
} catch (err) {
|
|
6120
|
-
|
|
6106
|
+
import_consola6.consola.error(err);
|
|
6107
|
+
throw Error(`Failed to load templates`);
|
|
6121
6108
|
}
|
|
6122
6109
|
}
|
|
6123
6110
|
async function cloneProject({
|
|
@@ -6183,7 +6170,7 @@ async function zip(config) {
|
|
|
6183
6170
|
const applyTemplate = (template) => template.replaceAll("{{name}}", projectName).replaceAll("{{browser}}", wxt.config.browser).replaceAll(
|
|
6184
6171
|
"{{version}}",
|
|
6185
6172
|
output.manifest.version_name ?? output.manifest.version
|
|
6186
|
-
).replaceAll("{{manifestVersion}}", `mv${wxt.config.manifestVersion}`);
|
|
6173
|
+
).replaceAll("{{mode}}", wxt.config.mode).replaceAll("{{manifestVersion}}", `mv${wxt.config.manifestVersion}`);
|
|
6187
6174
|
await import_fs_extra17.default.ensureDir(wxt.config.outBaseDir);
|
|
6188
6175
|
const outZipFilename = applyTemplate(wxt.config.zip.artifactTemplate);
|
|
6189
6176
|
const outZipPath = import_node_path22.default.resolve(wxt.config.outBaseDir, outZipFilename);
|
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 { v as BackgroundDefinition, l as BackgroundEntrypoint, g as BackgroundEntrypointOptions, h as BaseContentScriptEntrypointOptions, k as BaseEntrypoint, f as BaseEntrypointOptions, d as BuildStepOutput, F as ConfigEnv, u as ContentScriptDefinition, C as ContentScriptEntrypoint,
|
|
1
|
+
import { I as InlineConfig, B as BuildOutput, U as UserConfig, E as ExtensionRunnerConfig, W as WxtDevServer } from './index-mZodC81T.cjs';
|
|
2
|
+
export { v as BackgroundDefinition, l as BackgroundEntrypoint, g as BackgroundEntrypointOptions, h as BaseContentScriptEntrypointOptions, k as BaseEntrypoint, f as BaseEntrypointOptions, d as BuildStepOutput, F as ConfigEnv, u as ContentScriptDefinition, C as ContentScriptEntrypoint, a6 as Dependency, p as Entrypoint, q as EntrypointGroup, a0 as EslintGlobalsPropValue, a1 as Eslintrc, _ as ExtensionRunner, Z as FsCache, G as GenericEntrypoint, Q as HookResult, s as IsolatedWorldContentScriptDefinition, i as IsolatedWorldContentScriptEntrypointOptions, L as Logger, t as MainWorldContentScriptDefinition, M as MainWorldContentScriptEntrypointOptions, r as OnContentScriptStopped, n as OptionsEntrypoint, j as OptionsEntrypointOptions, c as OutputAsset, b as OutputChunk, O as OutputFile, y as PerBrowserMap, x as PerBrowserOption, m as PopupEntrypoint, P as PopupEntrypointOptions, R as ReloadContentScriptPayload, Y as ResolvedConfig, a2 as ResolvedEslintrc, z as ResolvedPerBrowserOptions, N as ServerInfo, o as SidepanelEntrypoint, S as SidepanelEntrypointOptions, T as TargetBrowser, e as TargetManifestVersion, w as UnlistedScriptDefinition, A as UserManifest, D as UserManifestFn, $ as VirtualEntrypointType, X as Wxt, J as WxtBuilder, K as WxtBuilderServer, H as WxtCommand, V as WxtHooks, a5 as WxtPackageManager, a4 as WxtResolvedUnimportOptions, a3 as WxtUnimportOptions, a as WxtViteConfig } from './index-mZodC81T.cjs';
|
|
3
3
|
import 'vite';
|
|
4
4
|
import 'webextension-polyfill';
|
|
5
5
|
import 'unimport';
|
|
@@ -65,6 +65,6 @@ declare function prepare(config: InlineConfig): Promise<void>;
|
|
|
65
65
|
*/
|
|
66
66
|
declare function zip(config?: InlineConfig): Promise<string[]>;
|
|
67
67
|
|
|
68
|
-
var version = "0.17.
|
|
68
|
+
var version = "0.17.9";
|
|
69
69
|
|
|
70
70
|
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 { v as BackgroundDefinition, l as BackgroundEntrypoint, g as BackgroundEntrypointOptions, h as BaseContentScriptEntrypointOptions, k as BaseEntrypoint, f as BaseEntrypointOptions, d as BuildStepOutput, F as ConfigEnv, u as ContentScriptDefinition, C as ContentScriptEntrypoint,
|
|
1
|
+
import { I as InlineConfig, B as BuildOutput, U as UserConfig, E as ExtensionRunnerConfig, W as WxtDevServer } from './index-mZodC81T.js';
|
|
2
|
+
export { v as BackgroundDefinition, l as BackgroundEntrypoint, g as BackgroundEntrypointOptions, h as BaseContentScriptEntrypointOptions, k as BaseEntrypoint, f as BaseEntrypointOptions, d as BuildStepOutput, F as ConfigEnv, u as ContentScriptDefinition, C as ContentScriptEntrypoint, a6 as Dependency, p as Entrypoint, q as EntrypointGroup, a0 as EslintGlobalsPropValue, a1 as Eslintrc, _ as ExtensionRunner, Z as FsCache, G as GenericEntrypoint, Q as HookResult, s as IsolatedWorldContentScriptDefinition, i as IsolatedWorldContentScriptEntrypointOptions, L as Logger, t as MainWorldContentScriptDefinition, M as MainWorldContentScriptEntrypointOptions, r as OnContentScriptStopped, n as OptionsEntrypoint, j as OptionsEntrypointOptions, c as OutputAsset, b as OutputChunk, O as OutputFile, y as PerBrowserMap, x as PerBrowserOption, m as PopupEntrypoint, P as PopupEntrypointOptions, R as ReloadContentScriptPayload, Y as ResolvedConfig, a2 as ResolvedEslintrc, z as ResolvedPerBrowserOptions, N as ServerInfo, o as SidepanelEntrypoint, S as SidepanelEntrypointOptions, T as TargetBrowser, e as TargetManifestVersion, w as UnlistedScriptDefinition, A as UserManifest, D as UserManifestFn, $ as VirtualEntrypointType, X as Wxt, J as WxtBuilder, K as WxtBuilderServer, H as WxtCommand, V as WxtHooks, a5 as WxtPackageManager, a4 as WxtResolvedUnimportOptions, a3 as WxtUnimportOptions, a as WxtViteConfig } from './index-mZodC81T.js';
|
|
3
3
|
import 'vite';
|
|
4
4
|
import 'webextension-polyfill';
|
|
5
5
|
import 'unimport';
|
|
@@ -65,6 +65,6 @@ declare function prepare(config: InlineConfig): Promise<void>;
|
|
|
65
65
|
*/
|
|
66
66
|
declare function zip(config?: InlineConfig): Promise<string[]>;
|
|
67
67
|
|
|
68
|
-
var version = "0.17.
|
|
68
|
+
var version = "0.17.9";
|
|
69
69
|
|
|
70
70
|
export { BuildOutput, ExtensionRunnerConfig, InlineConfig, UserConfig, WxtDevServer, build, clean, createServer, defineConfig, defineRunnerConfig, initialize, prepare, version, zip };
|
package/dist/index.js
CHANGED
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
unnormalizePath,
|
|
19
19
|
version,
|
|
20
20
|
wxt
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-ONUEB57P.js";
|
|
22
22
|
import "./chunk-VBXJIVYU.js";
|
|
23
23
|
|
|
24
24
|
// src/core/build.ts
|
|
@@ -332,30 +332,33 @@ function createFileReloader(server) {
|
|
|
332
332
|
`Changed: ${Array.from(new Set(fileChanges)).map((file) => pc2.dim(relative4(wxt.config.root, file))).join(", ")}`
|
|
333
333
|
);
|
|
334
334
|
const allEntrypoints = await findEntrypoints();
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
335
|
+
try {
|
|
336
|
+
const { output: newOutput } = await rebuild(
|
|
337
|
+
allEntrypoints,
|
|
338
|
+
// TODO: this excludes new entrypoints, so they're not built until the dev command is restarted
|
|
339
|
+
changes.rebuildGroups,
|
|
340
|
+
changes.cachedOutput
|
|
341
|
+
);
|
|
342
|
+
server.currentOutput = newOutput;
|
|
343
|
+
switch (changes.type) {
|
|
344
|
+
case "extension-reload":
|
|
345
|
+
server.reloadExtension();
|
|
346
|
+
consola2.success(`Reloaded extension`);
|
|
347
|
+
break;
|
|
348
|
+
case "html-reload":
|
|
349
|
+
const { reloadedNames } = reloadHtmlPages(
|
|
350
|
+
changes.rebuildGroups,
|
|
351
|
+
server
|
|
352
|
+
);
|
|
353
|
+
consola2.success(`Reloaded: ${getFilenameList(reloadedNames)}`);
|
|
354
|
+
break;
|
|
355
|
+
case "content-script-reload":
|
|
356
|
+
reloadContentScripts(changes.changedSteps, server);
|
|
357
|
+
const rebuiltNames = changes.rebuildGroups.flat().map((entry) => entry.name);
|
|
358
|
+
consola2.success(`Reloaded: ${getFilenameList(rebuiltNames)}`);
|
|
359
|
+
break;
|
|
360
|
+
}
|
|
361
|
+
} catch (err) {
|
|
359
362
|
}
|
|
360
363
|
});
|
|
361
364
|
};
|
|
@@ -466,6 +469,16 @@ async function initialize(options) {
|
|
|
466
469
|
input.directory ??= options.directory;
|
|
467
470
|
input.template ??= defaultTemplate;
|
|
468
471
|
input.packageManager ??= options.packageManager;
|
|
472
|
+
const isExists = await fs2.pathExists(input.directory);
|
|
473
|
+
if (isExists) {
|
|
474
|
+
const isEmpty = (await fs2.readdir(input.directory)).length === 0;
|
|
475
|
+
if (!isEmpty) {
|
|
476
|
+
consola3.error(
|
|
477
|
+
`The directory ${path2.resolve(input.directory)} is not empty. Aborted.`
|
|
478
|
+
);
|
|
479
|
+
process.exit(1);
|
|
480
|
+
}
|
|
481
|
+
}
|
|
469
482
|
await cloneProject(input);
|
|
470
483
|
const cdPath = path2.relative(process.cwd(), path2.resolve(input.directory));
|
|
471
484
|
console.log();
|
|
@@ -495,7 +508,8 @@ async function listTemplates() {
|
|
|
495
508
|
return l.name.localeCompare(r.name);
|
|
496
509
|
});
|
|
497
510
|
} catch (err) {
|
|
498
|
-
|
|
511
|
+
consola3.error(err);
|
|
512
|
+
throw Error(`Failed to load templates`);
|
|
499
513
|
}
|
|
500
514
|
}
|
|
501
515
|
async function cloneProject({
|
|
@@ -561,7 +575,7 @@ async function zip(config) {
|
|
|
561
575
|
const applyTemplate = (template) => template.replaceAll("{{name}}", projectName).replaceAll("{{browser}}", wxt.config.browser).replaceAll(
|
|
562
576
|
"{{version}}",
|
|
563
577
|
output.manifest.version_name ?? output.manifest.version
|
|
564
|
-
).replaceAll("{{manifestVersion}}", `mv${wxt.config.manifestVersion}`);
|
|
578
|
+
).replaceAll("{{mode}}", wxt.config.mode).replaceAll("{{manifestVersion}}", `mv${wxt.config.manifestVersion}`);
|
|
565
579
|
await fs3.ensureDir(wxt.config.outBaseDir);
|
|
566
580
|
const outZipFilename = applyTemplate(wxt.config.zip.artifactTemplate);
|
|
567
581
|
const outZipPath = path3.resolve(wxt.config.outBaseDir, outZipFilename);
|