enable disable webpack cache in loaders
GrapevineLin opened this issue · comments
GrapevineLin commented
Describe the feature
Some plugins cannot work with Webpack 5's persistent cache and require it to be disabled. What are the potential solutions to this issue?
can we just do this in tramsform
(same to load
):
export default async function transform(this: LoaderContext<{ unpluginName: string }>, source: string, map: any) {
const callback = this.async()
+ // add this line to disable cache in specific situations
+ this.cacheable(false)
let unpluginName: string
...
or just passing some options to the loader like this:
// transform hook
if (plugin.transform) {
const useLoader: RuleSetUseItem[] = [{
loader: `${TRANSFORM_LOADER}?unpluginName=${encodeURIComponent(plugin.name)}&cache[type]=memory`,
}]
Additional information
- Would you be willing to help implement this feature?
Anthony Fu commented
Giving transform
's this context the cacheable
function sounds good to me. PR welcome.