Skip to content
This repository was archived by the owner on Jan 24, 2025. It is now read-only.

Commit 0c61f64

Browse files
committed
fix: some general adjustments
1 parent a6dc286 commit 0c61f64

File tree

8 files changed

+989
-2883
lines changed

8 files changed

+989
-2883
lines changed

core/docz-core/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@
8484
"yargs": "^13.2.2"
8585
},
8686
"devDependencies": {
87-
"@types/chokidar": "^2.1.3",
8887
"@types/express": "^4.16.1",
8988
"@types/html-minifier": "^3.5.3",
9089
"@types/p-reduce": "^1.0.0",

core/docz-core/src/bundler/config.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ export const createConfig = (args: Args, env: Env) => async (hooks: Hooks) => {
7272
config
7373
.entry('app')
7474
.add(require.resolve('react-dev-utils/webpackHotDevClient'))
75-
.add(require.resolve('@babel/polyfill'))
7675
.add(paths.indexJs)
7776

7877
/**
@@ -116,6 +115,12 @@ export const createConfig = (args: Args, env: Env) => async (hooks: Hooks) => {
116115
.add(doczDependenciesDir)
117116
.add(paths.root)
118117

118+
if (inYarnWorkspaces) {
119+
config.module.noParse(content => {
120+
return /docz\/core\/docz/.test(content)
121+
})
122+
}
123+
119124
/**
120125
* loaders
121126
*/

core/docz-core/src/bundler/loaders.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import * as paths from '../config/paths'
55
import { Config as Args } from '../config/argv'
66
import { BabelRC } from '../config/babel'
77

8-
const excludeNodeModules = (filepath: string) => /node_modules/.test(filepath)
8+
const excludeNodeModules = (filepath: string) =>
9+
/node_modules/.test(filepath) || /@babel(?:\/|\\{1,2})runtime/.test(filepath)
910

1011
export const sourceMaps = (config: Config, args: Args) => {
1112
const srcPath = path.resolve(paths.root, args.src)
@@ -60,9 +61,8 @@ export const js = (config: Config, args: Args, babelrc: BabelRC) => {
6061
const srcPath = path.resolve(paths.root, args.src)
6162
const rule = config.module
6263
.rule('js')
63-
.test(/\.(js|mjs|jsx)$/)
64+
.test(/\.(jsx?|mjs)$/)
6465
.include.add(srcPath)
65-
.add(paths.root)
6666
.add(paths.app)
6767
.end()
6868
.exclude.add(excludeNodeModules)
@@ -75,9 +75,8 @@ export const ts = (config: Config, args: Args, babelrc: BabelRC) => {
7575
const srcPath = path.resolve(paths.root, args.src)
7676
const rule = config.module
7777
.rule('ts')
78-
.test(/\.(ts|tsx?)$/)
78+
.test(/\.tsx?$/)
7979
.include.add(srcPath)
80-
.add(paths.root)
8180
.add(paths.app)
8281
.end()
8382
.exclude.add(excludeNodeModules)
@@ -94,6 +93,7 @@ export const mdx = (config: Config, args: Args, babelrc: BabelRC) => {
9493
.test(/\.(md|markdown|mdx)$/)
9594
.include.add(srcPath)
9695
.add(paths.root)
96+
.add(paths.app)
9797
.end()
9898
.exclude.add(excludeNodeModules)
9999
.end()

core/docz-core/templates/root.tpl.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react'
22
import { Link, Router, Routes, useDataServer } from 'docz'
3-
import { hot } from 'react-hot-loader'
3+
import { hot } from 'react-hot-loader/root'
44
import Theme from '<%- theme %>'
55

66
import { imports } from './imports'

core/docz-utils/src/format.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ export const format = (code: string): Promise<string> =>
1717
resolve(result)
1818
} catch (err) {
1919
logger.fatal(err)
20-
resolve(err)
20+
resolve(code)
2121
}
2222
})

core/docz/src/components/AsyncRoute.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as React from 'react'
22
import { SFC } from 'react'
3+
import { get } from 'lodash/fp'
34
import loadable from '@loadable/component'
45

56
import { Entry } from '../state'
@@ -9,7 +10,8 @@ import { AsyncComponent } from './AsyncComponent'
910
export type Imports = Record<string, () => Promise<any>>
1011
export const loadRoute = (path: string, imports: Imports) => {
1112
return loadable(async () => {
12-
const { default: Component, getInitialProps } = await imports[path]()
13+
const importFn = get(path, imports)
14+
const { default: Component, getInitialProps } = await importFn()
1315
const ExportedComponent: SFC<any> = props => (
1416
<AsyncComponent
1517
{...props}

core/gatsby-theme-docz/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
},
1717
"dependencies": {
1818
"@mdx-js/tag": "^0.20.3",
19+
"@mdx-js/mdx": "^0.20.3",
1920
"babel-plugin-export-metadata": "^0.13.4",
2021
"change-case": "^3.1.0",
2122
"chokidar": "^2.1.2",

0 commit comments

Comments
 (0)