From 945e7393f42e6e5d7975400f79e77b28225fb0fc Mon Sep 17 00:00:00 2001 From: bluwy Date: Sun, 9 Apr 2023 13:30:52 +0800 Subject: [PATCH] Allow shouldTransformCachedModule to return null --- docs/plugin-development/index.md | 4 ++-- src/rollup/types.d.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/plugin-development/index.md b/docs/plugin-development/index.md index 94483871441..3d0df9afb2a 100644 --- a/docs/plugin-development/index.md +++ b/docs/plugin-development/index.md @@ -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 diff --git a/src/rollup/types.d.ts b/src/rollup/types.d.ts index fa6accb7a89..94759af04ca 100644 --- a/src/rollup/types.d.ts +++ b/src/rollup/types.d.ts @@ -254,7 +254,7 @@ export type ShouldTransformCachedModuleHook = ( resolvedSources: ResolvedIdMap; syntheticNamedExports: boolean | string; } -) => boolean; +) => boolean | NullValue; export type IsExternal = ( source: string,