Skip to content
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

createContentScriptIFrame API #205

Closed
molvqingtai opened this issue Nov 2, 2023 · 9 comments · Fixed by #206
Closed

createContentScriptIFrame API #205

molvqingtai opened this issue Nov 2, 2023 · 9 comments · Fixed by #206
Labels
Milestone

Comments

@molvqingtai
Copy link
Contributor

Feature Request

Currently, all WebExtension frameworks do not implement contentScript HMR. Perhaps this is the only solution that can achieve true HMR:

Inject an iframe into the page and load content.html.

You can refer to the following links for more information:

Consider adding a createContentScriptIFrame API to implement contentScript HMR.

Is your feature request related to a bug?

N

What are the alternatives?

N

Additional context

N

@aklinker1
Copy link
Collaborator

@molvqingtai Great feature idea, thanks for the suggestion.

Would an API similar to createContentScriptUi be what you're looking for? It would include options for positioning and alignment.

@aklinker1 aklinker1 added this to the v1.0 milestone Nov 2, 2023
@molvqingtai
Copy link
Contributor Author

@molvqingtai Great feature idea, thanks for the suggestion.

Would an API similar to createContentScriptUi be what you're looking for? It would include options for positioning and alignment.

I know createContentScriptUi, shadow can only be reload, and iframe can HMR.

@aklinker1
Copy link
Collaborator

Yes, it will use an iframe and include HMR. I'm gonna make the API similar to creayeContentScriptUi, with similar options.

@aklinker1
Copy link
Collaborator

aklinker1 commented Nov 3, 2023

Released in v0.8.7!

I'll add more in-depth examples in the future, but for now, you can see it's usage here: https://wxt.dev/entrypoints/content-scripts.html#iframe

@molvqingtai
Copy link
Contributor Author

Awesome work!

@onlyfortesting
Copy link

Released in v0.8.7!

I'll add more in-depth examples in the future, but for now, you can see it's usage here: https://wxt.dev/entrypoints/content-scripts.html#iframe

@aklinker1, I got ReferenceError: createContentScriptIframe is not defined. Looking at the dist files createContentScriptIframe doesn't seem to be exported. Can you verify this? Thank you.

@aklinker1
Copy link
Collaborator

aklinker1 commented Nov 5, 2023

@onlyfortesting Yes, it's exported

Screenshot 2023-11-05 at 7 59 37 AM

https://wxt.dev/api/wxt/client/functions/createContentScriptIframe.html

It's exported from the wxt/client module, but is also available via auto-imports. Try running

pnpm install [email protected] # or 0.9.0
pnpm wxt clean
pnpm wxt prepare
pnpm wxt dev

@onlyfortesting
Copy link

@aklinker1 For some reason, I thought I was running the latest version. It turns out it was 0.8.6. Sorry for the nuisance.

@aklinker1
Copy link
Collaborator

No worries! Glad you got it sorted 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants