0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-16 20:26:19 -05:00

refactor(core): use tsup for building

This commit is contained in:
Gao Sun 2024-07-28 11:04:36 +08:00
parent 5e7145b20c
commit b777db5df5
No known key found for this signature in database
GPG key ID: 13EBE123E4773688
13 changed files with 199 additions and 91 deletions

View file

@ -31,6 +31,7 @@
"@types/pg": "^8.6.6",
"husky": "^9.0.0",
"pg": "^8.8.0",
"tsup": "^8.1.0",
"typescript": "^5.0.0",
"vite": "^5.3.4"
},

View file

@ -1,17 +0,0 @@
{
"exec": "tsc -p tsconfig.build.json --incremental && pnpm copy:apidocs && node ./build/index.js || exit 1",
"ignore": [
"node_modules/**/node_modules",
"../integration-tests/"
],
"watch": [
"../*/lib/",
"../core/src/",
"../core/node_modules/",
".env",
"../../.env",
"../connectors/*/lib/"
],
"ext": "json,js,jsx,ts,tsx",
"delay": 500
}

View file

@ -13,11 +13,11 @@
"scripts": {
"precommit": "lint-staged",
"copy:apidocs": "rsync -a -m --include '*/' --include '*.openapi.json' --exclude '*' src/routes/ build/routes/",
"build": "rm -rf build/ && tsc -p tsconfig.build.json && pnpm run copy:apidocs",
"build": "tsup",
"build:test": "rm -rf build/ && tsc -p tsconfig.test.json --sourcemap && pnpm run copy:apidocs",
"lint": "eslint --ext .ts --ext .json src",
"lint:report": "pnpm lint --format json --output-file report.json",
"dev": "rm -rf build/ && nodemon",
"dev": "tsup --config tsup.dev.config.ts",
"start": "NODE_ENV=production node .",
"test:only": "NODE_OPTIONS=\"--experimental-vm-modules --max_old_space_size=4096\" jest --logHeapUsage",
"test": "pnpm build:test && pnpm test:only",
@ -127,6 +127,7 @@
"prettier": "^3.0.0",
"sinon": "^18.0.0",
"supertest": "^7.0.0",
"tsup": "^8.1.0",
"typescript": "^5.5.3"
},
"engines": {

View file

@ -1,13 +0,0 @@
{
"extends": "@silverhand/ts-config/tsconfig.base",
"compilerOptions": {
"declaration": false,
"outDir": "build",
"baseUrl": ".",
"paths": {
"#src/*": [
"src/*"
]
}
}
}

View file

@ -1,10 +0,0 @@
{
"extends": "./tsconfig.base",
"include": [
"src"
],
"exclude": [
"src/**/*.test.ts",
"src/**/__mocks__/",
]
}

View file

@ -1,7 +1,23 @@
{
"extends": "./tsconfig.base",
"extends": "@silverhand/ts-config/tsconfig.base",
"compilerOptions": {
"types": ["node", "jest", "jest-matcher-specific-error"]
"declaration": false,
"outDir": "build",
"baseUrl": ".",
"paths": {
"#src/*": [
"src/*"
]
},
"types": [
"node",
"jest",
"jest-matcher-specific-error"
]
},
"include": ["src"]
"include": [
"src",
"*.config.ts",
"*.setup.ts"
]
}

View file

@ -3,5 +3,8 @@
"compilerOptions": {
"isolatedModules": false,
"allowJs": true,
}
},
"include": [
"src/"
]
}

View file

@ -0,0 +1,11 @@
import { defineConfig, type Options } from 'tsup';
import { defaultConfig } from '../../tsup.shared.config.js';
export const config = Object.freeze({
...defaultConfig,
outDir: 'build',
onSuccess: 'pnpm run copy:apidocs',
} satisfies Options);
export default defineConfig(config);

View file

@ -0,0 +1,9 @@
import { defineConfig } from 'tsup';
import { config as baseConfig } from './tsup.config.js';
export default defineConfig({
...baseConfig,
watch: ['src/**/*.ts', '.env', '../../.env', '../connectors/*/lib/'],
onSuccess: baseConfig.onSuccess + ' && node ./build/index.js',
});

View file

@ -1,8 +1,11 @@
{
"extends": "./tsconfig",
"compilerOptions": {
"declaration": false,
"outDir": "alterations-js",
},
"include": ["alterations"],
"include": [
"alterations"
],
"exclude": []
}

View file

@ -1,4 +1,9 @@
{
"extends": "./tsconfig",
"include": ["src/gen"]
"compilerOptions": {
"declaration": false,
},
"include": [
"src/gen"
]
}

View file

@ -36,6 +36,9 @@ importers:
pg:
specifier: ^8.8.0
version: 8.8.0
tsup:
specifier: ^8.1.0
version: 8.1.0(@swc/core@1.3.52)(postcss@8.4.39)(ts-node@10.9.2(@swc/core@1.3.52)(@types/node@20.12.7)(typescript@5.0.2))(typescript@5.0.2)
typescript:
specifier: ^5.0.0
version: 5.0.2
@ -3421,7 +3424,7 @@ importers:
version: 8.57.0
jest:
specifier: ^29.7.0
version: 29.7.0(@types/node@20.10.4)(ts-node@10.9.2(@types/node@20.10.4)(typescript@5.5.3))
version: 29.7.0(@types/node@20.10.4)(ts-node@10.9.2(@swc/core@1.3.52)(@types/node@20.10.4)(typescript@5.5.3))
jest-matcher-specific-error:
specifier: ^1.0.0
version: 1.0.0
@ -3449,6 +3452,9 @@ importers:
supertest:
specifier: ^7.0.0
version: 7.0.0
tsup:
specifier: ^8.1.0
version: 8.1.0(@swc/core@1.3.52)(postcss@8.4.39)(ts-node@10.9.2(@swc/core@1.3.52)(@types/node@20.10.4)(typescript@5.5.3))(typescript@5.5.3)
typescript:
specifier: ^5.5.3
version: 5.5.3
@ -3855,7 +3861,7 @@ importers:
version: 10.0.0
jest:
specifier: ^29.7.0
version: 29.7.0(@types/node@20.10.4)(ts-node@10.9.2(@types/node@20.10.4)(typescript@5.5.3))
version: 29.7.0(@types/node@20.10.4)(ts-node@10.9.2(@swc/core@1.3.52)(@types/node@20.10.4)(typescript@5.5.3))
jest-matcher-specific-error:
specifier: ^1.0.0
version: 1.0.0
@ -14896,7 +14902,7 @@ snapshots:
- supports-color
- ts-node
'@jest/core@29.7.0(ts-node@10.9.2(@types/node@20.10.4)(typescript@5.5.3))':
'@jest/core@29.7.0(ts-node@10.9.2(@swc/core@1.3.52)(@types/node@20.10.4)(typescript@5.5.3))':
dependencies:
'@jest/console': 29.7.0
'@jest/reporters': 29.7.0
@ -14910,7 +14916,7 @@ snapshots:
exit: 0.1.2
graceful-fs: 4.2.11
jest-changed-files: 29.7.0
jest-config: 29.7.0(@types/node@20.12.7)(ts-node@10.9.2(@types/node@20.10.4)(typescript@5.5.3))
jest-config: 29.7.0(@types/node@20.12.7)(ts-node@10.9.2(@swc/core@1.3.52)(@types/node@20.10.4)(typescript@5.5.3))
jest-haste-map: 29.7.0
jest-message-util: 29.7.0
jest-regex-util: 29.6.3
@ -17859,13 +17865,13 @@ snapshots:
dependencies:
lodash.get: 4.4.2
create-jest@29.7.0(@types/node@20.10.4)(ts-node@10.9.2(@types/node@20.10.4)(typescript@5.5.3)):
create-jest@29.7.0(@types/node@20.10.4)(ts-node@10.9.2(@swc/core@1.3.52)(@types/node@20.10.4)(typescript@5.5.3)):
dependencies:
'@jest/types': 29.6.3
chalk: 4.1.2
exit: 0.1.2
graceful-fs: 4.2.11
jest-config: 29.7.0(@types/node@20.10.4)(ts-node@10.9.2(@types/node@20.10.4)(typescript@5.5.3))
jest-config: 29.7.0(@types/node@20.10.4)(ts-node@10.9.2(@swc/core@1.3.52)(@types/node@20.10.4)(typescript@5.5.3))
jest-util: 29.7.0
prompts: 2.4.2
transitivePeerDependencies:
@ -18180,10 +18186,6 @@ snapshots:
debounce@1.2.1: {}
debug@3.2.7:
dependencies:
ms: 2.1.3
debug@3.2.7(supports-color@5.5.0):
dependencies:
ms: 2.1.3
@ -18659,7 +18661,7 @@ snapshots:
eslint-import-resolver-node@0.3.9:
dependencies:
debug: 3.2.7
debug: 3.2.7(supports-color@5.5.0)
is-core-module: 2.13.1
resolve: 1.22.8
transitivePeerDependencies:
@ -18684,7 +18686,7 @@ snapshots:
eslint-module-utils@2.8.1(@typescript-eslint/parser@7.7.0(eslint@8.57.0)(typescript@5.5.3))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@7.7.0(eslint@8.57.0)(typescript@5.5.3))(eslint-plugin-import@2.29.1(@typescript-eslint/parser@7.7.0(eslint@8.57.0)(typescript@5.5.3))(eslint@8.57.0))(eslint@8.57.0))(eslint@8.57.0):
dependencies:
debug: 3.2.7
debug: 3.2.7(supports-color@5.5.0)
optionalDependencies:
'@typescript-eslint/parser': 7.7.0(eslint@8.57.0)(typescript@5.5.3)
eslint: 8.57.0
@ -18717,7 +18719,7 @@ snapshots:
array.prototype.findlastindex: 1.2.5
array.prototype.flat: 1.3.2
array.prototype.flatmap: 1.3.2
debug: 3.2.7
debug: 3.2.7(supports-color@5.5.0)
doctrine: 2.1.0
eslint: 8.57.0
eslint-import-resolver-node: 0.3.9
@ -20195,16 +20197,16 @@ snapshots:
- babel-plugin-macros
- supports-color
jest-cli@29.7.0(@types/node@20.10.4)(ts-node@10.9.2(@types/node@20.10.4)(typescript@5.5.3)):
jest-cli@29.7.0(@types/node@20.10.4)(ts-node@10.9.2(@swc/core@1.3.52)(@types/node@20.10.4)(typescript@5.5.3)):
dependencies:
'@jest/core': 29.7.0(ts-node@10.9.2(@types/node@20.10.4)(typescript@5.5.3))
'@jest/core': 29.7.0(ts-node@10.9.2(@swc/core@1.3.52)(@types/node@20.10.4)(typescript@5.5.3))
'@jest/test-result': 29.7.0
'@jest/types': 29.6.3
chalk: 4.1.2
create-jest: 29.7.0(@types/node@20.10.4)(ts-node@10.9.2(@types/node@20.10.4)(typescript@5.5.3))
create-jest: 29.7.0(@types/node@20.10.4)(ts-node@10.9.2(@swc/core@1.3.52)(@types/node@20.10.4)(typescript@5.5.3))
exit: 0.1.2
import-local: 3.1.0
jest-config: 29.7.0(@types/node@20.10.4)(ts-node@10.9.2(@types/node@20.10.4)(typescript@5.5.3))
jest-config: 29.7.0(@types/node@20.10.4)(ts-node@10.9.2(@swc/core@1.3.52)(@types/node@20.10.4)(typescript@5.5.3))
jest-util: 29.7.0
jest-validate: 29.7.0
yargs: 17.7.2
@ -20233,7 +20235,7 @@ snapshots:
- supports-color
- ts-node
jest-config@29.7.0(@types/node@20.10.4)(ts-node@10.9.2(@types/node@20.10.4)(typescript@5.5.3)):
jest-config@29.7.0(@types/node@20.10.4)(ts-node@10.9.2(@swc/core@1.3.52)(@types/node@20.10.4)(typescript@5.5.3)):
dependencies:
'@babel/core': 7.24.4
'@jest/test-sequencer': 29.7.0
@ -20259,7 +20261,7 @@ snapshots:
strip-json-comments: 3.1.1
optionalDependencies:
'@types/node': 20.10.4
ts-node: 10.9.2(@types/node@20.10.4)(typescript@5.5.3)
ts-node: 10.9.2(@swc/core@1.3.52)(@types/node@20.10.4)(typescript@5.5.3)
transitivePeerDependencies:
- babel-plugin-macros
- supports-color
@ -20295,7 +20297,7 @@ snapshots:
- babel-plugin-macros
- supports-color
jest-config@29.7.0(@types/node@20.12.7)(ts-node@10.9.2(@types/node@20.10.4)(typescript@5.5.3)):
jest-config@29.7.0(@types/node@20.12.7)(ts-node@10.9.2(@swc/core@1.3.52)(@types/node@20.10.4)(typescript@5.5.3)):
dependencies:
'@babel/core': 7.24.4
'@jest/test-sequencer': 29.7.0
@ -20321,7 +20323,7 @@ snapshots:
strip-json-comments: 3.1.1
optionalDependencies:
'@types/node': 20.12.7
ts-node: 10.9.2(@types/node@20.10.4)(typescript@5.5.3)
ts-node: 10.9.2(@swc/core@1.3.52)(@types/node@20.10.4)(typescript@5.5.3)
transitivePeerDependencies:
- babel-plugin-macros
- supports-color
@ -20634,12 +20636,12 @@ snapshots:
merge-stream: 2.0.0
supports-color: 8.1.1
jest@29.7.0(@types/node@20.10.4)(ts-node@10.9.2(@types/node@20.10.4)(typescript@5.5.3)):
jest@29.7.0(@types/node@20.10.4)(ts-node@10.9.2(@swc/core@1.3.52)(@types/node@20.10.4)(typescript@5.5.3)):
dependencies:
'@jest/core': 29.7.0(ts-node@10.9.2(@types/node@20.10.4)(typescript@5.5.3))
'@jest/core': 29.7.0(ts-node@10.9.2(@swc/core@1.3.52)(@types/node@20.10.4)(typescript@5.5.3))
'@jest/types': 29.6.3
import-local: 3.1.0
jest-cli: 29.7.0(@types/node@20.10.4)(ts-node@10.9.2(@types/node@20.10.4)(typescript@5.5.3))
jest-cli: 29.7.0(@types/node@20.10.4)(ts-node@10.9.2(@swc/core@1.3.52)(@types/node@20.10.4)(typescript@5.5.3))
transitivePeerDependencies:
- '@types/node'
- babel-plugin-macros
@ -22567,6 +22569,22 @@ snapshots:
possible-typed-array-names@1.0.0: {}
postcss-load-config@4.0.2(postcss@8.4.39)(ts-node@10.9.2(@swc/core@1.3.52)(@types/node@20.10.4)(typescript@5.5.3)):
dependencies:
lilconfig: 3.1.2
yaml: 2.4.5
optionalDependencies:
postcss: 8.4.39
ts-node: 10.9.2(@swc/core@1.3.52)(@types/node@20.10.4)(typescript@5.5.3)
postcss-load-config@4.0.2(postcss@8.4.39)(ts-node@10.9.2(@swc/core@1.3.52)(@types/node@20.12.7)(typescript@5.0.2)):
dependencies:
lilconfig: 3.1.2
yaml: 2.4.5
optionalDependencies:
postcss: 8.4.39
ts-node: 10.9.2(@swc/core@1.3.52)(@types/node@20.12.7)(typescript@5.0.2)
postcss-load-config@4.0.2(postcss@8.4.39)(ts-node@10.9.2(@swc/core@1.3.52)(@types/node@20.12.7)(typescript@5.5.3)):
dependencies:
lilconfig: 3.1.2
@ -24190,6 +24208,48 @@ snapshots:
'@swc/core': 1.3.52(@swc/helpers@0.5.1)
optional: true
ts-node@10.9.2(@swc/core@1.3.52)(@types/node@20.10.4)(typescript@5.5.3):
dependencies:
'@cspotcode/source-map-support': 0.8.1
'@tsconfig/node10': 1.0.9
'@tsconfig/node12': 1.0.11
'@tsconfig/node14': 1.0.3
'@tsconfig/node16': 1.0.4
'@types/node': 20.10.4
acorn: 8.11.3
acorn-walk: 8.3.2
arg: 4.1.3
create-require: 1.1.1
diff: 4.0.2
make-error: 1.3.6
typescript: 5.5.3
v8-compile-cache-lib: 3.0.1
yn: 3.1.1
optionalDependencies:
'@swc/core': 1.3.52(@swc/helpers@0.5.1)
optional: true
ts-node@10.9.2(@swc/core@1.3.52)(@types/node@20.12.7)(typescript@5.0.2):
dependencies:
'@cspotcode/source-map-support': 0.8.1
'@tsconfig/node10': 1.0.9
'@tsconfig/node12': 1.0.11
'@tsconfig/node14': 1.0.3
'@tsconfig/node16': 1.0.4
'@types/node': 20.12.7
acorn: 8.11.3
acorn-walk: 8.3.2
arg: 4.1.3
create-require: 1.1.1
diff: 4.0.2
make-error: 1.3.6
typescript: 5.0.2
v8-compile-cache-lib: 3.0.1
yn: 3.1.1
optionalDependencies:
'@swc/core': 1.3.52(@swc/helpers@0.5.1)
optional: true
ts-node@10.9.2(@swc/core@1.3.52)(@types/node@20.12.7)(typescript@5.5.3):
dependencies:
'@cspotcode/source-map-support': 0.8.1
@ -24211,25 +24271,6 @@ snapshots:
'@swc/core': 1.3.52(@swc/helpers@0.5.1)
optional: true
ts-node@10.9.2(@types/node@20.10.4)(typescript@5.5.3):
dependencies:
'@cspotcode/source-map-support': 0.8.1
'@tsconfig/node10': 1.0.9
'@tsconfig/node12': 1.0.11
'@tsconfig/node14': 1.0.3
'@tsconfig/node16': 1.0.4
'@types/node': 20.10.4
acorn: 8.11.3
acorn-walk: 8.3.2
arg: 4.1.3
create-require: 1.1.1
diff: 4.0.2
make-error: 1.3.6
typescript: 5.5.3
v8-compile-cache-lib: 3.0.1
yn: 3.1.1
optional: true
tsconfig-paths@3.15.0:
dependencies:
'@types/json5': 0.0.29
@ -24247,6 +24288,54 @@ snapshots:
tsscmp@1.0.6: {}
tsup@8.1.0(@swc/core@1.3.52)(postcss@8.4.39)(ts-node@10.9.2(@swc/core@1.3.52)(@types/node@20.10.4)(typescript@5.5.3))(typescript@5.5.3):
dependencies:
bundle-require: 4.2.1(esbuild@0.21.5)
cac: 6.7.14
chokidar: 3.5.3
debug: 4.3.4
esbuild: 0.21.5
execa: 5.1.1
globby: 11.1.0
joycon: 3.1.1
postcss-load-config: 4.0.2(postcss@8.4.39)(ts-node@10.9.2(@swc/core@1.3.52)(@types/node@20.10.4)(typescript@5.5.3))
resolve-from: 5.0.0
rollup: 4.14.3
source-map: 0.8.0-beta.0
sucrase: 3.35.0
tree-kill: 1.2.2
optionalDependencies:
'@swc/core': 1.3.52(@swc/helpers@0.5.1)
postcss: 8.4.39
typescript: 5.5.3
transitivePeerDependencies:
- supports-color
- ts-node
tsup@8.1.0(@swc/core@1.3.52)(postcss@8.4.39)(ts-node@10.9.2(@swc/core@1.3.52)(@types/node@20.12.7)(typescript@5.0.2))(typescript@5.0.2):
dependencies:
bundle-require: 4.2.1(esbuild@0.21.5)
cac: 6.7.14
chokidar: 3.5.3
debug: 4.3.4
esbuild: 0.21.5
execa: 5.1.1
globby: 11.1.0
joycon: 3.1.1
postcss-load-config: 4.0.2(postcss@8.4.39)(ts-node@10.9.2(@swc/core@1.3.52)(@types/node@20.12.7)(typescript@5.0.2))
resolve-from: 5.0.0
rollup: 4.14.3
source-map: 0.8.0-beta.0
sucrase: 3.35.0
tree-kill: 1.2.2
optionalDependencies:
'@swc/core': 1.3.52(@swc/helpers@0.5.1)
postcss: 8.4.39
typescript: 5.0.2
transitivePeerDependencies:
- supports-color
- ts-node
tsup@8.1.0(@swc/core@1.3.52)(postcss@8.4.39)(ts-node@10.9.2(@swc/core@1.3.52)(@types/node@20.12.7)(typescript@5.5.3))(typescript@5.5.3):
dependencies:
bundle-require: 4.2.1(esbuild@0.21.5)

10
tsup.shared.config.ts Normal file
View file

@ -0,0 +1,10 @@
import { type Options } from 'tsup';
export const defaultConfig = Object.freeze({
entry: ['src/index.ts'],
outDir: 'lib',
format: ['esm'],
dts: false,
sourcemap: true,
clean: true,
} satisfies Options);