Closed WillsonHaw closed 7 years ago
Actually, replacing minimatch with glob doesn't completely work, ran into an issue with loading some files from root, so that doesn't really fix it unfortunately...
But I found a workaround for my use case. Our folder structure is something like:
root
projects
apps
AppA
components
CompB
So when AppA's relative path to CompB is generated, you get ../../components/CompB
which then fails the above minimatch. However, if I change this line: https://github.com/aurelia/webpack-plugin/blob/master/src/ConventionDependenciesPlugin.ts#L24
to use the actual root folder root
(by putting in path.resolve('../../..')
for now), then everything works as it should.
Thanks for debugging this and identifying the root cause.
Indeed if one module resolves outside the root folder filtering ../../abc
against a "regular" glob **/*.js
won't work.
I have thought about this for a bit but couldn't find a better solution than: you should provide a better glob pattern.
**
not navigating up is somehow an important part of the filtering to ensure your viewmodels are in a specific folder and not somewhere else.
So if you know your VM can start with ../..
maybe you should try a glob pattern like ?(../../)**/*.js
(adjust accordingly). Minimatch supports extended glob patterns.
Another thing worth trying if you're using symlinks is to set the environment variable NODE_PRESERVE_SYMLINKS
. Not sure if it'll fix your problem, but it's worth a try.
I'm submitting a bug report
Please tell us about your environment:
Operating System: Windows 10
Node Version: 6.10.1
NPM Version: 3.10.10
JSPM OR Webpack AND Version webpack 2.6.1
Browser: all
Language: all
Current behavior: Our project is set up in a monorepo with a setup similar to a lerna project. ie. node_modules in root have our dependencies, with symlinks to our actual files. Because of this, ConventionDependenciesPlugin fails to pass this line: https://github.com/aurelia/webpack-plugin/blob/master/src/ConventionDependenciesPlugin.ts#L31 This is due to minimatch and this issue (of which @jods4 you've also posted in).
Expected/desired behavior:
Should return true.
I've tested locally, replacing
minimatch
with globby and glob instead, and that worked fine for my case. I can open a PR with the same change as well if you'd like.