Skip to content

feat: Overridable runner and entrypointFinder - #2647

Merged
aklinker1 merged 8 commits into
mainfrom
overridable-services
Oct 3, 2026
Merged

aklinker1 merged 8 commits into
mainfrom
overridable-services

Conversation

@aklinker1

@aklinker1 aklinker1 commented Oct 3, 2026 •

Copy link
Copy Markdown
Member

Overview

While typing up #2646, I realized we could be doing a better job of abstracting some logic into "overridable" helpers. The idea being a WXT module/project hook can override part of WXT's logic instead of modifying the results via hooks.

There are three parts of WXT I want to be "overridable" on the wxt object:

  1. wxt.builder: already overridable today, no changes
  2. wxt.runner: currently exists at wxt.config.runner, and can be overwritten there. But I want all these accessble directly on the wxt object
  3. wxt.entrypointFinder: New abstraction that let's people completely replace WXT's built-in entrypoint discovery logic

Modules or projects can then set the values on wxt object to completely replace a chunk logic.

import type { ResolvedConfig, EntrypointFinder } from 'wxt'

class MyEntrypointFinder implements EntrypointFinder {
  constructor(private config: ResolvedConfig) {}

  findEntrypoints(): Promise<EntrypointInfo[]> {
    // Implement custom logic here.
  }
}

export default defineWxtModule({
  setup(wxt) {
    wxt.entrypointFinder = new MyEntrypointFinder(wxt.config)
  }
})

To accomplish this, I had to refactor the web-ext.ts runner and find-entrypoints.ts file a bit.

Manual Testing

See new unit tests.

Related Issue

N/A

@netlify

netlify Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for creative-fairy-df92c4 ready!

Name Link
🔨 Latest commit f782927
🔍 Latest deploy log https://app.netlify.com/projects/creative-fairy-df92c4/deploys/6ac15c0d35c41b0008c72775
😎 Deploy Preview https://deploy-preview-2647--creative-fairy-df92c4.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai

coderabbitai Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5db538e1-f994-44e4-9c49-5f22f4c0a902

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added the pkg/wxt Includes changes to the `packages/wxt` directory label Oct 3, 2026
Comment on lines +14 to +62
const PATH_GLOB_TO_TYPE_MAP: Record<string, Entrypoint['type']> = {
'sandbox.html': 'sandbox',
'sandbox/index.html': 'sandbox',
'*.sandbox.html': 'sandbox',
'*.sandbox/index.html': 'sandbox',

'bookmarks.html': 'bookmarks',
'bookmarks/index.html': 'bookmarks',

'history.html': 'history',
'history/index.html': 'history',

'newtab.html': 'newtab',
'newtab/index.html': 'newtab',

'sidepanel.html': 'sidepanel',
'sidepanel/index.html': 'sidepanel',
'*.sidepanel.html': 'sidepanel',
'*.sidepanel/index.html': 'sidepanel',

'devtools.html': 'devtools',
'devtools/index.html': 'devtools',

'background.[jt]s': 'background',
'background/index.[jt]s': 'background',
[VIRTUAL_NOOP_BACKGROUND_MODULE_ID]: 'background',

'content.[jt]s?(x)': 'content-script',
'content/index.[jt]s?(x)': 'content-script',
'*.content.[jt]s?(x)': 'content-script',
'*.content/index.[jt]s?(x)': 'content-script',
[`content.${CSS_EXTENSIONS_PATTERN}`]: 'content-script-style',
[`*.content.${CSS_EXTENSIONS_PATTERN}`]: 'content-script-style',
[`content/index.${CSS_EXTENSIONS_PATTERN}`]: 'content-script-style',
[`*.content/index.${CSS_EXTENSIONS_PATTERN}`]: 'content-script-style',

'popup.html': 'popup',
'popup/index.html': 'popup',

'options.html': 'options',
'options/index.html': 'options',

'*.html': 'unlisted-page',
'*/index.html': 'unlisted-page',
'*.[jt]s?(x)': 'unlisted-script',
'*/index.[jt]s?(x)': 'unlisted-script',
[`*.${CSS_EXTENSIONS_PATTERN}`]: 'unlisted-style',
[`*/index.${CSS_EXTENSIONS_PATTERN}`]: 'unlisted-style',
};

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy-pasted with no changes

Comment on lines +73 to +106
const relativePaths = await glob(Object.keys(PATH_GLOB_TO_TYPE_MAP), {
cwd: this.config.entrypointsDir,
expandDirectories: false,
});
// Ensure consistent output
relativePaths.sort();

const pathGlobs = Object.keys(PATH_GLOB_TO_TYPE_MAP);
return relativePaths
.reduce<EntrypointInfo[]>((results, relativePath) => {
const inputPath = resolve(this.config.entrypointsDir, relativePath);
const name = getEntrypointName(this.config.entrypointsDir, inputPath);
const matchingGlob = pathGlobs.find((glob) =>
picomatch(glob)(relativePath),
);
if (matchingGlob) {
const type = PATH_GLOB_TO_TYPE_MAP[matchingGlob];
results.push({ name, inputPath, type });
}
return results;
}, [])
.filter(({ name, inputPath }, _, entrypointInfos) => {
// Remove <name>/index.* if <name>/index.html exists
if (inputPath.endsWith('.html')) return true;
const isIndexFile = /index\..+$/.test(inputPath);
if (!isIndexFile) return true;

const hasIndexHtml = entrypointInfos.some(
(entry) =>
entry.name === name && entry.inputPath.endsWith('index.html'),
);

return !hasIndexHtml;
});

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy-pasted with no changes

@pkg-pr-new

pkg-pr-new Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@wxt-dev/analytics

npm i https://pkg.pr.new/@wxt-dev/analytics@2647

@wxt-dev/auto-icons

npm i https://pkg.pr.new/@wxt-dev/auto-icons@2647

@wxt-dev/browser

npm i https://pkg.pr.new/@wxt-dev/browser@2647

@wxt-dev/i18n

npm i https://pkg.pr.new/@wxt-dev/i18n@2647

@wxt-dev/is-background

npm i https://pkg.pr.new/@wxt-dev/is-background@2647

@wxt-dev/module-react

npm i https://pkg.pr.new/@wxt-dev/module-react@2647

@wxt-dev/module-solid

npm i https://pkg.pr.new/@wxt-dev/module-solid@2647

@wxt-dev/module-svelte

npm i https://pkg.pr.new/@wxt-dev/module-svelte@2647

@wxt-dev/module-vue

npm i https://pkg.pr.new/@wxt-dev/module-vue@2647

@wxt-dev/runner

npm i https://pkg.pr.new/@wxt-dev/runner@2647

@wxt-dev/storage

npm i https://pkg.pr.new/@wxt-dev/storage@2647

@wxt-dev/unocss

npm i https://pkg.pr.new/@wxt-dev/unocss@2647

@wxt-dev/webextension-polyfill

npm i https://pkg.pr.new/@wxt-dev/webextension-polyfill@2647

wxt

npm i https://pkg.pr.new/wxt@2647

commit: f782927

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved from E2E tests to unit tests now that the runner is a bit more isolated. Always better to write unit tests since they're faster than E2E tests.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file now lazy-loads web-ext and handles all the checks that were delegated to the WSL, safari, and manual runners from before.

Comment on lines +10 to +12
export * from './entrypoint-finders/flat';
export * from './runners/manual';
export * from './runners/web-ext';

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New public APIs

Comment on lines +34 to +42
// TODO: Remove once config.runner is deprecated
Object.defineProperty(config, 'runner', {
get() {
return runner;
},
set(value) {
wxt.runner = value;
},
});

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep runner on config to prevent a breaking change, but make it a proxy to wxt.runner.

@codecov

codecov Bot commented Oct 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 79.51807% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.18%. Comparing base (804235e) to head (f782927).

Files with missing lines Patch % Lines
packages/wxt/src/core/runners/web-ext.ts 81.57% 5 Missing and 2 partials ⚠️
packages/wxt/src/core/wxt.ts 42.85% 4 Missing ⚠️
packages/wxt/src/core/create-server.ts 50.00% 3 Missing ⚠️
packages/wxt/src/core/runners/manual.ts 71.42% 2 Missing ⚠️
...ackages/wxt/src/core/utils/testing/fake-objects.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2647      +/-   ##
==========================================
+ Coverage   79.52%   80.18%   +0.65%     
==========================================
  Files         135      134       -1     
  Lines        4054     4072      +18     
  Branches      944      944              
==========================================
+ Hits         3224     3265      +41     
+ Misses        734      712      -22     
+ Partials       96       95       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@aklinker1
aklinker1 marked this pull request as ready for review October 3, 2026 19:52
@aklinker1
aklinker1 merged commit 0dd1045 into main Oct 3, 2026
20 checks passed
@aklinker1
aklinker1 deleted the overridable-services branch October 3, 2026 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg/wxt Includes changes to the `packages/wxt` directory

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant