From 229452c2628a4fa9e4e3494408a303f9e5b5f973 Mon Sep 17 00:00:00 2001 From: Alexey Date: Mon, 29 May 2023 03:54:14 +0400 Subject: [PATCH] Chore/prettier (#1707) * chore: add prettier * chore: format code * chore: remove eslint ts integration * chore: update webpack.config --- webapp/packages/core-cli/.eslintrc.json | 1 - .../core-cli/configs/webpack.config.js | 48 +------ .../core-cli/configs/webpack.plugin.config.js | 14 +- .../configs/webpack.product.config.js | 130 +++++++++++------- webapp/packages/core-di/.gitignore | 3 + webapp/packages/core-di/package.json | 10 +- webapp/packages/core-di/tsconfig.json | 6 +- webapp/packages/core-executor/.gitignore | 3 + webapp/packages/core-executor/package.json | 11 +- webapp/packages/core-executor/tsconfig.json | 8 +- webapp/packages/core-utils/.gitignore | 3 + webapp/packages/core-utils/package.json | 6 +- webapp/packages/core-utils/tsconfig.json | 8 +- webapp/tsconfig.eslint.json | 11 -- webapp/tsconfig.json | 5 - 15 files changed, 128 insertions(+), 139 deletions(-) delete mode 100644 webapp/tsconfig.eslint.json diff --git a/webapp/packages/core-cli/.eslintrc.json b/webapp/packages/core-cli/.eslintrc.json index a666b7b9ee..f9f03dade4 100644 --- a/webapp/packages/core-cli/.eslintrc.json +++ b/webapp/packages/core-cli/.eslintrc.json @@ -13,7 +13,6 @@ "parserOptions": { "ecmaVersion": 2019, "sourceType": "module", - "project": "tsconfig.eslint.json", "ecmaFeatures": { "jsx": true } diff --git a/webapp/packages/core-cli/configs/webpack.config.js b/webapp/packages/core-cli/configs/webpack.config.js index 238522dfd4..ea54571a7c 100644 --- a/webapp/packages/core-cli/configs/webpack.config.js +++ b/webapp/packages/core-cli/configs/webpack.config.js @@ -4,10 +4,8 @@ const ModuleDependencyWarning = require('webpack/lib/ModuleDependencyWarning'); const MiniCssExtractPlugin = require('mini-css-extract-plugin'); const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin'); const ExtraWatchWebpackPlugin = require('extra-watch-webpack-plugin'); -const WorkboxPlugin = require('workbox-webpack-plugin'); const excludedFromVendor = require('./excludedFromVendor.js'); -const { getServiceWorkerSource } = require('./webpack.product.utils.js'); // const ESLintPlugin = require('eslint-webpack-plugin'); class IgnoreNotFoundExportPlugin { @@ -63,10 +61,7 @@ module.exports = (env, argv) => { modules = false; } - const postCssPlugins = [ - require('postcss-preset-env')({ stage: 0 }), - require('@reshadow/postcss')({ scopeBehaviour: moduleScope }), - ]; + const postCssPlugins = [require('postcss-preset-env')({ stage: 0 }), require('@reshadow/postcss')({ scopeBehaviour: moduleScope })]; return [ ...getBaseStyleLoaders(), @@ -107,27 +102,6 @@ module.exports = (env, argv) => { }, }; - var workboxPlugin = []; - if (devMode) { - // TODO: workbox not working in dev mode - - // workboxPlugin = new WorkboxPlugin.InjectManifest({ - // swSrc: getServiceWorkerSource(), - // swDest: 'service-worker.js', - // }); - // Object.defineProperty(workboxPlugin, 'alreadyCalled', { - // get() { - // return false; - // }, - // set() {}, - // }); - } else { - workboxPlugin = [new WorkboxPlugin.InjectManifest({ - swSrc: getServiceWorkerSource(), - swDest: 'service-worker.js', - })]; - } - return { // target: !devMode ? "web" : "browserslist", optimization: { @@ -206,15 +180,11 @@ module.exports = (env, argv) => { fallback: { // path: require.resolve('path-browserify'), }, - plugins: [ - PnpWebpackPlugin, - ], + plugins: [PnpWebpackPlugin], }, resolveLoader: { modules: nodeModules, - plugins: [ - PnpWebpackPlugin.moduleLoader(module), - ], + plugins: [PnpWebpackPlugin.moduleLoader(module)], }, module: { rules: [ @@ -226,10 +196,7 @@ module.exports = (env, argv) => { { test: /\.(ts|js)x?$/, exclude: /node_modules/, - use: [ - 'thread-loader', - babelLoader, - ], + use: ['thread-loader', babelLoader], }, { test: /\.(css|s[ac]ss)$/, @@ -240,11 +207,7 @@ module.exports = (env, argv) => { }, { include: /node_modules/, - use: [ - ...getBaseStyleLoaders(), - 'css-loader', - 'sass-loader', - ], + use: [...getBaseStyleLoaders(), 'css-loader', 'sass-loader'], }, { test: /\.(theme|pure)\.(css|s[ac]ss)$/, @@ -291,7 +254,6 @@ module.exports = (env, argv) => { } }, }), - ...workboxPlugin, ], }; }; diff --git a/webapp/packages/core-cli/configs/webpack.plugin.config.js b/webapp/packages/core-cli/configs/webpack.plugin.config.js index 8d8e330d00..7752e11b60 100644 --- a/webapp/packages/core-cli/configs/webpack.plugin.config.js +++ b/webapp/packages/core-cli/configs/webpack.plugin.config.js @@ -1,17 +1,19 @@ const { resolve } = require('path'); -var PeerDepsExternalsPlugin = require('peer-deps-externals-webpack-plugin'); +const PeerDepsExternalsPlugin = require('peer-deps-externals-webpack-plugin'); const { merge } = require('webpack-merge'); const commonConfig = require('./webpack.config.js'); -var main = resolve('src/index.ts'); -var outputDir = resolve('lib'); -var package = require(resolve('package.json')); +const main = resolve('src/index.ts'); +const outputDir = resolve('lib'); +const package = require(resolve('package.json')); module.exports = (env, argv) => merge(commonConfig(env, argv), { - entry: main, + entry: { + [package.name.replace('@cloudbeaver/', '')]: main, + }, output: { - filename: 'index.[contenthash].js', + filename: '[name].js', chunkFilename: '[name].[contenthash].bundle.js', library: package.name, libraryTarget: 'commonjs', diff --git a/webapp/packages/core-cli/configs/webpack.product.config.js b/webapp/packages/core-cli/configs/webpack.product.config.js index 70423fc656..65a46a5435 100644 --- a/webapp/packages/core-cli/configs/webpack.product.config.js +++ b/webapp/packages/core-cli/configs/webpack.product.config.js @@ -3,6 +3,7 @@ const HtmlWebpackPlugin = require('html-webpack-plugin'); const CopyWebpackPlugin = require('copy-webpack-plugin'); const TerserPlugin = require('terser-webpack-plugin'); const webpack = require('webpack'); +const WorkboxPlugin = require('workbox-webpack-plugin'); const { merge } = require('webpack-merge'); const commonConfig = require('./webpack.config.js'); @@ -15,58 +16,85 @@ const sso = require.resolve('@cloudbeaver/plugin-sso/src/index.ts'); const ssoHtmlTemplate = require.resolve('@cloudbeaver/plugin-sso/src/index.html.ejs'); const outputDir = resolve('lib'); const package = require(resolve('package.json')); +const { getServiceWorkerSource } = require('./webpack.product.utils.js'); const timestampVersion = withTimestamp(package.version); -module.exports = (env, argv) => merge(commonConfig(env, argv), { - entry: { - main, - sso, - }, - output: { - filename: 'index.[contenthash].js', - chunkFilename: '[name].[contenthash].bundle.js', - library: package.name, - libraryTarget: 'umd', - path: outputDir, - pathinfo: false, - }, - optimization: { - minimize: true, +module.exports = (env, argv) => { + const devMode = argv.mode !== 'production'; - minimizer: [new TerserPlugin({ - extractComments: /Copyright \(C\)/i, - terserOptions: { - keep_classnames: true, - keep_fnames: true, - }, - })], - }, - plugins: [ - new CopyWebpackPlugin({ - patterns: getAssets(package, ''), - }), - new webpack.DefinePlugin({ - _VERSION_: JSON.stringify(timestampVersion), - _DEV_: false, - }), - new HtmlWebpackPlugin({ - template: resolve('src/index.html.ejs'), - inject: 'body', - chunks: ['main'], - version: timestampVersion, - title: package.product?.name, - }), - new HtmlWebpackPlugin({ - filename: 'sso.html', - template: ssoHtmlTemplate, - inject: 'body', - chunks: ['sso'], - version: timestampVersion, - title: package.product?.name, - }), - new HtmlInjectWebpackPlugin({ - body: [{ attributes: { hidden: true }, tagName: 'object', innerHTML: '{STATIC_CONTENT}', voidTag: false }], - }), - ], -}); + var workboxPlugin = []; + if (devMode) { + // TODO: workbox not working in dev mode + + // workboxPlugin = new WorkboxPlugin.InjectManifest({ + // swSrc: getServiceWorkerSource(), + // swDest: 'service-worker.js', + // }); + // Object.defineProperty(workboxPlugin, 'alreadyCalled', { + // get() { + // return false; + // }, + // set() {}, + // }); + } else { + workboxPlugin = [new WorkboxPlugin.InjectManifest({ + swSrc: getServiceWorkerSource(), + swDest: 'service-worker.js', + })]; + } + + return merge(commonConfig(env, argv), { + entry: { + main, + sso, + }, + output: { + filename: 'index.[contenthash].js', + chunkFilename: '[name].[contenthash].bundle.js', + library: package.name, + libraryTarget: 'umd', + path: outputDir, + pathinfo: false, + }, + optimization: { + minimize: true, + + minimizer: [new TerserPlugin({ + extractComments: /Copyright \(C\)/i, + terserOptions: { + keep_classnames: true, + keep_fnames: true, + }, + })], + }, + plugins: [ + new CopyWebpackPlugin({ + patterns: getAssets(package, ''), + }), + new webpack.DefinePlugin({ + _VERSION_: JSON.stringify(timestampVersion), + _DEV_: false, + }), + new HtmlWebpackPlugin({ + template: resolve('src/index.html.ejs'), + inject: 'body', + chunks: ['main'], + version: timestampVersion, + title: package.product?.name, + }), + new HtmlWebpackPlugin({ + filename: 'sso.html', + template: ssoHtmlTemplate, + inject: 'body', + chunks: ['sso'], + version: timestampVersion, + title: package.product?.name, + }), + new HtmlInjectWebpackPlugin({ + body: [{ attributes: { hidden: true }, tagName: 'object', innerHTML: '{STATIC_CONTENT}', voidTag: false }], + }), + ...workboxPlugin, + ], + }); +}; diff --git a/webapp/packages/core-di/.gitignore b/webapp/packages/core-di/.gitignore index 99902db863..71d6190715 100644 --- a/webapp/packages/core-di/.gitignore +++ b/webapp/packages/core-di/.gitignore @@ -19,3 +19,6 @@ npm-debug.log* yarn-debug.log* yarn-error.log* + +# typescript +*.tsbuildinfo diff --git a/webapp/packages/core-di/package.json b/webapp/packages/core-di/package.json index 577d267cba..81a934036f 100644 --- a/webapp/packages/core-di/package.json +++ b/webapp/packages/core-di/package.json @@ -4,12 +4,12 @@ "version": "0.1.0", "description": "", "license": "Apache-2.0", - "main": "lib/index.js", - "module": "lib/index.js", + "main": "lib/core-di.js", + "module": "lib/core-di.js", "types": "src/index.ts", "scripts": { "prebuild": "rimraf --glob lib/*", - "build": "webpack --config ../../configs/webpack.plugin.config.js", + "build": "core-cli-build --mode=production --config ../core-cli/configs/webpack.plugin.config.js", "postbuild": "tsc", "lint": "eslint ./src/ --ext .ts,.tsx", "lint-fix": "eslint ./src/ --ext .ts,.tsx --fix", @@ -17,11 +17,11 @@ "validate-dependencies": "core-cli-validate-dependencies" }, "dependencies": { - "@cloudbeaver/core-executor": "~0.1.0", - "@cloudbeaver/core-utils": "~0.1.0", "inversify": "~6.0.1" }, "peerDependencies": { + "@cloudbeaver/core-executor": "~0.1.0", + "@cloudbeaver/core-utils": "~0.1.0", "react": "~18.x.x" } } \ No newline at end of file diff --git a/webapp/packages/core-di/tsconfig.json b/webapp/packages/core-di/tsconfig.json index 2a4cc370f7..d11fd3e36f 100644 --- a/webapp/packages/core-di/tsconfig.json +++ b/webapp/packages/core-di/tsconfig.json @@ -3,9 +3,11 @@ "compilerOptions": { "rootDir": "src", "outDir": "lib", - "composite": true + "declarationMap": true, + "composite": true, + "declaration": true }, "include": ["src"], "exclude": ["**/node_modules", "**/.*/"], - "references": [{ "path": "../*" }] + "references": [{ "path": "../core-executor" }, { "path": "../core-utils" }] } diff --git a/webapp/packages/core-executor/.gitignore b/webapp/packages/core-executor/.gitignore index 99902db863..71d6190715 100644 --- a/webapp/packages/core-executor/.gitignore +++ b/webapp/packages/core-executor/.gitignore @@ -19,3 +19,6 @@ npm-debug.log* yarn-debug.log* yarn-error.log* + +# typescript +*.tsbuildinfo diff --git a/webapp/packages/core-executor/package.json b/webapp/packages/core-executor/package.json index defa108e18..991d414f85 100644 --- a/webapp/packages/core-executor/package.json +++ b/webapp/packages/core-executor/package.json @@ -4,21 +4,20 @@ "version": "0.1.0", "description": "", "license": "Apache-2.0", - "main": "lib/index.js", - "module": "lib/index.js", + "main": "lib/core-executor.js", + "module": "lib/core-executor.js", "types": "src/index.ts", "scripts": { "prebuild": "rimraf --glob lib/*", - "build": "webpack --config ../../configs/webpack.plugin.config.js", + "build": "core-cli-build --mode=production --config ../core-cli/configs/webpack.plugin.config.js", "postbuild": "tsc", "lint": "eslint ./src/ --ext .ts,.tsx", "lint-fix": "eslint ./src/ --ext .ts,.tsx --fix", "validate-dependencies": "core-cli-validate-dependencies" }, - "dependencies": { - "@cloudbeaver/core-utils": "~0.1.0" - }, + "dependencies": { }, "peerDependencies": { + "@cloudbeaver/core-utils": "~0.1.0", "mobx": "~6.x.x" } } \ No newline at end of file diff --git a/webapp/packages/core-executor/tsconfig.json b/webapp/packages/core-executor/tsconfig.json index 2a4cc370f7..7536065258 100644 --- a/webapp/packages/core-executor/tsconfig.json +++ b/webapp/packages/core-executor/tsconfig.json @@ -3,9 +3,11 @@ "compilerOptions": { "rootDir": "src", "outDir": "lib", - "composite": true + "declarationMap": true, + "composite": true, + "declaration": true }, "include": ["src"], - "exclude": ["**/node_modules", "**/.*/"], - "references": [{ "path": "../*" }] + "exclude": ["**/node_modules", "**/.*/", "src/**/*.test.ts", "src/**/*.test.tsx"], + "references": [{ "path": "../core-utils" }] } diff --git a/webapp/packages/core-utils/.gitignore b/webapp/packages/core-utils/.gitignore index 99902db863..0990be9258 100644 --- a/webapp/packages/core-utils/.gitignore +++ b/webapp/packages/core-utils/.gitignore @@ -19,3 +19,6 @@ npm-debug.log* yarn-debug.log* yarn-error.log* + +# typescript +*.tsbuildinfo \ No newline at end of file diff --git a/webapp/packages/core-utils/package.json b/webapp/packages/core-utils/package.json index 4bef071ae7..6d5d5110ea 100644 --- a/webapp/packages/core-utils/package.json +++ b/webapp/packages/core-utils/package.json @@ -4,12 +4,12 @@ "version": "0.1.0", "description": "", "license": "Apache-2.0", - "main": "lib/index.js", - "module": "lib/index.js", + "main": "lib/core-utils.js", + "module": "lib/core-utils.js", "types": "src/index.ts", "scripts": { "prebuild": "rimraf --glob lib/*", - "build": "webpack --config ../../configs/webpack.plugin.config.js", + "build": "core-cli-build --mode=production --config ../core-cli/configs/webpack.plugin.config.js", "postbuild": "tsc", "lint": "eslint ./src/ --ext .ts,.tsx", "lint-fix": "eslint ./src/ --ext .ts,.tsx --fix", diff --git a/webapp/packages/core-utils/tsconfig.json b/webapp/packages/core-utils/tsconfig.json index 2a4cc370f7..8ce04c7ffc 100644 --- a/webapp/packages/core-utils/tsconfig.json +++ b/webapp/packages/core-utils/tsconfig.json @@ -3,9 +3,11 @@ "compilerOptions": { "rootDir": "src", "outDir": "lib", - "composite": true + "declarationMap": true, + "composite": true, + "declaration": true }, "include": ["src"], - "exclude": ["**/node_modules", "**/.*/"], - "references": [{ "path": "../*" }] + "exclude": ["**/node_modules", "**/.*/", "src/**/*.test.ts", "src/**/*.test.tsx"], + "references": [] } diff --git a/webapp/tsconfig.eslint.json b/webapp/tsconfig.eslint.json deleted file mode 100644 index be91c238ba..0000000000 --- a/webapp/tsconfig.eslint.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "extends": "./tsconfig.json", - "include": [ - ".eslintrc.cjs", - "packages/*/src", - "packages/*/tests", - "packages/*/bin", - "packages/*/mocks", - "packages/*/configs" - ], -} \ No newline at end of file diff --git a/webapp/tsconfig.json b/webapp/tsconfig.json index fa41f780bd..8db58b36b0 100644 --- a/webapp/tsconfig.json +++ b/webapp/tsconfig.json @@ -52,10 +52,5 @@ "node", "jest" ], - }, - "references": [ - { - "path": "./packages/*" } - ] } \ No newline at end of file