diff --git a/.eslintrc.js b/.eslintrc.js index 64ff7f047c9..c411995fc87 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -44,6 +44,9 @@ module.exports = { parser: '@typescript-eslint/parser', parserOptions: { project: [path.join(__dirname, './tsconfig.json')] }, reportUnusedDisableDirectives: true, + globals: { + globalThis: false, + }, rules: { 'prettier/prettier': 'warn', diff --git a/.github/workflows/size-compare.yml b/.github/workflows/size-compare.yml index 0dfcda68a63..40da2aad617 100644 --- a/.github/workflows/size-compare.yml +++ b/.github/workflows/size-compare.yml @@ -66,11 +66,11 @@ jobs: run: | sed -i -E 's/\.[0-9a-f]{8,}\././g' ./head/*.json sed -i -E 's/\.[0-9a-f]{8,}\././g' ./base/*.json - - uses: github/webpack-bundlesize-compare-action@v1.8.2 + - uses: twk3/rollup-size-compare-action@v1.0.0 with: github-token: ${{ secrets.GITHUB_TOKEN }} - current-stats-json-path: ./head/desktop-client-stats.json - base-stats-json-path: ./base/desktop-client-stats.json + current-stats-json-path: ./head/web-stats.json + base-stats-json-path: ./base/web-stats.json title: desktop-client - uses: github/webpack-bundlesize-compare-action@v1.8.2 diff --git a/packages/desktop-client/.gitignore b/packages/desktop-client/.gitignore index 7a5faec2c43..08fad3425bd 100644 --- a/packages/desktop-client/.gitignore +++ b/packages/desktop-client/.gitignore @@ -10,11 +10,13 @@ test-results # production build build-stats +stats.json # misc .DS_Store .env npm-debug.log +.swc *kcab.* public/kcab diff --git a/packages/desktop-client/bin/build-browser b/packages/desktop-client/bin/build-browser index 37fddd17f27..3e6e18aa6c0 100755 --- a/packages/desktop-client/bin/build-browser +++ b/packages/desktop-client/bin/build-browser @@ -8,7 +8,6 @@ echo "Building the browser..." rm -fr build export IS_GENERIC_BROWSER=1 -export INLINE_RUNTIME_CHUNK=false export REACT_APP_BACKEND_WORKER_HASH=`ls "$ROOT"/../public/kcab/kcab.worker.*.js | sed 's/.*kcab\.worker\.\(.*\)\.js/\1/'` yarn build @@ -16,4 +15,4 @@ yarn build rm -fr build-stats mkdir build-stats mv build/kcab/stats.json build-stats/loot-core-stats.json -mv build/stats.json build-stats/desktop-client-stats.json +mv ./stats.json build-stats/web-stats.json diff --git a/packages/desktop-client/craco.config.ts b/packages/desktop-client/craco.config.ts deleted file mode 100644 index 42a428979a2..00000000000 --- a/packages/desktop-client/craco.config.ts +++ /dev/null @@ -1,116 +0,0 @@ -const path = require('path'); - -const { - loaderByName, - removeLoaders, - addAfterLoader, - addPlugins, -} = require('@craco/craco'); -const chokidar = require('chokidar'); -const TerserPlugin = require('terser-webpack-plugin'); -const { IgnorePlugin } = require('webpack'); -const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer'); - -if (process.env.CI) { - process.env.DISABLE_ESLINT_PLUGIN = 'true'; -} - -// Forward Netlify env variables -if (process.env.REVIEW_ID) { - process.env.REACT_APP_REVIEW_ID = process.env.REVIEW_ID; -} - -module.exports = { - webpack: { - configure: (webpackConfig, { env, paths }) => { - webpackConfig.mode = - process.env.NODE_ENV === 'development' ? 'development' : 'production'; - - // swc-loader - addAfterLoader(webpackConfig, loaderByName('babel-loader'), { - test: /\.m?[tj]sx?$/, - exclude: /node_modules/, - loader: require.resolve('swc-loader'), - }); - - // remove the babel loaders - removeLoaders(webpackConfig, loaderByName('babel-loader')); - - addPlugins(webpackConfig, [ - new BundleAnalyzerPlugin({ - analyzerMode: 'disabled', - generateStatsFile: true, - }), - // Pikaday throws a warning if Moment.js is not installed however it doesn't - // actually require it to be installed. As we don't use Moment.js ourselves - // then we can just silence this warning. - new IgnorePlugin({ - contextRegExp: /pikaday$/, - resourceRegExp: /moment$/, - }), - ]); - - webpackConfig.resolve.extensions = [ - '.web.js', - '.web.jsx', - '.web.ts', - '.web.tsx', - '.js', - '.jsx', - '.ts', - '.tsx', - ...webpackConfig.resolve.extensions, - ]; - - if (process.env.IS_GENERIC_BROWSER) { - webpackConfig.resolve.extensions = [ - '.browser.js', - '.browser.jsx', - '.browser.ts', - '.browser.tsx', - ...webpackConfig.resolve.extensions, - ]; - } - - webpackConfig.optimization = { - ...webpackConfig.optimization, - minimize: - process.env.CI === 'true' || process.env.NODE_ENV !== 'development', - minimizer: [ - new TerserPlugin({ - minify: TerserPlugin.swcMinify, - // `terserOptions` options will be passed to `swc` (`@swc/core`) - // Link to options - https://swc.rs/docs/config-js-minify - terserOptions: { - compress: false, - mangle: true, - }, - }), - ], - }; - - return webpackConfig; - }, - }, - devServer: (devServerConfig, { env, paths, proxy, allowedHost }) => { - devServerConfig.onBeforeSetupMiddleware = server => { - chokidar - .watch([ - path.resolve('../loot-core/lib-dist/*.js'), - path.resolve('../loot-core/lib-dist/browser/*.js'), - ]) - .on('all', function () { - for (const ws of server.webSocketServer.clients) { - ws.send(JSON.stringify({ type: 'static-changed' })); - } - }); - }; - devServerConfig.headers = { - ...devServerConfig.headers, - 'Cross-Origin-Opener-Policy': 'same-origin', - 'Cross-Origin-Embedder-Policy': 'require-corp', - }; - - return devServerConfig; - }, -}; diff --git a/packages/desktop-client/public/index.html b/packages/desktop-client/index.html similarity index 88% rename from packages/desktop-client/public/index.html rename to packages/desktop-client/index.html index 59f92d8c60d..e136b97dca1 100644 --- a/packages/desktop-client/public/index.html +++ b/packages/desktop-client/index.html @@ -8,25 +8,25 @@ />