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

module imports without dots are not resolved #865

Closed
sonaba opened this issue Mar 20, 2018 · 9 comments
Closed

module imports without dots are not resolved #865

sonaba opened this issue Mar 20, 2018 · 9 comments

Comments

@sonaba
Copy link

sonaba commented Mar 20, 2018

if im using dependency pathnames without dots i get "missing packages dependencies" error on "bit status".
u can find info about importing modules without dots:
https://medium.com/@ktruong008/absolute-imports-with-create-react-app-4338fbca7e3d
https://jaketrent.com/post/import-js-module-without-dot-dot-slash/
https://stackoverflow.com/questions/45213279/how-to-avoid-using-relative-path-imports-redux-action-action1-in-cre

@GiladShoham
Copy link
Member

Hi @sonaba
Thanks for reporting this.
We already start working on support NODE_PATH variable, and we will release it in the near future.
I believe this will solve your issue, correct?

Also, it's worth to know, that once you export bit component to a remote scope (or import a component from remote scope), you can require it using an absolute path without the need of anything else like NODE_PATH / webpack resolve and so on.
you can read more about it here:
https://docs.bitsrc.io/docs/importing-components.html#bindings
https://docs.bitsrc.io/docs/importing-components.html#linking-components

Anyway, I'll keep this issue open and updated.

@sonaba
Copy link
Author

sonaba commented Mar 20, 2018

thanks for the quick response. yes NODE_PATH support will be fine.

@James-E-Adams
Copy link

Any luck on the NODE_PATH support? :)

@GiladShoham
Copy link
Member

Yes! We're going to provide an option to configure alias and resolve folders (in a similar way to webpack resolve) in the bit.json file, and we'll use that configuration to correctly detect the dependencies.
You can follow the PR #980 to get updates.
I believe it'll be merged this week.

@James-E-Adams
Copy link

Nice work! Really like what you guys are doing with bit.
לא שמתי לב עד עכשיו שאתם חברה ישראלית! :)

@itaymendel
Copy link
Contributor

a new version of Bit is available and supports this feature.

more details here.

@manufont
Copy link

Thank you @itaymendel
The example in docs only shows how to define aliases for custom module resolution. Could you please show us an example using absolute paths with NODE_PATH ?

@itaymendel
Copy link
Contributor

itaymendel commented Jun 20, 2018

hi @manufont , i'll add a few more details and explanations around it... but basically this is what you want to configure - you need to add an array to of paths called 'modulesdirectories' to the 'resolvemodules' object in the bit.json file. all paths in the array will be used as items to the NODE_PATH env variable bit uses in the component isolated environment.

i understand why the current writeup in the docs may be confusing. an update to the docs will be posted later today.

 "resolveModules": {
        "modulesDirectories": ["src"]
    }

https://docs.bitsrc.io/docs/conf-bit-json.html#resolvemodules--object

@manufont
Copy link

I just figured it out. Thanks 🙂

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

No branches or pull requests

5 participants