Closed justingrant closed 8 months ago
There's a built-in compiler for MDX files, but it's currently limited to being auto-enabled only if @mdx-js/mdx
or astro
is in the list of dependencies (source code).
I guess we can add a dependency to the list of "enablers" here. What should that be? Some Storybook plugin?
To enable it today (without waiting for a fix in v4). In Knip v3, this was how you had to add it explicitly, and this should still work in v4:
https://knip.dev/v3/features/compilers#mdx
You can use any MDX compiler instead of the suggested one in the example (or even a regex like the other examples on the same page). Or copy the regex from Knip source code.
It looks like Storybook supports MDX without the need of any subpackage, so the dependency to add could just be storybook
.
Going to close this one:
mdx
compiler is auto-activated if @mdx-js/mdx
or astro
is listedThere's still the option to use different/custom compiler.
@webpro Writing stories in MDX was removed but writing docs for you storybooks in MDX is very much still in place.
It's be great if knip supported .mdx files which are used by Storybook and other documentation generators. In our project, there are a few internal-facing exports that are referenced only in our docs but don't (currently) have runtime code accessing them.
A good example of this is a color palette, where we export categories of colors (
reds
,greens
, etc.) so our dev docs can show a well-arranged palette page in the docs for our team members to choose from. But no actual code in our project importsgreens
. Instead, we import individual colors. Butgreens
is not an unused export, because it's used by our docs.Other than for documentation, AFAIK MDX is also sometimes used more generally as a low-cost way to generate mostly-static content.