Skip to content

Commit

Permalink
fix: fixed bundling types
Browse files Browse the repository at this point in the history
  • Loading branch information
favna committed Mar 23, 2024
1 parent f99ae78 commit 9c7dfbb
Show file tree
Hide file tree
Showing 3 changed files with 785 additions and 433 deletions.
17 changes: 10 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"bump": "cliff-jumper",
"check-update": "cliff-jumper --dry-run",
"prepack": "yarn build && concurrently \"yarn:prepack:*\"",
"prepack:clean-types": "tsx scripts/cleanup-dts-files.mts",
"prepack:cjs": "rollup-type-bundler -d dist/cjs -ot .cts",
"prepack:esm": "rollup-type-bundler -d dist/esm -t .mts"
},
Expand All @@ -44,18 +45,19 @@
"@sapphire/utilities": "^3.15.3"
},
"devDependencies": {
"@commitlint/cli": "^19.2.0",
"@commitlint/cli": "^19.2.1",
"@commitlint/config-conventional": "^19.1.0",
"@favware/cliff-jumper": "^3.0.1",
"@favware/npm-deprecate": "^1.0.7",
"@favware/rollup-type-bundler": "^3.3.0",
"@sapphire/eslint-config": "^5.0.4",
"@sapphire/node-utilities": "^1.0.2",
"@sapphire/prettier-config": "^2.0.0",
"@sapphire/ts-config": "^5.0.1",
"@types/node": "^20.11.28",
"@types/node": "^20.11.30",
"@types/ws": "^8.5.10",
"@typescript-eslint/eslint-plugin": "^7.2.0",
"@typescript-eslint/parser": "^7.2.0",
"@typescript-eslint/eslint-plugin": "^7.3.1",
"@typescript-eslint/parser": "^7.3.1",
"@vitest/coverage-v8": "^1.4.0",
"concurrently": "^8.2.2",
"cz-conventional-changelog": "^3.3.0",
Expand All @@ -69,11 +71,12 @@
"gen-esm-wrapper": "^1.1.3",
"lint-staged": "^15.2.2",
"prettier": "^3.2.5",
"tsup": "^8.0.1",
"tsup": "^8.0.2",
"tsx": "^4.7.1",
"typedoc": "^0.25.12",
"typedoc-json-parser": "^9.0.1",
"typescript": "^5.4.2",
"vite": "^5.1.6",
"typescript": "^5.4.3",
"vite": "^5.2.4",
"vitest": "^1.4.0"
},
"repository": {
Expand Down
20 changes: 20 additions & 0 deletions scripts/cleanup-dts-files.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { findFilesRecursivelyRegex } from '@sapphire/node-utilities';
import { readFile, writeFile } from 'fs/promises';

const distFolder = new URL('../dist/', import.meta.url);

const allTypingsFiles = findFilesRecursivelyRegex(distFolder, /\.d\.[cm]?ts$/);
const srcTypeRegex = /src\./g;
const srcImportAllRegex = /import \* as src from 'src';/g;
const srcImportSideEffectRegex = /import 'src';/g;

for await (const file of allTypingsFiles) {
const fileContent = await readFile(file, 'utf-8');

const replacedContent = fileContent //
.replace(srcTypeRegex, '')
.replace(srcImportAllRegex, '')
.replace(srcImportSideEffectRegex, '');

await writeFile(file, replacedContent);
}
Loading

0 comments on commit 9c7dfbb

Please sign in to comment.