-
Notifications
You must be signed in to change notification settings - Fork 53
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
TypeError: attacher.call
is not a function when using remark-shiki-twoslash
with unified
#147
Comments
Interesting, perhaps there's different constraints when running inside a module - I don't have any code which runs in ESM node, so I've not hit it. Open to PRs though 👍🏻 |
Heya @mattcroat Can you try using: .use([
[shikiTwoslash.default, { theme: 'dark-plus' }]
// ...
]) Have updated your example as well: https://stackblitz.com/edit/node-shiki-twoslash-tcez4v and it appears to be working as expected. I ran into a similar issue using |
@chopfitzroy ’s advice is useful I Think |
It occurs because you list the esm entrypoint through the To fix it, you have to list in the package.json something akin to: {
"main": "./dist/index.js",
"module": "./dist/remark-shiki-twoslash.esm.mjs",
"typings": "./dist/index.d.ts",
"exports": {
".": {
"import": "./dist/remark-shiki-twoslash.esm.mjs",
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
}
}
} Note that the esm file also needs to have its extension be |
When I use the const nextConfig = {
reactStrictMode: true,
webpack: (config, options) => {
config.module.rules.push({
test: /\.mdx?$/,
use: [
options.defaultLoaders.babel,
{
loader: '@mdx-js/loader',
options: {
providerImportSource: '@mdx-js/react',
remarkPlugins: [
remarkFrontmatter,
[remarkShikiTwoslash.default, {
themes: ['dark-plus', 'light-plus'],
alwayRaiseForTwoslashExceptions: true,
// https://github.com/shikijs/twoslash/issues/131
disableImplicitReactImport: true,
}],
remarkGfm,
remarkMath,
],
rehypePlugins: [
[rehypeKatex, { throwOnError: true, strict: true, output: 'mathml' }],
rehypeSlug,
[rehypeAutolinkHeadings, { behavior: 'wrap' }],
// [withShiki, { highlighter }],
[template, { template: wrapTemplate }]
],
},
},
],
});
// Fixes npm packages (mdx) that depend on `fs` module
if (!options.isServer) {
config.resolve.fallback.fs = false
}
return config;
},
pageExtensions: ['js', 'jsx', 'tsx', 'md', 'mdx'],
images: {
loader: 'imgix',
path: 'https://images.unsplash.com/',
},
}; |
Hey! 👋
I'm using
remark-shiki-twoslash
withunified
and I get this errorTypeError: attacher.call is not a function.
I already opened a discussion at unifiedjs/unified#187 but I was told to raise the issue here.Here is the reproduction on StackBlitz. I have a simple Express server without TypeScript and I use
"type": "module"
inpackage.json
.The text was updated successfully, but these errors were encountered: