Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(playground): migrate from Create React App to Vite #4570

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43,172 changes: 14,192 additions & 28,980 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
"eslint-plugin-prettier": "=5.2.1",
"file-loader": "=6.2.0",
"husky": "=9.1.7",
"jest-resolve": "^29.7.0",
"jsdom": "=25.0.1",
"jsdom-global": "=3.0.2",
"lerna": "=8.1.9",
Expand Down
2 changes: 0 additions & 2 deletions packages/apidom-playground/.eslintignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
build
scripts
node_modules
src/reportWebVitals.js
src/setupTests.js
4 changes: 2 additions & 2 deletions packages/apidom-playground/.eslintrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"extends": [
"react-app",
"react-app/jest",
"eslint:recommended",
"plugin:react/recommended",
"airbnb",
"plugin:jsx-a11y/recommended",
"prettier",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,26 @@
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="minimum-scale=1, initial-scale=1, width=device-width" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="ApiDOM playground"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<link rel="apple-touch-icon" href="/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.

Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<link rel="manifest" href="/manifest.json" />
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap" />
<title>ApiDOM playground</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<script type="module" src="/src/index.jsx"></script>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
Expand Down
22 changes: 9 additions & 13 deletions packages/apidom-playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
"license": "Apache-2.0",
"homepage": "https://swagger-api.github.io/apidom/",
"scripts": {
"start": "cross-env GENERATE_SOURCEMAP=false node ./scripts/start.js",
"build": "node ./scripts/build.js",
"test": "echo 'no tests defined for ApiDOM Playground'; # react-scripts test",
"start": "vite",
"build": "vite build",
"test": "echo 'no tests defined for ApiDOM Playground'",
"lint": "eslint ./",
"lint:fix": "eslint ./ --fix",
"clean": "rimraf ./build"
Expand All @@ -38,10 +38,10 @@
"@swagger-api/apidom-parser-adapter-asyncapi-yaml-2": "*",
"@swagger-api/apidom-parser-adapter-json": "*",
"@swagger-api/apidom-parser-adapter-openapi-json-2": "*",
"@swagger-api/apidom-parser-adapter-openapi-yaml-2": "*",
"@swagger-api/apidom-parser-adapter-openapi-json-3-0": "*",
"@swagger-api/apidom-parser-adapter-openapi-yaml-3-0": "*",
"@swagger-api/apidom-parser-adapter-openapi-json-3-1": "*",
"@swagger-api/apidom-parser-adapter-openapi-yaml-2": "*",
"@swagger-api/apidom-parser-adapter-openapi-yaml-3-0": "*",
"@swagger-api/apidom-parser-adapter-openapi-yaml-3-1": "*",
"@swagger-api/apidom-parser-adapter-workflows-json-1": "*",
"@swagger-api/apidom-parser-adapter-workflows-yaml-1": "*",
Expand All @@ -59,14 +59,10 @@
"web-vitals": "^4.0.0"
},
"devDependencies": {
"@testing-library/jest-dom": "^6.0.0",
"@testing-library/react": "^16.0.0",
"@testing-library/user-event": "^14.0.0",
"@vitejs/plugin-react": "^4.3.3",
"eslint-config-airbnb": "^19.0.4",
"react-scripts": "^5.0.1",
"react-dev-utils": "^12.0.1",
"@babel/plugin-proposal-private-property-in-object": "=7.21.11",
"rewire": "^7.0.0",
"sass": "^1.55.0"
"eslint-plugin-react": "^7.37.2",
"sass": "^1.55.0",
"vite": "^5.4.11"
}
}
17 changes: 0 additions & 17 deletions packages/apidom-playground/scripts/build.js

This file was deleted.

21 changes: 0 additions & 21 deletions packages/apidom-playground/scripts/start.js

This file was deleted.

4 changes: 3 additions & 1 deletion packages/apidom-playground/src/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ import reportWebVitals from './reportWebVitals.js';
const system = new System({
plugins: [ApiDOMPlaygroundPlugin],
middleware: (sys) => (getDefaultMiddleware) => {
const apiDOMWorker = new Worker(new URL('./playground/apidom.worker', import.meta.url));
const apiDOMWorker = new Worker(new URL('./playground/apidom.worker', import.meta.url), {
type: 'module',
});
const apiDOMService = Comlink.wrap(apiDOMWorker);

return getDefaultMiddleware({
Expand Down
5 changes: 0 additions & 5 deletions packages/apidom-playground/src/setupTests.js

This file was deleted.

26 changes: 26 additions & 0 deletions packages/apidom-playground/vite.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';

export default defineConfig({
plugins: [
react(),
{
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This plugin is a replacement for this part of the previous start script:

cross-env GENERATE_SOURCEMAP=false

Using other sourcemap configs did not disable them for JS files.

Source: vitejs/vite#9825 (comment)

name: 'remove-sourcemaps',
transform(code) {
return {
code,
map: { mappings: '' },
};
},
},
],
server: {
port: 3000,
},
assetsInclude: ['**/*.wasm'],
build: {
target: 'esnext',
outDir: 'build',
chunkSizeWarningLimit: 825,
},
});