How to load islands in Fresh 2.0 plugins?
Im doing this one but looks like it's not working
7 Replies
How are you using the islands? I can only see the setting up part in the snippet shared. That part seems correct
when you say "not working" are you getting an error in the browser console? Are the islands rendered at all, just not interactive? Are the relevant JS files loaded in the network tabs in devtools? Are you using something external that minifes the HTML and that could potentially strip out HTML comments?
Sorry I think I just ran the incorrect command haha.
deno task start
by default lol
@marvinh. if it's okay to follow up regarding this one, if you look at the way Im installing plugins, the ./islands/mod.ts
file there looks like this
is this expect to work? Im getting this error when running deno task dev
:
If I comment out the SomeComponent
export there, it will go to the next component exported and throw the same errorLooks fine, this should definitely work. Do you have a repro or a snippet with which I can reproduce the error on my end?
Let me check how I can share the code, but basically I tried creating a fresh project again
1.
deno run -Ar jsr:@fresh/init@2.0.0-alpha.21
2. Added a folder named (whatever
) with 2 files - (SomeComponent.tsx
, mod.ts
)
3. Create a plugin that adds it as island
SomeComponent
is a default export, just a button with an onClick
action.
mod.ts
exports SomeComponent
as named component
The plugin
and the dev.ts
file
and running deno task dev
already throws an error:
It errors here https://github.com/denoland/fresh/blob/e0f65319cd48753f5b9b4784f996a0eaf7e6ebff/src/dev/builder.ts#L196Does it work if you move
somePlugin(app)
into main.ts
instead of dev.ts
?same output
Tried to lower the version to the first alpha (
2.0.0-alpha.1
) to check if it might be caused by a reacent update, but still the same error
The crazy thing is if you have the package deployed to JSR, it works... so this only happens on localJust ran into the same issue. What worked for me is passing
pathname
instead of a URL
class
If you pass a URL
, it'll get the href
here - https://github.com/denoland/fresh/blob/e0f65319cd48753f5b9b4784f996a0eaf7e6ebff/src/app.ts#L87
Would love to contribute if we want to use pathname
in that specific line instead