1
0
mirror of https://github.com/MisskeyIO/misskey synced 2024-11-27 14:28:49 +09:00

perf: (productionの)dependenciesから@typesを削除、reversi/bubble-gameをesbuildにする (#13067)

* perf: (productionの)dependenciesから@typesを削除、reversi/bubble-gameをesbuildにする

* fix

* fix
This commit is contained in:
tamaina 2024-01-23 06:36:44 +09:00 committed by GitHub
parent 58ac8bc8e9
commit af2d81a990
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 104 additions and 27 deletions

View File

@ -92,6 +92,6 @@ jobs:
- run: pnpm i --frozen-lockfile - run: pnpm i --frozen-lockfile
- run: pnpm --filter misskey-js run build - run: pnpm --filter misskey-js run build
if: ${{ matrix.workspace == 'backend' }} if: ${{ matrix.workspace == 'backend' }}
- run: pnpm --filter misskey-reversi run build - run: pnpm --filter misskey-reversi run build:tsc
if: ${{ matrix.workspace == 'backend' }} if: ${{ matrix.workspace == 'backend' }}
- run: pnpm --filter ${{ matrix.workspace }} run typecheck - run: pnpm --filter ${{ matrix.workspace }} run typecheck

View File

@ -0,0 +1,31 @@
import { build } from "esbuild";
import { globSync } from "glob";
const entryPoints = globSync("./src/**/**.{ts,tsx}");
/** @type {import('esbuild').BuildOptions} */
const options = {
entryPoints,
minify: true,
outdir: "./built/esm",
target: "es2022",
platform: "browser",
format: "esm",
};
if (process.env.WATCH === "true") {
options.watch = {
onRebuild(error, result) {
if (error) {
console.error("watch build failed:", error);
} else {
console.log("watch build succeeded:", result);
}
},
};
}
build(options).catch((err) => {
process.stderr.write(err.stderr);
process.exit(1);
});

View File

@ -13,18 +13,21 @@
} }
}, },
"scripts": { "scripts": {
"build": "npm run ts", "build": "node ./build.js",
"ts": "npm run ts-esm && npm run ts-dts", "build:tsc": "npm run tsc",
"ts-esm": "tsc --outDir built/esm", "tsc": "npm run ts-esm && npm run ts-dts",
"ts-dts": "tsc --outDir built/dts --declaration true --emitDeclarationOnly true --declarationMap true", "tsc-esm": "tsc --outDir built/esm",
"watch": "nodemon -w src -e ts,js,cjs,mjs,json --exec \"pnpm run build\"", "tsc-dts": "tsc --outDir built/dts --declaration true --emitDeclarationOnly true --declarationMap true",
"watch": "nodemon -w src -e ts,js,cjs,mjs,json --exec \"pnpm run build:tsc\"",
"eslint": "eslint . --ext .js,.jsx,.ts,.tsx", "eslint": "eslint . --ext .js,.jsx,.ts,.tsx",
"typecheck": "tsc --noEmit", "typecheck": "tsc --noEmit",
"lint": "pnpm typecheck && pnpm eslint" "lint": "pnpm typecheck && pnpm eslint"
}, },
"devDependencies": { "devDependencies": {
"@misskey-dev/eslint-plugin": "1.0.0", "@misskey-dev/eslint-plugin": "1.0.0",
"@types/matter-js": "0.19.6",
"@types/node": "20.11.5", "@types/node": "20.11.5",
"@types/seedrandom": "3.0.8",
"@typescript-eslint/eslint-plugin": "6.18.1", "@typescript-eslint/eslint-plugin": "6.18.1",
"@typescript-eslint/parser": "6.18.1", "@typescript-eslint/parser": "6.18.1",
"eslint": "8.56.0", "eslint": "8.56.0",
@ -35,9 +38,9 @@
"built" "built"
], ],
"dependencies": { "dependencies": {
"@types/matter-js": "0.19.6", "esbuild": "0.19.11",
"@types/seedrandom": "3.0.8",
"eventemitter3": "5.0.1", "eventemitter3": "5.0.1",
"glob": "^10.3.10",
"matter-js": "0.19.0", "matter-js": "0.19.0",
"seedrandom": "3.0.5" "seedrandom": "3.0.5"
} }

View File

@ -1,4 +1,5 @@
module.exports = { module.exports = {
root: true,
parserOptions: { parserOptions: {
tsconfigRootDir: __dirname, tsconfigRootDir: __dirname,
project: ['./tsconfig.json'], project: ['./tsconfig.json'],

View File

@ -0,0 +1,31 @@
import { build } from "esbuild";
import { globSync } from "glob";
const entryPoints = globSync("./src/**/**.{ts,tsx}");
/** @type {import('esbuild').BuildOptions} */
const options = {
entryPoints,
minify: true,
outdir: "./built/esm",
target: "es2022",
platform: "browser",
format: "esm",
};
if (process.env.WATCH === "true") {
options.watch = {
onRebuild(error, result) {
if (error) {
console.error("watch build failed:", error);
} else {
console.log("watch build succeeded:", result);
}
},
};
}
build(options).catch((err) => {
process.stderr.write(err.stderr);
process.exit(1);
});

View File

@ -13,11 +13,12 @@
} }
}, },
"scripts": { "scripts": {
"build": "npm run ts", "build": "node ./build.js",
"ts": "npm run ts-esm && npm run ts-dts", "build:tsc": "npm run ts",
"ts-esm": "tsc --outDir built/esm", "tsc": "npm run ts-esm && npm run ts-dts",
"ts-dts": "tsc --outDir built/dts --declaration true --emitDeclarationOnly true --declarationMap true", "tsc-esm": "tsc --outDir built/esm",
"watch": "nodemon -w src -e ts,js,cjs,mjs,json --exec \"pnpm run build\"", "tsc-dts": "tsc --outDir built/dts --declaration true --emitDeclarationOnly true --declarationMap true",
"watch": "nodemon -w src -e ts,js,cjs,mjs,json --exec \"pnpm run build:tsc\"",
"eslint": "eslint . --ext .js,.jsx,.ts,.tsx", "eslint": "eslint . --ext .js,.jsx,.ts,.tsx",
"typecheck": "tsc --noEmit", "typecheck": "tsc --noEmit",
"lint": "pnpm typecheck && pnpm eslint" "lint": "pnpm typecheck && pnpm eslint"
@ -35,5 +36,7 @@
"built" "built"
], ],
"dependencies": { "dependencies": {
"esbuild": "0.19.11",
"glob": "^10.3.10"
} }
} }

View File

@ -1031,15 +1031,15 @@ importers:
packages/misskey-bubble-game: packages/misskey-bubble-game:
dependencies: dependencies:
'@types/matter-js': esbuild:
specifier: 0.19.6 specifier: 0.19.11
version: 0.19.6 version: 0.19.11
'@types/seedrandom':
specifier: 3.0.8
version: 3.0.8
eventemitter3: eventemitter3:
specifier: 5.0.1 specifier: 5.0.1
version: 5.0.1 version: 5.0.1
glob:
specifier: ^10.3.10
version: 10.3.10
matter-js: matter-js:
specifier: 0.19.0 specifier: 0.19.0
version: 0.19.0 version: 0.19.0
@ -1050,9 +1050,15 @@ importers:
'@misskey-dev/eslint-plugin': '@misskey-dev/eslint-plugin':
specifier: 1.0.0 specifier: 1.0.0
version: 1.0.0(@typescript-eslint/eslint-plugin@6.18.1)(@typescript-eslint/parser@6.18.1)(eslint-plugin-import@2.29.1)(eslint@8.56.0) version: 1.0.0(@typescript-eslint/eslint-plugin@6.18.1)(@typescript-eslint/parser@6.18.1)(eslint-plugin-import@2.29.1)(eslint@8.56.0)
'@types/matter-js':
specifier: 0.19.6
version: 0.19.6
'@types/node': '@types/node':
specifier: 20.11.5 specifier: 20.11.5
version: 20.11.5 version: 20.11.5
'@types/seedrandom':
specifier: 3.0.8
version: 3.0.8
'@typescript-eslint/eslint-plugin': '@typescript-eslint/eslint-plugin':
specifier: 6.18.1 specifier: 6.18.1
version: 6.18.1(@typescript-eslint/parser@6.18.1)(eslint@8.56.0)(typescript@5.3.3) version: 6.18.1(@typescript-eslint/parser@6.18.1)(eslint@8.56.0)(typescript@5.3.3)
@ -1170,6 +1176,13 @@ importers:
version: 5.3.3 version: 5.3.3
packages/misskey-reversi: packages/misskey-reversi:
dependencies:
esbuild:
specifier: 0.19.11
version: 0.19.11
glob:
specifier: ^10.3.10
version: 10.3.10
devDependencies: devDependencies:
'@misskey-dev/eslint-plugin': '@misskey-dev/eslint-plugin':
specifier: 1.0.0 specifier: 1.0.0
@ -8107,6 +8120,7 @@ packages:
/@types/matter-js@0.19.6: /@types/matter-js@0.19.6:
resolution: {integrity: sha512-ffk6tqJM5scla+ThXmnox+mdfCo3qYk6yMjQsNcrbo6eQ5DqorVdtnaL+1agCoYzxUjmHeiNB7poBMAmhuLY7w==} resolution: {integrity: sha512-ffk6tqJM5scla+ThXmnox+mdfCo3qYk6yMjQsNcrbo6eQ5DqorVdtnaL+1agCoYzxUjmHeiNB7poBMAmhuLY7w==}
dev: true
/@types/mdx@2.0.3: /@types/mdx@2.0.3:
resolution: {integrity: sha512-IgHxcT3RC8LzFLhKwP3gbMPeaK7BM9eBH46OdapPA7yvuIUJ8H6zHZV53J8hGZcTSnt95jANt+rTBNUUc22ACQ==} resolution: {integrity: sha512-IgHxcT3RC8LzFLhKwP3gbMPeaK7BM9eBH46OdapPA7yvuIUJ8H6zHZV53J8hGZcTSnt95jANt+rTBNUUc22ACQ==}
@ -8295,7 +8309,7 @@ packages:
/@types/seedrandom@3.0.8: /@types/seedrandom@3.0.8:
resolution: {integrity: sha512-TY1eezMU2zH2ozQoAFAQFOPpvP15g+ZgSfTZt31AUUH/Rxtnz3H+A/Sv1Snw2/amp//omibc+AEkTaA8KUeOLQ==} resolution: {integrity: sha512-TY1eezMU2zH2ozQoAFAQFOPpvP15g+ZgSfTZt31AUUH/Rxtnz3H+A/Sv1Snw2/amp//omibc+AEkTaA8KUeOLQ==}
dev: false dev: true
/@types/semver@7.5.6: /@types/semver@7.5.6:
resolution: {integrity: sha512-dn1l8LaMea/IjDoHNd9J52uBbInB796CDffS6VdIxvqYCPSG0V0DzHp76GpaWnlhg88uYyPbXCDIowa86ybd5A==} resolution: {integrity: sha512-dn1l8LaMea/IjDoHNd9J52uBbInB796CDffS6VdIxvqYCPSG0V0DzHp76GpaWnlhg88uYyPbXCDIowa86ybd5A==}
@ -9967,7 +9981,7 @@ packages:
clone-response: 1.0.3 clone-response: 1.0.3
get-stream: 5.2.0 get-stream: 5.2.0
http-cache-semantics: 4.1.1 http-cache-semantics: 4.1.1
keyv: 4.5.2 keyv: 4.5.4
lowercase-keys: 2.0.0 lowercase-keys: 2.0.0
normalize-url: 6.1.0 normalize-url: 6.1.0
responselike: 2.0.1 responselike: 2.0.1
@ -14648,12 +14662,6 @@ packages:
safe-buffer: 5.2.1 safe-buffer: 5.2.1
dev: false dev: false
/keyv@4.5.2:
resolution: {integrity: sha512-5MHbFaKn8cNSmVW7BYnijeAVlE4cYA/SVkifVgrh7yotnfhKmjuXpDKjrABLnT0SfHWV21P8ow07OGfRrNDg8g==}
dependencies:
json-buffer: 3.0.1
dev: false
/keyv@4.5.4: /keyv@4.5.4:
resolution: {integrity: sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==} resolution: {integrity: sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==}
dependencies: dependencies: