Skip to content

Commit

Permalink
Allow shouldTransformCachedModule to return null (#4932)
Browse files Browse the repository at this point in the history
Co-authored-by: Lukas Taegert-Atkinson <lukastaegert@users.noreply.github.com>
  • Loading branch information
bluwy and lukastaegert committed Apr 11, 2023
1 parent 6868eb4 commit c4cb264
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions docs/plugin-development/index.md
Expand Up @@ -564,14 +564,14 @@ type ShouldTransformCachedModuleHook = (options: {
meta: { [plugin: string]: any };
moduleSideEffects: boolean | 'no-treeshake';
syntheticNamedExports: boolean | string;
}) => boolean;
}) => boolean | NullValue;
```

If the Rollup cache is used (e.g. in watch mode or explicitly via the JavaScript API), Rollup will skip the [`transform`](#transform) hook of a module if after the [`load`](#transform) hook, the loaded `code` is identical to the code of the cached copy. To prevent this, discard the cached copy and instead transform a module, plugins can implement this hook and return `true`.

This hook can also be used to find out which modules were cached and access their cached meta information.

If a plugin does not return `true`, Rollup will trigger this hook for other plugins, otherwise all remaining plugins will be skipped.
If a plugin does not return a boolean, Rollup will trigger this hook for other plugins, otherwise all remaining plugins will be skipped.

### transform

Expand Down
2 changes: 1 addition & 1 deletion src/rollup/types.d.ts
Expand Up @@ -254,7 +254,7 @@ export type ShouldTransformCachedModuleHook = (
resolvedSources: ResolvedIdMap;
syntheticNamedExports: boolean | string;
}
) => boolean;
) => boolean | NullValue;

export type IsExternal = (
source: string,
Expand Down

1 comment on commit c4cb264

@vercel
Copy link

@vercel vercel bot commented on c4cb264 Apr 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

rollup – ./

rollup-eight.vercel.app
rollup-rollup-js.vercel.app
rollup-git-master-rollup-js.vercel.app

Please sign in to comment.