Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable disable webpack cache in loaders #303

Open
1 task done
GrapevineLin opened this issue May 15, 2023 · 1 comment
Open
1 task done

enable disable webpack cache in loaders #303

GrapevineLin opened this issue May 15, 2023 · 1 comment

Comments

@GrapevineLin
Copy link

GrapevineLin commented May 15, 2023

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?
@antfu
Copy link
Member

antfu commented May 16, 2023

Giving transform's this context the cacheable function sounds good to me. PR welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants