Skip to content

Commit 69a1102

Browse files
committed
fix: fix build bug
1 parent ef8d42c commit 69a1102

File tree

9 files changed

+419
-96
lines changed

9 files changed

+419
-96
lines changed

packages/hedgehog-core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"mathjs": "^7.1.0",
3434
"nerdamer": "^1.1.5",
3535
"webpack": "^5.21.2",
36-
"webpack-cli": "^4.5.0"
36+
"webpack-cli": "^4.5.0",
3737
"sync-fetch": "^0.3.0"
3838
},
3939
"devDependencies": {

packages/hedgehog-lab/.eslintrc

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,13 @@
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"]
2311
},
2412
"settings": {
2513
"react": {

packages/hedgehog-lab/config-overrides.js

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,46 @@ const {
44
getBabelLoader,
55
addWebpackPlugin,
66
addWebpackModuleRule,
7+
useEslintRc,
78
} = require("customize-cra");
89
const ReactRefreshPlugin = require("@pmmmwh/react-refresh-webpack-plugin");
910
const { ESBuildPlugin } = require("esbuild-loader");
11+
const path = require("path");
1012

1113
module.exports = (config, env) => {
1214
const prod = config.mode === "production";
1315
const babelLoader = getBabelLoader(config);
14-
console.log(prod, config.mode);
16+
1517
return override(
16-
!prod &&
17-
addWebpackModuleRule({
18-
test: /.tsx?$/,
19-
use: [
20-
{
21-
loader: "esbuild-loader",
22-
options: { loader: "tsx", target: "es2015" },
18+
addWebpackModuleRule({
19+
test: /.tsx?$/,
20+
use: [
21+
{
22+
loader: "esbuild-loader",
23+
options: {
24+
loader: "tsx",
25+
target: "es2015",
26+
jsxFactory: "React.createElement",
27+
jsxFragment: "React.Fragment",
2328
},
24-
],
25-
}),
26-
27-
!prod &&
28-
addWebpackModuleRule({
29-
test: /.jsx?$/,
30-
use: [
31-
{
32-
loader: "esbuild-loader",
33-
options: { loader: "jsx", target: "es2015" },
29+
},
30+
],
31+
}),
32+
useEslintRc(path.resolve(__dirname, "./.eslintrc")),
33+
addWebpackModuleRule({
34+
test: /.jsx?$/,
35+
use: [
36+
{
37+
loader: "esbuild-loader",
38+
options: {
39+
loader: "jsx",
40+
target: "es2015",
41+
jsxFactory: "React.createElement",
42+
jsxFragment: "React.Fragment",
3443
},
35-
],
36-
}),
44+
},
45+
],
46+
}),
3747
// You can choose to just use worker-loader! instead if you want
3848
addWebpackModuleRule({
3949
test: /\.worker\.[jt]sx?$/,
@@ -42,7 +52,7 @@ module.exports = (config, env) => {
4252
{ loader: babelLoader.loader, options: babelLoader.options },
4353
],
4454
}),
45-
!prod && addWebpackPlugin(new ESBuildPlugin()),
55+
addWebpackPlugin(new ESBuildPlugin()),
4656
!prod && addBabelPlugin("react-refresh/babel"),
4757
!prod && addWebpackPlugin(new ReactRefreshPlugin())
4858
)(config, env);

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/YourCode/YourCode.tsx

Lines changed: 25 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import React, { useState, Dispatch, SetStateAction } from "react";
2-
import { Button, Card, CardContent, CardHeader } from "@material-ui/core";
3-
import MonacoEditor, { EditorDidMount } from "react-monaco-editor";
4-
import * as monacoEditor from "monaco-editor/esm/vs/editor/editor.api";
5-
import ResizeObserver from "react-resize-detector";
6-
import { queryCache } from "react-query";
1+
import React, { useState, Dispatch, SetStateAction } from 'react';
2+
import { Button, Card, CardContent, CardHeader } from '@material-ui/core';
3+
import MonacoEditor, { EditorDidMount } from 'react-monaco-editor';
4+
import * as monacoEditor from 'monaco-editor/esm/vs/editor/editor.api';
5+
import ResizeObserver from 'react-resize-detector';
6+
import { queryCache } from 'react-query';
77

8-
const COMPILE_AND_RUN_BUTTON_ID = "compile-and-run-button-id";
8+
const COMPILE_AND_RUN_BUTTON_ID = 'compile-and-run-button-id';
99

1010
interface YourCodeProps {
1111
handleCompileAndRun: (event: React.MouseEvent) => void;
@@ -16,19 +16,16 @@ interface YourCodeProps {
1616

1717
const YourCode: React.FC<YourCodeProps> = (props: YourCodeProps) => {
1818
const { handleCompileAndRun, loading, setSource, source } = props;
19-
const [
20-
editor,
21-
setEditor,
22-
] = useState<monacoEditor.editor.IStandaloneCodeEditor | null>(null);
19+
const [editor, setEditor] = useState<monacoEditor.editor.IStandaloneCodeEditor | null>(null);
2320
const [monaco, setMonaco] = useState<typeof monacoEditor | null>(null);
2421

2522
const handleUploadSource = (v: string) => {
2623
setSource(v as string);
2724
};
2825

2926
const options = {
30-
wordWrap: "on" as const,
31-
scrollBeyondLastLine: false,
27+
wordWrap: 'on' as const,
28+
scrollBeyondLastLine: false
3229
};
3330

3431
const EditorDidMountHandle = (
@@ -37,20 +34,20 @@ const YourCode: React.FC<YourCodeProps> = (props: YourCodeProps) => {
3734
) => {
3835
editor.addAction({
3936
id: COMPILE_AND_RUN_BUTTON_ID,
40-
label: "compile-and-run-butt-label",
37+
label: 'compile-and-run-butt-label',
4138
keybindings: [2051], // Monaco.KeyMod.CtrlCmd | Monaco.KeyCode.Enter == 2051
4239
run: () => {
4340
document.getElementById(COMPILE_AND_RUN_BUTTON_ID)?.click();
44-
},
41+
}
4542
});
4643

4744
setEditor(editor);
4845
setMonaco(monaco);
4946
};
5047

5148
return (
52-
<div style={{ height: "100%" }}>
53-
<Card className={"your-code-card"} style={{ height: "100%" }}>
49+
<div style={{ height: '100%' }}>
50+
<Card className={'your-code-card'} style={{ height: '100%' }}>
5451
<CardHeader
5552
action={
5653
<div className="run-button">
@@ -59,19 +56,18 @@ const YourCode: React.FC<YourCodeProps> = (props: YourCodeProps) => {
5956
variant="contained"
6057
color="secondary"
6158
style={{
62-
textTransform: "none",
63-
width: 140,
59+
textTransform: 'none',
60+
width: 140
6461
}}
6562
onClick={() => {
6663
// stop the web-worker
67-
queryCache.cancelQueries(["compiler"]);
64+
queryCache.cancelQueries(['compiler']);
6865
// set result to initial state
69-
queryCache.setQueryData(["compiler", source], (data) => ({
66+
queryCache.setQueryData(['compiler', source], (data) => ({
7067
outputItem: [],
71-
outputString: "",
68+
outputString: ''
7269
}));
73-
}}
74-
>
70+
}}>
7571
Stop
7672
</Button>
7773
) : (
@@ -81,9 +77,8 @@ const YourCode: React.FC<YourCodeProps> = (props: YourCodeProps) => {
8177
color="primary"
8278
onClick={(e) => handleCompileAndRun(e)}
8379
style={{
84-
textTransform: "none",
85-
}}
86-
>
80+
textTransform: 'none'
81+
}}>
8782
Compile and run
8883
</Button>
8984
)}
@@ -98,13 +93,11 @@ const YourCode: React.FC<YourCodeProps> = (props: YourCodeProps) => {
9893
if (editor) {
9994
editor.layout();
10095
}
101-
}}
102-
>
96+
}}>
10397
<div
10498
style={{
105-
height: "calc(100vh - 174px)",
106-
}}
107-
>
99+
height: 'calc(100vh - 174px)'
100+
}}>
108101
<MonacoEditor
109102
language="javascript"
110103
value={source}

packages/hedgehog-lab/src/tutorials.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,6 @@ This document is created and maintained by Hedgehog Lab Community. The markdown
242242
243243
`;
244244

245-
246245
const moduleSource = `
247246
// import any HHS file on the web from URL
248247
*import https://gist.githubusercontent.com/lidangzzz/86c78163bf7838220224530d6e36aec9/raw/da89c75d4b6671dc0936240a62d483bf67e2b9ef/fibonacci.hs
@@ -291,6 +290,6 @@ export const tutorials = [
291290
},
292291
{
293292
description: 'Module',
294-
source: moduleSource,
293+
source: moduleSource
295294
}
296295
];

0 commit comments

Comments
 (0)