Skip to content

Commit

Permalink
perf: (productionの)dependenciesから@typesを削除、reversi/bubble-gameをesbuil…
Browse files Browse the repository at this point in the history
…dにする (misskey-dev#13067)

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

* fix

* fix
  • Loading branch information
tamaina authored Jan 22, 2024
1 parent 58ac8bc commit af2d81a
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,6 @@ jobs:
- run: pnpm i --frozen-lockfile
- run: pnpm --filter misskey-js run build
if: ${{ matrix.workspace == 'backend' }}
- run: pnpm --filter misskey-reversi run build
- run: pnpm --filter misskey-reversi run build:tsc
if: ${{ matrix.workspace == 'backend' }}
- run: pnpm --filter ${{ matrix.workspace }} run typecheck
31 changes: 31 additions & 0 deletions packages/misskey-bubble-game/build.js
Original file line number Diff line number Diff line change
@@ -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);
});
17 changes: 10 additions & 7 deletions packages/misskey-bubble-game/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,21 @@
}
},
"scripts": {
"build": "npm run ts",
"ts": "npm run ts-esm && npm run ts-dts",
"ts-esm": "tsc --outDir built/esm",
"ts-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\"",
"build": "node ./build.js",
"build:tsc": "npm run tsc",
"tsc": "npm run ts-esm && npm run ts-dts",
"tsc-esm": "tsc --outDir built/esm",
"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",
"typecheck": "tsc --noEmit",
"lint": "pnpm typecheck && pnpm eslint"
},
"devDependencies": {
"@misskey-dev/eslint-plugin": "1.0.0",
"@types/matter-js": "0.19.6",
"@types/node": "20.11.5",
"@types/seedrandom": "3.0.8",
"@typescript-eslint/eslint-plugin": "6.18.1",
"@typescript-eslint/parser": "6.18.1",
"eslint": "8.56.0",
Expand All @@ -35,9 +38,9 @@
"built"
],
"dependencies": {
"@types/matter-js": "0.19.6",
"@types/seedrandom": "3.0.8",
"esbuild": "0.19.11",
"eventemitter3": "5.0.1",
"glob": "^10.3.10",
"matter-js": "0.19.0",
"seedrandom": "3.0.5"
}
Expand Down
1 change: 1 addition & 0 deletions packages/misskey-reversi/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module.exports = {
root: true,
parserOptions: {
tsconfigRootDir: __dirname,
project: ['./tsconfig.json'],
Expand Down
31 changes: 31 additions & 0 deletions packages/misskey-reversi/build.js
Original file line number Diff line number Diff line change
@@ -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);
});
13 changes: 8 additions & 5 deletions packages/misskey-reversi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@
}
},
"scripts": {
"build": "npm run ts",
"ts": "npm run ts-esm && npm run ts-dts",
"ts-esm": "tsc --outDir built/esm",
"ts-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\"",
"build": "node ./build.js",
"build:tsc": "npm run ts",
"tsc": "npm run ts-esm && npm run ts-dts",
"tsc-esm": "tsc --outDir built/esm",
"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",
"typecheck": "tsc --noEmit",
"lint": "pnpm typecheck && pnpm eslint"
Expand All @@ -35,5 +36,7 @@
"built"
],
"dependencies": {
"esbuild": "0.19.11",
"glob": "^10.3.10"
}
}
36 changes: 22 additions & 14 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit af2d81a

Please sign in to comment.