Skip to content

feat: Add apply option to addWxtPlugin to filter which endpoint plugin load - #2613

Merged
aklinker1 merged 4 commits into
wxt-dev:mainfrom
fkatsuhiro:feat/issue-1627
Oct 25, 2026
Merged

aklinker1 merged 4 commits into
wxt-dev:mainfrom
fkatsuhiro:feat/issue-1627

Conversation

@fkatsuhiro

Copy link
Copy Markdown
Contributor

Overview

By embedding the entrypoint identifier as a query parameter (?entrypoint=<name>) into the virtual module ID, the entrypoint is determined dynamically upon module resolution. Each plugin's apply hook is then evaluated using the extracted entrypoint to generate code containing only the matching plugins.

Manual Testing

Prepare file which use addWxtPlugin and specify 'background' entry point. After it, run build and this commant under /packages/qwxt-demo directory grep -rl "test-plugin" .output/chrome-mv3. This result confirms that the build process run with the specifiled entrypoint.

Before implementation

image

After implentation

image

Related Issue

This PR closes #1627

@netlify

netlify Bot commented Sep 6, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for creative-fairy-df92c4 ready!

Name Link
🔨 Latest commit b06284d
🔍 Latest deploy log https://app.netlify.com/projects/creative-fairy-df92c4/deploys/6ade8d6f74fcf8959cb8b1a5
😎 Deploy Preview https://deploy-preview-2613--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.

@github-actions github-actions Bot added pkg/analytics Includes changes to the `packages/analytics` directory pkg/wxt Includes changes to the `packages/wxt` directory labels Sep 6, 2026
@fkatsuhiro
fkatsuhiro force-pushed the feat/issue-1627 branch 2 times, most recently from 8f454e0 to f9650aa Compare September 9, 2026 22:35
@fkatsuhiro
fkatsuhiro marked this pull request as ready for review September 9, 2026 22:35
@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
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9cf10834-a126-4176-b19f-970fbe76b598

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
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@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@2613

@wxt-dev/auto-icons

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

@wxt-dev/browser

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

@wxt-dev/i18n

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

@wxt-dev/is-background

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

@wxt-dev/module-react

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

@wxt-dev/module-solid

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

@wxt-dev/module-svelte

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

@wxt-dev/module-vue

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

@wxt-dev/runner

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

@wxt-dev/storage

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

@wxt-dev/unocss

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

@wxt-dev/webextension-polyfill

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

wxt

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

commit: b06284d

@aklinker1 aklinker1 mentioned this pull request Oct 4, 2026

@aklinker1 aklinker1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Alright, I like where this is going, but we can't store global state on the wxt object. Instead, we should pull plugins out into their own built-in WXT module. There you can store the list of entrypoints in the setup function's scope:

export default defineWxtModule({
  setup(wxt) {
    let entrypoints = []
    wxt.hook("entrypoints:resolved", (e) => {
      entrypoints = e
    })
  }
})

Comment thread packages/wxt/src/types.ts Outdated
Comment on lines +1530 to +1534
/**
* Refreshed each time entrypoints are resolved. Empty until initial
* resolution.
*/
entrypoints: Entrypoint[];

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is not the place to store state like this. Let me get through the rest of this to provide a better solution...

Comment thread packages/wxt/src/types.ts
@fkatsuhiro

Copy link
Copy Markdown
Contributor Author

Alright, I like where this is going, but we can't store global state on the wxt object. Instead, we should pull plugins out into their own built-in WXT module. There you can store the list of entrypoints in the setup function's scope:

export default defineWxtModule({
  setup(wxt) {
    let entrypoints = []
    wxt.hook("entrypoints:resolved", (e) => {
      entrypoints = e
    })
  }
})

Thank you for your review! Let me re-cehck current implementation and update it.
Thank you.

@PatrykKuniczak

Copy link
Copy Markdown
Collaborator

@aklinker1 Let's re-review it

Comment thread packages/wxt/src/internal/builders/vite/plugins/wxt-plugin-loader.ts Outdated
@aklinker1
aklinker1 enabled auto-merge (squash) October 25, 2026 23:17
@codecov

codecov Bot commented Oct 25, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.61702% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.38%. Comparing base (f8ed652) to head (b06284d).
⚠️ Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
packages/wxt/src/modules/index.ts 0.00% 2 Missing ⚠️
...nternal/builders/vite/plugins/wxt-plugin-loader.ts 97.29% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2613      +/-   ##
==========================================
+ Coverage   79.51%   80.38%   +0.87%     
==========================================
  Files         138      139       +1     
  Lines        4120     4160      +40     
  Branches      947      959      +12     
==========================================
+ Hits         3276     3344      +68     
+ Misses        744      717      -27     
+ Partials      100       99       -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 merged commit 406bbdf into wxt-dev:main Oct 25, 2026
19 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for helping make WXT better!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Module API] Filter which entrypoints plugins run in

3 participants