Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UBERF-5548: Use esbuild with webpack #4657

Merged
merged 1 commit into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion common/config/rush/command-line.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
],

Expand Down
13,111 changes: 6,639 additions & 6,472 deletions common/config/rush/pnpm-lock.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dev/generator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 3 additions & 3 deletions dev/prod/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
21 changes: 14 additions & 7 deletions dev/prod/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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}
Expand Down Expand Up @@ -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/,
},
Expand Down Expand Up @@ -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()
],
Expand Down
2 changes: 1 addition & 1 deletion dev/tool/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/collaborator-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
25 changes: 17 additions & 8 deletions packages/text-editor/src/provider/minio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down
2 changes: 1 addition & 1 deletion pods/account/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion pods/backup/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion pods/collaborator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion pods/front/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion pods/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion pods/server/src/__start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion server/collaborator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 3 additions & 1 deletion server/collaborator/src/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
8 changes: 6 additions & 2 deletions templates/apply.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'] )
Expand Down
2 changes: 1 addition & 1 deletion tools/apm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading