Open mhartington opened 4 years ago
It seems to be a problem when using gatsby-theme-mdx-deck
and importing a component that imports something from mdx-deck
.
For example, this deck fails:
import Component from "./component"
## Hi
When component.js
imports something from mdx-deck
:
// component.js
import React from "react";
import { useSteps } from "mdx-deck";
export default props => {
const length = 4;
const step = useSteps(length);
return (
<h2>
The current step is {step}/{length}
</h2>
);
};
So I sort of fixed it so far. I was getting an error about webpack, so I added a silly webpack rule (sorry I don't really know what I'm doing):
exports.onCreateWebpackConfig = ({ actions, loaders, getConfig }) => {
const config = getConfig()
config.module.rules = [
...config.module.rules,
{
...loaders.js(),
test: /\.js?$/,
// Exclude all node_modules from transpilation, except for 'the gatsby-plugin/src'
exclude: modulePath =>
/node_modules/.test(modulePath) &&
!/node_modules\/(@mdx-deck\/gatsby-plugin\/src)/.test(modulePath),
},
]
// This will completely replace the webpack config with the modified object.
actions.replaceWebpackConfig(config)
}
CodeSurfer isn't working entirely right, but at least it's compiling.
Okay, downgrading to v3 solved my CodeSurfer problems, at least.
I think it's something to do with the gatsby theme, because in a standalone, CodeSurfer and v4 work fine together.
👋 Hey there!
I just threw together a sample project with v4/gatsby and code-surfer@v3. When I attempted to run
gatsby develop
I got this errorIt seems to be related to code-surfer, though the error being printed is pointing to mdx-deck, so I figured I'd open an issue here and on code-surfer's repo.
Below is a sample project that should be able to recreate the error.
Sample Project: https://github.com/mhartington/mdx-deck-v4-issue