idyll-lang / idyll

Create explorable explanations and interactive essays.
http://idyll-lang.org/
MIT License
2.01k stars 87 forks source link

Multiple file support #69

Closed rreusser closed 7 years ago

rreusser commented 7 years ago

Right now the name of the output file is hard-coded as index.html. I'm just going to go out on a limb and propose:

  1. idyll can optionally (--batch?) look for all .idl files in the current directory.
  2. It would look for _filename.html and then _index.html and then the internal _index.html when looking for a template for filename.idl so that you could customize if desired.
  3. If there's more than one idyll file, idyll creates the ast for each one first (could store in .idyll/filename.ast.json instead of .idyll/ast.json) so that it can create a common bundle for all the components (can punt on component source bundle splitting for now, right?)
  4. The ast json is inlined into the html file so that each file still only has to include index.js. Or else it could be included separately so that you could do fancy history API transitions or something. But at that point, why are you using idyll instead of just writing a React app. Or at that point you could be using idyll-compiler and the InteractiveDocument component within your own react app.

The use-case of this would be, say, a project with multiple pages. Since they would all have the same component bundle you couldn't perfectly optimize the bundle for each page, but it would at least facilitate a MIMO pattern.

mathisonian commented 7 years ago

I'm not totally convinced that this should be Idyll's responsibility rather than something that could be built on top of idyll. I guess the main thing lacking there would be it (1) wouldn't be able to optimize the bundle across pages and (2) couldn't do fancy single-page app stuff like replacing the page contents rather than reloading the page?

bclinkinbeard commented 7 years ago

I agree this seems like something that could be done by a user on top of idyll and not something we should try to put in the project itself


From: Matthew Conlen notifications@github.com Sent: Thursday, June 8, 2017 6:51:20 PM To: idyll-lang/idyll Cc: Subscribed Subject: Re: [idyll-lang/idyll] Multiple file support (#69)

I'm not totally convinced that this should be Idyll's responsibility rather than something that could be built on top of idyll. I guess the main thing lacking there would be it (1) wouldn't be able to optimize the bundle across pages and (2) couldn't do fancy single-page app stuff like replacing the page contents rather than reloading the page?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/idyll-lang/idyll/issues/69#issuecomment-307248694, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AAIkN-rKddYVAdOzEm_nvNhd88U532Tzks5sCHrogaJpZM4NodJy.

rreusser commented 7 years ago

I kinda have to agree with both. I was thinking then it'd be a nice convenience to compute the output filename from the input filename, e.g. input.idl ➡️ input.html and page2.idl ➡️ page2.html. The problem is that the assets all overwrite each other. So then I was thinking maybe idyll *.idl would copy the assets once and parse + write for each file. Except then the bundles don't work together. So in the end I think leave as-is and you can get fancy on your own. 😄