Skip to content

Commit

Permalink
docs: Updated readme files
Browse files Browse the repository at this point in the history
  • Loading branch information
kshutkin committed Jun 21, 2023
1 parent 800fc0d commit befcdb4
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 47 deletions.
11 changes: 11 additions & 0 deletions .changeset/perfect-flies-kneel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
"@rollup-extras/plugin-angularjs-template-cache": patch
"@rollup-extras/plugin-binify": patch
"@rollup-extras/plugin-clean": patch
"@rollup-extras/plugin-serve": patch
"@rollup-extras/plugin-exec": patch
"@rollup-extras/plugin-html": patch
"@rollup-extras/utils": patch
---

Updated readme files
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Collection of rollup plugins
- [rollup-plugin-preprocess](https://github.com/Katochimoto/rollup-plugin-preprocess) - despite being version 0.0.4 and not being updated for many years flawlessly preprocess files using [preprocess](https://github.com/jsoverson/preprocess) syntax, relatively safe compared to [@rollup/plugin-replace](https://github.com/rollup/plugins/blob/master/packages/replace/README.md) which is good mainly in case you don't have access to the source code of a 3-d party library but still want to replace some expression there
- [rollup-plugin-styles](https://github.com/Anidetrix/rollup-plugin-styles) - if you want to bundle CSS/SCSS/SASS/LESS/Stylus and want to use PostCSS plugins. I recommend using it with [postcss-lightningcss](https://github.com/onigoetz/postcss-lightningcss)
- [rollup-plugin-livereload](https://github.com/thgh/rollup-plugin-livereload) - simple livereload, I recommend always having a delay in config
- [rollup-plugin-glob-import](https://github.com/gjbkz/rollup-plugin-glob-import) if you want to import files using glob pattern. I would say it is antipattern and vendor-lock in most cases but sometimes it is extremely useful, especially in migrating old code bases and building component showcases.
- [rollup-plugin-glob-import](https://github.com/gjbkz/rollup-plugin-glob-import) if you want to import files using a glob pattern. I would say it is antipattern and vendor-lock in most cases but sometimes it is extremely useful, especially in migrating old code bases and building component showcases.
- [rollup-plugin-html](https://github.com/bdadam/rollup-plugin-html) - allows importing html files as strings in that rare cases when you need it. Consider using [wildcard module declarations](https://www.typescriptlang.org/docs/handbook/modules.html#wildcard-module-declarations) if you are using Typescript.

## pkgbld
Expand Down
6 changes: 3 additions & 3 deletions plugin-angularjs-template-cache/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,16 @@ type AngularTemplatesCachePluginOptions = {
watch?: boolean, // true by default
rootDir?: string, // default to '.', root directory from which the plugin will construct template URIs (IDs)
transformTemplateUri?: (uri: string) => string, // last chance to transform template URI before actually using it in `templateCache.put` call
processHtml?: (html: string) => string, // function to process html templates, for example htmlmin, not applied when `useImports = true`
processHtml?: (html: string) => string, // function to process html templates, for example `htmlmin`, not applied when `useImports = true`
pluginName?: string, // defaults to '@rollup-extras/plugin-angularjs-template-cache'
angularModule?: string, // 'templates' by default, angular module name
standalone?: boolean, // true by default, true if we plugin needs to create module and false to just retrieve it
module?: string, // 'templates' by default, javascript module name, import not automatically injected into bundle
importAngular?: boolean, // default true, wheather to import angular or use global
importAngular?: boolean, // default true, defines if it is required to import angular or to use global
autoImport?: boolean, // false by default, automatically import generated module (useful for standalone module referenced by name)
verbose?: boolean | 'list-filenames', // false by default
useImports?: boolean, // false by default, instead of reading files from filesystem generate imports to get them through rollup pipeline. this probably requires additional plugins like `rollup-plugin-html`
transformHtmlImportsToUris?: boolean // false by default, wheather to replace template content with its Uri when using bare import
transformHtmlImportsToUris?: boolean // false by default, if true replaces template content with its Uri when using bare import
} | string | string[];
```

Expand Down
8 changes: 4 additions & 4 deletions plugin-binify/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Plugin Binify

Rollup plugin to create cli entry files during build.
Rollup plugin to create CLI entry files during the build.

Points:

- simple
- respects sourcemaps
- respects source maps
- changes permissions of the file(s)
- configurable

Expand Down Expand Up @@ -70,7 +70,7 @@ Optional, `number | false`.

Default: `0o755`

Number / string means try to set permissions on a file using fs.chmod.
Number/string defines permissions for a file, passed to `fs.chmod`.
`false` (falsy values not working) disables permissions settings.

### filter
Expand All @@ -79,7 +79,7 @@ Optional, `(item: OutputAsset | OutputChunk) => boolean`.

Default: `(item: OutputAsset | OutputChunk) => item.type === 'chunk' && item.isEntry`

Filters chunks / assets before applying plugin transformation.
Filters chunks/assets before applying plugin transformation.

## Configuration

Expand Down
15 changes: 8 additions & 7 deletions plugin-clean/README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# Plugin Clean

Rollup plugin to clean a directory during build.
Rollup plugin to clean a directory during the build.

Points:

- Uses fs.rm to remove directories that shipped with nodejs and has built-in retries
- Can be used with no configuration
- Runs once per directory by default (good for watch mode)
- Minimal amount of logs by default
- A minimal amount of logs by default

No globs support, please use [rollup-plugin-delete](https://github.com/vladshcherbin/rollup-plugin-delete) for globs.

Plugin runs on `renderStart` per each output and uses output.dir as a default target.
The plugin runs on `renderStart` per each output and uses output.dir as a default target.

Uses [`@niceties/logger`](https://github.com/kshutkin/niceties/blob/main/logger/README.md) to log messages, can be configured through `@niceties/logger` API.

Expand Down Expand Up @@ -42,7 +42,8 @@ export default {
}
```

To override / provide target directory to clean use:
To override/provide target directory to clean use:

```javascript
clean('dir')
```
Expand All @@ -63,13 +64,13 @@ or
clean({targets: ['dir1', 'dir2']})
```

Other supported fields in options object: `pluginName`, `deleteOnce`, `outputPlugin` and `verbose`.
Other supported fields in the options object: `pluginName`, `deleteOnce`, `outputPlugin` and `verbose`.

`pluginName` is just for debugging purposes so you can understand which instance of the plugin is responsible for an error.

`deleteOnce` can be set to `false` if you want to clean the directory every rebuild.
`deleteOnce` can be set to `false` if you want to clean the directory for every rebuild.

`outputPlugin` can be set to `false` if you want plugin to trigger earlier (use with caution, you may want to define `targets` yourself in this mode)
`outputPlugin` can be set to `false` if you want the plugin to trigger earlier (use with caution, you may want to define `targets` yourself in this mode)

`verbose` is to get more messages in the console.

Expand Down
6 changes: 3 additions & 3 deletions plugin-exec/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Plugin Exec

Exec some code when the bundle you are building is finished.
Executes some code when the bundle you are building is finished.

[Changelog](./CHANGELOG.md)

Expand Down Expand Up @@ -32,13 +32,13 @@ export default {

## Providing options

Just pass options to the plugin function. Returned object is the plugin instance which can be passed to rollup.
Just pass options to the plugin function. The returned object is the plugin instance which can be passed to rollup.

```javascript
exec({option: value, option2: value2})
```

For additional plugin instances (in case of multiple configs) please use: `firstInstance.api.addInstance()`
For additional plugin instances (in case of multiple configs) please use `firstInstance.api.addInstance()`

## Options

Expand Down
20 changes: 10 additions & 10 deletions plugin-html/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ Points:

- Inject file names with hashes
- Watch on a template file and trigger rebuild if it is changed
- Provides minimalistic template by default, so you are ready to start without configuration
- Provides a minimalistic template by default, so you are ready to start without configuration
- Supports multiple rollup configs (will trigger only when last output generated)
- Extensible through API so you can plug in something for html processing or generate new types of html elements
- Extensible through API so you can plug in something for HTML processing or generate new types of HTML elements

Uses [`@niceties/logger`](https://github.com/kshutkin/niceties/blob/main/logger/README.md) to log messages, can be configured through `@niceties/logger` API.
Uses [`@niceties/logger`](https://github.com/kshutkin/niceties/blob/main/logger/README.md) to log messages, which can be configured through `@niceties/logger` API.

[Changelog](./CHANGELOG.md)

Expand Down Expand Up @@ -40,13 +40,13 @@ export default {

## Providing options

Just pass options to the plugin function. Returned object is the plugin instance which can be passed to rollup.
Just pass options to the plugin function. The returned object is the plugin instance which can be passed to rollup.

```javascript
html({option: value, option2: value2})
```

For additional plugin instances (in case of multiple configs) please use: `firstInstance.api.addInstance()`
For additional plugin instances (in case of multiple configs) please use `firstInstance.api.addInstance()`

## Options

Expand All @@ -60,7 +60,7 @@ For debugging purposes, so many instances of a plugin can be differentiated in d

Optional, string, default: `'index.html'`.

Used to override output file name. If a filename with the same name exists in the pipeline it will be removed or overwritten in the process but its content by default will be used as an input for this plugin. In the following example file emitted by copy plugin will be used as an input for this plugin:
Used to override output file name. If a filename with the same name exists in the pipeline it will be removed or overwritten in the process but its content by default will be used as input for this plugin. In the following example file emitted by copy plugin will be used as input for this plugin:

```javascript
import copy from '@rollup-extras/plugin-copy';
Expand Down Expand Up @@ -94,19 +94,19 @@ If the plugin found a template file name this option defines if the plugin needs

Optional, boolean, default: true.

Defines if the plugin should use this.emitFile or should just write it to disk. Option can be ignored in setup with multiple rollup configs.
Defines if the plugin should use this.emitFile or should just write it to disk. The option can be ignored in setup with multiple rollup configs.

### useEmittedTemplate

Optional, boolean, default: true.

Defines what the plugin does if it finds a file with the expected file name in the bundle. By default it will be used as a template. Templates provided through the template option should be of higher priority to the plugin.
Defines what the plugin does if it finds a file with the expected file name in the bundle. By default, it will be used as a template. Templates provided through the template option should be of higher priority to the plugin.

### conditionalLoading

Optional, boolean, default: undefined.

Defines if plugin adds `nomodule` attribute for non modular js chunks. By default it is done only if we have `es` outputs in one of the bundles processed by the plugin. Also plugin values `iife` outputs higher than `umd` and if we have both filters out `umd` ones. This can be changed only by providing custom `assetFactory`.
Defines if the plugin adds `nomodule` attributes for non-modular js chunks. By default, it is done only if we have an `es` output in one of the bundles processed by the plugin. Also plugin values `iife` outputs higher than `umd` and if we have both filters out `umd` ones. This can be changed only by providing a custom `assetFactory`.

### injectIntoHead

Expand Down Expand Up @@ -216,7 +216,7 @@ Creates a simple module script element.

`(...factories: AssetFactory[]) => AssetFactory`

Combines several factories, calls them in order, the first factory created asset wins.
Combines several factories, and calls them in order, the first factory-created asset wins.

## Configuration

Expand Down
22 changes: 11 additions & 11 deletions plugin-serve/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Plugin Serve

Rollup plugin for dev server.
Rollup plugin for a dev server.

Points:

- Uses `koa`, customizable through koa middleware
- Zero config by default (works if you have output.dir defined)
- Zero-config by default (works if you have `output.dir` defined)

Uses [`@niceties/logger`](https://github.com/kshutkin/niceties/blob/main/logger/README.md) to log messages, can be configured through `@niceties/logger` API.
Uses [`@niceties/logger`](https://github.com/kshutkin/niceties/blob/main/logger/README.md) to log messages, which can be configured through `@niceties/logger` API.

[Changelog](./CHANGELOG.md)

Expand Down Expand Up @@ -37,13 +37,13 @@ export default {

## Providing options

Just pass options to the plugin function. Returned object is the plugin instance which can be passed to rollup.
Just pass options to the plugin function. The returned object is the plugin instance which can be passed to rollup.

```javascript
serve({option: value, option2: value2})
```

For additional plugin instances (in case of multiple configs) please use: `firstInstance.api.addInstance()`
For additional plugin instances (in case of multiple configs) please use `firstInstance.api.addInstance()`

## Options

Expand All @@ -69,19 +69,19 @@ Defines what dir to serve using `koa-static` middleware. If you want to disable

Optional, `number`, default: `8080`.

Port to use for server.
Port to use for the server.

### host

Optional, `string`.

Host to use, by default it does not provide host to createServer and lets nodejs decide.
Host to use, by default, does not provide a host to createServer and lets nodejs decide.

### useKoaLogger

Optional, `boolean`, default: `true`.

If plugin should use koa-logger middleware.
If the plugin should use koa-logger middleware.

### koaStaticOptions

Expand All @@ -93,7 +93,7 @@ Please check [`koa-static`](https://github.com/koajs/static) for options.

Optional, `{ cert: string, key: string, ca?: string; }`.

Key and certificate to use for https. Best way to generate cert and key (and to install ca) is [`mkcert`](https://github.com/FiloSottile/mkcert).
Key and certificate to use for https. The best way to generate a certificate and key (and to install ca) is [`mkcert`](https://github.com/FiloSottile/mkcert).

### customizeKoa

Expand All @@ -105,7 +105,7 @@ Extension point to customize `koa`.

Optional, `(server: Server) => void | true`

Extension point after server is live. Please return true to suppress the default banner.
Extension point after the server is live. Please return true to suppress the default banner.

## Configuration

Expand Down Expand Up @@ -133,7 +133,7 @@ type ServePluginOptions = {
- https://github.com/thgh/rollup-plugin-serve
- https://github.com/pearofducks/rollup-plugin-dev
- https://github.com/modernweb-dev/web/tree/master/packages/dev-server-rollup
- https://github.com/lukeed/sirv (and any another standalone server)
- https://github.com/lukeed/sirv
# License
Expand Down
16 changes: 8 additions & 8 deletions utils/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Utils

Utils to support creation of rollup plugins.
Utils to support the development of rollup plugins.

*Disclaimer: It is not a substitute for the `@rollup/pluginutils` package.*

Expand All @@ -20,33 +20,33 @@ function getOptions<T extends string | string[] | undefined | Record<string, unk

Utility function to get options object.

- `options` - object passed to plugin, can be `string`, `string[]` or `undefined` (applied second)
- `options` - object passed to the plugin, can be `string`, `string[]` or `undefined` (applied second)
- `defaults` - defaults (applied first)
- `factory` - additional factories (applied last)
- `field` - `string` to set property in case options is `string` or `string[]`, if `options[field]` is `string` it will be converted to `string[]`
- `field` - `string` to set a property in case options is `string` or `string[]`, if `options[field]` is `string` it will be converted to `string[]`

## Multiconfig Plugin Base
## Multi-config Plugin Base

Utility to construct plugins that should/can be executed when multiple configs used to gather information for plugin.
Utility to construct a plugin that should/can be executed when multiple configs are used to gather information for the plugin.

```typescript
function multiConfigPluginBase(useWriteBundle: boolean, pluginName: string, execute: ExecuteFn): Partial<PluginHooks>
```
- `useWriteBundle` - truthy if function should be executed on last `writeBundle`, falthy if it should be executed on `generateBundle`
- `useWriteBundle` - truthy if `execute` function should be executed on the last `writeBundle`, falsy if it should be executed on `generateBundle`
- `pluginName` - plugin name
- `execute` - function to execute

Returns a plugin instance.

## Statistics

Utility to construct a collector of data that reports count if verbose / more than 5 items. Assumption than in case of verbose an external logger will take care about reporting. It is very niche and probably you don't need it. Main idea for this is that in case we report thousands of files we are not holding data in memory but discarding it / writing it to log.
Utility to construct a collector of data that reports count if verbose / more than 5 items. The assumption is that in case of verbose an external logger will take care of reporting. It is very niche and probably you don't need it. The main idea for this is that in case we report thousands of files we are not holding data in memory but discarding it / writing it to log.

```typescript
function statistics(verbose: boolean, messageFactory: (result: number | string[]) => string): (name?: string) => undefined | string
```

Returns a collector that accepts new data if you pass a non null / non undefined parameter or constructs a message using message factory.
Returns a collector that accepts new data if you pass a non-null/non-undefined parameter or constructs a message using the message factory.

## Types

Expand Down

0 comments on commit befcdb4

Please sign in to comment.