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

Error when using a regex with managedPaths unless the regex includes a capture group #15491

Closed
SystemParadox opened this issue Mar 8, 2022 · 3 comments

Comments

@SystemParadox
Copy link

Bug report

What is the current behavior?

Using a regex with managedPaths results in the following error:

Uncaught error TypeError: Cannot read properties of undefined (reading 'length')
    at getManagedItem (node_modules/webpack/lib/FileSystemInfo.js:769:22)
    at checkManaged (node_modules/webpack/lib/FileSystemInfo.js:1992:26)

If the current behavior is a bug, please provide the steps to reproduce.

// webpack.config.js
module.exports = () => ({
    snapshot: {
        managedPaths: [
            /node_modules\/(?!@private\/).*\//,
        ],
    },
});

It appears that checkManaged uses match[1] when it should be using match[0].

Workaround: Enclosing the entire regex in a capture group fixes it.

What is the expected behavior?

A regex in managedPaths should work without a capture group. If for some reason a capture group is actually necessary then it should be clearly documented with an example and an explanation of the reason.

Other relevant information:

webpack version: 5.70.0
Node.js version: 16.14.0
Operating System: Linux
Additional tools: N/A

@webpack-bot
Copy link
Contributor

This issue had no activity for at least three months.

It's subject to automatic issue closing if there is no activity in the next 15 days.

@SystemParadox
Copy link
Author

This is still an issue.

@vankop
Copy link
Member

vankop commented Jun 9, 2022

created an issue in docs. webpack/webpack.js.org#6205


Capture group is expected and it is path itself

@vankop vankop closed this as completed Jun 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants