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 8 react native error on regex from jsdoc-type-pratt-parser #29130

Closed
dannyhw opened this issue Sep 15, 2024 · 2 comments · Fixed by #29134
Closed

[Bug]: storybook 8 react native error on regex from jsdoc-type-pratt-parser #29130

dannyhw opened this issue Sep 15, 2024 · 2 comments · Fixed by #29134

Comments

@dannyhw
Copy link
Member

dannyhw commented Sep 15, 2024

Describe the bug

jsdoc-type-pratt-parser in getQuoted which uses unicode patterns and "Unicode character class escape" which don't seem to be supported on react native

you can see the code here
code/node_modules/jsdoc-type-pratt-parser/dist/index.js

1: /[$_\p{ID_Start}]|\\u\p{Hex_Digit}{4}|\\u\{0*(?:\p{Hex_Digit}{1,5}|10\p{Hex_Digit}{4})\}/u

2: /[$\-\p{ID_Continue}\u200C\u200D]|\\u\p{Hex_Digit}{4}|\\u\{0*(?:\p{Hex_Digit}{1,5}|10\p{Hex_Digit}{4})\}/u

after being bundled into storybook it looks like

    let d = new RegExp("[$_\\p{ID_Start}]|\\\\u\\p{Hex_Digit}{4}|\\\\u\\{0*(?:\\p{Hex_Digit}{1,5}|10\\p{Hex_Digit}{4})\\}", "u"), m = new RegExp(
    "[$\\-\\p{ID_Continue}\\u200C\\u200D]|\\\\u\\p{Hex_Digit}{4}|\\\\u\\{0*(?:\\p{Hex_Digit}{1,5}|10\\p{Hex_Digit}{4})\\}", "u");

image

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Unicode_character_class_escape

Reproduction link

storybookjs/react-native#538

Reproduction steps

  1. Open branch feat/v8
  2. Install (yarn)
  3. Build (yarn build)
  4. comment out lines 62-74 in packages/react-native/metro/withStorybook.js
  5. yarn workspace expo-example storybook

No response

System

Storybook Environment Info:

  System:
    OS: macOS 15.0
    CPU: (10) arm64 Apple M1 Max
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.13.1 - ~/.local/state/fnm_multishells/12353_1726330415155/bin/node
    Yarn: 4.1.0 - ~/Library/pnpm/yarn <----- active
    npm: 10.5.2 - ~/.local/state/fnm_multishells/12353_1726330415155/bin/npm
  Browsers:
    Chrome: 128.0.6613.138
    Safari: 18.0

Additional context

Hermes's implementation of regex is lacking some of the advanced regex features

@valentinpalkovic
Copy link
Contributor

Hi @dannyhw

Could you please try out 0.0.0-pr-29134-sha-a3d75f58?

@dannyhw
Copy link
Member Author

dannyhw commented Sep 16, 2024

@valentinpalkovic it worked! No more error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants