Skip to content

Conversation

@PatrykKuniczak
Copy link
Contributor

Overview

I hope that's it :)

Manual Testing

Let's run pnpm -F wxt-demo dev and then check if wxt-demo/.output/chrome-mv3-dev/content-scripts/automount.js have automount on the very last line.

Related Issue

This PR closes #1717

@netlify
Copy link

netlify bot commented Jul 5, 2025

Deploy Preview for creative-fairy-df92c4 ready!

Name Link
🔨 Latest commit ff6e7da
🔍 Latest deploy log https://app.netlify.com/projects/creative-fairy-df92c4/deploys/688f6403649754000845236e
😎 Deploy Preview https://deploy-preview-1793--creative-fairy-df92c4.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

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

@ion1
Copy link
Contributor

ion1 commented Jul 9, 2025

A related issue: #1738. The script does not need to set a global variable at all for the return value from the IIFE to be returned by executeScript.

@PatrykKuniczak
Copy link
Contributor Author

PatrykKuniczak commented Jul 9, 2025

A related issue: #1738. The script does not need to set a global variable at all for the return value from the IIFE to be returned by executeScript.

If i'm understand you right, this plugin is unnecessary at all, yeah?

I can simply remove all of that, include esbuild prop from original solution, yes?

@ion1
Copy link
Contributor

ion1 commented Jul 9, 2025

We should probably get input from the project authors on this.

Copy link

@sm17p sm17p left a comment

Choose a reason for hiding this comment

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

Nice work!

generateBundle(_, bundle) {
for (const chunk of Object.values(bundle)) {
if (chunk.type === 'chunk' && chunk.isEntry) {
chunk.code += `${iifeReturnValueName};`;
Copy link

@sm17p sm17p Jul 18, 2025

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

  1. top level return for IIFEs rollup/rollup#5509 (comment)
  2. this.parse now only supports the allowReturnOutsideFunction option for now ([v4.0] Switch parser to SWC and introduce native/WASM code rollup/rollup#5073)

  3. feat!: rollup v4 vitejs/vite#14508

Copy link
Contributor Author

@PatrykKuniczak PatrykKuniczak Jul 19, 2025

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?

Copy link

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 allowReturnOutsideFunction which 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?

  • I thought if it's available at a bundler level, then it's better to use that to avoid maintenance overhead.

i need to adjust my code or what?

  • Upto the owner's descretion
  • Normally, what I would do is check if I can get it working with already existing API but that's your call

Copy link
Contributor Author

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-script and unlisted-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-script in which plugin i can enable allowReturnOutsideFunction.

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 :)

Copy link
Member

@aklinker1 aklinker1 left a comment

Choose a reason for hiding this comment

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

Thanks!

@pkg-pr-new
Copy link

pkg-pr-new bot commented Aug 3, 2025

Open in StackBlitz

@wxt-dev/analytics

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

@wxt-dev/auto-icons

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

@wxt-dev/browser

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

@wxt-dev/i18n

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

@wxt-dev/module-react

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

@wxt-dev/module-solid

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

@wxt-dev/module-svelte

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

@wxt-dev/module-vue

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

@wxt-dev/runner

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

@wxt-dev/storage

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

@wxt-dev/unocss

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

@wxt-dev/webextension-polyfill

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

wxt

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

commit: ff6e7da

@aklinker1 aklinker1 changed the title feat: create plugin for creating footer #1717 fix: Only apply footer to content and unlisted scripts via plugin Aug 3, 2025
@aklinker1 aklinker1 changed the title fix: Only apply footer to content and unlisted scripts via plugin fix(rolldown-compat): Only apply footer to content and unlisted scripts via plugin Aug 3, 2025
@aklinker1 aklinker1 merged commit 190be7f into wxt-dev:main Aug 3, 2025
16 checks passed
@github-actions
Copy link
Contributor

github-actions bot commented Aug 3, 2025

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Rolldown] esbuild.footer is deprecated

4 participants