-
-
Notifications
You must be signed in to change notification settings - Fork 18
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
allow hybrid static/dynamic pages/components #40
Comments
Idea: use |
I added this open-source library: https://github.com/aralroca/prerender-macro?tab=readme-ov-file |
Some problems with the integration of prerender-macro and Brisa:
On 1st: it would be nice to find a way to know the identifier of jsx or jsxDEV so that the current plugins will always work. On 3th: we will have to wait for meriyah and astring to support it, I have already opened the issues: |
The 1st problem (letter instead of |
Related with #183 |
Ok, an idea to solve it at the page level for now (for the component level we need to wait for the issues commented above). For example, for a dynamic route to prerender some params: export default function ProductPage() {
// ...
}
// Provides the function to generate static parameters to then prerender these pages in build-time
export const prerender = () => [{ slug: '1' }, { slug: '2' }]; For a page that has no dynamic route: // Configures to prerender this page in build-time
export const prerender = true; Warning This TODO:
|
Nowadays you can create static pages and have other dynamic ones thanks to the prerender export. However, I leave the issue open because it would be missing at the component level, I created this lib with the intention and it does it well, however we still can not integrate it until the external parser tools support import attributes. |
Both PR's are already merged, we can now integrate them into Brisa! 🎉 |
I have to look for alternatives to: import Foo from '@/foo' with { type: 'prerender' } More context is this library I made: https://github.com/aralroca/prerender-macro/ But it was not compatible until now with the parser and generator I was using in Brisa and I didn't want to use the TypeScript parser which is 3mb and very slow. Now they have accepted my PR in meriyah and in astring and it works fine, however, I have to look for an alternative to the declaration since meriyah does not support TypeScript and when transpiling it with Bun before using the parser is deleting the import attributes... It pisses me off a bit because “with { type: ‘prerender’ }” was nice. Nevertheless if it is possible to make that when analyzing it is without the import attribute although then from the parser if it adds the import attribute of the macro to be able to be done. I have thought about alternatives and we could use an attribute in the component, ex: <Foo is:prerendered foo="bar" /> There are good parts of this alternative:
However, other names came to my mind: |
Things to adapt:
notFound
during streaming works in a different way, for static pages should display the 404 page directlyThe text was updated successfully, but these errors were encountered: