Skip to content

Commit

Permalink
refactor(build): change entrypoints and run tsc before building
Browse files Browse the repository at this point in the history
  • Loading branch information
thelindat committed Sep 10, 2024
1 parent dcda5c7 commit a30eddc
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
19 changes: 19 additions & 0 deletions build.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,26 @@
//@ts-check

import { createBuilder, createFxmanifest } from '@overextended/fx-utils';
import { spawn } from 'child_process';

const watch = process.argv.includes('--watch');

function exec(command) {
return new Promise((resolve) => {
const child = spawn(command, { stdio: 'inherit', shell: true });

child.on('exit', (code) => {
resolve(code === 0);
});
});
}

if (!watch) {
const tsc = await exec(`tsc --build ${watch ? '--watch --preserveWatchOutput' : ''} && tsc-alias`);

if (!tsc) process.exit(0);
}

createBuilder(
watch,
{
Expand All @@ -16,6 +33,7 @@ createBuilder(
platform: 'node',
target: ['node16'],
format: 'cjs',
entryPoints: [`./server/index.ts`],
},
},
{
Expand All @@ -24,6 +42,7 @@ createBuilder(
platform: 'browser',
target: ['es2021'],
format: 'iife',
entryPoints: [`./client/index.ts`],
},
},
],
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"devDependencies": {
"@citizenfx/client": "latest",
"@citizenfx/server": "latest",
"@overextended/fx-utils": "^0.0.2",
"@overextended/fx-utils": "^0.0.4",
"@types/node": "^20.16.5",
"esbuild": "^0.23.1",
"prettier": "^3.3.3",
Expand Down
11 changes: 6 additions & 5 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 a30eddc

Please sign in to comment.