Repository navigation
feat: Add apply option to addWxtPlugin to filter which endpoint plugin load - #2613
Conversation
✅ Deploy Preview for creative-fairy-df92c4 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
8f454e0 to
f9650aa
Compare
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
@wxt-dev/analytics
@wxt-dev/auto-icons
@wxt-dev/browser
@wxt-dev/i18n
@wxt-dev/is-background
@wxt-dev/module-react
@wxt-dev/module-solid
@wxt-dev/module-svelte
@wxt-dev/module-vue
@wxt-dev/runner
@wxt-dev/storage
@wxt-dev/unocss
@wxt-dev/webextension-polyfill
wxt
commit: |
aklinker1
left a comment
There was a problem hiding this comment.
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
})
}
})| /** | ||
| * Refreshed each time entrypoints are resolved. Empty until initial | ||
| * resolution. | ||
| */ | ||
| entrypoints: Entrypoint[]; |
There was a problem hiding this comment.
This is not the place to store state like this. Let me get through the rest of this to provide a better solution...
Thank you for your review! Let me re-cehck current implementation and update it. |
1e7639f to
7e2b0cf
Compare
|
@aklinker1 Let's re-review it |
e6f90f9 to
ce96803
Compare
Codecov Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
|
Thanks for helping make WXT better! |
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
addWxtPluginand specify 'background' entry point. After it, run build and this commant under /packages/qwxt-demo directorygrep -rl "test-plugin" .output/chrome-mv3. This result confirms that the build process run with the specifiled entrypoint.Before implementation
After implentation
Related Issue
This PR closes #1627