Skip to content

Commit

Permalink
use tsup for dev and bundling application
Browse files Browse the repository at this point in the history
  • Loading branch information
ManAnRuck authored Oct 8, 2023
1 parent 7b784a2 commit 5c4d5ed
Show file tree
Hide file tree
Showing 13 changed files with 463 additions and 23 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/build-and-push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,14 @@ jobs:
turboChanges=$(turbo run build --dry-run=json --since=${{ env.SINCE }})
changedPackages=$(node -e "const results = $turboChanges.tasks.map((task) => ({ package: task.package, directory: task.directory })); process.stdout.write(JSON.stringify(results));")
echo "$changedPackages"
changedPackagesFiltered=$(node -e "const fs = require('fs'); const results = $changedPackages.filter(({directory}) => {const private = JSON.parse(fs.readFileSync(\`./\${directory}/package.json\`, 'utf8')).private; return private === false || private === undefined;}); process.stdout.write(JSON.stringify(results));")
echo "$changedPackagesFiltered"
echo "changedPackages=$changedPackages" >> $GITHUB_OUTPUT
changed=$(node -e "const results = $changedPackages.map(({package}) => package); process.stdout.write(JSON.stringify(results));")
changed=$(node -e "const results = $changedPackagesFiltered.map(({package}) => package); process.stdout.write(JSON.stringify(results));")
echo "changed=$changed" >> $GITHUB_OUTPUT
- run: echo ${{ steps.changed-packages.outputs.changed }}
- name: Print Changed Packages
run: echo ${{ steps.changed-packages.outputs.changed }}

push:
runs-on: ubuntu-latest
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ docker_volumes/*/*
!/**/.gitkeep
/services/cron-jobs/push-send-queued/.env
.turbo
out
out
build
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"private": true,
"packageManager": "[email protected]",
"workspaces": [
"services/**/*"
"services/**/*",
"packages/**/*"
],
"scripts": {
"build": "turbo run build",
Expand Down
15 changes: 15 additions & 0 deletions packages/tsup-config/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "tsup-config",
"version": "1.0.0",
"description": "configuration for tsup",
"main": "build/index.js",
"author": "Manuel Ruck <[email protected]>",
"license": "Apache-2.0",
"private": true,
"devDependencies": {
"tsup": "^7.2.0"
},
"scripts": {
"build": "tsup"
}
}
13 changes: 13 additions & 0 deletions packages/tsup-config/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { type Options } from 'tsup';

export const tsupConfig: Options = {
dts: true, // Generate .d.ts files
minify: true, // Minify output
sourcemap: true, // Generate sourcemaps
treeshake: true, // Remove unused code
splitting: true, // Split output into chunks
clean: true, // Clean output directory before building
outDir: 'build', // Output directory
entry: ['src/index.ts'], // Entry point(s)
format: ['cjs'], // Output format(s)
};
24 changes: 24 additions & 0 deletions packages/tsup-config/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"declaration": true,
"declarationMap": true,
"sourceMap": true,
"strict": true,
"noImplicitAny": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"strictBindCallApply": true,
"strictPropertyInitialization": true,
"noImplicitThis": true,
"alwaysStrict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
}
}
6 changes: 6 additions & 0 deletions packages/tsup-config/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { defineConfig } from 'tsup';
import { tsupConfig } from './src';

export default defineConfig({
...tsupConfig,
});
11 changes: 0 additions & 11 deletions services/qr-code-handler/Dockerfile.dev

This file was deleted.

11 changes: 7 additions & 4 deletions services/qr-code-handler/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "qr-code-handler",
"version": "1.0.3",
"main": "built/index.js",
"version": "1.0.4",
"main": "build/index.js",
"scripts": {
"dev": "tsnd src/index.ts",
"build": "tsc",
"dev": "tsup src/index.ts --watch --onSuccess 'node build/index.js'",
"build": "tsup-node",
"start": "node build/index.js"
},
"license": "MIT",
Expand All @@ -13,9 +13,12 @@
"mongoose": "^5.10.0"
},
"devDependencies": {
"@swc/core": "^1.3.92",
"@types/express": "^4.17.7",
"@types/mongoose": "^5.7.36",
"ts-node-dev": "^1.0.0-pre.57",
"tsup": "^7.2.0",
"tsup-config": "*",
"typescript": "^5.2.2"
}
}
2 changes: 1 addition & 1 deletion services/qr-code-handler/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"declarationMap": true /* Generates a sourcemap for each corresponding '.d.ts' file. */,
"sourceMap": true /* Generates corresponding '.map' file. */,
// "outFile": "./", /* Concatenate and emit output to single file. */
"outDir": "./build" /* Redirect output structure to the directory. */,
// "outDir": "./build" /* Redirect output structure to the directory. */,
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
Expand Down
6 changes: 6 additions & 0 deletions services/qr-code-handler/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { defineConfig } from 'tsup';
import { tsupConfig } from 'tsup-config';

export default defineConfig({
...tsupConfig,
});
6 changes: 5 additions & 1 deletion turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
"$schema": "https://turbo.build/schema.json",
"pipeline": {
"build": {
"outputs": [".next/**", "!.next/cache/**", "build"]
"outputs": [".next/**", "!.next/cache/**", "build"],
"dependsOn": ["^build"]
},
"dev": {
"dependsOn": ["^build"]
},
"lint": {}
}
Expand Down
Loading

0 comments on commit 5c4d5ed

Please sign in to comment.