Bit: required dependency is ignored

Created on 5 Jun 2019  路  3Comments  路  Source: teambit/bit

In our private component profab.lib.attention, a tracked file, which is also required by the main entry file, has this at the first line:

const { WebClient } = require(`@slack/client`)

Other dependencies are properly resolved, but this one seems to be ignored entirely. Bit does not list it as a dependency of the component and so of course, it is not installed when npm installing the component.

I am not sure how to reproduce it. It may be as simple as using any scoped package as a dependency. I may be able to investigate tomorrow.

Specifications

  • Bit version: 14.1.2
  • Node version: 10.16.0
  • npm / yarn version: 6.9.0
  • Platform: Ubuntu 18.04

Most helpful comment

With the fix above, the require works also with apostrophes.

All 3 comments

It seems that Bit does not track scoped packages correctly.

There is a workaround using overrides, so you can add the dependency to the component.

mkdir test-scoped && cd test-scoped
npm init -y && bit init
npm i @slack/client --save
touch slack.js
echo 'const { WebClient } = require(`@slack/client`);' > slack.js
bit add slack.js
bit show slack

See that @slack/client is not listed as a dependency. This can be resolved using overrides. But Bit should detect it.

@m59peacemaker , there is a bug there but it's not about scoped packages, it's about the apostrophe you used with the require statement. Replacing it with a single or double quotes fixes the issue.

In other words:

- const { WebClient } = require(`@slack/client`)
+ const { WebClient } = require('@slack/client')

I'm leaving this task open to fix the issue with the apostrophe.

With the fix above, the require works also with apostrophes.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ranm8 picture ranm8  路  16Comments

nsams picture nsams  路  12Comments

JoshK2 picture JoshK2  路  12Comments

jimmi-joensson picture jimmi-joensson  路  14Comments

iboldurev picture iboldurev  路  12Comments