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

MDX integration v3 #10935

Merged
merged 16 commits into from May 8, 2024
Merged

MDX integration v3 #10935

merged 16 commits into from May 8, 2024

Conversation

bluwy
Copy link
Member

@bluwy bluwy commented May 2, 2024

Changes

This PR is a feature branch merging all the existing work for the new MDX integration v3 major. It also adds code to astro and requires a minor bump of it. The MDX integration will depend on the latest Astro version on publish, which is v4.8.0.

All merged PRs (reviewed, chronological):

  1. fix(mdx): convert remark-images-to-component plugin to a rehype plugin #10697
  2. Remove fs read for MDX transform #10866
  3. Tag MDX component for faster checks when rendering #10864
  4. Use unified plugin only for MDX transform #10869
  5. Only traverse children and handle mdxJsxTextElement when optimizing #10885
  6. Rename to optimize.ignoreComponentNames in MDX #10884
  7. Allow remark/rehype plugins added after mdx to work #10877
  8. Improve MDX optimize with sibling nodes #10887
  9. Simplify plain MDX nodes in optimize option #10934

Other commits I added (unreviewed):

  1. 947b133: Improve types in rehype-optimize-static.ts. No logic changed so I figured it didn't need a review.
  2. 1d0c6be: Rename ignoreComponentNames to ignoreElementNames. I think it better reflected the intent. This was also renamed in PR no6 above.

Performance:

Rollup Render Total
Before 101.5s 38s 149.5s
After 85.5s 37.5s 123s
Improvement 16% faster 1% faster 18% faster

Thoughts: I expected more to be honest but I'll take what I can 😅

Raw data
before 1: build 99s. render 49s
before 2: build 104s. render 33s
before 3: build 104s. render 43s

after 1: build 86s. render 48s
after 2: build 88s. render 32s
after 3: build 85s. render 43s

I took the two fastest timing for each build/render phase and average them. As the render phase are dependent of network and fluctuate a bit.

Testing

Existing tests should pass. New tests added from PRs should also pass here.

Docs

Updated MDX integration page: withastro/docs#8151

@bluwy bluwy added this to the 4.8.0 milestone May 2, 2024
Copy link

changeset-bot bot commented May 2, 2024

🦋 Changeset detected

Latest commit: 4fd44da

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: integration Related to any renderer integration (scope) pkg: astro Related to the core `astro` package (scope) semver: minor Change triggers a `minor` release labels May 2, 2024
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

This PR is blocked because it contains a minor changeset. A reviewer will merge this at the next release if approved.

@bluwy
Copy link
Member Author

bluwy commented May 2, 2024

!preview mdx-v3

Copy link
Contributor

github-actions bot commented May 2, 2024

Snapshots have been released for the following packages:

  • @astrojs/mdx@experimental--mdx-v3
  • astro@experimental--mdx-v3
Publish Log
🦋  warn ===============================IMPORTANT!===============================
🦋  warn Packages will be released under the experimental--mdx-v3 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/internal-helpers
🦋  info npm info @astrojs/markdown-remark
🦋  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-mdx-v3-20240502124041) 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.5 is already published on npm
🦋  warn create-astro is not being published because version 4.8.0 is already published on npm
🦋  warn @astrojs/db is not being published because version 0.10.7 is already 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.0.1 is already published on npm
🦋  warn @astrojs/markdoc is not being published because version 0.11.0 is already published on npm
🦋  info @astrojs/mdx is being published because our local version (0.0.0-mdx-v3-20240502124041) has not been published on npm
🦋  warn @astrojs/node is not being published because version 8.2.5 is already published on npm
🦋  warn @astrojs/partytown is not being published because version 2.1.0 is already published on npm
🦋  warn @astrojs/preact is not being published because version 3.2.0 is already published on npm
🦋  warn @astrojs/react is not being published because version 3.3.2 is already published on npm
🦋  warn @astrojs/sitemap is not being published because version 3.1.4 is already published on npm
🦋  warn @astrojs/solid-js is not being published because version 4.1.0 is already published on npm
🦋  warn @astrojs/svelte is not being published because version 5.4.0 is already published on npm
🦋  warn @astrojs/tailwind is not being published because version 5.1.0 is already published on npm
🦋  warn @astrojs/vercel is not being published because version 7.5.4 is already published on npm
🦋  warn @astrojs/vue is not being published because version 4.1.0 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/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.0 is already published on npm
🦋  info Publishing "astro" at "0.0.0-mdx-v3-20240502124041"
🦋  info Publishing "@astrojs/mdx" at "0.0.0-mdx-v3-20240502124041"
🦋  success packages published successfully:
🦋  astro@0.0.0-mdx-v3-20240502124041
🦋  @astrojs/mdx@0.0.0-mdx-v3-20240502124041
🦋  Creating git tags...
🦋  New tag:  astro@0.0.0-mdx-v3-20240502124041
🦋  New tag:  @astrojs/mdx@0.0.0-mdx-v3-20240502124041
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/svelte, @astrojs/tailwind, @astrojs/telemetry, @astrojs/underscore-redirects, @astrojs/upgrade, @astrojs/vercel, @astrojs/vue, @benchmark/timer, astro, create-astro
• Running build in 27 packages
• Remote caching enabled
::group::@astrojs/internal-helpers:build
cache miss, executing e1ebaee47a22d8ff

> @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/telemetry:build
cache miss, executing 5170a25fc8496464

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

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

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

::endgroup::
::group::@astrojs/prism:build
cache miss, executing 964673014fc0348b

> @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::create-astro:build
cache miss, executing 98c65d1b5364a6b0

> 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/markdown-remark:build
cache miss, executing 0d39e0ca8075441b

> @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 cc86f084898be656

> astro@0.0.0-mdx-v3-20240502124041 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-mdx-v3-20240502124041 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-mdx-v3-20240502124041 postbuild /home/runner/work/astro/astro/packages/astro
> astro-scripts copy "src/**/*.astro" && astro-scripts copy "src/**/*.wasm"

::endgroup::
::group::@benchmark/timer:build
cache miss, executing 5f27f8c98eb69406

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

::endgroup::
::group::@astrojs/alpinejs:build
cache miss, executing 73a341284ef94b1f

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

::endgroup::
::group::@astrojs/underscore-redirects:build
cache miss, executing 0b4dc291a593bd4a

> @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/vercel:build
cache miss, executing b11d84b618a0de04

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

::endgroup::
::group::@astrojs/node:build
cache miss, executing 7cfa57e01106ca36

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

::endgroup::
::group::@astrojs/preact:build
cache miss, executing 9cc4af003e5f7a9d

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

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

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

::endgroup::
::group::@astrojs/mdx:build
cache miss, executing 6886db8996ecdf0a

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

::endgroup::
::group::@astrojs/svelte:build
cache miss, executing 9a21ad14baa9155e

> @astrojs/svelte@5.4.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 fa200db58db158dc

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

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

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

::endgroup::
::group::@astrojs/react:build
cache miss, executing 81eeeea8fa395024

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

::endgroup::
::group::@astrojs/tailwind:build
cache miss, executing 83560a6f6ea9e393

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

::endgroup::
::group::@astrojs/partytown:build
cache miss, executing 5c0d4eef6e84b793

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

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

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

::endgroup::
::group::@astrojs/sitemap:build
cache miss, executing 7efa28d5a35a6828

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

::endgroup::
::group::@astrojs/vue:build
cache miss, executing 872f6dfe41b7a006

> @astrojs/vue@4.1.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/db:build
cache miss, executing bb91b977be4251b0

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


> @astrojs/db@0.10.7 types:virtual /home/runner/work/astro/astro/packages/db
> tsc -p ./tsconfig.virtual.json

::endgroup::

 Tasks:    25 successful, 25 total
Cached:    0 cached, 25 total
  Time:    52.011s 

Copy link
Member

@sarah11918 sarah11918 left a comment

Choose a reason for hiding this comment

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

Just chiming in for docs that all the changesets look good! One tiny editing suggestion for you @bluwy, but otherwise approving for visibility!

.changeset/slimy-cobras-end.md Outdated Show resolved Hide resolved
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
Copy link
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

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

Great work @bluwy! Approving for visibility

@ematipico ematipico merged commit ddd8e49 into main May 8, 2024
14 checks passed
@ematipico ematipico deleted the mdx-v3 branch May 8, 2024 09:25
@astrobot-houston astrobot-houston mentioned this pull request May 8, 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: integration Related to any renderer integration (scope) semver: minor Change triggers a `minor` release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants