Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add defineConfig function in dts-cli/config #142

Merged
merged 1 commit into from
Apr 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,9 @@ DTS uses Rollup under the hood. The defaults are solid for most packages (Formik

```js
// Not transpiled with TypeScript or Babel, so use plain Es6/Node.js!
/**
* @type {import('dts-cli').DtsConfig}
*/
module.exports = {
// This function will run for each entry/format/env combination
rollup(config, options) {
Expand All @@ -351,17 +354,30 @@ module.exports = {
};
```

or

```js
const defineConfig = require('dts-cli').defineConfig;

module.exports = defineConfig({
// This function will run for each entry/format/env combination
rollup: (config, options) => {
return config; // always return a config.
},
});
```

**dts.config.ts**

```typescript
import { DtsOptions, RollupOptions } from 'dts-cli';
import { defineConfig } from 'dts-cli';

export default {
export default defineConfig({
// This function will run for each entry/format/env combination
rollup(config: RollupOptions, options: DtsOptions) {
rollup: (config, options) => {
return config; // always return a config.
},
};
});
```

The `options` object contains the following:
Expand Down
2 changes: 1 addition & 1 deletion docs/components/release.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const Release = (props) => {
<Box>
<Text fontWeight="bold" fontSize="3xl">
#{' '}
<a href={url} target="_blank" rel="noopener">
<a href={url} target="_blank" rel="noopener noreferrer">
{name}
</a>
</Text>
Expand Down
34 changes: 32 additions & 2 deletions docs/pages/customization.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,15 @@ name: Customization
> **❗⚠️❗ Warning**: <br/>
> These modifications will override the default behavior and configuration of DTS. As such they can invalidate internal guarantees and assumptions. These types of changes can break internal behavior and can be very fragile against updates. Use with discretion!

DTS uses Rollup under the hood. The defaults are solid for most packages (Formik uses the defaults!). However, if you do wish to alter the rollup configuration, you can do so by creating a file called `dts.config.js` at the root of your project like so:
DTS uses Rollup under the hood. The defaults are solid for most packages (Formik uses the defaults!). However, if you do wish to alter the rollup configuration, you can do so by creating a file called `dts.config.js` (or `dts.config.ts`) at the root of your project like so:

**dts.config.js**

```js
// Not transpiled with TypeScript or Babel, so use plain Es6/Node.js!
/**
* @type {import('dts-cli').DtsConfig}
*/
module.exports = {
// This function will run for each entry/format/env combination
rollup(config, options) {
Expand All @@ -21,10 +26,35 @@ module.exports = {
};
```

or

```js
const defineConfig = require('dts-cli').defineConfig;

module.exports = defineConfig({
// This function will run for each entry/format/env combination
rollup: (config, options) => {
return config; // always return a config.
},
});
```

**dts.config.ts**

```typescript
import { defineConfig } from 'dts-cli';

export default defineConfig({
rollup: (config, options) => {
return config; // always return a config.
},
});
```

The `options` object contains the following:

```tsx
export interface TsdxOptions {
export interface DtsOptions {
// path to file
input: string;
// Name of package
Expand Down
Loading