You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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)
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.
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 nativerequire.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
The text was updated successfully, but these errors were encountered: