Skip to content

Commit

Permalink
Merge pull request #24166 from storybookjs/fix-yarn-pnp
Browse files Browse the repository at this point in the history
Fix(builder-vite): Move mdx-plugin from @storybook/builder-vite to @storybook/addon-docs
  • Loading branch information
ndelangen authored Sep 22, 2023
2 parents df96c9d + 0f5e6c1 commit b308e54
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 14 deletions.
4 changes: 3 additions & 1 deletion code/addons/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,11 @@
"ts-dedent": "^2.0.0"
},
"devDependencies": {
"@rollup/pluginutils": "^5.0.2",
"react": "^16.14.0",
"react-dom": "^16.8.0",
"typescript": "~4.9.3"
"typescript": "~4.9.3",
"vite": "^4.0.4"
},
"peerDependencies": {
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { Options } from '@storybook/types';
import type { Plugin } from 'vite';
import remarkSlug from 'remark-slug';
import remarkExternalLinks from 'remark-external-links';
import { createFilter } from 'vite';
import { createFilter } from '@rollup/pluginutils';
import { dirname, join } from 'path';

const isStorybookMdx = (id: string) => id.endsWith('stories.mdx') || id.endsWith('story.mdx');
Expand Down
9 changes: 9 additions & 0 deletions code/addons/docs/src/preset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,15 @@ export const addons: StorybookConfig['addons'] = [
require.resolve('@storybook/react-dom-shim/dist/preset'),
];

export const viteFinal = async (config: any, options: Options) => {
const { plugins = [] } = config;
const { mdxPlugin } = await import('./plugins/mdx-plugin');

plugins.push(mdxPlugin(options));

return config;
};

/*
* This is a workaround for https://github.com/Swatinem/rollup-plugin-dts/issues/162
* something down the dependency chain is using typescript namespaces, which are not supported by rollup-plugin-dts
Expand Down
6 changes: 0 additions & 6 deletions code/builders/builder-vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
"@storybook/client-logger": "workspace:*",
"@storybook/core-common": "workspace:*",
"@storybook/csf-plugin": "workspace:*",
"@storybook/mdx2-csf": "^1.0.0",
"@storybook/node-logger": "workspace:*",
"@storybook/preview": "workspace:*",
"@storybook/preview-api": "workspace:*",
Expand All @@ -59,8 +58,6 @@
"find-cache-dir": "^3.0.0",
"fs-extra": "^11.1.0",
"magic-string": "^0.30.0",
"remark-external-links": "^8.0.0",
"remark-slug": "^6.0.0",
"rollup": "^2.25.0 || ^3.3.0"
},
"devDependencies": {
Expand Down Expand Up @@ -96,9 +93,6 @@
"entries": [
"./src/index.ts"
],
"externals": [
"@storybook/mdx1-csf"
],
"platform": "node"
},
"gitHead": "e6a7fd8a655c69780bc20b9749c2699e44beae17"
Expand Down
1 change: 0 additions & 1 deletion code/builders/builder-vite/src/plugins/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export * from './inject-export-order-plugin';
export * from './mdx-plugin';
export * from './strip-story-hmr-boundaries';
export * from './code-generator-plugin';
export * from './csf-plugin';
Expand Down
2 changes: 0 additions & 2 deletions code/builders/builder-vite/src/vite-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
codeGeneratorPlugin,
csfPlugin,
injectExportOrderPlugin,
mdxPlugin,
stripStoryHMRBoundary,
externalGlobalsPlugin,
} from './plugins';
Expand Down Expand Up @@ -81,7 +80,6 @@ export async function pluginConfig(options: Options) {
const plugins = [
codeGeneratorPlugin(options),
await csfPlugin(options),
await mdxPlugin(options),
injectExportOrderPlugin,
stripStoryHMRBoundary(),
{
Expand Down
5 changes: 2 additions & 3 deletions code/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5906,6 +5906,7 @@ __metadata:
dependencies:
"@jest/transform": ^29.3.1
"@mdx-js/react": ^2.1.5
"@rollup/pluginutils": ^5.0.2
"@storybook/blocks": "workspace:*"
"@storybook/client-logger": "workspace:*"
"@storybook/components": "workspace:*"
Expand All @@ -5926,6 +5927,7 @@ __metadata:
remark-slug: ^6.0.0
ts-dedent: ^2.0.0
typescript: ~4.9.3
vite: ^4.0.4
peerDependencies:
react: ^16.8.0 || ^17.0.0 || ^18.0.0
react-dom: ^16.8.0 || ^17.0.0 || ^18.0.0
Expand Down Expand Up @@ -6531,7 +6533,6 @@ __metadata:
"@storybook/client-logger": "workspace:*"
"@storybook/core-common": "workspace:*"
"@storybook/csf-plugin": "workspace:*"
"@storybook/mdx2-csf": ^1.0.0
"@storybook/node-logger": "workspace:*"
"@storybook/preview": "workspace:*"
"@storybook/preview-api": "workspace:*"
Expand All @@ -6546,8 +6547,6 @@ __metadata:
fs-extra: ^11.1.0
glob: ^10.0.0
magic-string: ^0.30.0
remark-external-links: ^8.0.0
remark-slug: ^6.0.0
rollup: ^3.20.1
slash: ^5.0.0
typescript: ~4.9.3
Expand Down

0 comments on commit b308e54

Please sign in to comment.