-
-
Notifications
You must be signed in to change notification settings - Fork 268
Closed
Description
Hello!
Right now, minimatch
includes the following code:
var path = { sep: '/' }
try {
path = require('path')
} catch (er) {
}
https://github.com/isaacs/minimatch/blob/master/minimatch.js#L4-L7
However, it doesn't work very well with the bundling tools like Webpack, because they need to resolve all the dependencies during the build time and not at runtime. Also, the browser environment doesn't has path
module built-in.
This causes the following error in Webpack:
WARNING in …/node_modules/minimatch/minimatch.js 6:9-24
Module not found: Error: Can't resolve 'path' in '…/node_modules/minimatch'
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback 'resolve.fallback: { "path": require.resolve("path-browserify") }'
- install 'path-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "path": false }
Of course, we don't want to load polyfill just to satisfy the minimatch
(which is using only the sep
property from the path
module) and we can't substitute it with the empty module also because it will break the minimatch
logic.
I would suggest to introduce a more browser/bundler friendly approach.
aaronadamsCA, harryatoms, ploutarchosm, SebastienDaniel, dmitry-vychikov and 1 more
Metadata
Metadata
Assignees
Labels
No labels