doczjs / docz

✍ It has never been so easy to document your things!
https://docz.site
MIT License
23.61k stars 1.46k forks source link

react-native is not fully supported properly #1654

Open renatobenks opened 3 years ago

renatobenks commented 3 years ago

Bug Report

Describe the bug

react-native is not fully supported properly.

To Reproduce

  1. Have a react-native app (apparently not expo) using a similar project structure from react-nativee init (react-native-cli)
  2. Add docz to the project, and create some .mdx file as documentation
  3. Run docz dev
  4. See the following webpack compiling build errors:

extracted from https://github.com/doczjs/docz/issues/1653

 ERROR #98123  WEBPACK

Generating development SSR bundle failed

Unexpected token (12:37)

File: ../node_modules/expo-asset/build/PlatformUtils.js:12:37

 ERROR #98123  WEBPACK

Generating development SSR bundle failed

Unexpected token (130:8)

File: ../node_modules/react-native-reanimated/lib/reanimated1/core/AnimatedBezier.js:130:8

 ERROR #98123  WEBPACK

Generating development SSR bundle failed

Unexpected token (13:44)

File: ../node_modules/expo-asset/build/EmbeddedAssets.js:13:44

 ERROR #98123  WEBPACK

Generating development SSR bundle failed

Unexpected token (13:7)

File: ../node_modules/react-native/Libraries/Image/AssetRegistry.js:13:7

 ERROR #98123  WEBPACK

Generating development SSR bundle failed

Unexpected token (13:7)

File: ../node_modules/react-native/Libraries/Image/AssetSourceResolver.js:13:7

 ERROR #98123  WEBPACK

Generating development SSR bundle failed

Unexpected token (13:7)

File: ../node_modules/react-native/index.js:13:7

 ERROR #98123  WEBPACK

Generating development SSR bundle failed

Unexpected token (14:11)

File: ../node_modules/react-native-reanimated/lib/reanimated1/core/AnimatedCall.js:14:11

 ERROR #98123  WEBPACK

Generating development SSR bundle failed

Unexpected token (18:12)

File: ../node_modules/react-native/Libraries/Image/resolveAssetSource.js:18:12

 ERROR #98123  WEBPACK

Generating development SSR bundle failed

Unexpected token (36:6)

File: ../node_modules/react-native-reanimated/lib/reanimated1/Transitioning.js:36:6

 ERROR #98123  WEBPACK

Generating development SSR bundle failed

Unexpected token (48:32)

File: ../node_modules/expo-constants/build/Constants.js:48:32

 ERROR #98123  WEBPACK

Generating development SSR bundle failed

Unexpected token (4:12)

File: ../node_modules/react-native-reanimated/lib/reanimated1/core/AnimatedClockTest.js:4:12

 ERROR #98123  WEBPACK

Generating development SSR bundle failed

Unexpected token (65:8)

File: ../node_modules/react-native-reanimated/lib/reanimated1/core/AnimatedOperator.js:65:8

 ERROR #98123  WEBPACK

Generating development SSR bundle failed

Unexpected token (69:40)

File: ../node_modules/react-native-reanimated/lib/createAnimatedComponent.js:69:40

 ERROR #98123  WEBPACK

Generating development SSR bundle failed

Unexpected token (6:16)

File: ../node_modules/react-native-reanimated/lib/reanimated1/core/AnimatedClock.js:6:16

 ERROR #98123  WEBPACK

Generating development SSR bundle failed

Unexpected token (6:7)

File: ../node_modules/react-native-reanimated/lib/reanimated1/core/AnimatedAlways.js:6:7

 ERROR #98123  WEBPACK

Generating development SSR bundle failed

Unexpected token (7:12)

File: ../node_modules/react-native-reanimated/lib/reanimated1/core/AnimatedCond.js:7:12

 ERROR #98123  WEBPACK

Generating development SSR bundle failed

Unexpected token (7:12)

File: ../node_modules/react-native-reanimated/lib/reanimated1/core/AnimatedStartClock.js:7:12

 ERROR #98123  WEBPACK

Generating development SSR bundle failed

Unexpected token (7:12)

File: ../node_modules/react-native-reanimated/lib/reanimated1/core/AnimatedStopClock.js:7:12

 ERROR #98123  WEBPACK

Generating development SSR bundle failed

Unexpected token (7:7)

File: ../node_modules/react-native-reanimated/lib/reanimated1/core/AnimatedSet.js:7:7

 ERROR #98123  WEBPACK

Generating development SSR bundle failed

Unexpected token (7:8)

File: ../node_modules/react-native-reanimated/lib/reanimated1/core/AnimatedBlock.js:7:8

 ERROR #98123  WEBPACK

Generating development SSR bundle failed

Unexpected token (83:10)

File: ../node_modules/react-native-reanimated/lib/reanimated1/core/AnimatedNode.js:83:10

 ERROR #98123  WEBPACK

Generating development SSR bundle failed

Unexpected token (8:7)

File: ../node_modules/react-native-reanimated/lib/reanimated1/core/AnimatedFunction.js:8:7

 ERROR #98123  WEBPACK

Generating development SSR bundle failed

Unexpected token (98:13)

File: ../node_modules/react-native-reanimated/lib/reanimated1/core/AnimatedEvent.js:98:13

 ERROR #98123  WEBPACK

Generating development SSR bundle failed

Unexpected token (9:10)

File: ../node_modules/react-native-reanimated/lib/reanimated1/core/AnimatedDebug.js:9:10

not finished Building development bundle - 5.390s

Expected behavior

Projects in react-native should be fully far at this far, using a smarter file-system discovery, we need to support it without any additional magic thing in config to use docz smoothly.

Because as it seems, we still have a lot of work to do to improve the docz DX with react-native, at least catching errors with better feedback and offering a better error-prone experience.

So, this issue is an entry-point to incrementally make the react-native experience with docz better, based on the following issues: https://github.com/doczjs/docz/issues/1652 https://github.com/doczjs/docz/issues/1637 https://github.com/doczjs/docz/issues/1633

Additional context/Screenshots