Skip to content

Commit 091403a

Browse files
committed
chore(examples): update base example to react@16.0.0-rc2
chore(*): add `start` script for running base typescript example as dev environment
1 parent b27f281 commit 091403a

File tree

6 files changed

+88
-62
lines changed

6 files changed

+88
-62
lines changed

examples/typescript/index.tsx

Lines changed: 50 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,75 @@
11
import * as React from 'react';
22
import * as ReactDOM from 'react-dom';
3-
import { UIRouter, UIRouterReact, UIView, UISrefActive, UISref, ReactStateDeclaration, ReactViewDeclaration, trace, pushStateLocationPlugin } from '@uirouter/react';
3+
import {
4+
UIRouter,
5+
UIRouterReact,
6+
UIView,
7+
UISrefActive,
8+
UISref,
9+
ReactStateDeclaration,
10+
ReactViewDeclaration,
11+
trace,
12+
pushStateLocationPlugin,
13+
} from '@uirouter/react';
414

515
import { Child } from './components/Child';
616
import { Header } from './components/Header';
717
import { Home } from './components/Home';
818
import { Nest } from './components/Nest';
919

10-
let home:ReactStateDeclaration = { name: 'home', component: Home, url: '/home?foo' };
11-
let child:ReactStateDeclaration = { name: 'home.child', component: Child, url: '/child' };
12-
let nest:ReactStateDeclaration = {
20+
let home: ReactStateDeclaration = {
21+
name: 'home',
22+
component: Home,
23+
url: '/home?foo',
24+
};
25+
let child: ReactStateDeclaration = {
26+
name: 'home.child',
27+
component: Child,
28+
url: '/child',
29+
};
30+
let nest: ReactStateDeclaration = {
1331
name: 'home.child.nest',
1432
views: {
1533
$default: Nest as ReactViewDeclaration,
16-
"header@home": Header as ReactViewDeclaration
34+
'header@home': Header as ReactViewDeclaration,
1735
},
1836
url: '/nest',
19-
resolve: [{
20-
token: 'foo',
21-
resolveFn: ($transition$) => {
22-
return new Promise<string>((resolve, reject) => {
23-
setTimeout(() => {
24-
resolve('bar');
25-
}, 1000);
26-
});
27-
}
28-
}]
37+
resolve: [
38+
{
39+
token: 'foo',
40+
resolveFn: $transition$ => {
41+
return new Promise<string>((resolve, reject) => {
42+
setTimeout(() => {
43+
resolve('bar');
44+
}, 1000);
45+
});
46+
},
47+
},
48+
],
2949
};
3050

31-
3251
const routerConfig = (router: UIRouterReact) => {
33-
router.urlRouter.otherwise("/home");
52+
router.urlRouter.otherwise('/home');
3453
trace.enable(1);
35-
}
54+
};
3655

37-
let el = document.getElementById("react-app");
56+
let el = document.getElementById('react-app');
3857
let app = (
39-
<UIRouter plugins={[pushStateLocationPlugin]} states={[home, child, nest]} config={routerConfig}>
58+
<UIRouter
59+
plugins={[pushStateLocationPlugin]}
60+
states={[home, child, nest]}
61+
config={routerConfig}
62+
>
4063
<div>
4164
<UISrefActive class="active">
42-
<UISref to="home"><a>Home</a></UISref>
65+
<UISref to="home">
66+
<a>Home</a>
67+
</UISref>
4368
</UISrefActive>
44-
<UIView render={(Comp, props) => <Comp {...props} foo="bar" />}><p>Content will load here</p></UIView>
69+
<UIView render={(Comp, props) => <Comp {...props} foo="bar" />}>
70+
<p>Content will load here</p>
71+
</UIView>
4572
</div>
4673
</UIRouter>
4774
);
48-
ReactDOM.render(app, el);
75+
ReactDOM.render(app, el);

examples/typescript/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
},
88
"dependencies": {
99
"@uirouter/react": "^0.5.0",
10-
"react": "^15.6.1",
11-
"react-dom": "^15.6.1"
10+
"react": "16.0.0-rc.2",
11+
"react-dom": "16.0.0-rc.2"
1212
},
1313
"devDependencies": {
1414
"awesome-typescript-loader": "^3.2.1",

examples/typescript/tsconfig.json

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,21 @@
33
"moduleResolution": "node",
44
"module": "commonjs",
55
"target": "es5",
6-
"lib": [ "es2015", "dom" ],
6+
"lib": ["es2015", "dom"],
77
"allowSyntheticDefaultImports": true,
88
"suppressImplicitAnyIndexErrors": true,
99
"forceConsistentCasingInFileNames": true,
1010
"sourceMap": true,
1111
"declaration": false,
12-
"jsx": "react"
12+
"jsx": "react",
13+
"baseUrl": ".",
14+
"paths": {
15+
"react": ["../../node_modules/react"],
16+
"react-dom": ["../../node_modules/react-dom"],
17+
"@uirouter/react": ["../../src/index.ts"]
18+
}
1319
},
14-
"files": [
15-
"./index.tsx"
16-
],
20+
"files": ["./index.tsx"],
1721
"compileOnSave": false,
1822
"buildOnSave": false
19-
}
23+
}
Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,28 @@
1-
var path = require("path");
1+
var path = require('path');
2+
const { TsConfigPathsPlugin } = require('awesome-typescript-loader');
3+
4+
var configFilePath = path.resolve(__dirname, 'tsconfig.json');
25

36
var config = {
4-
entry: ["./index.tsx"],
7+
entry: [path.resolve(__dirname, './index.tsx')],
58
output: {
6-
path: path.resolve(__dirname, "build"),
7-
filename: "bundle.js"
9+
path: path.resolve(__dirname, 'build'),
10+
filename: 'bundle.js',
811
},
912
resolve: {
10-
extensions: [".ts", ".tsx", ".js"]
13+
extensions: ['.ts', '.tsx', '.js'],
14+
plugins: [new TsConfigPathsPlugin({ configFileName: configFilePath })],
1115
},
12-
devtool: "inline-source-map",
16+
devtool: 'inline-source-map',
1317
module: {
1418
loaders: [
1519
{
1620
test: /\.tsx?$/,
17-
loader: "awesome-typescript-loader",
18-
exclude: /(node_modules|__tests__)/
19-
}
20-
]
21-
}
21+
loader: 'awesome-typescript-loader',
22+
exclude: /(node_modules|__tests__)/,
23+
},
24+
],
25+
},
2226
};
2327

24-
module.exports = config;
28+
module.exports = config;

examples/typescript/yarn.lock

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -618,14 +618,6 @@ create-hmac@^1.1.0, create-hmac@^1.1.2, create-hmac@^1.1.4:
618618
safe-buffer "^5.0.1"
619619
sha.js "^2.4.8"
620620

621-
create-react-class@^15.6.0:
622-
version "15.6.0"
623-
resolved "https://registry.yarnpkg.com/create-react-class/-/create-react-class-15.6.0.tgz#ab448497c26566e1e29413e883207d57cfe7bed4"
624-
dependencies:
625-
fbjs "^0.8.9"
626-
loose-envify "^1.3.1"
627-
object-assign "^4.1.1"
628-
629621
cross-env@^5.0.1:
630622
version "5.0.1"
631623
resolved "https://registry.yarnpkg.com/cross-env/-/cross-env-5.0.1.tgz#ff4e72ea43b47da2486b43a7f2043b2609e44913"
@@ -2261,7 +2253,7 @@ promise@^7.1.1:
22612253
dependencies:
22622254
asap "~2.0.3"
22632255

2264-
prop-types@^15.5.10:
2256+
prop-types@^15.5.10, prop-types@^15.5.6:
22652257
version "15.5.10"
22662258
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.5.10.tgz#2797dfc3126182e3a95e3dfbb2e893ddd7456154"
22672259
dependencies:
@@ -2347,24 +2339,23 @@ rc@^1.1.7:
23472339
minimist "^1.2.0"
23482340
strip-json-comments "~2.0.1"
23492341

2350-
react-dom@^15.6.1:
2351-
version "15.6.1"
2352-
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-15.6.1.tgz#2cb0ed4191038e53c209eb3a79a23e2a4cf99470"
2342+
react-dom@16.0.0-rc.2:
2343+
version "16.0.0-rc.2"
2344+
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-16.0.0-rc.2.tgz#f94dc1c350acd67284233558996a8293d7aa99c7"
23532345
dependencies:
23542346
fbjs "^0.8.9"
23552347
loose-envify "^1.1.0"
23562348
object-assign "^4.1.0"
2357-
prop-types "^15.5.10"
2349+
prop-types "^15.5.6"
23582350

2359-
react@^15.6.1:
2360-
version "15.6.1"
2361-
resolved "https://registry.yarnpkg.com/react/-/react-15.6.1.tgz#baa8434ec6780bde997cdc380b79cd33b96393df"
2351+
react@16.0.0-rc.2:
2352+
version "16.0.0-rc.2"
2353+
resolved "https://registry.yarnpkg.com/react/-/react-16.0.0-rc.2.tgz#1e55cc18fd9c56260f1d0ccf9caca6d3152dc83c"
23622354
dependencies:
2363-
create-react-class "^15.6.0"
23642355
fbjs "^0.8.9"
23652356
loose-envify "^1.1.0"
23662357
object-assign "^4.1.0"
2367-
prop-types "^15.5.10"
2358+
prop-types "^15.5.6"
23682359

23692360
read-pkg-up@^1.0.1:
23702361
version "1.0.1"

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
"jsnext:main": "lib-esm/index.js",
88
"scripts": {
99
"test": "jest --watch",
10-
"dev": "cross-env NODE_ENV=development webpack-dev-server --host 0.0.0.0 --port 8000 --config webpack.example.js --history-api-fallback --content-base example",
1110
"test:ci": "NODE_ENV=production jest --silent",
11+
"start": "cross-env NODE_ENV=development webpack-dev-server --host 0.0.0.0 --port 8000 --config ./examples/typescript/webpack.config.js --history-api-fallback --content-base examples/typescript",
1212
"build": "npm run clean && tsc && tsc -m es6 --outDir lib-esm && cross-env NODE_ENV=production webpack",
1313
"clean": "shx rm -rf _bundles lib lib-esm build",
1414
"docs": "./scripts/docs.js",

0 commit comments

Comments
 (0)