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(@astrojs/react): export renderer for easy loading #11234

Merged
merged 7 commits into from
Jun 13, 2024

Conversation

ematipico
Copy link
Member

@ematipico ematipico commented Jun 11, 2024

Changes

It addresses #11181

The PR adds a new function called addServerRenderer. This function accepts a name and a server renderer object. Usually, the server renderer object is exposed by and entrypoint called */server.js. This is a pattern used by all our renderers.

Ideally, we could remove the first argument of the function - which is the name - and expose is it from the renderer itself:

export default {
+	name: "@astrojs/react`,
	check,
	renderToStaticMarkup,
	supportsAstroStaticSlot: true,
};

If this suggestion is accepted, I will make a second PR to change all the renderers we maintain.

Testing

Created a new test case

Docs

N/A

I will update docs later once we agreed in this API

Copy link

changeset-bot bot commented Jun 11, 2024

🦋 Changeset detected

Latest commit: 3d87d08

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 pkg: react Related to React (scope) pkg: integration Related to any renderer integration (scope) pkg: astro Related to the core `astro` package (scope) pr: docs A PR that includes documentation for review labels Jun 11, 2024
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to create a runtime.js entry point, and re-export these values, but rollup has some issues with it. For the time being, this works

@github-actions github-actions bot added the pkg: example Related to an example package (scope) label Jun 13, 2024
@ematipico
Copy link
Member Author

!preview experimental-container

Copy link
Contributor

Snapshots have been released for the following packages:

  • @astrojs/react@experimental--experimental-container
  • astro@experimental--experimental-container
  • @astrojs/partytown@experimental--experimental-container
  • @astrojs/db@experimental--experimental-container
  • @astrojs/vercel@experimental--experimental-container
  • @astrojs/node@experimental--experimental-container
Publish Log
🦋  warn ===============================IMPORTANT!===============================
🦋  warn Packages will be released under the experimental--experimental-container tag
🦋  warn ----------------------------------------------------------------------
🦋  info npm info astro
🦋  info npm info @astrojs/prism
🦋  info npm info @astrojs/rss
🦋  info npm info create-astro
🦋  info npm info @astrojs/db
🦋  info npm info @astrojs/alpinejs
🦋  info npm info @astrojs/lit
🦋  info npm info @astrojs/markdoc
🦋  info npm info @astrojs/mdx
🦋  info npm info @astrojs/node
🦋  info npm info @astrojs/partytown
🦋  info npm info @astrojs/preact
🦋  info npm info @astrojs/react
🦋  info npm info @astrojs/sitemap
🦋  info npm info @astrojs/solid-js
🦋  info npm info @astrojs/svelte
🦋  info npm info @astrojs/tailwind
🦋  info npm info @astrojs/vercel
🦋  info npm info @astrojs/vue
🦋  info npm info @astrojs/web-vitals
🦋  info npm info @astrojs/internal-helpers
🦋  info npm info @astrojs/markdown-remark
🦋  info npm info @astrojs/studio
🦋  info npm info @astrojs/telemetry
🦋  info npm info @astrojs/underscore-redirects
🦋  info npm info @astrojs/upgrade
🦋  info astro is being published because our local version (0.0.0-experimental-container-20240613104104) has not been published on npm
🦋  warn @astrojs/prism is not being published because version 3.1.0 is already published on npm
🦋  warn @astrojs/rss is not being published because version 4.0.6 is already published on npm
🦋  warn create-astro is not being published because version 4.8.0 is already published on npm
🦋  info @astrojs/db is being published because our local version (0.0.0-experimental-container-20240613104104) has not been published on npm
🦋  warn @astrojs/alpinejs is not being published because version 0.4.0 is already published on npm
🦋  warn @astrojs/lit is not being published because version 4.2.0 is already published on npm
🦋  warn @astrojs/markdoc is not being published because version 0.11.0 is already published on npm
🦋  warn @astrojs/mdx is not being published because version 3.1.0 is already published on npm
🦋  info @astrojs/node is being published because our local version (0.0.0-experimental-container-20240613104104) has not been published on npm
🦋  info @astrojs/partytown is being published because our local version (0.0.0-experimental-container-20240613104104) has not been published on npm
🦋  warn @astrojs/preact is not being published because version 3.4.0 is already published on npm
🦋  info @astrojs/react is being published because our local version (0.0.0-experimental-container-20240613104104) has not been published on npm
🦋  warn @astrojs/sitemap is not being published because version 3.1.5 is already published on npm
🦋  warn @astrojs/solid-js is not being published because version 4.3.0 is already published on npm
🦋  warn @astrojs/svelte is not being published because version 5.5.0 is already published on npm
🦋  warn @astrojs/tailwind is not being published because version 5.1.0 is already published on npm
🦋  info @astrojs/vercel is being published because our local version (0.0.0-experimental-container-20240613104104) has not been published on npm
🦋  warn @astrojs/vue is not being published because version 4.4.0 is already published on npm
🦋  warn @astrojs/web-vitals is not being published because version 0.2.1 is already published on npm
🦋  warn @astrojs/internal-helpers is not being published because version 0.4.0 is already published on npm
🦋  warn @astrojs/markdown-remark is not being published because version 5.1.0 is already published on npm
🦋  warn @astrojs/studio is not being published because version 0.1.0 is already published on npm
🦋  warn @astrojs/telemetry is not being published because version 3.1.0 is already published on npm
🦋  warn @astrojs/underscore-redirects is not being published because version 0.3.3 is already published on npm
🦋  warn @astrojs/upgrade is not being published because version 0.3.1 is already published on npm
🦋  info Publishing "astro" at "0.0.0-experimental-container-20240613104104"
🦋  info Publishing "@astrojs/db" at "0.0.0-experimental-container-20240613104104"
🦋  info Publishing "@astrojs/node" at "0.0.0-experimental-container-20240613104104"
🦋  info Publishing "@astrojs/partytown" at "0.0.0-experimental-container-20240613104104"
🦋  info Publishing "@astrojs/react" at "0.0.0-experimental-container-20240613104104"
🦋  info Publishing "@astrojs/vercel" at "0.0.0-experimental-container-20240613104104"
🦋  success packages published successfully:
🦋  astro@0.0.0-experimental-container-20240613104104
🦋  @astrojs/db@0.0.0-experimental-container-20240613104104
🦋  @astrojs/node@0.0.0-experimental-container-20240613104104
🦋  @astrojs/partytown@0.0.0-experimental-container-20240613104104
🦋  @astrojs/react@0.0.0-experimental-container-20240613104104
🦋  @astrojs/vercel@0.0.0-experimental-container-20240613104104
🦋  Creating git tags...
🦋  New tag:  astro@0.0.0-experimental-container-20240613104104
🦋  New tag:  @astrojs/db@0.0.0-experimental-container-20240613104104
🦋  New tag:  @astrojs/node@0.0.0-experimental-container-20240613104104
🦋  New tag:  @astrojs/partytown@0.0.0-experimental-container-20240613104104
🦋  New tag:  @astrojs/react@0.0.0-experimental-container-20240613104104
🦋  New tag:  @astrojs/vercel@0.0.0-experimental-container-20240613104104
Build Log

> root@0.0.0 build /home/runner/work/astro/astro
> turbo run build --filter=astro --filter=create-astro --filter="@astrojs/*" --filter="@benchmark/*"

• Packages in scope: @astrojs/alpinejs, @astrojs/cloudflare, @astrojs/db, @astrojs/internal-helpers, @astrojs/lit, @astrojs/markdoc, @astrojs/markdown-remark, @astrojs/mdx, @astrojs/netlify, @astrojs/node, @astrojs/partytown, @astrojs/preact, @astrojs/prism, @astrojs/react, @astrojs/rss, @astrojs/sitemap, @astrojs/solid-js, @astrojs/studio, @astrojs/svelte, @astrojs/tailwind, @astrojs/telemetry, @astrojs/underscore-redirects, @astrojs/upgrade, @astrojs/vercel, @astrojs/vue, @astrojs/web-vitals, @benchmark/timer, astro, create-astro
• Running build in 29 packages
• Remote caching enabled
::group::@astrojs/internal-helpers:build
cache miss, executing 2668068f1bcd6c3a

> @astrojs/internal-helpers@0.4.0 build /home/runner/work/astro/astro/packages/internal-helpers
> astro-scripts build "src/**/*.ts" && tsc -p tsconfig.json

::endgroup::
::group::@astrojs/prism:build
cache miss, executing 151d24bc531a0166

> @astrojs/prism@3.1.0 build /home/runner/work/astro/astro/packages/astro-prism
> astro-scripts build "src/**/*.ts" && tsc -p ./tsconfig.json

::endgroup::
::group::@astrojs/telemetry:build
cache miss, executing 4d5a9a2768c94b76

> @astrojs/telemetry@3.1.0 build /home/runner/work/astro/astro/packages/telemetry
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::create-astro:build
cache miss, executing 3e0bcb60a2be8efe

> create-astro@4.8.0 build /home/runner/work/astro/astro/packages/create-astro
> astro-scripts build "src/index.ts" --bundle && tsc

::endgroup::
::group::@astrojs/upgrade:build
cache miss, executing afcdab7904b08190

> @astrojs/upgrade@0.3.1 build /home/runner/work/astro/astro/packages/upgrade
> astro-scripts build "src/index.ts" --bundle && tsc

::endgroup::
::group::@astrojs/markdown-remark:build
cache miss, executing 2ea9bbdc9a9271a9

> @astrojs/markdown-remark@5.1.0 build /home/runner/work/astro/astro/packages/markdown/remark
> astro-scripts build "src/**/*.ts" && tsc -p tsconfig.json

::endgroup::
::group::astro:build
cache miss, executing 2da478960288c28e

> astro@0.0.0-experimental-container-20240613104104 build /home/runner/work/astro/astro/packages/astro
> pnpm run prebuild && astro-scripts build "src/**/*.{ts,js}" && tsc && pnpm run postbuild


> astro@0.0.0-experimental-container-20240613104104 prebuild /home/runner/work/astro/astro/packages/astro
> astro-scripts prebuild --to-string "src/runtime/server/astro-island.ts" "src/runtime/client/{idle,load,media,only,visible}.ts"


> astro@0.0.0-experimental-container-20240613104104 postbuild /home/runner/work/astro/astro/packages/astro
> astro-scripts copy "src/**/*.astro" && astro-scripts copy "src/**/*.wasm"

::endgroup::
::group::@astrojs/studio:build
cache miss, executing 1177c4da7e609c5b

> @astrojs/studio@0.1.0 build /home/runner/work/astro/astro/packages/studio
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/underscore-redirects:build
cache miss, executing 43d0846c0a847843

> @astrojs/underscore-redirects@0.3.3 build /home/runner/work/astro/astro/packages/underscore-redirects
> astro-scripts build "src/**/*.ts" && tsc -p tsconfig.json

::endgroup::
::group::@astrojs/alpinejs:build
cache miss, executing 6755584b7e7d5d48

> @astrojs/alpinejs@0.4.0 build /home/runner/work/astro/astro/packages/integrations/alpinejs
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/tailwind:build
cache miss, executing 682153c0fff2121a

> @astrojs/tailwind@5.1.0 build /home/runner/work/astro/astro/packages/integrations/tailwind
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/react:build
cache miss, executing 6aa261e71f6b160c

> @astrojs/react@0.0.0-experimental-container-20240613104104 build /home/runner/work/astro/astro/packages/integrations/react
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/preact:build
cache miss, executing 7ec6ff0e770cefeb

> @astrojs/preact@3.4.0 build /home/runner/work/astro/astro/packages/integrations/preact
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/vercel:build
cache miss, executing e17657e2d6d3b40f

> @astrojs/vercel@0.0.0-experimental-container-20240613104104 build /home/runner/work/astro/astro/packages/integrations/vercel
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/node:build
cache miss, executing 8c41aad8d1344169

> @astrojs/node@0.0.0-experimental-container-20240613104104 build /home/runner/work/astro/astro/packages/integrations/node
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/mdx:build
cache miss, executing 663feeca1fb2117a

> @astrojs/mdx@3.1.0 build /home/runner/work/astro/astro/packages/integrations/mdx
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/svelte:build
cache miss, executing 4b8b43ecb1a81173

> @astrojs/svelte@5.5.0 build /home/runner/work/astro/astro/packages/integrations/svelte
> astro-scripts build "src/index.ts" && astro-scripts build "src/editor.cts" --force-cjs --no-clean-dist && tsc

::endgroup::
::group::@astrojs/rss:build
cache miss, executing c31bf337692c54dc

> @astrojs/rss@4.0.6 build /home/runner/work/astro/astro/packages/astro-rss
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/lit:build
cache miss, executing 90e0d4abcc8dd6ab

> @astrojs/lit@4.2.0 build /home/runner/work/astro/astro/packages/integrations/lit
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/partytown:build
cache miss, executing 71b571a6791f564e

> @astrojs/partytown@0.0.0-experimental-container-20240613104104 build /home/runner/work/astro/astro/packages/integrations/partytown
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@benchmark/timer:build
cache miss, executing 50c8a06f4d4c9f64

> @benchmark/timer@0.0.0 build /home/runner/work/astro/astro/benchmark/packages/timer
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/solid-js:build
cache miss, executing cf570e41be66f1dd

> @astrojs/solid-js@4.3.0 build /home/runner/work/astro/astro/packages/integrations/solid
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/sitemap:build
cache miss, executing 5e084d991d1c86b5

> @astrojs/sitemap@3.1.5 build /home/runner/work/astro/astro/packages/integrations/sitemap
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/vue:build
cache miss, executing 303762028995b763

> @astrojs/vue@4.4.0 build /home/runner/work/astro/astro/packages/integrations/vue
> astro-scripts build "src/index.ts" && astro-scripts build "src/editor.cts" --force-cjs --no-clean-dist && tsc

::endgroup::
::group::@astrojs/markdoc:build
cache miss, executing 597316c530051833

> @astrojs/markdoc@0.11.0 build /home/runner/work/astro/astro/packages/integrations/markdoc
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/db:build
cache miss, executing aa30049bdba29a99

> @astrojs/db@0.0.0-experimental-container-20240613104104 build /home/runner/work/astro/astro/packages/db
> astro-scripts build "src/**/*.ts" && tsc && pnpm types:virtual


> @astrojs/db@0.0.0-experimental-container-20240613104104 types:virtual /home/runner/work/astro/astro/packages/db
> tsc -p ./tsconfig.virtual.json

::endgroup::
::group::@astrojs/web-vitals:build
cache miss, executing 70ff8d27d59720f1

> @astrojs/web-vitals@0.2.1 build /home/runner/work/astro/astro/packages/integrations/web-vitals
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::

 Tasks:    27 successful, 27 total
Cached:    0 cached, 27 total
  Time:    56.331s 

@ematipico ematipico requested a review from matthewp June 13, 2024 10:44
Copy link
Contributor

@matthewp matthewp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

like this new approach.

@ematipico ematipico merged commit 4385bf7 into main Jun 13, 2024
5 checks passed
@ematipico ematipico deleted the fix/container-renderers branch June 13, 2024 13:05
@astrobot-houston astrobot-houston mentioned this pull request Jun 13, 2024
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) pkg: example Related to an example package (scope) pkg: integration Related to any renderer integration (scope) pkg: react Related to React (scope) pr: docs A PR that includes documentation for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants