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

attacher.call is not a function when used in a solid-start/vinxi project #129

Closed
arnfaldur opened this issue May 18, 2024 · 1 comment
Closed

Comments

@arnfaldur
Copy link

  • remark-embedder-core version: 3.0.2
  • node version: 22.0.0
  • pnpm version: 9.1.1

Relevant code or config

// file: app.config.ts

import { defineConfig } from "@solidjs/start/config";

import mdx from "@vinxi/plugin-mdx";

import remarkEmbedder from "@remark-embedder/core";
import oembedTransformer from "@remark-embedder/transformer-oembed";

export default defineConfig({
  extensions: ["tsx", "mdx", "md"],
  server: {
    preset: "aws-amplify",
  },
  vite: {
    plugins: [
      mdx.default.withImports({})({
        jsx: true,
        jsxImportSource: "solid-js",
        providerImportSource: "solid-mdx",
        remarkPlugins: [
          [
            remarkEmbedder.default,
            { transformers: [oembedTransformer.default] },
          ],
        ],
        enforce: "pre",
      }),
    ],
  },
});

Trying to use this plugin in a SolidStart 1.0 RC project. SolidStart uses vinxi as a build system which provides a wrapper for the vite mdx processor.

When trying to use the plugin, this error occurs when processing an md/mdx file:

  file: src/routes/.../index.md
  at Function.freeze (node_modules/.pnpm/unified@11.0.4/node_modules/unified/lib/index.js:636:36)
  at Function.process (node_modules/.pnpm/unified@11.0.4/node_modules/unified/lib/index.js:716:10)
  at Module.compile (node_modules/.pnpm/@mdx-js+mdx@3.0.1/node_modules/@mdx-js/mdx/lib/compile.js:40:35)
  at transform2 (node_modules/.pnpm/@vinxi+plugin-mdx@3.7.1_@mdx-js+mdx@3.0.1/node_modules/@vinxi/plugin-mdx/dist/index.cjs:1535:30)
  at async Object.transform (node_modules/.pnpm/@vinxi+plugin-mdx@3.7.1_@mdx-js+mdx@3.0.1/node_modules/@vinxi/plugin-mdx/dist/index.cjs:2171:16)
  at async transform (node_modules/.pnpm/rollup@4.17.2/node_modules/rollup/dist/es/shared/node-entry.js:18680:16)
  at async ModuleLoader.addModuleSource (node_modules/.pnpm/rollup@4.17.2/node_modules/rollup/dist/es/shared/node-entry.js:18896:36) 

This issue is the same as the one encountered here and it has an easy workaround.

Just use remarkEmbedder.default instead of remarkEmbedder directly, like I do in the config above. The same goes for the Oembed transformer.

I solved this issue with the debugger but wanted to save someone else the trouble by writing about it here. I'm not sure which piece of the stack is responsible for the problem but the workaround is easy so it's no biggie.

@arnfaldur
Copy link
Author

As I already provided a decent solution and I'm not sure the problem is due to any issue with the code in this repo, I'm just going to close the issue.

If you think that it is an issue with this repo's code, you can of course open it again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant