Reorganize tsconfig.json files
According to: https://github.com/RyanCavanaugh/learn-a
This commit is contained in:
parent
7201cbcc34
commit
8fd2eafdca
@ -7,6 +7,6 @@
|
|||||||
"react-redux": "^6.0.0",
|
"react-redux": "^6.0.0",
|
||||||
"redux": "^4.0.1"
|
"redux": "^4.0.1"
|
||||||
},
|
},
|
||||||
"main": "src/index.js",
|
"main": "lib/index.js",
|
||||||
"types": "src/index.d.ts"
|
"types": "lib/index.d.ts"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,19 +7,18 @@ import {IRenderer} from './IRenderer'
|
|||||||
export class ClientRenderer implements IRenderer {
|
export class ClientRenderer implements IRenderer {
|
||||||
constructor(
|
constructor(
|
||||||
readonly createStore: IStoreFactory,
|
readonly createStore: IStoreFactory,
|
||||||
readonly Component: Component,
|
readonly RootComponent: typeof Component,
|
||||||
readonly target = document.body,
|
readonly target = document.body,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
render() {
|
render(state = (window as any).__PRELOADED_STATE__) {
|
||||||
const state = (window as any).__PRELOADED_STATE__
|
const {RootComponent} = this
|
||||||
const {Component} = this
|
|
||||||
|
|
||||||
if (state) {
|
if (state) {
|
||||||
const store = this.createStore(state)
|
const store = this.createStore(state)
|
||||||
ReactDOM.hydrate(
|
ReactDOM.hydrate(
|
||||||
<Provider store={store}>
|
<Provider store={store}>
|
||||||
<Component />
|
<RootComponent />
|
||||||
</Provider>,
|
</Provider>,
|
||||||
this.target,
|
this.target,
|
||||||
)
|
)
|
||||||
@ -27,11 +26,10 @@ export class ClientRenderer implements IRenderer {
|
|||||||
const store = this.createStore()
|
const store = this.createStore()
|
||||||
ReactDOM.render(
|
ReactDOM.render(
|
||||||
<Provider store={store}>
|
<Provider store={store}>
|
||||||
<Component />
|
<RootComponent />
|
||||||
</Provider>,
|
</Provider>,
|
||||||
this.target,
|
this.target,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
export interface IRenderer {
|
export interface IRenderer {
|
||||||
render(): any
|
render(state?: any): any
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import {Store} from 'redux'
|
import {Store} from 'redux'
|
||||||
|
|
||||||
// TODO maybe Store should also be typed
|
// TODO maybe Store should also be typed
|
||||||
export type IStoreFactory<T> = (state?: T) => Store
|
export type IStoreFactory = (state?: any) => Store
|
||||||
|
|||||||
@ -1,18 +1,22 @@
|
|||||||
|
import React from 'react'
|
||||||
|
import {Component} from 'react'
|
||||||
import {IRenderer} from './IRenderer'
|
import {IRenderer} from './IRenderer'
|
||||||
|
import {IStoreFactory} from './IStoreFactory'
|
||||||
|
import {Provider} from 'react-redux'
|
||||||
import {renderToNodeStream} from 'react-dom/server'
|
import {renderToNodeStream} from 'react-dom/server'
|
||||||
|
|
||||||
export class ServerRenderer implements IRenderer {
|
export class ServerRenderer implements IRenderer {
|
||||||
constructor(
|
constructor(
|
||||||
readonly createStore: IStoreFactory,
|
readonly createStore: IStoreFactory,
|
||||||
readonly Component: Component,
|
readonly RootComponent: typeof Component,
|
||||||
) {}
|
) {}
|
||||||
render() {
|
render(state?: any) {
|
||||||
const {Component} = this
|
const {RootComponent} = this
|
||||||
const store = this.createStore(state)
|
const store = this.createStore(state)
|
||||||
|
|
||||||
const stream = renderToNodeStream(
|
const stream = renderToNodeStream(
|
||||||
<Provider store={store}>
|
<Provider store={store}>
|
||||||
<Component />
|
<RootComponent />
|
||||||
</Provider>,
|
</Provider>,
|
||||||
)
|
)
|
||||||
return stream
|
return stream
|
||||||
|
|||||||
@ -1,19 +1,7 @@
|
|||||||
{
|
{
|
||||||
|
"extends": "../tsconfig.common.json"
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"lib": ["es2015", "dom"],
|
"outDir": "lib",
|
||||||
"target": "es3",
|
"rootDir": "src"
|
||||||
"moduleResolution": "node",
|
|
||||||
"jsx": "react",
|
|
||||||
"noImplicitAny": true,
|
|
||||||
"strict": true,
|
|
||||||
"skipLibCheck": true,
|
|
||||||
"noUnusedLocals": true,
|
|
||||||
"esModuleInterop": true,
|
|
||||||
"emitDecoratorMetadata": true,
|
|
||||||
"experimentalDecorators": true,
|
|
||||||
"plugins": [{
|
|
||||||
"name": "typescript-tslint-plugin",
|
|
||||||
"suppressWhileTypeErrorsPresent": true
|
|
||||||
}]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@rondo/common",
|
"name": "@rondo/common",
|
||||||
"private": true,
|
"private": true,
|
||||||
"main": "src/index.js",
|
"main": "lib/index.js",
|
||||||
"types": "src/index.d.ts"
|
"types": "lib/index.d.ts"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,19 +1,7 @@
|
|||||||
{
|
{
|
||||||
|
"extends": "../tsconfig.common.json",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"lib": ["es2015", "dom"],
|
"outDir": "lib",
|
||||||
"target": "es3",
|
"rootDir": "src"
|
||||||
"moduleResolution": "node",
|
|
||||||
"jsx": "react",
|
|
||||||
"noImplicitAny": true,
|
|
||||||
"strict": true,
|
|
||||||
"skipLibCheck": true,
|
|
||||||
"noUnusedLocals": true,
|
|
||||||
"esModuleInterop": true,
|
|
||||||
"emitDecoratorMetadata": true,
|
|
||||||
"experimentalDecorators": true,
|
|
||||||
"plugins": [{
|
|
||||||
"name": "typescript-tslint-plugin",
|
|
||||||
"suppressWhileTypeErrorsPresent": true
|
|
||||||
}]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,6 +34,6 @@
|
|||||||
"uuid": "^3.3.2",
|
"uuid": "^3.3.2",
|
||||||
"winston": "^3.1.0"
|
"winston": "^3.1.0"
|
||||||
},
|
},
|
||||||
"main": "src/index.js",
|
"main": "lib/index.js",
|
||||||
"types": "src/index.d.ts"
|
"types": "lib/index.d.ts"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import {IApplication} from './IApplication'
|
|||||||
import {IConfig} from './IConfig'
|
import {IConfig} from './IConfig'
|
||||||
import {IDatabase} from '../database/IDatabase'
|
import {IDatabase} from '../database/IDatabase'
|
||||||
import {ILogger} from '../logger/ILogger'
|
import {ILogger} from '../logger/ILogger'
|
||||||
import {IRoutes} from '../../common/REST'
|
import {IRoutes} from '@rondo/common'
|
||||||
import {ITransactionManager} from '../database/ITransactionManager'
|
import {ITransactionManager} from '../database/ITransactionManager'
|
||||||
import {IUserService, UserService} from '../services'
|
import {IUserService, UserService} from '../services'
|
||||||
import {loggerFactory, LoggerFactory} from '../logger/LoggerFactory'
|
import {loggerFactory, LoggerFactory} from '../logger/LoggerFactory'
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import express from 'express'
|
import express from 'express'
|
||||||
import {AsyncRouter} from '../router'
|
import {AsyncRouter} from '../router'
|
||||||
import {IRoutes} from '../../common/REST'
|
import {IRoutes} from '@rondo/common'
|
||||||
import {IDatabase} from '../database/IDatabase'
|
import {IDatabase} from '../database/IDatabase'
|
||||||
|
|
||||||
export interface IApplication {
|
export interface IApplication {
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import {IRoutes, IRoute, IMethod} from '../../common/REST'
|
import {IRoutes, IRoute, IMethod} from '@rondo/common'
|
||||||
import express, {NextFunction} from 'express'
|
import express, {NextFunction} from 'express'
|
||||||
|
|
||||||
export interface IRequest<T extends IRoute> extends express.Request {
|
export interface IRequest<T extends IRoute> extends express.Request {
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import express from 'express'
|
import express from 'express'
|
||||||
import {AsyncRouter, IHandler} from './AsyncRouter'
|
import {AsyncRouter, IHandler} from './AsyncRouter'
|
||||||
import {IRoutes, IMethod} from '../../common/REST'
|
import {IRoutes, IMethod} from '@rondo/common'
|
||||||
import {ITransactionManager} from '../database/ITransactionManager'
|
import {ITransactionManager} from '../database/ITransactionManager'
|
||||||
|
|
||||||
export class TransactionalRouter<R extends IRoutes> extends AsyncRouter<R> {
|
export class TransactionalRouter<R extends IRoutes> extends AsyncRouter<R> {
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
import {IHandler} from '../middleware/IHandler'
|
import {IHandler} from '../middleware/IHandler'
|
||||||
import {AsyncRouter} from '../router'
|
import {AsyncRouter} from '../router'
|
||||||
import {IAPIDef} from '../../common/IAPIDef'
|
import {IRoutes} from '@rondo/common'
|
||||||
|
|
||||||
export abstract class BaseRoute<T extends IAPIDef> {
|
export abstract class BaseRoute<T extends IRoutes> {
|
||||||
readonly handle: IHandler
|
readonly handle: IHandler
|
||||||
|
|
||||||
constructor(protected readonly t: AsyncRouter<T>) {
|
constructor(protected readonly t: AsyncRouter<T>) {
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import {AsyncRouter} from '../router'
|
import {AsyncRouter} from '../router'
|
||||||
import {BaseRoute} from './BaseRoute'
|
import {BaseRoute} from './BaseRoute'
|
||||||
import {IAPIDef} from '../../common/IAPIDef'
|
import {IAPIDef} from '@rondo/common'
|
||||||
import {IUserService} from '../services'
|
import {IUserService} from '../services'
|
||||||
import {Authenticator} from '../middleware'
|
import {Authenticator} from '../middleware'
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import {AsyncRouter} from '../router'
|
import {AsyncRouter} from '../router'
|
||||||
import {BaseRoute} from './BaseRoute'
|
import {BaseRoute} from './BaseRoute'
|
||||||
import {IAPIDef} from '../../common/IAPIDef'
|
import {IAPIDef} from '@rondo/common'
|
||||||
import {IUserService} from '../services'
|
import {IUserService} from '../services'
|
||||||
import {ensureLoggedInApi} from '../middleware'
|
import {ensureLoggedInApi} from '../middleware'
|
||||||
|
|
||||||
|
|||||||
@ -1,45 +1,49 @@
|
|||||||
import React from 'react'
|
// import React from 'react'
|
||||||
import {CComponent} from '../../client/components/Component'
|
// import {CComponent} from '@rondo/client'
|
||||||
import {Provider} from 'react-redux'
|
// import {Provider} from 'react-redux'
|
||||||
import {Router} from 'express'
|
import {Router} from 'express'
|
||||||
import {createReadStream} from 'fs'
|
// import {createReadStream} from 'fs'
|
||||||
import {createStore} from '../../client/store'
|
// import {createStore} from '../../client/store'
|
||||||
import {join} from 'path'
|
// import {join} from 'path'
|
||||||
import {renderToNodeStream} from 'react-dom/server'
|
// import {renderToNodeStream} from 'react-dom/server'
|
||||||
|
|
||||||
export const application = Router()
|
export const application = Router()
|
||||||
|
|
||||||
application.get('/client.js', (req, res) => {
|
// application.get('/client.js', (req, res) => {
|
||||||
const stream = createReadStream(join(__dirname, '../build/client.js'))
|
// const stream = createReadStream(join(__dirname, '../build/client.js'))
|
||||||
stream.pipe(res)
|
// stream.pipe(res)
|
||||||
})
|
// })
|
||||||
|
|
||||||
application.get('/no-ssr', (req, res) => {
|
// application.get('/no-ssr', (req, res) => {
|
||||||
res.write('<!DOCTYPE html><html><head><title>My Page</title></head><body>')
|
// res.write('<!DOCTYPE html><html><head><title>My Page</title></head><body>')
|
||||||
res.write(`</body><script src='client.js'></script></html>`)
|
// res.write(`</body><script src='client.js'></script></html>`)
|
||||||
res.end()
|
// res.end()
|
||||||
})
|
// })
|
||||||
|
|
||||||
|
// application.get('/', (req, res) => {
|
||||||
|
// const store = createStore({
|
||||||
|
// csrfToken: req.csrfToken(),
|
||||||
|
// value: '1234',
|
||||||
|
// })
|
||||||
|
// const stream = renderToNodeStream(
|
||||||
|
// <Provider store={store}>
|
||||||
|
// <CComponent />
|
||||||
|
// </Provider>,
|
||||||
|
// )
|
||||||
|
// const state = store.getState()
|
||||||
|
// res.write('<!DOCTYPE html><html><head><title>My Page</title></head><body>')
|
||||||
|
// // TODO attach javascript
|
||||||
|
// stream.pipe(res, { end: false })
|
||||||
|
// stream.on('end', () => {
|
||||||
|
// res.write(`</body>
|
||||||
|
// <script>window.__PRELOADED_STATE__ = ${JSON.stringify(state)
|
||||||
|
// .replace( /</g, '\\u003c')}</script>
|
||||||
|
// <script src='client.js'></script>
|
||||||
|
// </html>`)
|
||||||
|
// res.end()
|
||||||
|
// })
|
||||||
|
// })
|
||||||
|
|
||||||
application.get('/', (req, res) => {
|
application.get('/', (req, res) => {
|
||||||
const store = createStore({
|
res.json({csrfToken: req.csrfToken})
|
||||||
csrfToken: req.csrfToken(),
|
|
||||||
value: '1234',
|
|
||||||
})
|
|
||||||
const stream = renderToNodeStream(
|
|
||||||
<Provider store={store}>
|
|
||||||
<CComponent />
|
|
||||||
</Provider>,
|
|
||||||
)
|
|
||||||
const state = store.getState()
|
|
||||||
res.write('<!DOCTYPE html><html><head><title>My Page</title></head><body>')
|
|
||||||
// TODO attach javascript
|
|
||||||
stream.pipe(res, { end: false })
|
|
||||||
stream.on('end', () => {
|
|
||||||
res.write(`</body>
|
|
||||||
<script>window.__PRELOADED_STATE__ = ${JSON.stringify(state)
|
|
||||||
.replace( /</g, '\\u003c')}</script>
|
|
||||||
<script src='client.js'></script>
|
|
||||||
</html>`)
|
|
||||||
res.end()
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import supertest from 'supertest'
|
import supertest from 'supertest'
|
||||||
import {IMethod, IRoutes} from '../../common/REST'
|
import {IMethod, IRoutes} from '@rondo/common'
|
||||||
|
|
||||||
// https://stackoverflow.com/questions/48215950/exclude-property-from-type
|
// https://stackoverflow.com/questions/48215950/exclude-property-from-type
|
||||||
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>
|
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import {Connection, QueryRunner} from 'typeorm'
|
|||||||
import {
|
import {
|
||||||
ENTITY_MANAGER, ITransactionManager,
|
ENTITY_MANAGER, ITransactionManager,
|
||||||
} from '../database/ITransactionManager'
|
} from '../database/ITransactionManager'
|
||||||
import {IRoutes} from '../../common/REST'
|
import {IRoutes} from '@rondo/common'
|
||||||
import {IBootstrap} from '../application/IBootstrap'
|
import {IBootstrap} from '../application/IBootstrap'
|
||||||
import {RequestTester} from './RequestTester'
|
import {RequestTester} from './RequestTester'
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import {Bootstrap} from './application/Bootstrap'
|
import {Bootstrap} from './application/Bootstrap'
|
||||||
import {IAPIDef} from '../common/IAPIDef'
|
import {IAPIDef} from '@rondo/common'
|
||||||
import {NamespaceMock, TestUtils} from './test-utils'
|
import {NamespaceMock, TestUtils} from './test-utils'
|
||||||
import {config} from './config'
|
import {config} from './config'
|
||||||
|
|
||||||
|
|||||||
@ -1,19 +1,11 @@
|
|||||||
{
|
{
|
||||||
|
"extends": "../tsconfig.common.json",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"lib": ["es2015", "dom"],
|
"outDir": "lib",
|
||||||
"target": "es3",
|
"rootDir": "src"
|
||||||
"moduleResolution": "node",
|
},
|
||||||
"jsx": "react",
|
"references": [
|
||||||
"noImplicitAny": true,
|
{"path": "../client"},
|
||||||
"strict": true,
|
{"path": "../common"}
|
||||||
"skipLibCheck": true,
|
]
|
||||||
"noUnusedLocals": true,
|
|
||||||
"esModuleInterop": true,
|
|
||||||
"emitDecoratorMetadata": true,
|
|
||||||
"experimentalDecorators": true,
|
|
||||||
"plugins": [{
|
|
||||||
"name": "typescript-tslint-plugin",
|
|
||||||
"suppressWhileTypeErrorsPresent": true
|
|
||||||
}]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
25
packages/tsconfig.common.json
Normal file
25
packages/tsconfig.common.json
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
// following settings required for referenced projects
|
||||||
|
"composite": true,
|
||||||
|
"declaration": true,
|
||||||
|
"declarationMap": true,
|
||||||
|
"sourceMap": true,
|
||||||
|
|
||||||
|
"lib": ["es2015", "dom"],
|
||||||
|
"target": "es3",
|
||||||
|
"moduleResolution": "node",
|
||||||
|
"jsx": "react",
|
||||||
|
"noImplicitAny": true,
|
||||||
|
"strict": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"noUnusedLocals": true,
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"emitDecoratorMetadata": true,
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"plugins": [{
|
||||||
|
"name": "typescript-tslint-plugin",
|
||||||
|
"suppressWhileTypeErrorsPresent": true
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
}
|
||||||
8
packages/tsconfig.json
Normal file
8
packages/tsconfig.json
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"files": [],
|
||||||
|
"references": [
|
||||||
|
{"path": "client"},
|
||||||
|
{"path": "common"},
|
||||||
|
{"path": "server"}
|
||||||
|
]
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user