delucis / astro-embed

Low-JavaScript embed components for Astro websites
https://astro-embed.netlify.app
MIT License
172 stars 25 forks source link

[BUG] The requested module '@astrojs/markdown-remark' does not provide an export named 'DEFAULT_REHYPE_PLUGINS' #43

Closed Marocco2 closed 1 year ago

Marocco2 commented 1 year ago
1:30:09 PM: 11:30:09 AM [vite] Error when evaluating SSR module /opt/build/repo/astro.config.mjs: failed to import astro-embed/integration
1:30:09 PM: |- file:///opt/build/repo/node_modules/@astro-community/astro-embed-integration/index.js:2
1:30:09 PM:     DEFAULT_REHYPE_PLUGINS,
1:30:09 PM:     ^^^^^^^^^^^^^^^^^^^^^^
1:30:09 PM: SyntaxError: The requested module '@astrojs/markdown-remark' does not provide an export named 'DEFAULT_REHYPE_PLUGINS'
1:30:09 PM:     at ModuleJob._instantiate (node:internal/modules/esm/module_job:123:21)
1:30:09 PM:     at async ModuleJob.run (node:internal/modules/esm/module_job:189:5)
1:30:09 PM:     at async Promise.all (index 0)
1:30:09 PM:     at async ESMLoader.import (node:internal/modules/esm/loader:530:24)
1:30:09 PM:     at async nodeImport (file:///opt/build/repo/node_modules/vite/dist/node/chunks/dep-abb4f102.js:55920:17)
1:30:09 PM:     at async ssrImport (file:///opt/build/repo/node_modules/vite/dist/node/chunks/dep-abb4f102.js:55813:24)
1:30:09 PM:     at async eval (/opt/build/repo/astro.config.mjs:6:31)
1:30:09 PM:     at async instantiateModule (file:///opt/build/repo/node_modules/vite/dist/node/chunks/dep-abb4f102.js:55875:9)

My astro.config.mjs:

import { defineConfig } from 'astro/config';
import image from "@astrojs/image";
import NetlifyCMS from 'astro-netlify-cms';
import embeds from 'astro-embed/integration';

// https://astro.build/config
export default defineConfig({
  integrations: [NetlifyCMS({...}), image({
    serviceEntryPoint: '@astrojs/image/sharp'
  }), embeds()],
  legacy: {
    astroFlavoredMarkdown: true,
  },
  site: `https://example.com/`,
  output: 'static'
});

My package.json:

{
  "name": "@example/web",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "dev": "astro dev",
    "start": "astro dev",
    "build": "astro build",
    "preview": "astro preview",
    "astro": "astro",
    "functions": "cd functions/app && yarn install"
  },
  "devDependencies": {
    "@astrojs/image": "^0.17.2",
    "astro": "^2.8.2"
  },
  "dependencies": {
    "astro-embed": "^0.2.1",
    "astro-netlify-cms": "^0.5.3"
  }
}
delucis commented 1 year ago

Thanks for the report. I believe DEFAULT_REHYPE_PLUGINS was removed in Astro v2, so we’ll need to adapt astro-embed for that. Should be simple as v2 removed the unintuitive behaviour of v1 where setting any plugin disabled the defaults, so we can drop support for Astro v1 and remove usage of DEFAULT_REHYPE_PLUGINS entirely.

delucis commented 1 year ago

@Marocco2 One side comment — I noticed you have legacy.astroFlavoredMarkdown: true in your config, but be aware that that option was removed from Astro in v2 too. So if you’re hoping to use components in .md that won’t work. You’d need to either switch to use MDX (not supported out of the box by Netlify CMS though I believe) or downgrade Astro to v1.

Marocco2 commented 1 year ago

@Marocco2 One side comment — I noticed you have legacy.astroFlavoredMarkdown: true in your config, but be aware that that option was removed from Astro in v2 too. So if you’re hoping to use components in .md that won’t work. You’d need to either switch to use MDX (not supported out of the box by Netlify CMS though I believe) or downgrade Astro to v1.

I did follow your older instructions to get the plugin working (with no luck) but .MD files are still working in Astro 2.8 without legacy.astroFlavoredMarkdown: true. Switching to .mdx is not possible as I use NetlifyCMS to this day and it doesn't treat nicely with hero images

delucis commented 1 year ago

.md files will work fine for standard Markdown usage but do not support components — so astro-embed also cannot work for Astro v2 with plain .md unfortunately.

Marocco2 commented 1 year ago

I see. Well, let's just make this plugin compiling first and foremost for those who are interested in using this integration