Skip to content
This repository has been archived by the owner on Feb 16, 2024. It is now read-only.

Commit

Permalink
docs: document transformation output options
Browse files Browse the repository at this point in the history
  • Loading branch information
brawaru committed Oct 5, 2023
1 parent f613fd1 commit df9b3be
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,13 @@ A method to handle any errors that may arise during the parsing of one of the me

Plugins wrapping enables additional hooks in compatible bundlers to prevent other plugins from transforming files that would be transformed by this plugin.

#### **`output`**

- **Type**: [`OutputOptions`](#outputoptions)
- **Default**: `{ format: 'module', type: 'ast' }`

Options that allow to configure the output of transformation.

---

### `ParseErrorHandlingOption`
Expand Down Expand Up @@ -248,6 +255,42 @@ Whether to extend the defaults with provided `wrappers` or overwrite them.

A map of wrapping functions that can be used to modify the behavior of plugins. The map is an object where each key is a plugin name and the value is a function that accepts a plugin object and a filter function, and mutates the plugin hooks to use the provided filter function.

---

### `OutputOptions`

Represents options for the transformation output.

#### **`format`**

- **Type**: `'module' | 'json' | ((messages: MessagesASTMap | MessagesMap) => string)`
- **Default**: `'module'`

Defines the format of the output file or provides a function that will encode input JavaScript object containing the messages into a string representing contents of the transformed file.

The following formats are supported:

| Name | Description |
| :--------: | :------------------------------------------------------------ |
| `'module'` | Outputs an ESM JavaScript module. |
| `'json'` | Outputs a JSON string that can be processed by other plugins. |

You can also provide a custom function that accepts either a `MessagesASTMap` or a `MessagesMap` and returns a string.

#### **`type`**

- **Type**: `'raw' | 'ast'`
- **Default**: `'ast'`

Defines what kind of output should be generated.

The following output types are supported:

| Name | Description |
| :-----: | :--------------------------------------------- |
| `'raw'` | Outputs the messages as is. |
| `'ast'` | Pre-parses the messages and outputs their AST. |

</details>

## Usage with other plugins
Expand Down

0 comments on commit df9b3be

Please sign in to comment.