storybookjs / storybook

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

[Bug]: Silent fail when building results with incomplete build #19649

Open gbkwiatt opened 2 years ago

gbkwiatt commented 2 years ago

Describe the bug

In my case there was an issue with *.md being treated as mdx, so anything with { } and without backtick, was failing with Could not parse expression with acorn: Unexpected token

However whole build was not failing and completing with success. But as a result there was missing files in storybook-static output dir. ( missing iframe.html )

You can see those errors in logs from build, but it's very easy to miss, especially that build does not report error at all.

To Reproduce

Create mdx file that has incorrect text format inside.

System

No response

Additional context

No response

JReinhold commented 2 years ago

I know you and I talked about this yesterday, but I'm actually unable to reproduce this in v7.0.0-alpha.45.

Adding {hello} to an mdx file will cause the doc to not render at all, but the build will work fine and produce an iframe.html

Adding {[key: string]: string} like I know you tried will make both dev and the build fail explicitly with a syntax error like

ERR! [12:6: Could not parse expression with acorn: Unexpected token] {
ERR!   reason: 'Could not parse expression with acorn: Unexpected token',
ERR!   line: 12,
ERR!   column: 6,
ERR!   source: 'micromark-extension-mdx-expression',
ERR!   ruleId: 'acorn',
ERR!   position: {
ERR!     start: { line: 12, column: 6, offset: 437 },
ERR!     end: { line: null, column: null }
ERR!   }
ERR! }                                      

The reason these two lines don't work is that MDX2 parses {...} as JavaScript, so {hello} will result in "hello is undefined" while {[key: string]: string} will result in an unexpected token.