pshrmn / curi

A JavaScript router for single-page applications
https://curi.js.org
MIT License
268 stars 10 forks source link

@curi/static and svelte #245

Open wighawag opened 4 years ago

wighawag commented 4 years ago

I'd like to use @curi/static to generate the index.html for each pages I am using rollup to generate the bundle so I added a plugin function that call staticFiles But for that I need to import the routes, which in turn import the component. Since these component are svelte files, roll up complain with

[!] Error: Unexpected token (Note that you need plugins to import files that are not JavaScript)
src\pages\index.svelte (1:0)
1: <script>
   ^
...
Error: Unexpected token (Note that you need plugins to import files that are not JavaScript)
    at error ...

Do you have an svelte example using @curi/static ?

pshrmn commented 4 years ago

rollup-plugin-svelte doesn't take care of those for you?

I'm going to be AFK for a few days, but if that doesn't work, I'll try to play around with this a bit next week. I need to give some more attention to both the svelte and static packages.

wighawag commented 4 years ago

I am using that plugin, but It is not enabled in the rollup.config.js itself so when I import my routes file it does not know how to process these svelte file. Maybe I could do it in 2 phases and load the bundled js somehow ?

pshrmn commented 4 years ago

I'm finally looking into this today, but I don't have an immediate answer. I think that I'll have to look into how Sapper works to figure out a solution.

wighawag commented 4 years ago

Cool,

From what I gather sapper crawl the pages, by first having a server running the app

There is also routify (https://routify.dev) whose approach is to use jsdom (https://github.com/jsdom/jsdom) to instantiate the app and generate the pre-render

quantuminformation commented 3 years ago

Is there any docs for svelte usage?

pshrmn commented 3 years ago

https://curi.js.org/guides/svelte/