doczjs / docz

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

bug: typescript error in umi project with docz, Generating development SSR bundle failed #1619

Open et-hh opened 3 years ago

et-hh commented 3 years ago

Bug Report

Describe the bug

use docz in umi project,there will be typescript error, and can't successfully run yarn docz dev

To Reproduce

  1. mkdir myapp && cd myapp && git clone https://github.com/zhouJiecode/testDocz.git && yarn
  2. yarn docz dev
Building app
success open and validate gatsby-configs - 2.342s
success load plugins - 1.474s
success onPreInit - 0.070s
success initialize cache - 0.146s
success copy gatsby files - 0.292s
success onPreBootstrap - 1.429s
success createSchemaCustomization - 0.004s
⠦ source and transform nodes
‼  warning   No cache was found with your props definitions
‼  warning   We'll parse your components to get props from them
success Checking for changed pages - 0.002s
success source and transform nodes - 1.566s
success building schema - 0.356s
info Total nodes: 124, SitePage nodes: 1 (use --verbose for breakdown)
success createPages - 0.006s
success Checking for changed pages - 0.003s
success createPagesStatefully - 0.273s
success update schema - 0.035s
success write out redirect data - 0.002s
success onPostBootstrap - 0.002s
info bootstrap finished - 13.851s
success onPreExtractQueries - 0.001s
success extract queries from components - 0.105s
success write out requires - 0.014s
success run static queries - 0.022s - 1/1 45.75/s
success run page queries - 0.023s - 3/3 132.05/s

 ERROR #98123  WEBPACK

Generating development SSR bundle failed

D:\test\docz-master\docz-master\examples\myapp\src\.umi\core\history.ts:
Unexpected token (14:2)

  12 | let history: History = process.env.__IS_SERVER ? null :
createBrowserHistory(options);
  13 | export const createHistory = (hotReload = false) => {
> 14 |   if (!hotReload) {
     |   ^
  15 |     history = createBrowserHistory(options);
  16 |   }
  17 |

File: ..\src\.umi\core\history.ts:14:2

not finished Building development bundle - 24.229s

Expected behavior run dev success

Environment

Additional context/Screenshots image

et-hh commented 3 years ago

i think this is a loader problem. i find that docz deal .ts with

{
    test: /\.tsx?$/,
    use: {
      options: {
        stage: 'develop-html',
        reactRuntime: 'classic',
        cacheDirectory: 'D:\\test\\docz-master\\docz-master\\examples\\myapp\\.doc
  z\\.cache\\webpack\\babel',
        rootDir: 'D:\\test\\docz-master\\docz-master\\examples\\myapp\\.docz'
      },
      loader: 'D:\\test\\docz-master\\docz-master\\examples\\myapp\\node_modules\\
  gatsby\\dist\\utils\\babel-loader.js'
    }
  }

is there some wrong?