withastro / astro

The web framework for content-driven websites. ⭐️ Star to support our work!
https://astro.build
Other
45.93k stars 2.42k forks source link

Unhelpful error message when 0.x @astrojs/mdx used with Astro 3 #8985

Closed JoshuaKGoldberg closed 10 months ago

JoshuaKGoldberg commented 11 months ago

Astro Info

Astro                    v3.4.2
Node                     v20.2.0
System                   macOS (arm64)
Package Manager          pnpm
Output                   static
Adapter                  none
Integrations             astro-konamimojisplosion
                         @astrojs/solid-js
                         @astrojs/prefetch
                         @astrojs/mdx

If this issue only occurs in one browser, which browser is a problem?

n/a

Describe the Bug

After upgrading all packages except @astrojs/mdx to the latest for Astro 3 (hooray! congrats again on the launch! 🥳), trying to visit or build a .mdx page with frontmatter yields:

[astro:jsx] Transform failed with 1 error:
/Users/josh/repos/dot-com/src/content/blog/binary-arithmetic/index.mdx:2:11: ERROR: Expected ";" but found ":"
file: /Users/josh/repos/dot-com/src/content/blog/binary-arithmetic/index.mdx:2:11

Expected ";" but found ":"
1  |  ---
2  |  description: "Just for fun, what if we represented binary values purely within TypeScript's logical type system?"
   |             ^
3  |  download: https://1drv.ms/p/s!AvUc1cvPrJnWvqNRDN6yLPZvYTb8KA?e=aNxTrY
4  |  pubDate: 2019-10-11

 error   Expected ";" but found ":"
  File:
    /Users/josh/repos/dot-com/src/content/blog/binary-arithmetic/index.mdx:2:11
  Code:
    1 | ---
    > 2 | description: "Just for fun, what if we represented binary values purely within TypeScript's logical type system?"
        |           ^
      3 | download: https://1drv.ms/p/s!AvUc1cvPrJnWvqNRDN6yLPZvYTb8KA?e=aNxTrY
      4 | pubDate: 2019-10-11
      5 | title: Binary Arithmetic in the TypeScript Type System
  Stacktrace:
Error: Transform failed with 1 error:
/Users/josh/repos/dot-com/src/content/blog/binary-arithmetic/index.mdx:2:11: ERROR: Expected ";" but found ":"
    at failureErrorWithLog (/Users/josh/repos/dot-com/node_modules/.pnpm/esbuild@0.18.17/node_modules/esbuild/lib/main.js:1649:15)
    at /Users/josh/repos/dot-com/node_modules/.pnpm/esbuild@0.18.17/node_modules/esbuild/lib/main.js:847:29
    at responseCallbacks.<computed> (/Users/josh/repos/dot-com/node_modules/.pnpm/esbuild@0.18.17/node_modules/esbuild/lib/main.js:703:9)
    at handleIncomingPacket (/Users/josh/repos/dot-com/node_modules/.pnpm/esbuild@0.18.17/node_modules/esbuild/lib/main.js:762:9)
    at Socket.readFromStdout (/Users/josh/repos/dot-com/node_modules/.pnpm/esbuild@0.18.17/node_modules/esbuild/lib/main.js:679:7)
    at Socket.emit (node:events:511:28)
    at addChunk (node:internal/streams/readable:332:12)
    at readableAddChunk (node:internal/streams/readable:305:9)
    at Readable.push (node:internal/streams/readable:242:10)
    at Pipe.onStreamRead (node:internal/stream_base_commons:190:23)

What's the expected result?

pls work :c

Aside: I tried astro.new for a bit but it didn't give the error I wanted 😞 sorry! But this was reported on Discord too: https://discord.com/channels/830184174198718474/1162386580548362344

Repro steps:

  1. Checkout https://github.com/JoshuaKGoldberg/dot-com/tree/694445d
  2. pnpm install
  3. pnpm build

Link to Minimal Reproducible Example

https://github.com/JoshuaKGoldberg/dot-com/tree/694445d (sorry)

Participation

matthewp commented 10 months ago

Hey @JoshuaKGoldberg sorry for not responding earlier. I see that the commit no longer exists. Are you still having this problem? If not can we close the issue? Thanks.

JoshuaKGoldberg commented 10 months ago

Oop, sorry, I don't know what force push I did to get rid of it 😅.

I'd assume the issue still exists but will probably be less relevant as time goes on. It was quite irritating to discover the hard way when upgrading.

bluwy commented 10 months ago

Thanks for the issue. While I think it's nice to prevent hard breakage like these in the future, we don't have much bandwidth to fix this case at the moment. All packages should usually be upgraded to latest when upgrading Astro as well. And for that, https://github.com/withastro/astro/pull/8525 may help with this. For now I'll close this issue.

v11ncent commented 3 months ago

I had this same issue when attempting to rebuild my Astro site that wasn't touched for a year.

I ended up using npm update to update all my dependencies since I couldn't figure out what was wrong. The core dependency for Astro was being annoying and installing the older version 3.x so I uninstalled it and manually added the latest version using npm i astro@4.11 / npm i astro@latest.

I then went to rebuild it using npm run build, and it gave me the following error:

[vite]: Rollup failed to resolve import "sharp" from "C:/Users/Vince/Desktop/fun/Vince-Web-Designs/node_modules/astro/dist/assets/services/sharp.js".

I then installed Sharp using npm i sharp, and rebuilt my site. Now it works! 🥳