astro 0.23.0-next.7
Patch Changes
-
#2586
d6d35bcaThanks @tony-sull! - Support for non-HTML pages⚠️ This feature is currently only supported with the
--experimental-static-buildCLI flag. This feature may be refined over the next few weeks/months as SSR support is finalized.This adds support for generating non-HTML pages form
.jsand.tspages during the build. Built file and extensions are based on the source file's name, ex:src/pages/data.json.tswill be built todist/data.json.Is this different from SSR? Yes! This feature allows JSON, XML, etc. files to be output at build time. Keep an eye out for full SSR support if you need to build similar files when requested, for example as a serverless function in your deployment host.
Examples
// src/pages/company.json.ts export async function get() { return { body: JSON.stringify({ name: 'Astro Technology Company', url: 'https://astro.build/', }), }; }What about
getStaticPaths()? It just works™.export async function getStaticPaths() { return [ { params: { slug: 'thing1' }}, { params: { slug: 'thing2' }} ] } export async function get(params) { const { slug } = params return { body: // ...JSON.stringify() } } -
#2548
ba5e2b5eThanks @matthewp! - Experimental SSR Support⚠️ If you are a user of Astro and see this PR and think that you can start deploying your app to a server and get SSR, slow down a second! This is only the initial flag and very basic support. Styles are not loading correctly at this point, for example. Like we did with the
--experimental-static-buildflag, this feature will be refined over the next few weeks/months and we'll let you know when its ready for community testing.Changes
-
This adds a new
--experimental-ssrflag toastro buildwhich will result indist/server/anddist/client/directories. -
SSR can be used through this API:
import { createServer } from 'http'; import { loadApp } from 'astro/app/node'; const app = await loadApp(new URL('./dist/server/', import.meta.url)); createServer((req, res) => { const route = app.match(req); if(route) { let html = await app.render(req, route); } }).listen(8080); -
This API will be refined over time.
-
This only works in Node.js at the moment.
-
Many features will likely not work correctly, but rendering HTML at least should.
-
-
#2581
ec6f148fThanks @matthewp! - Fix for resolving relative imports from hoisted scripts in the static build. -
#2594
085468e9Thanks @natemoo-re! - Upgrade@astrojs/compilertov0.10.2