-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch to Vite from Create React App (#1152)
- CRA/Craco -> Vite + Vitest + eslint - TypeScript 4->5 npm audit issues are now at 0 🎉 bundle size slightly smaller with fewer total requests and quicker load time in Chrome Notable changes: - Use a Web Worker bundle per language to workaround Vite/Safari 14 limitations - I also renamed the main worker-side file to make it clearer what was what as I found it confusing to come back to. - Fixed a dev-only API tab initialisation issue found by e2e tests - Fixed a layout shift issue spotted in review that turned out to be due to useMediaQuery behaviour changes in the recent Chakra UI upgrade - Adding updated eslint config caught a missing await in storage.ts. Should only have been significant when deleting files that don't exist which we never intend to do. We'll run this on beta for a while (along with the Chakra UI upgrade) before considering a release.
- Loading branch information
1 parent
c16d50d
commit 4425d16
Showing
105 changed files
with
8,525 additions
and
21,406 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
REACT_APP_VERSION=$npm_package_version | ||
REACT_APP_NAME=$npm_package_name | ||
VITE_VERSION=$npm_package_version | ||
VITE_NAME=$npm_package_name | ||
VITE_FULL_URL=/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
module.exports = { | ||
root: true, | ||
env: { browser: true, es2020: true }, | ||
extends: [ | ||
"eslint:recommended", | ||
// We should switch to recommended-type-checked but there are many issues to review | ||
"plugin:@typescript-eslint/recommended", | ||
//"plugin:@typescript-eslint/recommended-type-checked", | ||
"plugin:react-hooks/recommended", | ||
"plugin:react/recommended", | ||
"plugin:react/jsx-runtime", | ||
], | ||
ignorePatterns: [ | ||
"dist", | ||
".eslintrc.cjs", | ||
"deployment.cjs", | ||
"bin/**/*.js", | ||
"bootstrap-template.js", | ||
"playwright.config.ts", | ||
], | ||
parser: "@typescript-eslint/parser", | ||
parserOptions: { | ||
ecmaVersion: "latest", | ||
sourceType: "module", | ||
project: ["./tsconfig.json", "./tsconfig.node.json"], | ||
tsconfigRootDir: __dirname, | ||
}, | ||
plugins: ["react-refresh"], | ||
settings: { | ||
react: { | ||
version: "18", | ||
}, | ||
}, | ||
rules: { | ||
// More trouble than it's worth | ||
"react/no-unescaped-entities": "off", | ||
// False positives from library imports from Chakra UI | ||
"@typescript-eslint/unbound-method": "off", | ||
"@typescript-eslint/no-misused-promises": [ | ||
"error", | ||
{ | ||
checksVoidReturn: false, | ||
}, | ||
], | ||
"@typescript-eslint/no-unused-vars": [ | ||
"error", | ||
{ | ||
args: "all", | ||
argsIgnorePattern: "^_", | ||
caughtErrors: "all", | ||
// Let's remove e from here | ||
caughtErrorsIgnorePattern: "^_|e", | ||
destructuredArrayIgnorePattern: "^_", | ||
varsIgnorePattern: "^_", | ||
ignoreRestSiblings: true, | ||
}, | ||
], | ||
// Temporary, new rules on Vite migration that are widely flouted | ||
"@typescript-eslint/no-explicit-any": "off", | ||
"prefer-const": "off", | ||
"react/display-name": "off", | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/usr/bin/env node | ||
let baseUrl; | ||
if (process.env.GITHUB_REPOSITORY_OWNER === "microbit-foundation") { | ||
// STAGE must be defined before this is imported | ||
const { bucketPrefix, bucketName } = require("../deployment.cjs"); | ||
baseUrl = `/${bucketPrefix}/`; | ||
|
||
const fullUrl = `https://${bucketName}${baseUrl}`; | ||
// This is used for og:url and similar. Not quite right for review domain but we don't really care. | ||
console.log(`VITE_FULL_URL=${fullUrl}`); | ||
} else { | ||
baseUrl = "/"; | ||
} | ||
|
||
// Two env vars as BASE_URL seems to be blank when running jest even if we set it. | ||
console.log(`BASE_URL=${baseUrl}`); | ||
console.log(`E2E_BASE_URL=${baseUrl}`); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.