mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-24 07:29:30 +01:00
web: optimize tests by ~120% (#1018)
This is mainly done via sharding, caching & reducing total work: 1. `terser` is turned off when generating test build 2. `nx` distributed cache allows reusing build outputs 3. `playwright` sharding allows running tests in parallel This can further be improved by using `swc` & `esbuild` during build
This commit is contained in:
@@ -1,8 +1,27 @@
|
||||
diff --git a/node_modules/react-scripts/config/webpack.config.js b/node_modules/react-scripts/config/webpack.config.js
|
||||
index e465d8e..7a393f6 100644
|
||||
index e465d8e..769f0dd 100644
|
||||
--- a/node_modules/react-scripts/config/webpack.config.js
|
||||
+++ b/node_modules/react-scripts/config/webpack.config.js
|
||||
@@ -304,6 +304,13 @@ module.exports = function (webpackEnv) {
|
||||
@@ -106,6 +106,9 @@ module.exports = function (webpackEnv) {
|
||||
const isEnvProductionProfile =
|
||||
isEnvProduction && process.argv.includes('--profile');
|
||||
|
||||
+ const isEnvProductionTest =
|
||||
+ isEnvProduction && process.argv.includes('--test');
|
||||
+
|
||||
// We will provide `paths.publicUrlOrPath` to our app
|
||||
// as %PUBLIC_URL% in `index.html` and `process.env.PUBLIC_URL` in JavaScript.
|
||||
// Omit trailing slash as %PUBLIC_URL%/xyz looks better than %PUBLIC_URL%xyz.
|
||||
@@ -256,7 +259,7 @@ module.exports = function (webpackEnv) {
|
||||
level: 'none',
|
||||
},
|
||||
optimization: {
|
||||
- minimize: isEnvProduction,
|
||||
+ minimize: isEnvProduction && !isEnvProductionTest,
|
||||
minimizer: [
|
||||
// This is only used in production mode
|
||||
new TerserPlugin({
|
||||
@@ -304,6 +307,13 @@ module.exports = function (webpackEnv) {
|
||||
},
|
||||
resolve: {
|
||||
// This allows you to set a fallback for where webpack should look for modules.
|
||||
@@ -16,16 +35,24 @@ index e465d8e..7a393f6 100644
|
||||
// We placed these paths second because we want `node_modules` to "win"
|
||||
// if there are any conflicts. This matches Node resolution mechanism.
|
||||
// https://github.com/facebook/create-react-app/issues/253
|
||||
@@ -327,6 +334,8 @@ module.exports = function (webpackEnv) {
|
||||
@@ -320,13 +330,15 @@ module.exports = function (webpackEnv) {
|
||||
.map(ext => `.${ext}`)
|
||||
.filter(ext => useTypeScript || !ext.includes('ts')),
|
||||
alias: {
|
||||
+ "react": path.resolve(path.join(__dirname,'../../react')),
|
||||
+ "react-dom": path.resolve(path.join(__dirname,'../../react-dom')),
|
||||
// Support React Native Web
|
||||
// https://www.smashingmagazine.com/2016/08/a-glimpse-into-the-future-with-react-native-for-web/
|
||||
'react-native': 'react-native-web',
|
||||
// Allows for better profiling with ReactDevTools
|
||||
...(isEnvProductionProfile && {
|
||||
'react-dom$': 'react-dom/profiling',
|
||||
'scheduler/tracing': 'scheduler/tracing-profiling',
|
||||
+ "react": path.resolve(path.join(__dirname,'../../react')),
|
||||
+ "react-dom": path.resolve(path.join(__dirname,'../../react-dom'))
|
||||
- 'scheduler/tracing': 'scheduler/tracing-profiling',
|
||||
+ 'scheduler/tracing': 'scheduler/tracing-profiling'
|
||||
}),
|
||||
...(modules.webpackAliases || {}),
|
||||
},
|
||||
@@ -336,14 +345,14 @@ module.exports = function (webpackEnv) {
|
||||
@@ -336,14 +348,14 @@ module.exports = function (webpackEnv) {
|
||||
// To fix this, we prevent you from importing files out of src/ -- if you'd like to,
|
||||
// please link the files into your node_modules/ and let module-resolution kick in.
|
||||
// Make sure your source files are compiled, as they will not be processed in any way.
|
||||
|
||||
Reference in New Issue
Block a user