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

Migrate to Vite #315

Merged
merged 16 commits into from
Jan 30, 2024
Merged
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
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
max_line_length = 80
max_line_length = 120
trim_trailing_whitespace = true

[*.md]
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@ jobs:
working-directory: ./web
env:
NODE_ENV: "production"
REACT_APP_VERSION: "${{ env.RELEASE_VERSION }}"
REACT_APP_GITHUB_URL: "${{ github.server_url }}/${{ github.repository }}"
REACT_APP_GO_VERSION: "${{ env.GO_VERSION }}"
REACT_APP_PREV_GO_VERSION: "${{ env.PREV_GO_VERSION }}"
REACT_APP_WASM_API_VER: "${{ env.WASM_API_VER }}"
REACT_APP_WASM_BASE_URL: "/wasm"
VITE_VERSION: "${{ env.RELEASE_VERSION }}"
VITE_GITHUB_URL: "${{ github.server_url }}/${{ github.repository }}"
VITE_GO_VERSION: "${{ env.GO_VERSION }}"
VITE_PREV_GO_VERSION: "${{ env.PREV_GO_VERSION }}"
VITE_WASM_API_VER: "${{ env.WASM_API_VER }}"
VITE_WASM_BASE_URL: "/wasm"

- name: Build and push image
uses: docker/build-push-action@v5
Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ include build.mk
include docker.mk

# Exports
export REACT_APP_VERSION=$(APP_VERSION)
export REACT_APP_GITHUB_URL=$(REPO_URL)
export REACT_APP_WASM_API_VER=$(WASM_API_VER)
export REACT_APP_WASM_BASE_URL=/wasm
export VITE_VERSION=$(APP_VERSION)
export VITE_GITHUB_URL=$(REPO_URL)
export VITE_WASM_API_VER=$(WASM_API_VER)
export VITE_WASM_BASE_URL=/wasm

.PHONY:run
run:
Expand Down
2 changes: 1 addition & 1 deletion build.mk
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ build-ui:

.PHONY: wasm_exec.js
wasm_exec.js:
@cp "$(GOROOT)/misc/wasm/wasm_exec.js" $(PUBLIC_DIR)/wasm/wasm_exec@$(WASM_API_VER).js
@cp "$(GOROOT)/misc/wasm/wasm_exec.js" $(UI)/src/lib/go/wasm_exec.js

.PHONY:build-webworker
analyzer.wasm:
Expand Down
16 changes: 7 additions & 9 deletions build/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ ARG PREV_GO_VERSION
COPY web /tmp/web
WORKDIR /tmp/web
RUN yarn install --silent && \
REACT_APP_VERSION=$APP_VERSION \
VITE_VERSION=$APP_VERSION \
NODE_ENV=production \
REACT_APP_GITHUB_URL=$GITHUB_URL \
REACT_APP_GO_VERSION=$GO_VERSION \
REACT_APP_PREV_GO_VERSION=$PREV_GO_VERSION \
REACT_APP_WASM_API_VER=$WASM_API_VER \
REACT_APP_WASM_BASE_URL=/wasm \
VITE_GITHUB_URL=$GITHUB_URL \
VITE_GO_VERSION=$GO_VERSION \
VITE_PREV_GO_VERSION=$PREV_GO_VERSION \
VITE_WASM_API_VER=$WASM_API_VER \
VITE_WASM_BASE_URL=/wasm \
yarn build

FROM golang:${GO_VERSION}-alpine as build
Expand All @@ -45,8 +45,7 @@ RUN echo "Building server with version $APP_VERSION" && \
-buildvcs=false \
-ldflags "-s -w" \
-trimpath \
-o ./analyzer@$WASM_API_VER.wasm ./cmd/wasm/analyzer && \
cp $(go env GOROOT)/misc/wasm/wasm_exec.js ./wasm_exec@$WASM_API_VER.js
-o ./analyzer@$WASM_API_VER.wasm ./cmd/wasm/analyzer

FROM golang:${GO_VERSION}-alpine as production
ARG GO_VERSION
Expand All @@ -62,7 +61,6 @@ COPY data ./data
COPY --from=ui-build /tmp/web/build ./public
COPY --from=build /tmp/playground/server .
COPY --from=build /tmp/playground/*.wasm ./public/wasm/
COPY --from=build /tmp/playground/*.js ./public/wasm/
EXPOSE 8000
ENTRYPOINT /opt/playground/server \
-f='/opt/playground/data/packages.json' \
Expand Down
4 changes: 1 addition & 3 deletions build/release.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ RUN echo "Building server with version $APP_VERSION" && \
-buildvcs=false \
-ldflags "-s -w" \
-trimpath \
-o ./analyzer@$WASM_API_VER.wasm ./cmd/wasm/analyzer && \
cp $(go env GOROOT)/misc/wasm/wasm_exec.js ./wasm_exec@$WASM_API_VER.js
-o ./analyzer@$WASM_API_VER.wasm ./cmd/wasm/analyzer

FROM golang:${GO_VERSION}-alpine as production
ARG GO_VERSION
Expand All @@ -48,7 +47,6 @@ COPY data ./data
COPY web/build ./public
COPY --from=build /tmp/playground/server .
COPY --from=build /tmp/playground/*.wasm ./public/wasm/
COPY --from=build /tmp/playground/*.js ./public/wasm/
EXPOSE 8000
ENTRYPOINT /opt/playground/server \
-f='/opt/playground/data/packages.json' \
Expand Down
9 changes: 8 additions & 1 deletion web/.eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
build/
public/
public/
.eslintrc.cjs
vite.config.ts
.vscode
.github
*.d.ts
wasm_exec.js
**/node_modules
82 changes: 82 additions & 0 deletions web/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
module.exports = {
env: {
browser: true,
es2021: true
},
extends: [
"plugin:react/recommended",
"eslint:recommended",
"plugin:react-hooks/recommended",
"standard-with-typescript",
"plugin:import/recommended",
"plugin:import/typescript",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended"
],
plugins: [
"react",
"react-hooks",
"import",
"@typescript-eslint",
"prettier",
"unused-imports"
],
parserOptions: {
ecmaVersion: "latest",
ecmaFeatures: {
jsx: true
},
sourceType: "module",
project: [
"tsconfig.json"
],
tsconfigRootDir: __dirname
},
settings: {
react: {
version: "detect"
},
'import/extensions': [
".js",
".jsx",
".ts",
".tsx"
],
'import/parsers': {
'@typescript-eslint/parser': [
".ts",
".tsx"
]
},
'import/resolver': {
typescript: {
alwaysTryTypes: true
}
}
},
rules: {
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/strict-boolean-expressions': 'off',
'@typescript-eslint/consistent-indexed-object-style': 'off',
'@typescript-eslint/no-dynamic-delete': 'off',
'@typescript-eslint/no-misused-promises': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/restrict-template-expressions': 'off',
'@typescript-eslint/triple-slash-reference': 'off',
'@typescript-eslint/prefer-nullish-coalescing': 'off',
'@typescript-eslint/no-confusing-void-expression': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'import/no-named-as-default-member': 'off',
'@typescript-eslint/ban-types': [
"error",
{
"types": {
"Function": false,
"{}": false,
},
"extendDefaults": true
}
],
}
}
1 change: 0 additions & 1 deletion web/.eslintrc.yml

This file was deleted.

15 changes: 15 additions & 0 deletions web/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"bracketSpacing": true,
"singleQuote": true,
"jsxSingleQuote": false,
"printWidth": 120,
"proseWrap": "always",
"semi": false,
"tabWidth": 2,
"arrowParens": "always",
"trailingComma": "all",
"bracketSameLine": false,
"options": {
"editorconfig": true
}
}
42 changes: 0 additions & 42 deletions web/craco.config.js

This file was deleted.

41 changes: 26 additions & 15 deletions web/package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "ui",
"type": "module",
"version": "0.1.0",
"private": true,
"dependencies": {
"@craco/craco": "^6.4.3",
"@fluentui/react": "^8.52.3",
"@monaco-editor/loader": "^1.4.0",
"@monaco-editor/react": "^4.6.0",
Expand All @@ -21,12 +21,10 @@
"@xterm/addon-webgl": "^0.17.0-beta.1",
"@xterm/xterm": "^5.4.0-beta.1",
"axios": "^1.6.0",
"circular-dependency-plugin": "^5.2.2",
"clsx": "^1.1.1",
"connected-react-router": "^6.9.2",
"copy-to-clipboard": "^3.3.1",
"core-js": "^3.35.1",
"craco-alias": "^3.0.1",
"dexie": "^3.2.3",
"file-saver": "^2.0.5",
"monaco-editor": "^0.45.0",
Expand All @@ -37,10 +35,9 @@
"react-icons": "^4.3.1",
"react-redux": "^7.2.6",
"react-router-dom": "^5.3.0",
"react-scripts": "5.0.0",
"redux": "^4.1.2",
"redux-thunk": "^2.4.1",
"typescript": "^4.5.5",
"typescript": "^5.3.3",
"util": "^0.12.4",
"uuid": "^3.4.0",
"web-vitals": "^2.1.4",
Expand All @@ -58,10 +55,9 @@
"workbox-streams": "^6.5.4"
},
"scripts": {
"start": "GENERATE_SOURCEMAP=true craco start",
"build": "GENERATE_SOURCEMAP=false craco build",
"test": "craco test",
"eject": "craco eject",
"start": "vite",
"build": "GENERATE_SOURCEMAP=false vite build",
"serve": "vite preview",
"lint": "npx eslint .",
"gen:suggestions": "node ./src/editor/internal/genpkgcache.js"
},
Expand All @@ -85,15 +81,30 @@
},
"devDependencies": {
"@types/node": "^17.0.16",
"eslint": "^8.37.0",
"@typescript-eslint/eslint-plugin": "^6.20.0",
"@typescript-eslint/parser": "^6.20.0",
"@vitejs/plugin-react-swc": "^3.5.0",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-config-react-app": "^7.0.0",
"eslint-plugin-flowtype": "^8.0.3",
"eslint-plugin-import": "^2.25.3",
"eslint-config-standard-with-typescript": "^43.0.1",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jest": "^25.3.0",
"eslint-plugin-jsx-a11y": "^6.5.1",
"eslint-plugin-react": "^7.27.1",
"eslint-plugin-react-hooks": "^4.3.0",
"eslint-plugin-n": "^16.6.2",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-testing-library": "^5.0.1",
"http-proxy-middleware": "^2.0.6"
"eslint-plugin-unused-imports": "^3.0.0",
"prettier": "^3.2.4",
"vite": "^5.0.12",
"vite-plugin-html": "^3.2.2",
"vite-plugin-node-polyfills": "^0.19.0",
"vite-plugin-static-copy": "^1.0.1",
"vite-plugin-svgr": "^4.2.0",
"vite-tsconfig-paths": "^4.3.1"
}
}
14 changes: 7 additions & 7 deletions web/src/App.test.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from 'react';
import { render } from '@testing-library/react';
import { App } from './App';
import React from 'react'
import { render } from '@testing-library/react'
import { App } from './App'

test('renders learn react link', () => {
const { getByText } = render(<App />);
const linkElement = getByText(/learn react/i);
expect(linkElement).toBeInTheDocument();
});
const { getByText } = render(<App />)
const linkElement = getByText(/learn react/i)
expect(linkElement).toBeInTheDocument()
})
Loading
Loading