Skip to content

Commit b3fa486

Browse files
committedSep 5, 2019
tooling: Replaces awesome ts loader with babel loader
1 parent 5662119 commit b3fa486

File tree

6 files changed

+53
-118
lines changed

6 files changed

+53
-118
lines changed
 

‎.babelrc

+16-17
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
11
{
2+
"presets": [
3+
"@babel/typescript",
4+
"@babel/react",
5+
"linaria/babel",
6+
[
7+
"@babel/env",
8+
{
9+
"useBuiltIns": "usage",
10+
"corejs": "3",
11+
"targets": {
12+
"esmodules": true
13+
}
14+
}
15+
]
16+
],
17+
// "plugins": ["@babel/plugin-syntax-dynamic-import"],
218
"env": {
3-
"development": {
4-
"presets": [
5-
"@babel/preset-typescript",
6-
[
7-
"@babel/preset-env",
8-
{
9-
"useBuiltIns": "entry",
10-
"corejs": "3",
11-
"targets": {
12-
"esmodules": true
13-
}
14-
}
15-
],
16-
"@babel/preset-react",
17-
"linaria/babel"
18-
]
19-
},
2019
"production": {
2120
"plugins": [
2221
["react-remove-properties", { "properties": ["data-testid"] }]

‎package-lock.json

+20-94
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"license": "ISC",
1919
"devDependencies": {
2020
"@babel/core": "^7.5.0",
21+
"@babel/plugin-syntax-dynamic-import": "^7.2.0",
2122
"@babel/preset-env": "^7.5.0",
2223
"@babel/preset-react": "^7.0.0",
2324
"@babel/preset-typescript": "^7.3.3",
@@ -27,7 +28,7 @@
2728
"@types/react-router-dom": "^4.3.4",
2829
"@typescript-eslint/eslint-plugin": "^2.0.0",
2930
"@typescript-eslint/parser": "^2.0.0",
30-
"awesome-typescript-loader": "^5.2.1",
31+
"babel-loader": "^8.0.6",
3132
"babel-plugin-react-remove-properties": "^0.3.0",
3233
"clean-webpack-plugin": "^3.0.0",
3334
"copy-webpack-plugin": "^5.0.4",
@@ -75,6 +76,7 @@
7576
"scripts": {
7677
"dev:client": "webpack-dev-server",
7778
"dev:server": "node src/server/index.js",
79+
"dev:type-check": "tsc --noEmit --watch",
7880
"lint:styles": "stylelint \"src/client/**/*.js\"",
7981
"lint:prettier": "prettier --write \"src/**/*.{js,ts,tsx}\"",
8082
"lint:eslint": "eslint --fix \"src/**/*.{js,ts,tsx}\"",
@@ -87,7 +89,7 @@
8789
"cy:open": "cypress open --env API_URL=http://localhost:4000",
8890
"cy:verify": "cypress verify",
8991
"ci:serve": "CI_ENV=true now dev",
90-
"build": "webpack --env.production",
92+
"build": "tsc --noEmit && webpack --env.production",
9193
"test": "cypress run --record --key f8b075fe-ce9f-4712-ad42-96c913b58cf6 --env API_URL=http://localhost:4000/",
9294
"test:ci": "cypress run --record --key f8b075fe-ce9f-4712-ad42-96c913b58cf6 --env API_URL=http://localhost:3000/graphql"
9395
},

‎src/client/hooks/useGraphQLAPI.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function useGraphQLAPI<T>(): [NetworkState<T>, SubmitQueryFn] {
3131
});
3232
}
3333

34-
async function handleResponse(res?: Response): Promise<void> {
34+
async function handleResponse(res: Response): Promise<void> {
3535
if (!res || !res.ok) {
3636
const errorMsg: string = res ? res.statusText : "No network connection";
3737

@@ -62,7 +62,7 @@ function useGraphQLAPI<T>(): [NetworkState<T>, SubmitQueryFn] {
6262
method: "POST"
6363
})
6464
.catch(console.warn)
65-
.then(handleResponse);
65+
.then(res => res && handleResponse(res));
6666
}
6767

6868
return [networkState, submitQuery];

‎tsconfig.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
{
22
"compilerOptions": {
3+
"allowSyntheticDefaultImports": true,
4+
"esModuleInterop": true,
35
"outDir": "./dist/",
4-
"sourceMap": true,
56
"strictNullChecks": true,
7+
"sourceMap": true,
8+
"strict": true,
69
"module": "ESNext",
710
"jsx": "react",
811
"target": "ESNext",

‎webpack.config.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ module.exports = (env = {}) => {
4747
exclude: /node_modules/,
4848
use: [
4949
{
50-
loader: "awesome-typescript-loader"
50+
loader: "babel-loader",
5151
},
5252
{
5353
loader: "linaria/loader",
@@ -114,6 +114,11 @@ module.exports = (env = {}) => {
114114
}
115115
]),
116116
new GenerateSW()
117-
]
117+
],
118+
optimization: {
119+
splitChunks: {
120+
chunks: "all"
121+
}
122+
}
118123
};
119124
};

0 commit comments

Comments
 (0)
Please sign in to comment.