Bit: Vuejs relative path starting with @/ considered as packages

Created on 21 Mar 2018  路  8Comments  路  Source: teambit/bit

Expected Behavior

Imports other vue components or any other relative files when running bit add ... when the imports are structured as follow:

  import SimpleHeader from '@/components/base/SimpleHeader'
  import Login from '@/components/authentication/Login'
  import UserProfile from '@/components/authentication/UserProfile'
  import { HTTP, sureThing } from '@/helpers/http'

@/ stands for src or root kind of like in unix cd ~ it just replaces ../../../helpers and if you move files around the imports are not broken

Actual Behavior

bit wants to resolve @/components as a node package and not as a relative path.

     > authentication/auth-app ...  missing dependencies
       missing packages dependencies (use your package manager to make sure all package dependencies are installed):
          src/components/authentication/AuthApp.vue -> @/components, @/components, @/components

Steps to Reproduce the Problem

  1. clone https://github.com/EuropeanRespiratorySociety/search
  2. (probably npm install) bit init and add components
  3. bit status you should see the above message

Specifications

  • Bit version: 0.12.10
  • Node version: 8.4.0
  • npm / yarn version: npm 5.7.1
  • Platform: OsX
  • Bit compiler (include version): none
  • Bit tester (include version): none
aredependencies typfeature

Most helpful comment

hi @idealley , a new version of Bit is finally available, and supports configuring a custom module resolution.

more about it here

All 8 comments

@idealley Thanks for reporting this.

We are still in the process of finding a solution for absolute paths in require statements.
In general, there is 2 concern regarding this:

  1. Identify the dependencies for the component
  2. Make sure the component works for someone else import the component (since he might not have the same configuration as the author), so we need to resolve the require on his environment somehow.

We are trying to find a good solution which will know to handle all the cases like the described here and in the following issues:
https://github.com/teambit/bit/issues/865
https://github.com/teambit/bit/issues/852

I see! Thank you. I really look forward to it as this is for me the only blocking things to go ahead with Bit.

Did you find any solution?

Yes! We're going to provide an option to configure the alias ("@" in this case) in the bit.json file, and we'll use that configuration to correctly detect the dependencies.
You can follow the PR https://github.com/teambit/bit/pull/980 to get updates.
I believe it'll be merged this week.

Yeah!!! thank you.

Just to keep this post up to date, the feature is merged into master, and some e2e tests were added to make sure Vue files are supported.
It'll be part of the next release, very soon.

hi @idealley , a new version of Bit is finally available, and supports configuring a custom module resolution.

more about it here

Thank you guys. Impressive work. I will try that in details.

Was this page helpful?
0 / 5 - 0 ratings