File tree Expand file tree Collapse file tree
packages/razzle-plugin-typescript Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1818 "@types/express" : " ^4.11.1" ,
1919 "@types/jest" : " ^22.2.3" ,
2020 "@types/node" : " 9.6.6" ,
21- "@types/react" : " ^16.3.12 " ,
21+ "@types/react" : " ^16.3.13 " ,
2222 "@types/react-dom" : " ^16.0.5" ,
2323 "@types/react-router-dom" : " ^4.2.6" ,
2424 "@types/webpack-env" : " ^1.13.6" ,
2525 "razzle" : " ^2.0.0-alpha.12" ,
2626 "razzle-plugin-typescript" : " ^2.0.0-alpha.12" ,
27- "ts-jest" : " ^22.4.4 " ,
28- "tslint" : " ^5.9.1 " ,
27+ "ts-jest" : " ^22.4.5 " ,
28+ "tslint" : " ^5.10.0 " ,
2929 "tslint-react" : " ^3.5.1" ,
3030 "typescript" : " ^2.8.3"
3131 },
Original file line number Diff line number Diff line change 1- import * as React from 'react' ;
2- import * as ReactDOM from 'react-dom' ;
1+ import React from 'react' ;
2+ import { render } from 'react-dom' ;
33
44import App from './App' ;
55
@@ -8,7 +8,7 @@ import { MemoryRouter } from 'react-router-dom';
88describe ( '<App />' , ( ) => {
99 test ( 'renders without exploding' , ( ) => {
1010 const div = document . createElement ( 'div' ) ;
11- ReactDOM . render (
11+ render (
1212 < MemoryRouter >
1313 < App />
1414 </ MemoryRouter > ,
Original file line number Diff line number Diff line change 1- import * as React from 'react' ;
1+ import React from 'react' ;
22import { Route , Switch } from 'react-router-dom' ;
33import Home from './Home' ;
44
Original file line number Diff line number Diff line change 1- import * as React from 'react' ;
1+ import React from 'react' ;
22import logo from './react.svg' ;
33
44import './Home.css' ;
Original file line number Diff line number Diff line change 1- import * as React from 'react' ;
2- import * as ReactDOM from 'react-dom' ;
1+ import React from 'react' ;
2+ import { hydrate } from 'react-dom' ;
33import { BrowserRouter } from 'react-router-dom' ;
44
55import App from './App' ;
66
7- ReactDOM . hydrate (
7+ hydrate (
88 < BrowserRouter >
99 < App />
1010 </ BrowserRouter > ,
Original file line number Diff line number Diff line change 1+ /* tslint:disable:no-console */
12import express from 'express' ;
23import app from './server' ;
34
45if ( module . hot ) {
5- module . hot . accept ( './server' , function ( ) {
6+ module . hot . accept ( './server' , ( ) => {
67 console . log ( '🔁 HMR Reloading `./server`...' ) ;
78 } ) ;
89 console . info ( '✅ Server-side HMR Enabled!' ) ;
@@ -11,8 +12,8 @@ if (module.hot) {
1112const port = process . env . PORT || 3000 ;
1213
1314export default express ( )
14- . use ( ( req , res ) => app . handle ( req , res ) )
15- . listen ( port , function ( err ) {
15+ . use ( app )
16+ . listen ( port , ( err : Error ) => {
1617 if ( err ) {
1718 console . error ( err ) ;
1819 return ;
Original file line number Diff line number Diff line change 1- import * as express from 'express' ;
2- import * as React from 'react' ;
1+ import express from 'express' ;
2+ import React from 'react' ;
33import { renderToString } from 'react-dom/server' ;
44import { StaticRouter } from 'react-router-dom' ;
55
@@ -8,7 +8,7 @@ import App from './App';
88let assets : any ;
99
1010const syncLoadAssets = ( ) => {
11- assets = require ( process . env . RAZZLE_ASSETS_MANIFEST ! ) ;
11+ assets = require ( process . env . RAZZLE_ASSETS_MANIFEST ! ) ;
1212} ;
1313syncLoadAssets ( ) ;
1414
Original file line number Diff line number Diff line change 2626 "no-arg" : true ,
2727 "no-bitwise" : true ,
2828 "no-consecutive-blank-lines" : true ,
29- "no-console" : false ,
29+ "no-console" : true ,
3030 "no-construct" : true ,
3131 "no-debugger" : true ,
3232 "no-duplicate-variable" : true ,
Original file line number Diff line number Diff line change @@ -10,7 +10,6 @@ npm install --save razzle-plugin-typescript
1010
1111Using the plugin with the default options
1212
13-
1413``` js
1514// razzle.config.js
1615
@@ -38,18 +37,19 @@ module.exports = {
3837 // any babel transforms
3938 useBabel: true ,
4039
41- // Any option you want to pass to tslint -loader: https://github.com/wbuchwalter/tslint -loader
42- tslintLoader : {
40+ // Any option you want to pass to ts -loader: https://github.com/TypeStrong/ts -loader
41+ tsLoader : {
4342 transpileOnly: true ,
43+ experimentalWatchApi: true ,
4444 },
4545
46- // Any option you want to pass to ts-loader: https://github.com/TypeStrong/ts-loader
47- tsLoader: {
48- emitErrors: true ,
46+ // Any option you want to pass to fork-ts-checker-webpack-plugin: https://github.com/Realytics/fork-ts-checker-webpack-plugin
47+ forkTsChecker: {
48+ tsconfig: ' ./tsconfig.json' ,
49+ tslint: ' ./tslint.json' ,
50+ watch: ' ./src' ,
4951 typeCheck: true ,
50- configFile: ' ./tslint.json' ,
51- tsConfigFile: ' ./tsconfig.json' ,
52- },
52+ }
5353 },
5454 },
5555 ],
Original file line number Diff line number Diff line change @@ -4,26 +4,27 @@ const loaderFinder = loaderName => rule => {
44 // i.e.: /eslint-loader/
55 const loaderRegex = new RegExp ( `[/\\\\]${ loaderName } [/\\\\]` ) ;
66
7+ // Checks if there's a loader string in rule.loader matching loaderRegex.
8+ const inLoaderString =
9+ typeof rule . loader === 'string' && rule . loader . match ( loaderRegex ) ;
10+
711 // Checks if there is an object inside rule.use with loader matching loaderRegex, OR
8- // If there's a loader string in rule.loader matching loaderRegex.
9- return (
10- ( Array . isArray ( rule . use ) &&
11- rule . use . find (
12- loader =>
13- typeof loader . loader === 'string' && loader . loader . match ( loaderRegex )
14- ) ) ||
15- ( typeof rule . loader === 'string' && rule . loader . match ( loaderRegex ) )
16- ) ;
12+ const inUseArray =
13+ Array . isArray ( rule . use ) &&
14+ rule . use . find (
15+ loader =>
16+ typeof loader . loader === 'string' && loader . loader . match ( loaderRegex )
17+ ) ;
18+
19+ return inUseArray || inLoaderString ;
1720} ;
1821
19- const eslintLoaderFinder = loaderFinder ( 'eslint-loader' ) ;
2022const babelLoaderFinder = loaderFinder ( 'babel-loader' ) ;
21- const tslintLoaderFinder = loaderFinder ( 'tslint-loader' ) ;
2223const tsLoaderFinder = loaderFinder ( 'ts-loader' ) ;
24+ const eslintLoaderFinder = loaderFinder ( 'eslint-loader' ) ;
2325
2426module . exports = {
2527 eslintLoaderFinder,
2628 babelLoaderFinder,
27- tslintLoaderFinder,
2829 tsLoaderFinder,
2930} ;
You can’t perform that action at this time.
0 commit comments