Skip to content

Commit

Permalink
Add missing type declaration for getCombinedSourcemap (#3431)
Browse files Browse the repository at this point in the history
* Add missing type declaration for getCombinedSourcemap

* Only add getCombinedSourcemap to transform hook

Co-authored-by: Lukas Taegert-Atkinson <lukas.taegert-atkinson@tngtech.com>
Co-authored-by: Lukas Taegert-Atkinson <lukastaegert@users.noreply.github.com>
  • Loading branch information
3 people committed Mar 10, 2020
1 parent 9d4a49f commit ddc267e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/05-plugin-development.md
Expand Up @@ -478,7 +478,7 @@ Structurally equivalent to `this.warn`, except that it will also abort the bundl

#### `this.getCombinedSourcemap() => SourceMap`

Get the combined source maps of all previous plugins. This context function can only be used in [`transform`](guide/en/#transform) plugin hook.
Get the combined source maps of all previous plugins. This context function can only be used in the [`transform`](guide/en/#transform) plugin hook.

#### `this.getFileName(referenceId: string) => string`

Expand Down
6 changes: 5 additions & 1 deletion src/rollup/types.d.ts
Expand Up @@ -228,10 +228,14 @@ type LoadResult = SourceDescription | string | null | undefined;

export type LoadHook = (this: PluginContext, id: string) => Promise<LoadResult> | LoadResult;

export interface TransformPluginContext extends PluginContext {
getCombinedSourcemap: () => SourceMap;
}

export type TransformResult = string | null | undefined | SourceDescription;

export type TransformHook = (
this: PluginContext,
this: TransformPluginContext,
code: string,
id: string
) => Promise<TransformResult> | TransformResult;
Expand Down
3 changes: 2 additions & 1 deletion src/utils/transform.ts
Expand Up @@ -10,6 +10,7 @@ import {
RollupWarning,
SourceDescription,
TransformModuleJSON,
TransformPluginContext,
TransformResult
} from '../rollup/types';
import { collapseSourcemap } from './collapseSourcemaps';
Expand Down Expand Up @@ -81,7 +82,7 @@ export default function transform(
'transform',
[curSource, id],
transformReducer,
(pluginContext, plugin) => {
(pluginContext, plugin): TransformPluginContext => {
curPlugin = plugin;
return {
...pluginContext,
Expand Down

0 comments on commit ddc267e

Please sign in to comment.