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

Issue with symlinks / recursive dependencies in monorepos #301

Closed
thomheymann opened this issue Aug 23, 2017 · 3 comments
Closed

Issue with symlinks / recursive dependencies in monorepos #301

thomheymann opened this issue Aug 23, 2017 · 3 comments
Milestone

Comments

@thomheymann
Copy link

Opening an issue in case other's have the same problem:

There's a bug in the current version of PostCSS import plugin that occurs when using symlinks and causes invalid dependencies to be loaded in when using different versions of the same dependency within the same app.

The bug occurs as the default behaviour of the resolve module (used to resolve ids to filenames) is different to the default behaviour of Node.js's native require.resolve method.

I know this is probably a bit of an edge case as most people don't use symlinks but it causes huge issues in monorepos (e.g. lerna / yarn workspaces).

The fix is to disable the following option in the resolve module:

  • opts.preserveSymlinks - if true, doesn't resolve basedir to real path before resolving. This is the way Node resolves dependencies when executed with the --preserve-symlinks flag. Note: this property is currently true by default but it will be changed to false in the next major version because Node's resolution algorithm does not preserve symlinks by default.
    (https://www.npmjs.com/package/resolve)

I have sent a pull request here: #300

@RyanZim
Copy link
Collaborator

RyanZim commented Nov 6, 2017

Fixed in v11; not sure why I forgot to close this.

@RyanZim RyanZim closed this as completed Nov 6, 2017
@RyanZim RyanZim added this to the 11.0.0 milestone Nov 6, 2017
@skipjack
Copy link

skipjack commented Jul 26, 2018

Still seeing this issue when using this package through webpack for some reason. I'm on v11.1.0 and I have resolve.symlinks set to false in my webpack config (although it seems like that shouldn't make a difference from what I've read). I was able to fix this via the path option, but shouldn't that be unnecessary based on the preserveSymlinks / --preserve-symlinks change?

path: [ Path.resolve(__dirname, 'node_modules') ]

The only thing I can think of after some debugging is that maybe webpack executes the postcss-loader (and its plugins), from within the symlinked directory. Hope I'm not polluting this thread, it just seemed like the most relevant one I could find.

@RyanZim
Copy link
Collaborator

RyanZim commented Jul 26, 2018

@skipjack My guess is that you've got something misconfigured, and webpack is doing the importing, not this plugin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants