forked from karlprieb/babel-plugin-add-import-extension
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## [1.3.0](v1.2.0...v1.3.0) (2024-10-27) #### ✨ Features * Make `filepath` available in replacer context and add support for `TSImportType` replacements ([0be1eda](0be1eda)) #### ⚙️ Build system * **husky:** update commit hooks ([5719706](5719706))
- Loading branch information
Showing
9 changed files
with
541 additions
and
5,996 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,103 +1,18 @@ | ||
babel-plugin-transform-rewrite-imports | ||
**babel-plugin-transform-rewrite-imports** • **Docs** | ||
|
||
# babel-plugin-transform-rewrite-imports | ||
|
||
## Table of contents | ||
|
||
### Type Aliases | ||
|
||
- [Callback](README.md#callback) | ||
- [Options](README.md#options) | ||
|
||
### Variables | ||
*** | ||
|
||
- [defaultRecognizedExtensions](README.md#defaultrecognizedextensions) | ||
|
||
### Functions | ||
|
||
- [default](README.md#default) | ||
# babel-plugin-transform-rewrite-imports | ||
|
||
## Type Aliases | ||
|
||
### Callback | ||
|
||
Ƭ **Callback**<`ReturnType`\>: (`context`: { `capturingGroups`: `string`[] ; `specifier`: `string` }) => `ReturnType` | ||
|
||
#### Type parameters | ||
|
||
| Name | | ||
| :------ | | ||
| `ReturnType` | | ||
|
||
#### Type declaration | ||
|
||
▸ (`context`): `ReturnType` | ||
|
||
A callback function provided as a value to `Options.appendExtension` or to an | ||
entry in `Options.replaceExtensions`. | ||
|
||
##### Parameters | ||
|
||
| Name | Type | Description | | ||
| :------ | :------ | :------ | | ||
| `context` | `Object` | - | | ||
| `context.capturingGroups` | `string`[] | An array of capturing groups returned by `String.prototype.match()` or an empty array if the matcher string was not a regular expression. | | ||
| `context.specifier` | `string` | The import/export specifier being evaluated by babel. | | ||
|
||
##### Returns | ||
|
||
`ReturnType` | ||
|
||
#### Defined in | ||
|
||
[index.ts:15](https://github.com/Xunnamius/babel-plugin-transform-rewrite-imports/blob/e42f369/src/index.ts#L15) | ||
|
||
___ | ||
|
||
### Options | ||
|
||
Ƭ **Options**: `Object` | ||
|
||
The options that can be passed to this plugin from babel. | ||
|
||
#### Type declaration | ||
|
||
| Name | Type | Description | | ||
| :------ | :------ | :------ | | ||
| `appendExtension?` | `string` \| [`Callback`](README.md#callback)<`string` \| `undefined`\> | This string will be appended to all relative import specifiers that do not already have a recognized extension. Also accepts a callback function for advanced use cases. **`Default`** undefined | | ||
| `recognizedExtensions?` | `string`[] | Members of this array will be considered a "recognized extension". **`Default`** defaultRecognizedExtensions | | ||
| `replaceExtensions?` | `Record`<`string`, `string` \| [`Callback`](README.md#callback)<`string`\>\> | Map of specifiers to their replacements. Specifiers can be strings or regular expressions (i.e. strings that start with ^ and/or end with $). If a specifier is a regular expression, capturing group notation can be used in the replacement. Replacements can either be a string or a callback function that returns a string. **`Default`** | | ||
| `silent?` | `boolean` | If true, this plugin will generate no output. **`Default`** false | | ||
| `verbose?` | `boolean` | If true, this plugin will generate more output than usual. **`Default`** false | | ||
|
||
#### Defined in | ||
|
||
[index.ts:30](https://github.com/Xunnamius/babel-plugin-transform-rewrite-imports/blob/e42f369/src/index.ts#L30) | ||
- [Callback](type-aliases/Callback.md) | ||
- [Options](type-aliases/Options.md) | ||
|
||
## Variables | ||
|
||
### defaultRecognizedExtensions | ||
|
||
• `Const` **defaultRecognizedExtensions**: readonly [``".js"``, ``".jsx"``, ``".mjs"``, ``".cjs"``, ``".json"``] | ||
|
||
The default value of `Options.recognizedExtensions`. | ||
|
||
#### Defined in | ||
|
||
[index.ts:83](https://github.com/Xunnamius/babel-plugin-transform-rewrite-imports/blob/e42f369/src/index.ts#L83) | ||
- [defaultRecognizedExtensions](variables/defaultRecognizedExtensions.md) | ||
|
||
## Functions | ||
|
||
### default | ||
|
||
▸ **default**(): `PluginObj`<`State`\> | ||
|
||
A babel plugin that reliably rewrites import (and export) specifiers. | ||
|
||
#### Returns | ||
|
||
`PluginObj`<`State`\> | ||
|
||
#### Defined in | ||
|
||
[index.ts:96](https://github.com/Xunnamius/babel-plugin-transform-rewrite-imports/blob/e42f369/src/index.ts#L96) | ||
- [default](functions/default.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
[**babel-plugin-transform-rewrite-imports**](../README.md) • **Docs** | ||
|
||
*** | ||
|
||
[babel-plugin-transform-rewrite-imports](../README.md) / default | ||
|
||
# Function: default() | ||
|
||
> **default**(): `PluginObj`\<`State`\> | ||
A babel plugin that reliably rewrites import (and export) specifiers. | ||
|
||
## Returns | ||
|
||
`PluginObj`\<`State`\> | ||
|
||
## Defined in | ||
|
||
[index.ts:101](https://github.com/Xunnamius/babel-plugin-transform-rewrite-imports/blob/0be1eda4a2b30709c0755c0ffd994f51ba295498/src/index.ts#L101) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
[**babel-plugin-transform-rewrite-imports**](../README.md) • **Docs** | ||
|
||
*** | ||
|
||
[babel-plugin-transform-rewrite-imports](../README.md) / Callback | ||
|
||
# Type Alias: Callback()\<ReturnType\> | ||
|
||
> **Callback**\<`ReturnType`\>: (`context`) => `ReturnType` | ||
A callback function provided as a value to `Options.appendExtension` or to an | ||
entry in `Options.replaceExtensions`. | ||
|
||
## Type Parameters | ||
|
||
• **ReturnType** | ||
|
||
## Parameters | ||
|
||
• **context** | ||
|
||
• **context.capturingGroups**: `string`[] | ||
|
||
An array of capturing groups returned by `String.prototype.match()` or an | ||
empty array if the matcher string was not a regular expression. | ||
|
||
• **context.filepath**: `string` | ||
|
||
The absolute path of the file containing the specifier being evaluated by | ||
Babel. | ||
|
||
• **context.specifier**: `string` | ||
|
||
The import/export specifier being evaluated by Babel. | ||
|
||
## Returns | ||
|
||
`ReturnType` | ||
|
||
## Defined in | ||
|
||
[index.ts:15](https://github.com/Xunnamius/babel-plugin-transform-rewrite-imports/blob/0be1eda4a2b30709c0755c0ffd994f51ba295498/src/index.ts#L15) |
Oops, something went wrong.