Skip to content

Commit

Permalink
add rollup workaround
Browse files Browse the repository at this point in the history
  • Loading branch information
yannbf committed Mar 16, 2024
1 parent c13cfed commit d085032
Show file tree
Hide file tree
Showing 3 changed files with 277 additions and 35 deletions.
11 changes: 11 additions & 0 deletions packages/docs/.storybook/main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { dirname, join } from "path";
import replace from '@rollup/plugin-replace';

import { StorybookConfig } from "@storybook/react-vite";
import { mergeConfig } from "vite";
Expand All @@ -25,6 +26,16 @@ const config: StorybookConfig = {
resolve: {
preserveSymlinks: true,
},
plugins: [
// Workaround necessary because of a bug in Vite
// They replace the string process.env.NODE_ENV at build time,
// but they don't properly skip replacing globalThis.process.env.NODE_ENV so that graphql check becomes globalThis."development", which is invalid
// https://github.com/graphql/graphql-js/issues/3918#issuecomment-1692475931
replace({
preventAssignment: true,
'globalThis.process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
}),
]
});
},
};
Expand Down
3 changes: 2 additions & 1 deletion packages/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"dependencies": {
"@apollo/client": "^3.3.6",
"axios": "^0.21.1",
"graphql": "^15.4.0",
"graphql": "16.6.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-query": "^3.5.5",
Expand All @@ -37,6 +37,7 @@
"urql": "^1.11.4"
},
"devDependencies": {
"@rollup/plugin-replace": "^5.0.5",
"@storybook/addon-a11y": "^7.6.0",
"@storybook/addon-actions": "^7.6.0",
"@storybook/addon-essentials": "^7.6.0",
Expand Down

0 comments on commit d085032

Please sign in to comment.