Skip to content

Commit f52c8db

Browse files
authored
Merge pull request #86 from akitaSummer/feat/akita
Speed up build
2 parents aa11158 + 76c0cab commit f52c8db

File tree

12 files changed

+5521
-4893
lines changed

12 files changed

+5521
-4893
lines changed

packages/hedgehog-core/package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
],
1010
"scripts": {
1111
"build": "tsc -p tsconfig.json",
12+
"esbuild": "webpack ./webpack.config.js",
1213
"watch": "tsc -p tsconfig.json --watch --preserveWatchOutput",
1314
"prettier": "prettier --single-quote --write '**/*.{js,json,md}'",
1415
"lint": "eslint src --fix --ext .ts,.tsx,.js,.jsx"
@@ -26,9 +27,13 @@
2627
"@babel/standalone": "^7.10.5",
2728
"@tensorflow/tfjs": "^2.7.0",
2829
"babel-template": "^6.26.0",
30+
"clean-webpack-plugin": "^3.0.0",
31+
"esbuild-loader": "^2.9.1",
2932
"gpu.js": "^2.9.5",
3033
"mathjs": "^7.1.0",
3134
"nerdamer": "^1.1.5",
35+
"webpack": "^5.21.2",
36+
"webpack-cli": "^4.5.0",
3237
"sync-fetch": "^0.3.0"
3338
},
3439
"devDependencies": {
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
const path = require("path");
2+
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
3+
const { ESBuildPlugin } = require("esbuild-loader");
4+
5+
module.exports = {
6+
resolve: {
7+
extensions: [".js", ".ts", ".json"],
8+
},
9+
devtool: "source-map",
10+
mode: "production",
11+
entry: "./src/index.ts",
12+
output: {
13+
filename: "[name].js",
14+
path: path.resolve(__dirname, "dist"),
15+
libraryTarget: "commonjs",
16+
},
17+
module: {
18+
rules: [
19+
{
20+
test: /\.tsx?$/,
21+
use: [
22+
{
23+
loader: "tslint-loader",
24+
options: {
25+
configFile: path.resolve(__dirname, "./tslint.json"),
26+
},
27+
},
28+
],
29+
},
30+
{
31+
test: /\.js$/,
32+
loader: "esbuild-loader",
33+
options: {
34+
target: "es2015",
35+
},
36+
exclude: /node_modules/,
37+
},
38+
{
39+
test: /\.ts$/,
40+
loader: "esbuild-loader",
41+
options: {
42+
target: "es2015",
43+
tsconfigRaw: path.resolve(__dirname, "./tsconfig.json"),
44+
},
45+
exclude: /node_modules/,
46+
},
47+
],
48+
},
49+
plugins: [new CleanWebpackPlugin(), new ESBuildPlugin()],
50+
};

packages/hedgehog-lab/.eslintrc

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,14 @@
11
{
2-
"plugins": ["prettier", "@typescript-eslint"],
2+
"plugins": ["@typescript-eslint"],
33
"parser": "@typescript-eslint/parser",
44
"extends": [
55
"plugin:react/recommended",
66
"plugin:@typescript-eslint/recommended"
77
],
88
"rules": {
9-
"prettier/prettier": [
10-
"error",
11-
{
12-
"printWidth": 100,
13-
"tabWidth": 2,
14-
"semi": true,
15-
"trailingComma": "none",
16-
"singleQuote": true,
17-
"bracketSpacing": true,
18-
"jsxBracketSameLine": true,
19-
"alwaysParens": "avoid",
20-
"@typescript-eslint/ban-ts-ignore": "off"
21-
}
22-
]
9+
"no-unused-vars": "off",
10+
"@typescript-eslint/no-unused-vars": ["off"],
11+
"@typescript-eslint/no-use-before-define": "off"
2312
},
2413
"settings": {
2514
"react": {

packages/hedgehog-lab/config-overrides.js

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,55 @@ const {
44
getBabelLoader,
55
addWebpackPlugin,
66
addWebpackModuleRule,
7-
} = require('customize-cra');
8-
const ReactRefreshPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
7+
disableEsLint,
8+
} = require("customize-cra");
9+
const ReactRefreshPlugin = require("@pmmmwh/react-refresh-webpack-plugin");
10+
const { ESBuildPlugin } = require("esbuild-loader");
911

1012
module.exports = (config, env) => {
11-
const prod = config.mode === 'production';
13+
const prod = config.mode === "production";
1214
const babelLoader = getBabelLoader(config);
1315

1416
return override(
17+
addWebpackModuleRule({
18+
test: /.tsx?$/,
19+
use: [
20+
{
21+
loader: "esbuild-loader",
22+
options: {
23+
loader: "tsx",
24+
target: "es2015",
25+
jsxFactory: "React.createElement",
26+
jsxFragment: "React.Fragment",
27+
},
28+
},
29+
],
30+
}),
31+
disableEsLint(),
32+
addWebpackModuleRule({
33+
test: /.jsx?$/,
34+
use: [
35+
{
36+
loader: "esbuild-loader",
37+
options: {
38+
loader: "jsx",
39+
target: "es2015",
40+
jsxFactory: "React.createElement",
41+
jsxFragment: "React.Fragment",
42+
},
43+
},
44+
],
45+
}),
1546
// You can choose to just use worker-loader! instead if you want
1647
addWebpackModuleRule({
1748
test: /\.worker\.[jt]sx?$/,
1849
use: [
19-
{ loader: 'worker-loader' },
50+
{ loader: "worker-loader" },
2051
{ loader: babelLoader.loader, options: babelLoader.options },
2152
],
2253
}),
23-
24-
!prod && addBabelPlugin('react-refresh/babel'),
54+
addWebpackPlugin(new ESBuildPlugin()),
55+
!prod && addBabelPlugin("react-refresh/babel"),
2556
!prod && addWebpackPlugin(new ReactRefreshPlugin())
2657
)(config, env);
2758
};

packages/hedgehog-lab/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,20 @@
1212
"clsx": "^1.1.1",
1313
"codemirror": "^5.58.3",
1414
"comlink": "^4.3.0",
15+
"esbuild-loader": "^2.9.1",
1516
"ky": "^0.23.0",
16-
"monaco-editor": "^0.20.0",
17+
"monaco-editor": "^0.23.0",
1718
"plotly.js": "^1.54.6",
1819
"qs": "^6.9.4",
1920
"react": "^16.13.1",
2021
"react-codemirror2": "^7.2.1",
2122
"react-dom": "^16.13.1",
2223
"react-markdown": "^4.3.1",
2324
"react-mathjax": "^1.0.1",
25+
"react-monaco-editor": "^0.43.0",
2426
"react-plotly.js": "^2.4.0",
2527
"react-query": "^2.5.6",
28+
"react-resize-detector": "^6.6.4",
2629
"worker-loader": "^2.0.0"
2730
},
2831
"devDependencies": {

packages/hedgehog-lab/src/HedgehogLab.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ const HedgehogLab: React.FC = () => {
7373
const obj = Qs.parse(params, { ignoreQueryPrefix: true });
7474
yourUrl = obj.your_url ? (obj.your_url as string) : null;
7575
autoRun = obj.auto_run === 'true';
76-
code = obj.code? (obj.code as string): null;
76+
code = obj.code ? (obj.code as string) : null;
7777
showCode = obj.show_code === 'true';
7878
}
7979

@@ -89,7 +89,7 @@ const HedgehogLab: React.FC = () => {
8989
onSuccess: (result: OutputResult) => {
9090
setResult(result);
9191
},
92-
onError: (lastError:any) => {
92+
onError: (lastError: any) => {
9393
// It's necessary to output all exception messages to user at output textbox,
9494
// including execution runtime exception and compiling exception -Lidang
9595
console.log('Hedgehog Lab error: \n' + lastError.toString());
@@ -164,8 +164,8 @@ const HedgehogLab: React.FC = () => {
164164
siderBarOpen={siderBarOpen}
165165
setOpen={setOpen}
166166
lgBreakpointMatches={lgBreakpointMatches}
167-
switchShowCodes = {codeEditorOpen}
168-
setShowCode = {setCodeEditorOpen}
167+
switchShowCodes={codeEditorOpen}
168+
setShowCode={setCodeEditorOpen}
169169
/>
170170

171171
<SideBar

packages/hedgehog-lab/src/components/Header/Header.tsx

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ interface HeaderProps {
1212
setOpen: React.Dispatch<React.SetStateAction<boolean>>;
1313
lgBreakpointMatches: boolean;
1414
switchShowCodes: boolean;
15-
setShowCode: React.Dispatch<React.SetStateAction<boolean>>;
15+
setShowCode: React.Dispatch<React.SetStateAction<boolean>>;
1616
}
1717

1818
const useStyles = makeStyles((theme: Theme) =>
@@ -33,9 +33,9 @@ const Header: React.FC<HeaderProps> = (props: HeaderProps) => {
3333
setOpen(!siderBarOpen);
3434
};
3535

36-
const handleShowOrHideCodes = () =>{
36+
const handleShowOrHideCodes = () => {
3737
setShowCode(!switchShowCodes);
38-
}
38+
};
3939

4040
/*todo: add show code
4141
@@ -48,7 +48,7 @@ const Header: React.FC<HeaderProps> = (props: HeaderProps) => {
4848
/>
4949
</FormGroup>
5050
51-
*/
51+
*/
5252

5353
return (
5454
<div>
@@ -63,13 +63,13 @@ const Header: React.FC<HeaderProps> = (props: HeaderProps) => {
6363
{siderBarOpen ? (
6464
<ArrowBackOutlinedIcon style={{ fontSize: '1.25rem' }} />
6565
) : (
66-
// <img
67-
// src={process.env.PUBLIC_URL + '/cat.png'}
68-
// style={{ height: '1.25rem' }}
69-
// alt="Hedgehog Lab Logo"
70-
// />
71-
<MenuIcon style={{ fontSize: '1.25rem' }} />
72-
)}
66+
// <img
67+
// src={process.env.PUBLIC_URL + '/cat.png'}
68+
// style={{ height: '1.25rem' }}
69+
// alt="Hedgehog Lab Logo"
70+
// />
71+
<MenuIcon style={{ fontSize: '1.25rem' }} />
72+
)}
7373
</IconButton>
7474

7575
<Typography
@@ -82,7 +82,6 @@ const Header: React.FC<HeaderProps> = (props: HeaderProps) => {
8282
Hedgehog Lab
8383
</Typography>
8484

85-
8685
<Button
8786
color="inherit"
8887
style={{ textTransform: 'none', height: 36 }}

packages/hedgehog-lab/src/components/Results/Results.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const Results: React.FC<ResultsProps> = (props: ResultsProps) => {
5151
</div>
5252
) : (
5353
<React.Fragment>
54-
<CardHeader/>
54+
<CardHeader />
5555

5656
<Divider />
5757

packages/hedgehog-lab/src/components/SideBar/SaveButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const useStyles = makeStyles((theme: Theme) =>
1414
width: '50%',
1515
fontSize: '0.875rem',
1616
fontWeight: 500,
17-
color: 'white',
17+
color: 'white'
1818
}
1919
})
2020
);

0 commit comments

Comments
 (0)