@favware/rollup-type-bundler
Advanced tools
Comparing version 0.0.1-next.53fb21e.0 to 0.0.1-next.83d8f98.0
{ | ||
"name": "@favware/rollup-type-bundler", | ||
"version": "0.0.1-next.53fb21e.0", | ||
"version": "0.0.1-next.83d8f98.0", | ||
"description": "A small CLI tool to bundle types with rollup", | ||
@@ -5,0 +5,0 @@ "author": "@favware", |
@@ -8,3 +8,2 @@ <div align="center"> | ||
[![GitHub](https://img.shields.io/github/license/favware/rollup-type-bundler)](https://github.com/favware/rollup-type-bundler/blob/main/LICENSE) | ||
[![npm bundle size](https://img.shields.io/bundlephobia/min/@favware/rollup-type-bundler?logo=webpack&style=flat-square)](https://bundlephobia.com/result?p=@favware/rollup-type-bundler) | ||
[![npm](https://img.shields.io/npm/v/@favware/rollup-type-bundler?color=crimson&logo=npm)](https://www.npmjs.com/package/@favware/rollup-type-bundler) | ||
@@ -19,5 +18,13 @@ [![Depfu](https://badges.depfu.com/badges/97d09026f35f8886a8bca2e8c7caa533/count.svg)](https://depfu.com/github/favware/rollup-type-bundler?project_id=28226) | ||
When creating a library with TypeScript you will often be able to just publish it with your current toolset, however once your library grows and grows then you might want to make it possible for people of your library to use [TypeScript Module Augmentation](https://www.typescriptlang.org/docs/handbook/declaration-merging.html) to merge additional types into the types that you provide. | ||
When you create a library in TypeScript, you will often be able to just publish | ||
it with your current toolset; however, once your library grows and grows, you | ||
might want to make it possible for people of your library to use [TypeScript | ||
Module Augmentation][tma] to merge additional types into the types that you | ||
provide. | ||
This however introduces a big issue in TypeScript. Even when re-exporting all your interfaces/types/classes in a root `index.d.ts` that you are referencing in `"types"` in your `package.json`, TypeScript still won't properly apply folder-nested (i.e. a type that's in `your-package/dist/lib/structures/SomeClass.d.ts`) module augmentation when augmenting with: | ||
Unfortunately, this introduces a big issue in TypeScript. Even when | ||
re-exporting all your interfaces/types/classes in a root `index.d.ts` that you | ||
are referencing in `"types"` in your `package.json`, TypeScript still won't | ||
properly apply folder-nested module augmentation (i.e. a type that's in | ||
`your-package/dist/lib/structures/SomeClass.d.ts`) when augmenting like this: | ||
@@ -28,3 +35,3 @@ ```ts | ||
Without this package your users would have to augment the type with: | ||
Without this package, your users would have to augment the type like this: | ||
@@ -35,16 +42,30 @@ ```ts | ||
this is extremely bad developer experience because you cannot apply all module augmentations in 1 block. To solve this issue, there is this library. | ||
As you might guess, this is extremely bad developer experience because you | ||
cannot apply all module augmentations in 1 block. That's where this rollup | ||
module comes in - now, you can bundle types in a developer-friendly way and | ||
make life easier for everyone involved. | ||
[tma]: https://www.typescriptlang.org/docs/handbook/declaration-merging.html | ||
### How this works | ||
The library uses [rollup](https://www.npmjs.com/package/rollup) with [rollup-plugin-dts](https://www.npmjs.com/package/rollup-plugin-dts) under the hood. It will execute a few steps: | ||
The library uses [rollup] with [rollup-plugin-dts] under the hood. It will | ||
execute a few steps: | ||
1. It cleans the configured dist directory (`--dist` flag or `dist` in config). | ||
2. It calls the `--build-script` (or `buildScript` in config) to build your code with your compiler. This defaults to `build`. | ||
3. It executes [rollup](https://www.npmjs.com/package/rollup) to bundle your types into 1 `index.d.ts` file, output to the configured `dist` directory. | ||
4. It removes all other `.d.ts` and `.d.ts.map` files from your configured `dist` directory as they are now superfluous. | ||
1. It cleans the configured distribution directory (`--dist` flag or `dist` in | ||
config). | ||
2. It calls the `--build-script` (or `buildScript` in config) to build your code | ||
with your compiler. This defaults to `build`. | ||
3. It executes [rollup] to bundle your types into 1 `index.d.ts` file, output to | ||
the configured `dist` directory. | ||
4. It removes all other `.d.ts` and `.d.ts.map` files from your configured | ||
`dist` directory as they are now superfluous. | ||
[rollup]: https://www.npmjs.com/package/rollup | ||
[rollup-plugin-dts]: https://www.npmjs.com/package/rollup-plugin-dts | ||
## Installation | ||
You can use the following command to install this package, or replace `npm install -D` with your package manager of choice. | ||
You can use the following command to install this package, or replace | ||
`npm install -D` with your package manager of choice. | ||
@@ -91,13 +112,9 @@ ```sh | ||
Or you can provide most of these options through a configuration file. The following files are supported: | ||
Or, you can set most of these options through a configuration file. This | ||
file should be located at your current working directory (where you're | ||
calling this package). It should be named `.rollup-type-bundlerrc`, optionally | ||
suffixed with `.json`, `.yaml`, or `.yml`. | ||
- `.rollup-type-bundlerrc` | ||
- `.rollup-type-bundlerrc.json` | ||
- `.rollup-type-bundlerrc.yaml` | ||
- `.rollup-type-bundlerrc.yml` | ||
### Config file fields | ||
The file should either be located at the current working directory from where this rollup-type-bundler is called, or provided as a custom path with `--config`. | ||
### Fields in config file | ||
- `--dist` maps to `dist` | ||
@@ -108,3 +125,5 @@ - `--build-script` maps to `buildScript` | ||
When using `.rollup-type-bundlerrc` or `.rollup-type-bundlerrc.json` as your config file you can also use the JSON schema to get schema validation. Add to your config file: | ||
When using `.rollup-type-bundlerrc` or `.rollup-type-bundlerrc.json` as | ||
your config file you can also use the JSON schema to get schema | ||
validation. To do so, add the following to your config file: | ||
@@ -129,3 +148,3 @@ ```json | ||
**Example Yaml file**: | ||
**Example YAML file**: | ||
@@ -143,5 +162,10 @@ ```yaml | ||
Favware projects is and always will be open source, even if we don't get donations. That being said, we know there are amazing people who may still want to donate just to show their appreciation. Thank you very much in advance! | ||
Favware projects are and always will be open source, even if we don't get | ||
donations. That being said, we know there are amazing people who may still | ||
want to donate just to show their appreciation. Thank you very much in | ||
advance! | ||
We accept donations through Ko-fi, Paypal, Patreon, GitHub Sponsorships, and various crypto currencies. You can use the buttons below to donate through your method of choice. | ||
We accept donations through Ko-fi, Paypal, Patreon, GitHub Sponsorships, | ||
and various cryptocurrencies. You can use the buttons below to donate | ||
through your method of choice. | ||
@@ -168,2 +192,3 @@ | Donate With | Address | | ||
<td align="center"><a href="https://favware.tech/"><img src="https://avatars3.githubusercontent.com/u/4019718?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jeroen Claassens</b></sub></a><br /><a href="https://github.com/favware/rollup-type-bundler/commits?author=Favna" title="Code">💻</a> <a href="#design-Favna" title="Design">🎨</a> <a href="#ideas-Favna" title="Ideas, Planning, & Feedback">🤔</a> <a href="#infra-Favna" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="#maintenance-Favna" title="Maintenance">🚧</a> <a href="#platform-Favna" title="Packaging/porting to new platform">📦</a> <a href="#projectManagement-Favna" title="Project Management">📆</a></td> | ||
<td align="center"><a href="https://github.com/Nytelife26"><img src="https://avatars.githubusercontent.com/u/22531310?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Tyler J Russell</b></sub></a><br /><a href="https://github.com/favware/rollup-type-bundler/commits?author=Nytelife26" title="Documentation">📖</a></td> | ||
</tr> | ||
@@ -170,0 +195,0 @@ </table> |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
44058
194