Skip to content
This repository has been archived by the owner on Aug 4, 2021. It is now read-only.

Symlink resolution #100

Closed
scola84 opened this issue Apr 20, 2017 · 7 comments
Closed

Symlink resolution #100

scola84 opened this issue Apr 20, 2017 · 7 comments

Comments

@scola84
Copy link

scola84 commented Apr 20, 2017

This line is wrong: https://github.com/rollup/rollup-plugin-node-resolve/blob/master/src/index.js#L74

/project/packageA/index.js
/project/packageA/node_modules/async
/project/packageA/node_modules/packageB as symlink
/project/packageB/index.js

packageA includes packageB and packageB includes async. But async lives under packageA as per how npm installs packages (cf. https://docs.npmjs.com/cli/dedupe).

Now, because of the L74, packageB gets resolved to /project/packageB and rollup tries to import async from packageB/node_modules/async, which does not exist.

@fregante
Copy link

Perhaps related to #98. Can you provide a repro?

@scola84
Copy link
Author

scola84 commented Aug 2, 2017

@scola84
Copy link
Author

scola84 commented Nov 20, 2017

I solved my problem by setting opts.main = false. This will force disregardResult = true on line https://github.com/rollup/rollup-plugin-node-resolve/blob/master/src/index.js#L65 which in turn will force skipping the if block starting at https://github.com/rollup/rollup-plugin-node-resolve/blob/master/src/index.js#L72

This works with the following plugins:

plugins: [
    resolve({
      main: false
    }),
    commonjs(),
    css({
      output: 'dist/browser.css'
    }),
    buble(),
    livereload({
      watch: 'dist',
      https: {
        ...
      }
    })
]

@whaaaley
Copy link

whaaaley commented Apr 9, 2019

Now that main has been deprecated in the latest version this workaround requires an alternative syntax to avoid the deprecation message.

  resolve({ mainFields: ['module'] })

@bterlson
Copy link
Contributor

This no longer repros. Probably fixed by some of the recent symlinking improvements across this plugin, rollup-plugin-commonjs, and browserify/resolve. Please re-open if this is still an issue!

@whaaaley
Copy link

whaaaley commented Aug 20, 2019

@bterlson Hello. 👋

I just updated my rollup packages and commented out the workaround and the issue still seems to be present for me. What this screenshot is showing is that the files I'm importing from symlinked folders are not being found. I'm not sure if it matters, but the symlink that I'm using in my project is a relative softlink. In my project I have a root level folder called lib that I link into multiple apps' src folders like this.

# mac
ln -s ../../../lib apps/foobar/src

# win
mklink /D apps\foobar\src\lib ..\..\..\lib

untitled

EDIT: Also, fwiw, this was working in version 2.0.0 and prior.

@whaaaley
Copy link

whaaaley commented Aug 21, 2019

I created an updated repro in this repository.
https://github.com/whaaaley/symlink-bug

npm i && npm start

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

No branches or pull requests

4 participants