Skip to content

Make managedPaths support globs/anymatch #12036

Closed

Description

@martpie

Feature request

With some setups (especially the ones making use of Yarn Workspaces), it is fairly common to use Webpack to apply some loaders to files located in node_modules (like a local package, or a module that needs to go through Babel, etc), and also watch changes happening in those files.

The problem with Webpack 5 is snapshot.managedPaths/cache.managedPaths only accepts an array of string representing a list of folders that "are not supposed to change" (that's my understanding of the feature).

So now, a solution is to just disable them:

{
  snapshot: { 
    managedPaths: []
}

...which I would not recommend at all, as I assume it would introduce some severe performances hits for the cache.

So, it would be great if we could have the following:

{
  snapshot: { 
    managedPaths: ['**node_modules/{!some-module,!or-another}/**/*']
  }
}

What is the expected behavior?

Nothing is expected, this is a proposal/requet.

What is motivation or use case for adding/changing the behavior?

cf. above.

How should this be implemented in your opinion?

It looks to me that using anymatch on managedPaths would not break anything. I have absolutely no knowledge of Webpack's internals, I may say something really stupid here.

Are you willing to work on this yourself?

If it receives the blessing of an official Webpack member, yes!

Activity

  1. webpack-bot commented on Nov 20, 2020

    @webpack-bot
    Contributor

    For maintainers only:

    • webpack-4
    • webpack-5
    • bug
    • critical-bug
    • enhancement
    • documentation
    • performance
    • dependencies
    • question
  2. alexander-akait commented on Nov 20, 2020

    @alexander-akait
    Member

    Sorry out of scope webpack, we avoid using glob syntax in the config (except edge cases - watching, but it is legacy reasons), you can achieve this on own side, just write own logic in the config file, feel free to feedback

  3. alexander-akait commented on Nov 20, 2020

    @alexander-akait
    Member

    Logic for this options can be very complex, so we try to keep it simple as possible and complex solutions we leave it to the developers

  4. sokra commented on Nov 20, 2020

    @sokra
    Member

    Wrap the glob within glob.sync in the config

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions