UBERF-5548: Use esbuild with webpack (#4657)

Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
Andrey Sobolev 2024-02-16 13:20:03 +07:00 committed by GitHub
parent 56b43dbc7f
commit 34b16ae88d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
18 changed files with 6696 additions and 6507 deletions

View File

@ -229,7 +229,7 @@
"summary": "Format changed projects",
"description": "Format and autofix linting issues in changed projects",
"safeForSimultaneousRushProcesses": true,
"shellCommand": "./common/scripts/each-diff.sh rushx format"
"shellCommand": "./common/scripts/each-diff.sh rushx format --force"
}
],

File diff suppressed because it is too large Load Diff

View File

@ -25,7 +25,7 @@
"eslint-plugin-n": "^15.4.0",
"eslint": "^8.54.0",
"ts-node": "^10.8.0",
"esbuild": "^0.16.14",
"esbuild": "^0.20.0",
"@types/node": "~20.11.16",
"@typescript-eslint/parser": "^6.11.0",
"eslint-config-standard-with-typescript": "^40.0.0",

View File

@ -4,9 +4,7 @@
"license": "EPL-2.0",
"template": "@hcengineering/webpack-package",
"scripts": {
"_phase:build": "compile ui",
"_phase:package": "rushx package",
"build": "compile ui",
"package": "rm -rf ./dist && cross-env NODE_ENV=production webpack --stats-error-details && echo 'done'",
"analyze": "cross-env NODE_ENV=production webpack --json > stats.json",
"show": "webpack-bundle-analyzer stats.json dist",
@ -44,7 +42,9 @@
"html-webpack-plugin": "^5.5.0",
"fork-ts-checker-webpack-plugin": "~7.3.0",
"update-browserslist-db": "~1.0.11",
"browserslist": "4.21.5"
"browserslist": "4.21.5",
"esbuild": "^0.20.0",
"esbuild-loader": "^4.0.3"
},
"dependencies": {
"@hcengineering/platform": "^0.6.9",

View File

@ -18,7 +18,6 @@ const Dotenv = require('dotenv-webpack')
const path = require('path')
const autoprefixer = require('autoprefixer')
const CompressionPlugin = require('compression-webpack-plugin')
const DefinePlugin = require('webpack').DefinePlugin
const { resolve } = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin');
const { Configuration } = require('webpack')
@ -28,7 +27,8 @@ const prod = mode === 'production'
const devServer = (process.env.CLIENT_TYPE ?? '') === 'dev-server'
const devProduction = (process.env.CLIENT_TYPE ?? '') === 'dev-production'
const dev = (process.env.CLIENT_TYPE ?? '') === 'dev' || devServer || devProduction
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin')
const { EsbuildPlugin } = require('esbuild-loader')
/**
* @type {Configuration}
@ -68,15 +68,20 @@ module.exports = {
pathinfo: false
},
optimization: {
minimize: prod
minimize: prod,
minimizer: [
new EsbuildPlugin({
target: 'es2021' // Syntax to transpile to (see options below for possible values)
})
]
},
module: {
rules: [
{
test: /\.ts?$/,
loader:'ts-loader',
loader:'esbuild-loader',
options: {
transpileOnly: true
target: 'es2021'
},
exclude: /node_modules/,
},
@ -203,8 +208,10 @@ module.exports = {
// filename: '[name].[id][contenthash].css'
// }),
new Dotenv({path: prod ? '.env-prod' : '.env'}),
new DefinePlugin({
'process.env.CLIENT_TYPE': JSON.stringify(process.env.CLIENT_TYPE)
new EsbuildPlugin({
define: {
'process.env.CLIENT_TYPE': JSON.stringify(process.env.CLIENT_TYPE ?? '')
}
}),
new ForkTsCheckerWebpackPlugin()
],

View File

@ -34,7 +34,7 @@
"eslint-plugin-n": "^15.4.0",
"eslint": "^8.54.0",
"ts-node": "^10.8.0",
"esbuild": "^0.16.14",
"esbuild": "^0.20.0",
"@types/minio": "~7.0.11",
"@types/node": "~20.11.16",
"@typescript-eslint/parser": "^6.11.0",

View File

@ -22,7 +22,7 @@
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-n": "^15.4.0",
"eslint": "^8.54.0",
"esbuild": "^0.16.14",
"esbuild": "^0.20.0",
"@typescript-eslint/parser": "^6.11.0",
"eslint-config-standard-with-typescript": "^40.0.0",
"prettier": "^3.1.0",

View File

@ -23,17 +23,26 @@ interface EVENTS {
}
async function fetchContent (doc: YDoc, name: string): Promise<void> {
const frontUrl = getMetadata(presentation.metadata.FrontUrl) ?? window.location.origin
for (let i = 0; i < 5; i++) {
try {
const frontUrl = getMetadata(presentation.metadata.FrontUrl) ?? window.location.origin
try {
const res = await fetch(concatLink(frontUrl, `/files?file=${name}`))
try {
const res = await fetch(concatLink(frontUrl, `/files?file=${name}`))
if (res.ok) {
const blob = await res.blob()
const buffer = await blob.arrayBuffer()
applyUpdate(doc, new Uint8Array(buffer))
if (res.ok) {
const blob = await res.blob()
const buffer = await blob.arrayBuffer()
applyUpdate(doc, new Uint8Array(buffer))
return
}
} catch {}
} catch (err: any) {
console.error(err)
}
} catch {}
// White a while
await new Promise((resolve) => setTimeout(resolve, 50))
}
}
export class MinioProvider extends Observable<EVENTS> {

View File

@ -32,7 +32,7 @@
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-n": "^15.4.0",
"eslint": "^8.54.0",
"esbuild": "^0.16.14",
"esbuild": "^0.20.0",
"@types/koa-bodyparser": "^4.3.3",
"@types/koa-router": "^7.4.4",
"@types/koa": "^2.13.4",

View File

@ -32,7 +32,7 @@
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-n": "^15.4.0",
"eslint": "^8.54.0",
"esbuild": "^0.16.14",
"esbuild": "^0.20.0",
"@typescript-eslint/parser": "^6.11.0",
"eslint-config-standard-with-typescript": "^40.0.0",
"prettier": "^3.1.0",

View File

@ -31,7 +31,7 @@
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-n": "^15.4.0",
"eslint": "^8.54.0",
"esbuild": "^0.16.14",
"esbuild": "^0.20.0",
"@typescript-eslint/parser": "^6.11.0",
"eslint-config-standard-with-typescript": "^40.0.0",
"prettier": "^3.1.0",

View File

@ -39,7 +39,7 @@
"@types/express-fileupload": "^1.1.7",
"@types/uuid": "^8.3.1",
"@types/cors": "^2.8.12",
"esbuild": "^0.16.14",
"esbuild": "^0.20.0",
"prettier": "^3.1.0",
"typescript": "^5.3.3",
"@types/body-parser": "~1.19.2",

View File

@ -35,7 +35,7 @@
"eslint": "^8.54.0",
"@types/ws": "^8.5.3",
"ts-node": "^10.8.0",
"esbuild": "^0.16.14",
"esbuild": "^0.20.0",
"@typescript-eslint/parser": "^6.11.0",
"eslint-config-standard-with-typescript": "^40.0.0",
"prettier": "^3.1.0",

View File

@ -92,7 +92,7 @@ if (accountsUrl === undefined) {
const sesUrl = process.env.SES_URL
const cursorMaxTime = process.env.SERVER_CURSOR_MAXTIMEMS
const lastNameFirst = process.env.LAST_NAME_FIRST === 'true' ?? false
const lastNameFirst = process.env.LAST_NAME_FIRST === 'true'
setMetadata(serverCore.metadata.CursorMaxTimeMS, cursorMaxTime)
setMetadata(serverCore.metadata.FrontUrl, frontUrl)
setMetadata(serverToken.metadata.Secret, serverSecret)

View File

@ -30,7 +30,7 @@
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-n": "^15.4.0",
"eslint": "^8.54.0",
"esbuild": "^0.16.14",
"esbuild": "^0.20.0",
"@typescript-eslint/parser": "^6.11.0",
"eslint-config-standard-with-typescript": "^40.0.0",
"prettier": "^3.1.0",

View File

@ -116,6 +116,8 @@ export class WorkspaceClient {
}
private async txHandler (tx: Tx): Promise<void> {
this.txHandlers.map((handler) => handler(tx))
for (const h of this.txHandlers) {
await h(tx)
}
}
}

View File

@ -95,8 +95,12 @@ function updatePackage(packageRoot, templates) {
if( template.package['#clean'] !== undefined ) {
for( const d of template.package['#clean'] ) {
delete currentPackage.devDependencies[d]
delete currentPackage.dependencies[d]
if(currentPackage.devDependencies) {
delete currentPackage.devDependencies[d]
}
if(currentPackage.dependencies) {
delete currentPackage.dependencies[d]
}
}
}
currentPackage.scripts = update(currentPackage.scripts, packageJson.scripts, currentPackage['#override'] )

View File

@ -28,7 +28,7 @@
"eslint-config-standard-with-typescript": "^40.0.0",
"prettier": "^3.1.0",
"typescript": "^5.3.3",
"esbuild": "^0.16.14",
"esbuild": "^0.20.0",
"@types/node": "~20.11.16",
"jest": "^29.7.0",
"ts-jest": "^29.1.1",