Skip to content

Commit

Permalink
fix: some general adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
pedronauck committed Mar 11, 2019
1 parent a6dc286 commit 0c61f64
Show file tree
Hide file tree
Showing 8 changed files with 989 additions and 2,883 deletions.
1 change: 0 additions & 1 deletion core/docz-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@
"yargs": "^13.2.2"
},
"devDependencies": {
"@types/chokidar": "^2.1.3",
"@types/express": "^4.16.1",
"@types/html-minifier": "^3.5.3",
"@types/p-reduce": "^1.0.0",
Expand Down
7 changes: 6 additions & 1 deletion core/docz-core/src/bundler/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ export const createConfig = (args: Args, env: Env) => async (hooks: Hooks) => {
config
.entry('app')
.add(require.resolve('react-dev-utils/webpackHotDevClient'))
.add(require.resolve('@babel/polyfill'))
.add(paths.indexJs)

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

if (inYarnWorkspaces) {
config.module.noParse(content => {
return /docz\/core\/docz/.test(content)
})
}

/**
* loaders
*/
Expand Down
10 changes: 5 additions & 5 deletions core/docz-core/src/bundler/loaders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import * as paths from '../config/paths'
import { Config as Args } from '../config/argv'
import { BabelRC } from '../config/babel'

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

export const sourceMaps = (config: Config, args: Args) => {
const srcPath = path.resolve(paths.root, args.src)
Expand Down Expand Up @@ -60,9 +61,8 @@ export const js = (config: Config, args: Args, babelrc: BabelRC) => {
const srcPath = path.resolve(paths.root, args.src)
const rule = config.module
.rule('js')
.test(/\.(js|mjs|jsx)$/)
.test(/\.(jsx?|mjs)$/)
.include.add(srcPath)
.add(paths.root)
.add(paths.app)
.end()
.exclude.add(excludeNodeModules)
Expand All @@ -75,9 +75,8 @@ export const ts = (config: Config, args: Args, babelrc: BabelRC) => {
const srcPath = path.resolve(paths.root, args.src)
const rule = config.module
.rule('ts')
.test(/\.(ts|tsx?)$/)
.test(/\.tsx?$/)
.include.add(srcPath)
.add(paths.root)
.add(paths.app)
.end()
.exclude.add(excludeNodeModules)
Expand All @@ -94,6 +93,7 @@ export const mdx = (config: Config, args: Args, babelrc: BabelRC) => {
.test(/\.(md|markdown|mdx)$/)
.include.add(srcPath)
.add(paths.root)
.add(paths.app)
.end()
.exclude.add(excludeNodeModules)
.end()
Expand Down
2 changes: 1 addition & 1 deletion core/docz-core/templates/root.tpl.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react'
import { Link, Router, Routes, useDataServer } from 'docz'
import { hot } from 'react-hot-loader'
import { hot } from 'react-hot-loader/root'
import Theme from '<%- theme %>'

import { imports } from './imports'
Expand Down
2 changes: 1 addition & 1 deletion core/docz-utils/src/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ export const format = (code: string): Promise<string> =>
resolve(result)
} catch (err) {
logger.fatal(err)
resolve(err)
resolve(code)
}
})
4 changes: 3 additions & 1 deletion core/docz/src/components/AsyncRoute.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as React from 'react'
import { SFC } from 'react'
import { get } from 'lodash/fp'
import loadable from '@loadable/component'

import { Entry } from '../state'
Expand All @@ -9,7 +10,8 @@ import { AsyncComponent } from './AsyncComponent'
export type Imports = Record<string, () => Promise<any>>
export const loadRoute = (path: string, imports: Imports) => {
return loadable(async () => {
const { default: Component, getInitialProps } = await imports[path]()
const importFn = get(path, imports)
const { default: Component, getInitialProps } = await importFn()
const ExportedComponent: SFC<any> = props => (
<AsyncComponent
{...props}
Expand Down
1 change: 1 addition & 0 deletions core/gatsby-theme-docz/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
},
"dependencies": {
"@mdx-js/tag": "^0.20.3",
"@mdx-js/mdx": "^0.20.3",
"babel-plugin-export-metadata": "^0.13.4",
"change-case": "^3.1.0",
"chokidar": "^2.1.2",
Expand Down
Loading

0 comments on commit 0c61f64

Please sign in to comment.