Skip to content
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

[Bug]: storybook react-vite build throw JavaScript error on autodocs #26944

Open
hiren3897 opened this issue Apr 24, 2024 · 1 comment
Open

Comments

@hiren3897
Copy link

Describe the bug

The storybook doesnt build the Docs in the storybook-static directory

To Reproduce

When I run my storybook on localhost I can see the story Documentation but when I build the storybook and serve the storybook-static The Documentation of the docs doesnt appear and I see some warning/error in the console mentioned below

Following ERROR

runtime.js:121 Uncaught (in promise) ReferenceError: Cannot access 'Mo' before initialization
    at DocsRenderer-K4EAMTC…11396af.js:159:8822
renderToElement	@	runtime.js:121
await in renderToElement (async)		
renderSelection	@	runtime.js:121
await in renderSelection (async)		
onSetCurrentStory	@	runtime.js:121
await in onSetCurrentStory (async)		
(anonymous)	@	runtime.js:7
handleEvent	@	runtime.js:7
(anonymous)	@	runtime.js:7
handler	@	runtime.js:7
handleEvent	@	runtime.js:7
postMessage (async)		
(anonymous)	@	chunk-RHK3WMPG.js:16
send	@	chunk-RHK3WMPG.js:16
(anonymous)	@	chunk-RHK3WMPG.js:16
handler	@	chunk-RHK3WMPG.js:16
emit	@	chunk-RHK3WMPG.js:16
emit	@	chunk-RHK3WMPG.js:21
(anonymous)	@	chunk-O6NCVXC4.js:177
commitHookEffectListMount	@	chunk-UOBNU442.js:98
commitPassiveMountOnFiber	@	chunk-UOBNU442.js:111
commitPassiveMountEffects_complete	@	chunk-UOBNU442.js:111
commitPassiveMountEffects_begin	@	chunk-UOBNU442.js:111
commitPassiveMountEffects	@	chunk-UOBNU442.js:111
flushPassiveEffectsImpl	@	chunk-UOBNU442.js:111
flushPassiveEffects	@	chunk-UOBNU442.js:111
commitRootImpl	@	chunk-UOBNU442.js:111
commitRoot	@	chunk-UOBNU442.js:111
performSyncWorkOnRoot	@	chunk-UOBNU442.js:111
flushSyncCallbacks	@	chunk-UOBNU442.js:32
(anonymous)	@	chunk-UOBNU442.js:111
````

### System

```bash
Storybook Environment Info:
(node:125689) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)

  System:
    OS: Linux 6.8 Ubuntu 22.04.4 LTS 22.04.4 LTS (Jammy Jellyfish)
    CPU: (16) x64 AMD Ryzen 7 5825U with Radeon Graphics
    Shell: 5.1.16 - /bin/bash
  Binaries:
    Node: 21.4.0 - ~/.nvm/versions/node/v21.4.0/bin/node
    Yarn: 1.22.19 - /usr/bin/yarn
    npm: 10.2.5 - ~/.nvm/versions/node/v21.4.0/bin/npm
    pnpm: 8.15.1 - ~/.local/share/pnpm/pnpm <----- active
  Browsers:
    Chrome: 123.0.6312.105
  npmPackages:
    @storybook/addon-controls: ^8.0.6 => 8.0.7 
    @storybook/addon-docs: ^8.0.6 => 8.0.7 
    @storybook/addon-interactions: ^8.0.5 => 8.0.7 
    @storybook/addon-links: ^8.0.5 => 8.0.7 
    @storybook/addon-onboarding: ^8.0.5 => 8.0.7 
    @storybook/addon-viewport: ^8.0.6 => 8.0.7 
    @storybook/blocks: ^8.0.5 => 8.0.7 
    @storybook/builder-vite: ^8.0.6 => 8.0.7 
    @storybook/react: ^8.0.5 => 8.0.7 
    @storybook/react-vite: ^8.0.5 => 8.0.7 
    @storybook/test: ^8.0.5 => 8.0.7 
    eslint-plugin-storybook: ^0.8.0 => 0.8.0 
    storybook: ^8.0.5 => 8.0.7

Additional context

// .storybook/main.ts
import type { StorybookConfig } from "@storybook/react-vite";

const config: StorybookConfig = {
  stories: ["../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"],
  addons: [
    "@storybook/addon-links",
    "@storybook/addon-docs",
    "@chromatic-com/storybook",
    "@storybook/addon-controls",
    "@storybook/addon-viewport",
    "@storybook/addon-interactions",
    "@storybook/addon-backgrounds"
  ],
  typescript: {
    reactDocgen: "react-docgen-typescript",
    reactDocgenTypescriptOptions: {
      exclude: [
        "../src/cornerstone/tools/*Tool.ts"
      ],
    }
  },
  staticDirs: ['../public'],
  core: {
    builder: "@storybook/builder-vite",
  },
  framework: {
    name: "@storybook/react-vite",
    options: {},
  },
  docs: {
    autodocs: "tag",
    defaultName: 'Documentation',
    docsMode: false,
  },
};
export default config;
import { StoryObj, Meta } from "@storybook/react";
import { IoMdConstruct } from "react-icons/io";

import AntDIcon from "components/UI/AntdIcon";
import "./mock-css.css";

const meta = {
  title: "STORIES/UI/AntDIcon",
  component: AntDIcon,
  parameters: {
    layout: "centered",
  },
  tags: ["autodocs"],
} satisfies Meta<typeof AntDIcon>;

export default meta;

type Story = StoryObj<typeof meta>;

export const Default: Story = {
  args: {
    icon: IoMdConstruct,
  },
};
export const WithSize: Story = {
  args: {
    icon: IoMdConstruct,
    size: "48",
  },
};

export const WithColor: Story = {
  args: {
    icon: IoMdConstruct,
    color: "red",
  },
};

export const WithCustomClass: Story = {
  args: {
    icon: IoMdConstruct,
    className: "custom-icon",
  },
};
@hiren3897
Copy link
Author

hiren3897 commented Apr 30, 2024

More Info:

theme:React2.useContext(ThemeContext)},ele=props.children(content);return hasRendered=!0,React2.createElement(React2.Fragment,null,React2.createElement(Insertion3,{cache,serializedArr}),ele)});process.env.NODE_ENV!=="production"&&(ClassNames.displayName="EmotionClassNames");process.env.NODE_ENV!=="production"&&(isBrowser5=typeof document<"u",isTestEnv=typeof jest<"u"||typeof vi<"u",isBrowser5&&!isTestEnv&&(globalContext=typeof globalThis<"u"?globalThis:isBrowser5?window:global,globalKey="_EMOTION_REACT"

The error points out on ;process.env.NODE_ENV!=="production" as runtime.js:121 Uncaught (in promise) ReferenceError: Cannot access 'Po' before initialization at DocsRenderer-K4EAMTC…11396af.js:159:8822

in file path

../node_modules/.pnpm/@storybook+addon-docs@8.0.7/node_modules/@storybook/theming/dist/index.js

image

@hiren3897 hiren3897 changed the title [Bug]: auto docs doesn't build in static-storybook 8 [Bug]: storybook react-vite build throw JavaScript error on autodocs May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant