-
-
Notifications
You must be signed in to change notification settings - Fork 444
fix(rolldown-compat): Only apply footer to content and unlisted scripts via plugin #1793
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
aklinker1
merged 6 commits into
wxt-dev:main
from
PatrykKuniczak:feat/create-plugin-for-creating-footer-#1717
Aug 3, 2025
+36
−18
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
fc297ab
feat: create iife-footer plugin for vite and adjust tests
PatrykKuniczak 65a396c
fix: rename footer plugin to match cammelCase
PatrykKuniczak 7bc6cf5
fix: add footer only to content-scripts and unlisted-script
PatrykKuniczak 80be4d8
chore: simplify WxtAppConfig import in wxt/src/utils/app-config.ts
PatrykKuniczak 29559bf
chore: simplify `fs` import of build-entrypoints.ts
PatrykKuniczak ff6e7da
Merge branch 'main' into feat/create-plugin-for-creating-footer-#1717
aklinker1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| import type { Plugin } from 'vite'; | ||
|
|
||
| /** | ||
| * Add a footer with the returned value so it can return values to `scripting.executeScript` | ||
| * Footer is added a part of esbuild to make sure it's not minified. It | ||
| * get's removed if added to `build.rollupOptions.output.footer` | ||
| * See https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/scripting/executeScript#return_value | ||
| */ | ||
| export function iifeFooter(iifeReturnValueName: string): Plugin { | ||
| return { | ||
| name: 'wxt:iife-footer', | ||
| generateBundle(_, bundle) { | ||
| for (const chunk of Object.values(bundle)) { | ||
| if (chunk.type === 'chunk' && chunk.isEntry) { | ||
| chunk.code += `${iifeReturnValueName};`; | ||
| } | ||
| } | ||
| }, | ||
| }; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works, but linking relevant issues for support at bundler level
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sm17p I don't understand.
What are you want to achive, i need to adjust my code or what?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I found is that there is a rollup specific option called
allowReturnOutsideFunctionwhich does what this plugin is trying to do.The first issue has usage examples for areas where we need that option for code transformation.
The 2nd and 3rd are just supporting issues indicating that it's available for use for
Vite v6.Why I mentioned it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sm17p Now i see, what are you want to achive.
But this prop could be use only inside plugin context, i need to make plugin after all, especially if we want to run it under condition(Only for
content-scriptandunlisted-script)I was studying the structure of project and of building process, and there's no place do enable it for plugin of one of entrypoints, because it's fetching dynamically, and there's no plugin for e.g
content-scriptin which plugin i can enableallowReturnOutsideFunction.Maybe there's a chance. owner will answer, i'm still begginer in this project :)
Now it's simply IMO, but if it could be more simply, let's feel free to open PR to my branch with your solution or wait for owner answer, we knows more than us, about his product :)