react-styleguidist icon indicating copy to clipboard operation
react-styleguidist copied to clipboard

Installed webpack, babel, styleguidist and ends up throwing error when built

Open umakantp opened this issue 1 year ago • 2 comments

Current behaviour

Styleguidist breaks with showing es6 or typescript files as not parsable and breaks. I have no file in my broken yet, just webpack, babel, styleguidist and bare minimum config for styleguidist.

To reproduce

  1. git clone https://github.com/umakantp/styleguidist-broken
  2. npm install
  3. npm run build

Error seen on screen

> [email protected] build
> styleguidist build

Building style guide...
 FAIL  Failed to compile

node_modules/markdown-to-jsx/index.js from Terser plugin
Unexpected token: operator (<) [node_modules/markdown-to-jsx/index.js:779,21]
node_modules/tiny-warning/src/index.js from Terser plugin
Missing initializer in const declaration [node_modules/tiny-warning/src/index.js:2,18]
node_modules/@babel/helpers/scripts/generate-regenerator-runtime.js from Terser plugin
Unexpected token: name (Promise) [node_modules/@babel/helpers/scripts/generate-regenerator-runtime.js:6,32]
node_modules/@babel/plugin-proposal-private-property-in-object/lib/index.js from Terser plugin
'return' outside of function [node_modules/@babel/plugin-proposal-private-property-in-object/lib/index.js:25,2]
node_modules/@webassemblyjs/helper-numbers/src/index.js from Terser plugin
Unexpected token punc «:», expected punc «,» [node_modules/@webassemblyjs/helper-numbers/src/index.js:7,37]
node_modules/@webassemblyjs/ieee754/src/index.js from Terser plugin
Unexpected token punc «:», expected punc «,» [node_modules/@webassemblyjs/ieee754/src/index.js:21,27]
node_modules/has-symbols/test/shams/core-js.js from Terser plugin
'return' outside of function [node_modules/has-symbols/test/shams/core-js.js:11,1]
node_modules/has-symbols/test/shams/get-own-property-symbols.js from Terser plugin
'return' outside of function [node_modules/has-symbols/test/shams/get-own-property-symbols.js:11,1]
node_modules/jss/src/flow-types/cssom.js from Terser plugin
Unexpected token: name (StylePropertyMap) [node_modules/jss/src/flow-types/cssom.js:5,17]
node_modules/jss/src/flow-types/dom.js from Terser plugin
Unexpected token: name (DOMString) [node_modules/jss/src/flow-types/dom.js:5,12]
node_modules/jss/src/flow-types/jss.js from Terser plugin
Unexpected token name «Jss», expected name «from» [node_modules/jss/src/flow-types/jss.js:2,12]
node_modules/istanbul-reports/lib/html-spa/src/fileBreadcrumbs.js from Terser plugin
Unexpected token: operator (<) [node_modules/istanbul-reports/lib/html-spa/src/fileBreadcrumbs.js:20,12]
node_modules/istanbul-reports/lib/html-spa/src/flattenToggle.js from Terser plugin
Unexpected token: operator (<) [node_modules/istanbul-reports/lib/html-spa/src/flattenToggle.js:5,8]
node_modules/istanbul-reports/lib/html-spa/src/filterToggle.js from Terser plugin
Unexpected token: operator (<) [node_modules/istanbul-reports/lib/html-spa/src/filterToggle.js:5,8]
node_modules/istanbul-reports/lib/html-spa/src/index.js from Terser plugin
Unexpected token: operator (<) [node_modules/istanbul-reports/lib/html-spa/src/index.js:93,8]
node_modules/istanbul-reports/lib/html-spa/src/summaryHeader.js from Terser plugin
Unexpected token: operator (<) [node_modules/istanbul-reports/lib/html-spa/src/summaryHeader.js:26,8]
node_modules/istanbul-reports/lib/html-spa/src/summaryTableHeader.js from Terser plugin
Unexpected token: operator (<) [node_modules/istanbul-reports/lib/html-spa/src/summaryTableHeader.js:27,8]
node_modules/istanbul-reports/lib/html-spa/src/summaryTableLine.js from Terser plugin
Unexpected token: operator (<) [node_modules/istanbul-reports/lib/html-spa/src/summaryTableLine.js:7,8]

Expected behavior

It should create, build and generate a minimum style guide based on config.

Notes I feel this issue could be due to Webpack not being configured properly. It works as expected when we do npm run start i.e. server. But fails on the building part.

umakantp avatar Dec 27 '23 11:12 umakantp

I added a verbose flag and as I said, it could be Webpack config. I get following details:

Loading components:

clean-webpack-plugin: pausing due to webpack errors
 FAIL  Failed to compile

node_modules/markdown-to-jsx/index.js from Terser plugin
Unexpected token: operator (<) [node_modules/markdown-to-jsx/index.js:779,21]
    at js_error (/Users/user/projects/styleguidist/node_modules/terser/dist/bundle.min.js:549:11)
    at croak (/Users/user/projects/styleguidist/node_modules/terser/dist/bundle.min.js:1273:9)
    at token_error (/Users/user/projects/styleguidist/node_modules/terser/dist/bundle.min.js:1281:9)
    at unexpected (/Users/user/projects/styleguidist/node_modules/terser/dist/bundle.min.js:1287:9)
    at expr_atom (/Users/user/projects/styleguidist/node_modules/terser/dist/bundle.min.js:2563:9)
    at maybe_unary (/Users/user/projects/styleguidist/node_modules/terser/dist/bundle.min.js:3421:19)
    at expr_ops (/Users/user/projects/styleguidist/node_modules/terser/dist/bundle.min.js:3472:24)
    at maybe_conditional (/Users/user/projects/styleguidist/node_modules/terser/dist/bundle.min.js:3477:20)
    at maybe_assign (/Users/user/projects/styleguidist/node_modules/terser/dist/bundle.min.js:3554:20)
    at expression (/Users/user/projects/styleguidist/node_modules/terser/dist/bundle.min.js:3589:24)
node_modules/tiny-warning/src/index.js from Terser plugin
Missing initializer in const declaration [node_modules/tiny-warning/src/index.js:2,18]
    at js_error (/Users/user/projects/styleguidist/node_modules/terser/dist/bundle.min.js:549:11)
    at croak (/Users/user/projects/styleguidist/node_modules/terser/dist/bundle.min.js:1273:9)

umakantp avatar Dec 27 '23 16:12 umakantp

More info to add. Interestingly minimize: false in the config, fixes the problem

umakantp avatar Dec 27 '23 16:12 umakantp