Skip to content

Add ability to whitelist/blacklist modules that should (not) be decached #47

@mihkeleidast

Description

@mihkeleidast

This is somewhat related to #29 but a more specific feature request so filing it separately.

I'm running into some issues with decache uncaching instances of react and react-dom, so I'm getting errors like:

Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:

You might have mismatching versions of React and the renderer (such as React DOM)

I'm really guessing here, but it seems that deleting and re-requiring react causes some identity change for the library and... just ruins everything :)

This is most probably a very specific issue related to my dev environment, but I can pretty safely say that I do not need to uncache these modules (nor some other third party dependencies) since I'm not actively working on them.

Proposed syntax:

decache('./path/to/module', {
    // specify only which modules should be uncached,
    // child odules not matching these regex patterns should NOT be uncahced
    whitelist: [
        /node_modules\/react/,
        /node_modules\/react-dom/
    ],
    // specify which modules should NOT be uncached,
    // all other child modules should be uncached
    blacklist: [
        /node_modules\/react/,
        /node_modules\/react-dom/
    ]
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or enhancement of existing functionality

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions