Dynamically load script
Based on https://docs.plasmo.com/quickstarts/with-google-analytics , I should be able to load https://developers.google.com/maps/documentation/javascript/examples/place-search#maps_place_search-typescript as well
I tied to do it in a CSUI Svelte component:
Plasmo Docs
Quickstart with Google Analytics – Plasmo
Guide on how to use Google Analytics with a Manifest Version 3 browser extension
Google for Developers
Place Searches  | Maps JavaScript API  | Google for Developers
21 Replies
@lab Sorry for the ping, any idea how to solve it?
Check if the map js lib is cached in the .plasmo directory
but otherwise it's up to the host if it want to return the js lib as a file tbh
and whether the script would even let itself load
you might want to take a look at the bundle and see what's inside
@lab has reached level 52. GG!
you might find occasionally they have some logic inside that would prevent it to actually load
seems not :\
lol yeah if that's the case it's prob not possible
that feature basically download whatever js is in that URL and try to embed it in the bundle
Yeah I know
I guess I need to try to bundle it manually
nevermind, it's probably impossible to load it as it loads remote scripts
@lab Could a sandbox page help me out? https://docs.plasmo.com/framework/sandbox-pages
Plasmo Docs
Sandbox Pages – Plasmo
Using sandbox pages with Plasmo to create secure context pages for browser extensions.
The thought process is to run the remotely hosted script in a sandbox page and then embed it in a CSUI with an iframe
I just tried
sandbox.svelte
apparently Parcel prints out the text as-is in <pre>
:thinkingHD:
Wait, now I noticed that no matter if I put sandbox.svelte
or sandbox.html
, it's not even registered in the manifest@lab Assuming that https://github.com/PlasmoHQ/plasmo-test/blob/main/rfc%2Frfc-263-sandbox-pages%2Fsandboxes%2Ftest.tsx results In adding
"sandbox"
entry to the manifest, the issue is that Plasmo doesn't take care of sandbox.svelte
/sandbox.html
GitHub
plasmo-test/rfc/rfc-263-sandbox-pages/sandboxes/test.tsx at main · ...
RFC and BUG reproduction. In the future, it can serve as a regression test suite! - PlasmoHQ/plasmo-test
According to my testing, that's indeed the issue
As soon as I added React dependencies and
sandbox.tsx
, it began to workHm m interesting, I guess it only deal with sandbox.tsx xd
check this codepath:
GitHub
plasmo/core/parcel-transformer-manifest/src/handle-sandboxes.ts at ...
🧩 The Browser Extension Framework. Contribute to PlasmoHQ/plasmo development by creating an account on GitHub.
RIP yeah it only deal with .tsx atm lol
wanna make a PR to add svelte/vue etc?
How hard will it be for me to add Svelte?
Prob adding just that .svelte name to the list will work lol
huh, maybe using sandbox is not the right route whatsoever https://support.mozilla.org/en-US/questions/1111998
Hopefully that works 🤞 https://github.com/PlasmoHQ/plasmo/pull/977
GitHub
Update handle-sandboxes.ts by avi12 · Pull Request #977 · PlasmoHQ/...
Added Svelte support
Details
This PR ...
Code of Conduct
I agree to follow this project's Code of Conduct
I agree to license this contribution under the MIT LICENSE
I checked the current P...
Try testing it with a local build xD
It will be way too much work :KEKWlaugh:
Last time I tried the testing framework locally didn't end good