Skip to content

Commit

Permalink
Optimized build
Browse files Browse the repository at this point in the history
  • Loading branch information
erayhanoglu committed May 16, 2023
1 parent 4296ed0 commit 17d029b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@
"build": "npm run build:cjs && npm run build:esm",
"build:cjs": "tsc -b tsconfig-build-cjs.json",
"build:esm": "tsc -b tsconfig-build-esm.json",
"postbuild": "cp ./support/package.cjs.json ./build/cjs/package.json && cp LICENSE package.json README.md CHANGELOG.md ./build",
"postbuild": "npm run postbuild:copyfiles && node ./support/postbuild.cjs",
"postbuild:copyfiles": "cp ./support/package.cjs.json ./build/cjs/package.json && cp LICENSE README.md CHANGELOG.md ./build",
"test": "jest",
"precover": "rimraf coverage",
"cover": "jest --runInBand --detectOpenHandles --coverage",
Expand All @@ -63,7 +64,7 @@
"version": "auto-changelog -p && git add CHANGELOG.md"
},
"type": "module",
"types": "esm/index.d.ts",
"types": "typings/index.d.ts",
"exports": {
".": {
"require": "./cjs/index.js",
Expand All @@ -73,7 +74,7 @@
"./esm": "./esm/index.js"
},
"engines": {
"node": ">=14.0",
"node": ">=16.0",
"npm": ">=7.0.0"
},
"files": [
Expand All @@ -85,7 +86,6 @@
],
"keywords": [
"backend",
"frontent",
"postgresql",
"postgres",
"pg",
Expand All @@ -96,7 +96,6 @@
"db",
"rdbms",
"sql",
"javascript",
"typescript",
"ts",
"esm"
Expand Down
11 changes: 11 additions & 0 deletions support/postbuild.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const fs = require('node:fs');
const path = require('node:path');

function clearPackageJson() {
const json = JSON.parse(fs.readFileSync(path.resolve(__dirname, '../package.json'), 'utf-8'));
delete json.scripts;
delete json.devDependencies;
fs.writeFileSync(path.resolve(__dirname, '../build/package.json'), JSON.stringify(json, undefined, 2));
}

clearPackageJson();
3 changes: 2 additions & 1 deletion tsconfig-build-esm.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"declaration": true,
"noEmit": false,
"module": "ESNext",
"outDir": "build/esm"
"outDir": "build/esm",
"declarationDir": "build/typings"
},
"include": ["src"]
}

0 comments on commit 17d029b

Please sign in to comment.