Skip to content

Commit 5a52fce

Browse files
committed
Updates the react app build system from using create-react-app to vite.
1 parent 6b42176 commit 5a52fce

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+8569
-30055
lines changed

.github/actions/generate-code-coverage/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2020-2024 The MathWorks, Inc.
1+
# Copyright 2020-2025 The MathWorks, Inc.
22

33
name: Generate Code Coverage XML
44
description: |
@@ -49,7 +49,7 @@ runs:
4949
shell: bash
5050

5151
- name: Generate code coverage for Javascript code
52-
run: npm --prefix gui test -- --coverage --watchAll=false
52+
run: npm --prefix gui test -- --coverage
5353
shell: bash
5454

5555
- name: Upload Javscript coverage report to Codecov

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,6 @@ If you encounter a technical issue or have an enhancement request, create an iss
187187

188188
---
189189

190-
Copyright 2020-2024 The MathWorks, Inc.
190+
Copyright 2020-2025 The MathWorks, Inc.
191191

192192
---

gui/.eslintrc.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,39 +5,39 @@
55
],
66
"plugins": [
77
"react",
8-
"jest",
9-
"testing-library"
8+
"testing-library",
9+
"node"
1010
],
1111
"env": {
12-
"jest/globals": true,
12+
"vitest/globals": true,
1313
"browser": true
1414
},
1515
"rules": {
1616
"indent": ["error", 4, {"SwitchCase": 1}],
1717
"semi": ["error", "always"],
1818
"no-extra-semi": "error",
19-
"quote-props": "warn",
19+
"quote-props": ["error", "as-needed"],
2020
"dot-notation": "warn",
2121
"object-curly-newline": "warn",
2222
"multiline-ternary": "warn",
2323
"prefer-const": "warn",
2424
"no-prototype-builtins": "warn",
2525
"array-callback-return": "warn",
2626
"array-bracket-spacing": "warn",
27-
"quotes": "warn",
27+
"quotes": ["warn", "single"],
2828
"lines-between-class-members": "warn",
2929
"no-empty": "warn",
3030
"prefer-regex-literals": "warn",
31-
"n/no-callback-literal": "warn",
31+
"node/no-callback-literal": "warn",
3232
"no-useless-catch": "warn",
33-
"n/handle-callback-err": "warn",
33+
"node/handle-callback-err": "warn",
3434
"no-case-declarations": "warn",
3535
"computed-property-spacing": "warn",
3636
"no-async-promise-executor": "warn",
37-
"no-unused-vars": "warn",
38-
"n/no-deprecated-api": "warn",
37+
"node/no-deprecated-api": "warn",
3938
"no-unreachable-loop": "warn",
40-
"no-void": "warn"
39+
"no-void": "warn",
40+
"no-unused-vars": ["error", { "varsIgnorePattern": "React" }]
4141
},
4242
"ignorePatterns": ["build/**"],
4343
"settings": {

gui/README.md

Lines changed: 14 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
1-
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
1+
This project contains the source code for the react app served by `matlab-proxy`
22

33
## Available Scripts
44

55
In the project directory, you can run:
66

7-
### `npm start`
7+
### `npm run dev`
88

99
Runs the app in the development mode.<br />
10-
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
10+
Open [http://localhost:5173](http://localhost:5173) to view it in the browser.
1111

1212
The page will reload if you make edits.<br />
1313
You will also see any lint errors in the console.
1414

1515
### `npm test`
1616

1717
Launches the test runner in the interactive watch mode.<br />
18-
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
18+
19+
### `npm run test:coverage`
20+
21+
Launches the test runner and generates code coverage based on configuration specified in `vite.config.js`.
1922

2023
### `npm run build`
2124

@@ -25,44 +28,16 @@ It correctly bundles React in production mode and optimizes the build for the be
2528
The build is minified and the filenames include the hashes.<br />
2629
Your app is ready to be deployed!
2730

28-
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
29-
30-
### `npm run eject`
31-
32-
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
33-
34-
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
35-
36-
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
37-
38-
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
39-
40-
## Learn More
41-
42-
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
43-
44-
To learn React, check out the [React documentation](https://reactjs.org/).
45-
46-
### Code Splitting
47-
48-
This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting
49-
50-
### Analyzing the Bundle Size
51-
52-
This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size
53-
54-
### Making a Progressive Web App
55-
56-
This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app
31+
### `npm run eslint`
5732

58-
### Advanced Configuration
33+
Runs lint checks on the source code based on `eslint.config.js` file
5934

60-
This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration
35+
### `npm run eslint:fix`
6136

62-
### Deployment
37+
Attempts to automatically correct problems in the source code according to the rules specified in `eslint.config.js`.
6338

64-
This section has moved here: https://facebook.github.io/create-react-app/docs/deployment
39+
---
6540

66-
### `npm run build` fails to minify
41+
Copyright 2020-2025 The MathWorks, Inc.
6742

68-
This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify
43+
---

gui/eslint.config.js

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// Copyright 2025 The MathWorks, Inc.
2+
3+
import globals from 'globals';
4+
import react from 'eslint-plugin-react';
5+
import reactHooks from 'eslint-plugin-react-hooks';
6+
import reactRefresh from 'eslint-plugin-react-refresh';
7+
import nodePlugin from 'eslint-plugin-node';
8+
import vitestPlugin from 'eslint-plugin-vitest';
9+
import fs from 'fs';
10+
11+
const eslintrcJson = JSON.parse(fs.readFileSync('./.eslintrc.json', 'utf8'));
12+
13+
14+
function cleanGlobals(globalsObject) {
15+
return Object.fromEntries(
16+
Object.entries(globalsObject).map(([key, value]) => [key.trim(), value])
17+
);
18+
}
19+
20+
export default [
21+
{ ignores: ['build'] },
22+
{
23+
files: ['**/*.{js,jsx}'],
24+
languageOptions: {
25+
ecmaVersion: 2020,
26+
globals: {
27+
...cleanGlobals(globals.browser),
28+
...eslintrcJson.env
29+
},
30+
parserOptions: {
31+
ecmaVersion: 'latest',
32+
ecmaFeatures: { jsx: true },
33+
sourceType: 'module',
34+
},
35+
},
36+
settings: eslintrcJson.settings,
37+
plugins: {
38+
...Object.fromEntries(eslintrcJson.plugins.map(plugin => [plugin, import(`eslint-plugin-${plugin}`)])),
39+
react,
40+
node: nodePlugin,
41+
vitest: vitestPlugin,
42+
'react-hooks': reactHooks,
43+
'react-refresh': reactRefresh,
44+
},
45+
rules: {
46+
...react.configs.recommended.rules,
47+
...react.configs['jsx-runtime'].rules,
48+
...reactHooks.configs.recommended.rules,
49+
'react/jsx-no-target-blank': 'off',
50+
'react-refresh/only-export-components': [
51+
'warn',
52+
{ allowConstantExport: true },
53+
],
54+
...eslintrcJson.rules,
55+
},
56+
},
57+
];

gui/index.css

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/* Copyright 2020-2025 The MathWorks, Inc. */
2+
3+
html {
4+
height: 100%;
5+
}
6+
7+
#root {
8+
height: 100%;
9+
}
10+
11+
body {
12+
margin: 0;
13+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
14+
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
15+
sans-serif;
16+
-webkit-font-smoothing: antialiased;
17+
-moz-osx-font-smoothing: grayscale;
18+
}
19+
20+
code {
21+
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
22+
monospace;
23+
}

gui/index.html

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<!-- Copyright 2025 The MathWorks, Inc. -->
2+
3+
<!doctype html>
4+
<html lang="en">
5+
<head>
6+
<meta charset="UTF-8" />
7+
<link rel="icon" href="./favicon.ico" />
8+
<meta name="viewport" content="width=device-width, initial-scale=1" />
9+
<meta name="theme-color" content="#000000" />
10+
<meta name="description" content="MATLAB" />
11+
<meta name="internal_mw_identifier" content="MWI_MATLAB_PROXY_IDENTIFIER" />
12+
<link rel="manifest" href="./manifest.json" />
13+
<link rel="stylesheet" href="./index.css">
14+
<title>MATLAB</title>
15+
</head>
16+
<body>
17+
<div id="root"></div>
18+
<script type="module" src="./src/main.jsx"></script>
19+
</body>
20+
</html>

0 commit comments

Comments
 (0)