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

bit doesn't recognize dependencies in self reference use case #1779

Closed
qballer opened this issue Jul 3, 2019 · 6 comments
Closed

bit doesn't recognize dependencies in self reference use case #1779

qballer opened this issue Jul 3, 2019 · 6 comments

Comments

@qballer
Copy link
Contributor

qballer commented Jul 3, 2019

Describe the bug

When using ngx-bootstrap and adding accordion bit doesn't recognize dependencies when resolveModules properties is defined.

Steps to Reproduce

  1. clone ngx-bootstrap
  2. npm i && npm run build
  3. define an alias for ngx-bootstrap to src
  4. bit add src/accordion
  5. bit status
  6. notice accordion doesn't have dependencies.
  "bit": {
    "env": {},
    "componentsDefaultDirectory": "components/{name}",
    "packageManager": "npm",
    "resolveModules": {
      "aliases": {
        "ngx-bootstrap": "src"
      }
    }
  }

Specifications

bit version : 14.1.4-dev.6
node version : v12.3.1
npm version : 6.9.0
yarn version : 1.16.0
platform : linux

@davidfirst
Copy link
Member

davidfirst commented Jul 11, 2019

Here is the thing, when running npm run build, you get actually the package into node_modules/ngx-bootstrap.
So, when Bit resolves the dependencies, it doesn't use the custom-resolve, it handles it as a regular package. In fact, if you run bit show accordion, you'll see the package ngx-bootstrap@5.1.1 listed as a dependency.
On the other hand, when npm run build wasn't running, the node_modules/ngx-bootstrap is missing, and then bit uses the custom-resolve logic.

@qballer , in other words, this is working as expected, I'm closing it. Please re-open if you think otherwise.

@qballer
Copy link
Contributor Author

qballer commented Jul 14, 2019

I still think this is an issue. lets discuss this off-github and summarize.

@itaymendel
Copy link
Contributor

itaymendel commented Jul 14, 2019

@davidfirst @GiladShoham perhaps Bit should prefer resolving dependencies using resolveModules when available, instead of resolving via node_modules?

I agree with @qballer that we should tackle this issue. As it creates an inconsistent behavior. In this case, if I run npm build before bit status, Bit resolves dependencies differently.

@GiladShoham
Copy link
Member

@qballer @itaymendel I agree.
We should resolve from our configuration before we resolve from node_modules FS content.
@davidfirst Let's change the strategy a bit.

@davidfirst
Copy link
Member

Implemented according to the suggestions above.

@davidfirst
Copy link
Member

I just came across a case (A Gitter user) when you have both, the custom-resolve path and the node-modules path and you actually prefer the node-modules.
Project 1: I created a component foo with an alias: "src": "@ui".
Project 2: I imported foo and I got the generated @ui dir inside the node_modules of the component.
In the same project, I created another component where I need the exact same alias: "src": "@ui".

I end up with the alias configured in my workspace and the path set in my node-modules as a result of importing the component.
In this case, because it ignored the node_modules and used the alias, bit status showed an error about untrack dist file.
(The user was able to recover the error because the alias was not actually needed. However, in the future, we might find the exact same issue when the alias is needed.)

cc: @GiladShoham .

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

4 participants