From 5a028d255156fc789e9079a7ea276ef423bfbe88 Mon Sep 17 00:00:00 2001 From: Aaron Date: Mon, 9 Feb 2026 01:45:11 -0600 Subject: [PATCH] chore: Remove unused code (#2087) Co-authored-by: Patryk Kuniczak --- packages/wxt/e2e/utils.ts | 8 -------- .../wxt/src/core/utils/building/detect-dev-changes.ts | 4 ---- packages/wxt/src/core/utils/building/internal-build.ts | 4 ++-- packages/wxt/src/core/utils/log/printHeader.ts | 3 +-- packages/wxt/src/core/utils/testing/fake-objects.ts | 5 ----- packages/wxt/src/modules.ts | 3 --- packages/wxt/src/utils/content-script-ui/iframe.ts | 2 +- packages/wxt/src/utils/content-script-ui/integrated.ts | 2 +- packages/wxt/src/utils/content-script-ui/shared.ts | 3 +-- packages/wxt/src/utils/internal/dev-server-websocket.ts | 3 --- 10 files changed, 6 insertions(+), 31 deletions(-) diff --git a/packages/wxt/e2e/utils.ts b/packages/wxt/e2e/utils.ts index bcca1a26..cd258c2c 100644 --- a/packages/wxt/e2e/utils.ts +++ b/packages/wxt/e2e/utils.ts @@ -138,14 +138,6 @@ export class TestProject { return this.serializeDir('.output', ignoreContentsOfFilenames); } - /** - * Read all the files from the test project's `.wxt` directory and combine them into a string - * that can be used in a snapshot. - */ - serializeWxtDir(): Promise { - return this.serializeDir(resolve(this.root, '.wxt/types')); - } - /** * Deeply print the filename and contents of all files in a directory. * diff --git a/packages/wxt/src/core/utils/building/detect-dev-changes.ts b/packages/wxt/src/core/utils/building/detect-dev-changes.ts index 1fe00653..ce11ef66 100644 --- a/packages/wxt/src/core/utils/building/detect-dev-changes.ts +++ b/packages/wxt/src/core/utils/building/detect-dev-changes.ts @@ -207,10 +207,6 @@ interface ExtensionReload extends RebuildChange { type: 'extension-reload'; } -// interface BrowserRestart extends RebuildChange { -// type: 'browser-restart'; -// } - interface ContentScriptReload extends RebuildChange { type: 'content-script-reload'; changedSteps: BuildStepOutput[]; diff --git a/packages/wxt/src/core/utils/building/internal-build.ts b/packages/wxt/src/core/utils/building/internal-build.ts index 03d5035e..d01ad509 100644 --- a/packages/wxt/src/core/utils/building/internal-build.ts +++ b/packages/wxt/src/core/utils/building/internal-build.ts @@ -133,8 +133,8 @@ function printValidationResults({ }, new Map()); Array.from(entrypointErrors.entries()).forEach(([entrypoint, errors]) => { - wxt.logger.log(relative(cwd, entrypoint.inputPath)); - console.log(); + wxt.logger.log(relative(cwd, entrypoint.inputPath) + '\n'); + errors.forEach((err) => { const type = err.type === 'error' ? pc.red('ERROR') : pc.yellow('WARN'); const received = pc.dim(`(received: ${JSON.stringify(err.value)})`); diff --git a/packages/wxt/src/core/utils/log/printHeader.ts b/packages/wxt/src/core/utils/log/printHeader.ts index 5d7dbd7c..09bbc76a 100644 --- a/packages/wxt/src/core/utils/log/printHeader.ts +++ b/packages/wxt/src/core/utils/log/printHeader.ts @@ -3,6 +3,5 @@ import { version } from '../../../version'; import { consola } from 'consola'; export function printHeader() { - console.log(); - consola.log(`${pc.gray('WXT')} ${pc.gray(pc.bold(version))}`); + consola.log(`\n${pc.gray('WXT')} ${pc.gray(pc.bold(version))}`); } diff --git a/packages/wxt/src/core/utils/testing/fake-objects.ts b/packages/wxt/src/core/utils/testing/fake-objects.ts index bb10ca76..2f9bd317 100644 --- a/packages/wxt/src/core/utils/testing/fake-objects.ts +++ b/packages/wxt/src/core/utils/testing/fake-objects.ts @@ -14,7 +14,6 @@ import { OptionsEntrypoint, PopupEntrypoint, OutputChunk, - OutputFile, OutputAsset, BuildOutput, BuildStepOutput, @@ -208,10 +207,6 @@ export const fakeOutputAsset = fakeObjectCreator(() => ({ fileName: fakeFileName(), })); -export function fakeOutputFile(): OutputFile { - return faker.helpers.arrayElement([fakeOutputAsset(), fakeOutputChunk()]); -} - export const fakeManifest = fakeObjectCreator(() => ({ manifest_version: faker.helpers.arrayElement([2, 3]), name: faker.string.alphanumeric(), diff --git a/packages/wxt/src/modules.ts b/packages/wxt/src/modules.ts index 91ac8f67..a7e35a6c 100644 --- a/packages/wxt/src/modules.ts +++ b/packages/wxt/src/modules.ts @@ -170,9 +170,6 @@ export function addImportPreset( preset: UnimportOptions['presets'][0], ): void { wxt.hooks.hook('config:resolved', (wxt) => { - // In older versions of WXT, `wxt.config.imports` could be false - if (!wxt.config.imports) return; - wxt.config.imports.presets ??= []; // De-duplicate built-in named presets if (wxt.config.imports.presets.includes(preset)) return; diff --git a/packages/wxt/src/utils/content-script-ui/iframe.ts b/packages/wxt/src/utils/content-script-ui/iframe.ts index aa968f9b..a020f107 100644 --- a/packages/wxt/src/utils/content-script-ui/iframe.ts +++ b/packages/wxt/src/utils/content-script-ui/iframe.ts @@ -19,7 +19,7 @@ export function createIframeUi( iframe.src = browser.runtime.getURL(options.page); wrapper.appendChild(iframe); - let mounted: TMounted | undefined = undefined; + let mounted: TMounted | undefined; const mount = () => { applyPosition(wrapper, iframe, options); options.onBeforeMount?.(wrapper, iframe); diff --git a/packages/wxt/src/utils/content-script-ui/integrated.ts b/packages/wxt/src/utils/content-script-ui/integrated.ts index 37689ec6..4cf15c87 100644 --- a/packages/wxt/src/utils/content-script-ui/integrated.ts +++ b/packages/wxt/src/utils/content-script-ui/integrated.ts @@ -14,7 +14,7 @@ export function createIntegratedUi( ): IntegratedContentScriptUi { const wrapper = document.createElement(options.tag || 'div'); - let mounted: TMounted | undefined = undefined; + let mounted: TMounted | undefined; const mount = () => { applyPosition(wrapper, undefined, options); mountUi(wrapper, options); diff --git a/packages/wxt/src/utils/content-script-ui/shared.ts b/packages/wxt/src/utils/content-script-ui/shared.ts index d1efea6e..d0bfdbf5 100644 --- a/packages/wxt/src/utils/content-script-ui/shared.ts +++ b/packages/wxt/src/utils/content-script-ui/shared.ts @@ -108,7 +108,6 @@ export function mountUi( break; default: options.append(anchor, root); - break; } } @@ -116,7 +115,7 @@ export function createMountFunctions( baseFunctions: BaseMountFunctions, options: ContentScriptUiOptions, ): MountFunctions { - let autoMountInstance: AutoMount | undefined = undefined; + let autoMountInstance: AutoMount | undefined; const stopAutoMount = () => { autoMountInstance?.stopAutoMount(); diff --git a/packages/wxt/src/utils/internal/dev-server-websocket.ts b/packages/wxt/src/utils/internal/dev-server-websocket.ts index 83a15980..c3c4556a 100644 --- a/packages/wxt/src/utils/internal/dev-server-websocket.ts +++ b/packages/wxt/src/utils/internal/dev-server-websocket.ts @@ -29,9 +29,6 @@ let ws: WxtWebSocket | undefined; /** * Connect to the websocket and listen for messages. - * - * @param onMessage Optional callback that is called when a message is recieved and we've verified - * it's structure is what we expect. */ export function getDevServerWebSocket(): WxtWebSocket { if (import.meta.env.COMMAND !== 'serve')