storybookjs / storybook

Storybook is the industry standard workshop for building, documenting, and testing UI components in isolation
https://storybook.js.org
MIT License
84.49k stars 9.29k forks source link

Uncaught TypeError: _typeof3 is not a function when build storybook as a static app #9047

Closed subelta closed 4 years ago

subelta commented 4 years ago

Describe the bug Uncaught TypeError: _typeof3 is not a function when build static files of storybook and try to execute them

To Reproduce Steps to reproduce the behavior:

  1. Write stories for React/TS app, test them with yarn run storybook and have no problems 1.yarn build-storybook ("build-storybook": "build-storybook -c .storybook -o dir-name" or "build-storybook": "build-storybook")
  2. go to directory with built files
  3. open index.html in browser or start a server (npx http-server dir-name)
  4. See empty storybook page stuck on loading and error in the console

Expected behavior Storybook with my React components to run without errors, just like when I do yarn storybook

What tried to do to fix: delete all the stories files and try build again(got the exact same error) delete node_modules, lock file and cache and reinstall dependencies

Screenshots

Screenshot 2019-12-03 at 20 53 01

Code snippets package.json

....
"dependencies": {
    "@babel/core": "7.4.3",
    "@jetbrains/icons": "^3.2.1",
    "@jetbrains/ring-ui": "2.0.41",
    "@svgr/webpack": "4.1.0",
    "@types/jest": "24.0.15",
    "@types/node": "12.0.10",
    "@types/react": "16.8.22",
    "@types/react-dom": "16.8.4",
    "@typescript-eslint/eslint-plugin": "1.6.0",
    "@typescript-eslint/parser": "1.6.0",
    "babel-eslint": "^10.0.3",
    "babel-jest": "^24.8.0",
    "babel-loader": "^8.0.6",
    "babel-plugin-named-asset-import": "^0.3.2",
    "babel-preset-react-app": "^9.0.0",
    "camelcase": "^5.2.0",
    "case-sensitive-paths-webpack-plugin": "2.2.0",
    "color": "^3.1.2",
    "core-js": "2",
    "css-loader": "2.1.1",
    "d3": "^5.9.7",
    "dompurify": "^2.0.7",
    "dotenv": "6.2.0",
    "dotenv-expand": "4.2.0",
    "eslint": "^5.16.0",
    "eslint-config-react-app": "^4.0.1",
    "eslint-loader": "2.1.2",
    "eslint-plugin-flowtype": "2.50.1",
    "eslint-plugin-import": "2.16.0",
    "eslint-plugin-jsx-a11y": "6.2.1",
    "eslint-plugin-react": "7.12.4",
    "eslint-plugin-react-hooks": "^2.1.2",
    "file-loader": "^4.2.0",
    "fs-extra": "7.0.1",
    "html-webpack-plugin": "4.0.0-beta.5",
    "identity-obj-proxy": "3.0.0",
    "is-wsl": "^1.1.0",
    "isomorphic-fetch": "latest",
    "jest": "24.7.1",
    "jest-environment-jsdom-fourteen": "0.1.0",
    "jest-resolve": "24.7.1",
    "jest-watch-typeahead": "0.3.0",
    "mini-css-extract-plugin": "0.5.0",
    "optimize-css-assets-webpack-plugin": "5.0.1",
    "pnp-webpack-plugin": "1.2.1",
    "postcss-flexbugs-fixes": "4.1.0",
    "postcss-loader": "3.0.0",
    "postcss-normalize": "7.0.1",
    "postcss-preset-env": "6.6.0",
    "postcss-safe-parser": "4.0.1",
    "prop-types": "^15.5.7",
    "react": "^16.8.6",
    "react-app-polyfill": "^1.0.1",
    "react-beautiful-dnd": "^11.0.5",
    "react-dev-utils": "^9.0.1",
    "react-dom": "^16.8.6",
    "react-focus-lock": "^2.1.1",
    "react-redux": "^7.1.0",
    "react-scripts": "^3.2.0",
    "redux": "^4.0.4",
    "redux-thunk": "latest",
    "resolve": "1.10.0",
    "semver": "6.0.0",
    "style-loader": "0.23.1",
    "terser-webpack-plugin": "1.2.3",
    "ts-pnp": "1.1.2",
    "typescript": "3.5.2",
    "url-loader": "^2.2.0",
    "uuid": "^3.3.2",
    "webpack": "^4.41.0",
    "webpack-dev-server": "3.2.1",
    "webpack-manifest-plugin": "2.0.4",
    "workbox-webpack-plugin": "4.2.0"
  },
  "scripts": {
    "start": "node scripts/start.js",
    "build": "node scripts/build.js",
    "test": "jest",
    "tslint-check": "tslint-config-prettier-check ./tslint.json",
    "storybook": "start-storybook -p 6006",
    "build-storybook": "build-storybook"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "jest": {
    "collectCoverageFrom": [
      "src/**/*.{js,jsx,ts,tsx}",
      "!src/**/*.d.ts"
    ],
    "setupFiles": [
      "react-app-polyfill/jsdom"
    ],
    "setupFilesAfterEnv": [],
    "testMatch": [
      "<rootDir>/src/**/__tests__/**/*.{js,jsx,ts,tsx}",
      "<rootDir>/src/**/*.{spec,test}.{js,jsx,ts,tsx}"
    ],
    "testEnvironment": "jest-environment-jsdom-fourteen",
    "transform": {
      "^.+\\.(js|jsx|ts|tsx)$": "<rootDir>/node_modules/babel-jest",
      "^.+\\.css$": "<rootDir>/config/jest/cssTransform.js",
      "^(?!.*\\.(js|jsx|ts|tsx|css|json)$)": "<rootDir>/config/jest/fileTransform.js"
    },
    "transformIgnorePatterns": [
      "[/\\\\]node_modules[/\\\\](?!(@jetbrains|react-virtualized)).+\\.(js|jsx|ts|tsx)$",
      "^.+\\.module\\.(css|sass|scss)$"
    ],
    "modulePaths": [],
    "moduleNameMapper": {
      "^react-native$": "react-native-web",
      "^.+\\.module\\.(css|sass|scss)$": "identity-obj-proxy",
      "\\.(svg|po)$": "<rootDir>/__mocks__/fileMock.js"
    },
    "moduleFileExtensions": [
      "web.js",
      "js",
      "web.ts",
      "ts",
      "web.tsx",
      "tsx",
      "json",
      "web.jsx",
      "jsx",
      "node"
    ],
    "watchPlugins": [
      "jest-watch-typeahead/filename",
      "jest-watch-typeahead/testname"
    ]
  },
  "devDependencies": {
    "@babel/plugin-proposal-class-properties": "^7.7.0",
    "@jetbrains/babel-preset-jetbrains": "^2.1.4",
    "@storybook/addon-actions": "^5.1.9",
    "@storybook/addon-knobs": "^5.1.9",
    "@storybook/addon-notes": "^5.2.4",
    "@storybook/addon-storyshots": "^5.1.9",
    "@storybook/addon-storysource": "^5.2.4",
    "@storybook/react": "^5.1.9",
    "css-loader": "2.1.1",
    "prettier": "^1.18.2",
    "react-test-renderer": "^16.8.6",
    "redux-devtools-extension": "^2.13.8",
    "require-context.macro": "^1.0.4",
    "style-loader": "0.23.1",
    "tslint": "^5.18.0",
    "tslint-config-prettier": "^1.18.0",
    "tslint-plugin-prettier": "^2.0.1",
    "tslint-react": "^4.0.0"
  }
}

System: Macbook pro 2019 Mac OS 10.15.11

subelta commented 4 years ago

Fixed by adding "exclude: /node_modules/" next to babel-loader in webpack.config.js (in my case it was webpack.config.js in .storybook dir)

marciocamello commented 2 years ago

If I try to build with minify disabled result on this error

image