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

Fix experimental.assets's Squoosh service not working on Netlify and Vercel SSR #6765

Merged
merged 9 commits into from
Apr 12, 2023

Conversation

Princesseuh
Copy link
Member

@Princesseuh Princesseuh commented Apr 5, 2023

Changes

I have tried a thousand ways to bundle .wasm files on SSR hosts and concluded that: There's no way. Every runtime has its own way of doing it (Vercel supports .wasm?module imports, Netlify doesn't have an option, who knows what other are doing).

A promising way was to use Vite's WASM imports, but this doesn't work either for multiple reasons, notably those don't work in SSR the way you would expect them to. Both ?init and ?url don't work because the .wasm files end at the wrong place and for the former, it only supports fetching the wasm file so it's ultimately unsuitable for SSR. Even if that worked, some SSR hosts just won't include the .wasm files in their final bundle (ex: Netlify)

So I went the shameful way. I inlined them.

Testing

Tested manually. See <https://mechanical-magnitude-princesseuh.vercel.app/

Docs

N/A

@changeset-bot
Copy link

changeset-bot bot commented Apr 5, 2023

🦋 Changeset detected

Latest commit: a7e3ef3

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

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

@github-actions github-actions bot added the pkg: astro Related to the core `astro` package (scope) label Apr 5, 2023
@github-actions github-actions bot removed the pkg: astro Related to the core `astro` package (scope) label Apr 6, 2023
@github-actions github-actions bot added pkg: astro Related to the core `astro` package (scope) pkg: integration Related to any renderer integration (scope) labels Apr 11, 2023
@github-actions github-actions bot removed the pkg: integration Related to any renderer integration (scope) label Apr 11, 2023
@Princesseuh Princesseuh changed the title [WIP] Fix experimental.assets not working in Vercel SSR [WIP] Fix experimental.assets's Squoosh service not working on Netlify and Vercel SSR Apr 11, 2023
@Princesseuh
Copy link
Member Author

!preview image-wasm-ssr

@github-actions
Copy link
Contributor

 > [email protected] release /home/runner/work/astro/astro > pnpm run build && changeset publish "--tag" "next--image-wasm-ssr" > [email protected] build /home/runner/work/astro/astro > turbo run build --output-logs=new-only --no-deps --filter=astro --filter=create-astro --filter="@astrojs/*" --filter="@benchmark/*" �[2m• Packages in scope: @astrojs/alpinejs, @astrojs/cloudflare, @astrojs/deno, @astrojs/image, @astrojs/lit, @astrojs/markdoc, @astrojs/markdown-component, @astrojs/markdown-remark, @astrojs/mdx, @astrojs/netlify, @astrojs/node, @astrojs/partytown, @astrojs/preact, @astrojs/prefetch, @astrojs/prism, @astrojs/react, @astrojs/rss, @astrojs/sitemap, @astrojs/solid-js, @astrojs/svelte, @astrojs/tailwind, @astrojs/telemetry, @astrojs/turbolinks, @astrojs/vercel, @astrojs/vue, @astrojs/webapi, @benchmark/timer, astro, create-astro�[0m �[2m• Running�[0m �[2m�[1mbuild�[0m�[0m �[2min 29 packages�[0m �[2m• Remote computation caching enabled (experimental)�[0m �[35m@astrojs/webapi:build: �[0mcache hit, suppressing output �[2m26af238a5fba5399�[0m �[34mcreate-astro:build: �[0mcache hit, suppressing output �[2ma9456ab8df6af85e�[0m �[33m@astrojs/prism:build: �[0mcache hit, suppressing output �[2me4717ba930267553�[0m �[36m@astrojs/telemetry:build: �[0mcache hit, suppressing output �[2m0f27e0b083650f99�[0m �[35m@astrojs/markdown-remark:build: �[0mcache hit, suppressing output �[2m49bf57288d663cfd�[0m �[32mastro:build: �[0mcache miss, executing �[2m1801b82396a61494�[0m �[32mastro:build: �[0m �[32mastro:build: �[0m> [email protected] build /home/runner/work/astro/astro/packages/astro �[32mastro:build: �[0m> pnpm run prebuild && astro-scripts build "src/**/*.{ts,js}" && tsc && pnpm run postbuild �[32mastro:build: �[0m �[32mastro:build: �[0m �[32mastro:build: �[0m> [email protected] prebuild /home/runner/work/astro/astro/packages/astro �[32mastro:build: �[0m> astro-scripts prebuild --to-string "src/runtime/server/astro-island.ts" "src/runtime/client/{idle,load,media,only,visible}.ts" �[32mastro:build: �[0m �[32mastro:build: �[0m �[32mastro:build: �[0m> [email protected] postbuild /home/runner/work/astro/astro/packages/astro �[32mastro:build: �[0m> astro-scripts copy "src/**/*.astro" && astro-scripts copy "src/**/*.wasm" �[32mastro:build: �[0m �[34m@astrojs/vercel:build: �[0mcache miss, executing �[2m3bcc85f309405955�[0m �[34m@astrojs/mdx:build: �[0mcache miss, executing �[2m4cff206d54399092�[0m �[32m@astrojs/sitemap:build: �[0mcache miss, executing �[2m95d8f5f32dc2a122�[0m �[33m@astrojs/tailwind:build: �[0mcache miss, executing �[2m3655d16e5dace89f�[0m �[36m@astrojs/netlify:build: �[0mcache miss, executing �[2m7243ddf9248ccf70�[0m �[35m@astrojs/lit:build: �[0mcache miss, executing �[2m94e4778fb4165b6c�[0m �[36m@astrojs/markdoc:build: �[0mcache miss, executing �[2m63896bdf1de75851�[0m �[35m@astrojs/react:build: �[0mcache miss, executing �[2m667d3c9eaa7743ea�[0m �[33m@astrojs/turbolinks:build: �[0mcache miss, executing �[2m27e8105e0b2d468b�[0m �[32m@astrojs/preact:build: �[0mcache miss, executing �[2m09d606c63f7113e4�[0m �[35m@astrojs/lit:build: �[0m �[35m@astrojs/lit:build: �[0m> @astrojs/[email protected] build /home/runner/work/astro/astro/packages/integrations/lit �[35m@astrojs/lit:build: �[0m> astro-scripts build "src/**/*.ts" && tsc �[35m@astrojs/lit:build: �[0m �[33m@astrojs/tailwind:build: �[0m �[33m@astrojs/tailwind:build: �[0m> @astrojs/[email protected] build /home/runner/work/astro/astro/packages/integrations/tailwind �[33m@astrojs/tailwind:build: �[0m> astro-scripts build "src/**/*.ts" && tsc �[33m@astrojs/tailwind:build: �[0m �[34m@astrojs/vercel:build: �[0m �[34m@astrojs/vercel:build: �[0m> @astrojs/[email protected] build /home/runner/work/astro/astro/packages/integrations/vercel �[34m@astrojs/vercel:build: �[0m> astro-scripts build "src/**/*.ts" && tsc �[34m@astrojs/vercel:build: �[0m �[36m@astrojs/netlify:build: �[0m �[36m@astrojs/netlify:build: �[0m> @astrojs/[email protected] build /home/runner/work/astro/astro/packages/integrations/netlify �[36m@astrojs/netlify:build: �[0m> astro-scripts build "src/**/*.ts" && tsc �[36m@astrojs/netlify:build: �[0m �[32m@astrojs/sitemap:build: �[0m �[32m@astrojs/sitemap:build: �[0m> @astrojs/[email protected] build /home/runner/work/astro/astro/packages/integrations/sitemap �[32m@astrojs/sitemap:build: �[0m> astro-scripts build "src/**/*.ts" && tsc �[32m@astrojs/sitemap:build: �[0m �[35m@astrojs/react:build: �[0m �[35m@astrojs/react:build: �[0m> @astrojs/[email protected] build /home/runner/work/astro/astro/packages/integrations/react �[35m@astrojs/react:build: �[0m> astro-scripts build "src/**/*.ts" && tsc �[35m@astrojs/react:build: �[0m �[34m@astrojs/mdx:build: �[0m �[34m@astrojs/mdx:build: �[0m> @astrojs/[email protected] build /home/runner/work/astro/astro/packages/integrations/mdx �[34m@astrojs/mdx:build: �[0m> astro-scripts build "src/**/*.ts" && tsc �[34m@astrojs/mdx:build: �[0m �[36m@astrojs/markdoc:build: �[0m �[36m@astrojs/markdoc:build: �[0m> @astrojs/[email protected] build /home/runner/work/astro/astro/packages/integrations/markdoc �[36m@astrojs/markdoc:build: �[0m> astro-scripts build "src/**/*.ts" && tsc �[36m@astrojs/markdoc:build: �[0m �[33m@astrojs/turbolinks:build: �[0m �[33m@astrojs/turbolinks:build: �[0m> @astrojs/[email protected] build /home/runner/work/astro/astro/packages/integrations/turbolinks �[33m@astrojs/turbolinks:build: �[0m> astro-scripts build "src/**/*.ts" && tsc �[33m@astrojs/turbolinks:build: �[0m �[32m@astrojs/preact:build: �[0m �[32m@astrojs/preact:build: �[0m> @astrojs/[email protected] build /home/runner/work/astro/astro/packages/integrations/preact �[32m@astrojs/preact:build: �[0m> astro-scripts build "src/**/*.ts" && tsc �[32m@astrojs/preact:build: �[0m �[33m@astrojs/vue:build: �[0mcache miss, executing �[2m5b43cb41e44f98ad�[0m �[34m@astrojs/partytown:build: �[0mcache miss, executing �[2m89c9da494d6522e3�[0m �[36m@astrojs/cloudflare:build: �[0mcache miss, executing �[2mbda8ff3d8f7dc7ab�[0m �[32m@astrojs/prefetch:build: �[0mcache miss, executing �[2m0a6c3214a3d9aa57�[0m �[35m@astrojs/image:build: �[0mcache miss, executing �[2md10b338169b6b11a�[0m �[33m@astrojs/vue:build: �[0m �[33m@astrojs/vue:build: �[0m> @astrojs/[email protected] build /home/runner/work/astro/astro/packages/integrations/vue �[33m@astrojs/vue:build: �[0m> astro-scripts build "src/index.ts" && astro-scripts build "src/editor.cts" --force-cjs --no-clean-dist && tsc �[33m@astrojs/vue:build: �[0m �[34m@astrojs/partytown:build: �[0m �[34m@astrojs/partytown:build: �[0m> @astrojs/[email protected] build /home/runner/work/astro/astro/packages/integrations/partytown �[34m@astrojs/partytown:build: �[0m> astro-scripts build "src/**/*.ts" && tsc �[34m@astrojs/partytown:build: �[0m �[33m@astrojs/node:build: �[0mcache miss, executing �[2m7566d71c508e9e41�[0m �[34m@astrojs/solid-js:build: �[0mcache miss, executing �[2m71568590620e197f�[0m �[36m@astrojs/alpinejs:build: �[0mcache miss, executing �[2m4e75e34a97b6060e�[0m �[36m@astrojs/cloudflare:build: �[0m �[36m@astrojs/cloudflare:build: �[0m> @astrojs/[email protected] build /home/runner/work/astro/astro/packages/integrations/cloudflare �[36m@astrojs/cloudflare:build: �[0m> astro-scripts build "src/**/*.ts" && tsc �[36m@astrojs/cloudflare:build: �[0m �[32m@astrojs/deno:build: �[0mcache miss, executing �[2m5cf098faa4c747ba�[0m �[32m@astrojs/prefetch:build: �[0m �[32m@astrojs/prefetch:build: �[0m> @astrojs/[email protected] build /home/runner/work/astro/astro/packages/integrations/prefetch �[32m@astrojs/prefetch:build: �[0m> astro-scripts build "src/**/*.ts" && tsc �[32m@astrojs/prefetch:build: �[0m �[35m@astrojs/image:build: �[0m �[35m@astrojs/image:build: �[0m> @astrojs/[email protected] build /home/runner/work/astro/astro/packages/integrations/image �[35m@astrojs/image:build: �[0m> astro-scripts build "src/**/*.ts" && tsc �[35m@astrojs/image:build: �[0m �[34m@astrojs/solid-js:build: �[0m �[34m@astrojs/solid-js:build: �[0m> @astrojs/[email protected] build /home/runner/work/astro/astro/packages/integrations/solid �[34m@astrojs/solid-js:build: �[0m> astro-scripts build "src/**/*.ts" && tsc �[34m@astrojs/solid-js:build: �[0m �[33m@astrojs/node:build: �[0m �[33m@astrojs/node:build: �[0m> @astrojs/[email protected] build /home/runner/work/astro/astro/packages/integrations/node �[33m@astrojs/node:build: �[0m> astro-scripts build "src/**/*.ts" && tsc �[33m@astrojs/node:build: �[0m �[36m@astrojs/alpinejs:build: �[0m �[36m@astrojs/alpinejs:build: �[0m> @astrojs/[email protected] build /home/runner/work/astro/astro/packages/integrations/alpinejs �[36m@astrojs/alpinejs:build: �[0m> astro-scripts build "src/**/*.ts" && tsc �[36m@astrojs/alpinejs:build: �[0m �[32m@astrojs/deno:build: �[0m �[32m@astrojs/deno:build: �[0m> @astrojs/[email protected] build /home/runner/work/astro/astro/packages/integrations/deno �[32m@astrojs/deno:build: �[0m> astro-scripts build "src/**/*.ts" && tsc �[32m@astrojs/deno:build: �[0m �[33m@benchmark/timer:build: �[0mcache miss, executing �[2m3289c7c0078d302f�[0m �[33m@benchmark/timer:build: �[0m �[33m@benchmark/timer:build: �[0m> @benchmark/[email protected] build /home/runner/work/astro/astro/benchmark/packages/timer �[33m@benchmark/timer:build: �[0m> astro-scripts build "src/**/*.ts" && tsc �[33m@benchmark/timer:build: �[0m �[34m@astrojs/rss:build: �[0mcache miss, executing �[2m2dcd5a6fb9a92f34�[0m �[36m@astrojs/svelte:build: �[0mcache miss, executing �[2m1eba8a21cc1b6880�[0m �[34m@astrojs/rss:build: �[0m �[34m@astrojs/rss:build: �[0m> @astrojs/[email protected] build /home/runner/work/astro/astro/packages/astro-rss �[34m@astrojs/rss:build: �[0m> astro-scripts build "src/**/*.ts" && tsc �[34m@astrojs/rss:build: �[0m �[36m@astrojs/svelte:build: �[0m �[36m@astrojs/svelte:build: �[0m> @astrojs/[email protected] build /home/runner/work/astro/astro/packages/integrations/svelte �[36m@astrojs/svelte:build: �[0m> astro-scripts build "src/index.ts" && astro-scripts build "src/editor.cts" --force-cjs --no-clean-dist && tsc �[36m@astrojs/svelte:build: �[0m Tasks: 28 successful, 28 total Cached: 5 cached, 28 total Time: 1m20.467s Package �[36m"@astrojs/markdown-remark"�[39m must depend on the current version of �[36m"astro"�[39m: �[32m"0.0.0-image-wasm-ssr-20230411145607"�[39m vs �[31m"^2.2.0"�[39m 🦋 �[33mwarn�[39m �[31m===============================IMPORTANT!===============================�[39m 🦋 �[33mwarn�[39m Packages will be released under the next--image-wasm-ssr tag 🦋 �[33mwarn�[39m �[31m----------------------------------------------------------------------�[39m 🦋 �[36minfo�[39m npm info astro 🦋 �[36minfo�[39m npm info @astrojs/prism 🦋 �[36minfo�[39m npm info @astrojs/rss 🦋 �[36minfo�[39m npm info create-astro 🦋 �[36minfo�[39m npm info @astrojs/alpinejs 🦋 �[36minfo�[39m npm info @astrojs/cloudflare 🦋 �[36minfo�[39m npm info @astrojs/deno 🦋 �[36minfo�[39m npm info @astrojs/image 🦋 �[36minfo�[39m npm info @astrojs/lit 🦋 �[36minfo�[39m npm info @astrojs/markdoc 🦋 �[36minfo�[39m npm info @astrojs/mdx 🦋 �[36minfo�[39m npm info @astrojs/netlify 🦋 �[36minfo�[39m npm info @astrojs/node 🦋 �[36minfo�[39m npm info @astrojs/partytown 🦋 �[36minfo�[39m npm info @astrojs/preact 🦋 �[36minfo�[39m npm info @astrojs/prefetch 🦋 �[36minfo�[39m npm info @astrojs/react 🦋 �[36minfo�[39m npm info @astrojs/sitemap 🦋 �[36minfo�[39m npm info @astrojs/solid-js 🦋 �[36minfo�[39m npm info @astrojs/svelte 🦋 �[36minfo�[39m npm info @astrojs/tailwind 🦋 �[36minfo�[39m npm info @astrojs/turbolinks 🦋 �[36minfo�[39m npm info @astrojs/vercel 🦋 �[36minfo�[39m npm info @astrojs/vue 🦋 �[36minfo�[39m npm info @astrojs/markdown-component 🦋 �[36minfo�[39m npm info @astrojs/markdown-remark 🦋 �[36minfo�[39m npm info @astrojs/telemetry 🦋 �[36minfo�[39m npm info @astrojs/webapi 🦋 �[36minfo�[39m astro is being published because our local version (0.0.0-image-wasm-ssr-20230411145607) has not been published on npm 🦋 �[33mwarn�[39m @astrojs/prism is not being published because version 2.1.1 is already published on npm 🦋 �[33mwarn�[39m @astrojs/rss is not being published because version 2.3.2 is already published on npm 🦋 �[33mwarn�[39m create-astro is not being published because version 3.1.2 is already published on npm 🦋 �[33mwarn�[39m @astrojs/alpinejs is not being published because version 0.2.1 is already published on npm 🦋 �[33mwarn�[39m @astrojs/cloudflare is not being published because version 6.2.2 is already published on npm 🦋 �[33mwarn�[39m @astrojs/deno is not being published because version 4.1.0 is already published on npm 🦋 �[36minfo�[39m @astrojs/image is being published because our local version (0.0.0-image-wasm-ssr-20230411145607) has not been published on npm 🦋 �[33mwarn�[39m @astrojs/lit is not being published because version 2.0.1 is already published on npm 🦋 �[33mwarn�[39m @astrojs/markdoc is not being published because version 0.1.1 is already published on npm 🦋 �[33mwarn�[39m @astrojs/mdx is not being published because version 0.18.3 is already published on npm 🦋 �[33mwarn�[39m @astrojs/netlify is not being published because version 2.2.2 is already published on npm 🦋 �[33mwarn�[39m @astrojs/node is not being published because version 5.1.1 is already published on npm 🦋 �[33mwarn�[39m @astrojs/partytown is not being published because version 1.2.0 is already published on npm 🦋 �[33mwarn�[39m @astrojs/preact is not being published because version 2.1.0 is already published on npm 🦋 �[33mwarn�[39m @astrojs/prefetch is not being published because version 0.2.1 is already published on npm 🦋 �[33mwarn�[39m @astrojs/react is not being published because version 2.1.1 is already published on npm 🦋 �[33mwarn�[39m @astrojs/sitemap is not being published because version 1.2.2 is already published on npm 🦋 �[33mwarn�[39m @astrojs/solid-js is not being published because version 2.1.0 is already published on npm 🦋 �[33mwarn�[39m @astrojs/svelte is not being published because version 2.1.0 is already published on npm 🦋 �[33mwarn�[39m @astrojs/tailwind is not being published because version 3.1.1 is already published on npm 🦋 �[33mwarn�[39m @astrojs/turbolinks is not being published because version 0.2.1 is already published on npm 🦋 �[33mwarn�[39m @astrojs/vercel is not being published because version 3.2.3 is already published on npm 🦋 �[33mwarn�[39m @astrojs/vue is not being published because version 2.1.1 is already published on npm 🦋 �[33mwarn�[39m @astrojs/markdown-component is not being published because version 1.0.3 is already published on npm 🦋 �[33mwarn�[39m @astrojs/markdown-remark is not being published because version 2.1.3 is already published on npm 🦋 �[33mwarn�[39m @astrojs/telemetry is not being published because version 2.1.0 is already published on npm 🦋 �[33mwarn�[39m @astrojs/webapi is not being published because version 2.1.0 is already published on npm 🦋 �[36minfo�[39m Publishing �[36m"astro"�[39m at �[32m"0.0.0-image-wasm-ssr-20230411145607"�[39m 🦋 �[36minfo�[39m Publishing �[36m"@astrojs/image"�[39m at �[32m"0.0.0-image-wasm-ssr-20230411145607"�[39m 🦋 �[32msuccess�[39m packages published successfully: 🦋 [email protected] 🦋 @astrojs/[email protected] 🦋 Creating git tags... 🦋 New tag: [email protected] 🦋 New tag: @astrojs/[email protected]

@Princesseuh Princesseuh changed the title [WIP] Fix experimental.assets's Squoosh service not working on Netlify and Vercel SSR Fix experimental.assets's Squoosh service not working on Netlify and Vercel SSR Apr 11, 2023
@Princesseuh Princesseuh marked this pull request as ready for review April 11, 2023 15:19
@Princesseuh Princesseuh merged commit 6c09ac0 into main Apr 12, 2023
@Princesseuh Princesseuh deleted the fix/ssr-images branch April 12, 2023 08:45
@astrobot-houston astrobot-houston mentioned this pull request Apr 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: astro Related to the core `astro` package (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants