Skip to content

Commit

Permalink
exclude external dependencies & simplify d.ts generation
Browse files Browse the repository at this point in the history
  • Loading branch information
karmaniverous committed Sep 5, 2024
1 parent 251c86c commit f837fe1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@
"exports": {
".": {
"import": {
"types": "./dist/index.d.mts",
"types": "./dist/index.d.ts",
"default": "./dist/mjs/index.js"
},
"require": {
"types": "./dist/index.d.cts",
"types": "./dist/index.d.ts",
"default": "./dist/cjs/index.js"
}
}
Expand Down
17 changes: 7 additions & 10 deletions rollup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import fs from 'fs-extra';
import type { InputOptions, OutputOptions, RollupOptions } from 'rollup';
import dtsPlugin from 'rollup-plugin-dts';

import pkg from './package.json' assert { type: 'json' };
import { packageName } from './src/util/packageName';

const outputPath = `dist`;
Expand All @@ -21,8 +22,14 @@ const commonPlugins = [

const commonAliases: Alias[] = [];

type Package = Record<string, Record<string, string> | undefined>;

const commonInputOptions: InputOptions = {
input: 'src/index.ts',
external: [
...Object.keys((pkg as unknown as Package).dependencies ?? {}),
...Object.keys((pkg as unknown as Package).peerDependencies ?? {}),
],
plugins: [aliasPlugin({ entries: commonAliases }), commonPlugins],
};

Expand Down Expand Up @@ -97,16 +104,6 @@ const config: RollupOptions[] = [
file: `${outputPath}/index.d.ts`,
format: 'esm',
},
{
extend: true,
file: `${outputPath}/index.d.mts`,
format: 'esm',
},
{
extend: true,
file: `${outputPath}/index.d.cts`,
format: 'cjs',
},
],
},

Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,6 @@
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
// "skipLibCheck": true /* Skip type checking all .d.ts files. */
},
"exclude": ["coverage/", "dist/", "docs/"],
"exclude": ["coverage", "dist", "docs", "node_modules"],
"include": ["**/*"]
}

0 comments on commit f837fe1

Please sign in to comment.