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

feat: add `bundleStrategy: 'inline' #13193

Merged
merged 35 commits into from
Dec 22, 2024
Merged

feat: add `bundleStrategy: 'inline' #13193

merged 35 commits into from
Dec 22, 2024

Conversation

Rich-Harris
Copy link
Member

This is something of an experiment. The idea is that, building on top of #13173, it should be possible to bundle a SvelteKit app right into the HTML, so that you can literally just double-click an app.html file.

Most apps shouldn't be built this way! But there are certain use cases where it's kinda fun — imagine being able to build a game and literally email it to your friends, without needing to host it somewhere.

This PR has no tests yet and there are probably some things that don't work correctly. It may turn out that there are insurmountable technical challenges, I don't know yet.

If this works, it should basically close #907, though there may be some wrinkles around .html extensions depending on how the app is consumed.


Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

  • Run the tests with pnpm test and lint the project with pnpm lint and pnpm check

Changesets

  • If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpm changeset and following the prompts. Changesets that add features should be minor and those that fix bugs should be patch. Please prefix changeset messages with feat:, fix:, or chore:.

Edits

  • Please ensure that 'Allow edits from maintainers' is checked. PRs without this option may be closed.

Copy link

changeset-bot bot commented Dec 18, 2024

🦋 Changeset detected

Latest commit: 37c8787

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@sveltejs/kit Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@Rich-Harris
Copy link
Member Author

preview: https://svelte-dev-git-preview-kit-13193-svelte.vercel.app/

this is an automated message

@tizu69
Copy link

tizu69 commented Dec 21, 2024

what is the play for routes? Does each route get its own bundled code, or is there one bundled codebase that is then just put into all pages? I was gonna ask about dynamic routes, but I'm assuming they aren't possible with this either way I'm assuming.

@Rich-Harris
Copy link
Member Author

One bundle. It doesn't impose any restrictions on what kind of app you can build, just means that the bundle size is correlated to app size

@dummdidumm
Copy link
Member

This doesn't seem to work for me at all. It may work by chance if you prerender the entry point, but if you don't, or navigate anywhere in the app, then everything breaks:

  • protocol is file:, so pathname contains the whole path to the file on disk (e.g. on windows something like /C:/foo/bar/index.html. That breaks all matching logic
  • it's not self-contained yet: it contains __vitePreload entries, one for each node (page/layout/etc), which all try to load a JS bundle. That fails completely
  • when something fails it tries to request version.json to see if a new version is available, this fails

@Rich-Harris
Copy link
Member Author

It doesn't work after merging the hash based routing PR — I have some changes locally, and a test app that works perfectly

@Rich-Harris Rich-Harris merged commit 9a6f461 into main Dec 22, 2024
14 checks passed
@Rich-Harris Rich-Harris deleted the inline-app branch December 22, 2024 17:28
@github-actions github-actions bot mentioned this pull request Dec 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Build an output that is usable from local disk (file:// URL)
4 participants