teambit / envs

Component development environments for the Bit community
https://bit.dev/bit/envs
Other
63 stars 9 forks source link

react-typescript compiler doesn't recognize @bit imports in the author env #89

Open odedre opened 4 years ago

odedre commented 4 years ago

Describe the bug

I have a button component and I want to add a story file to it. I created a button.story.tsx file with the following code:

import React from 'react';
import {CtaButton} from '@bit/bit.marketing.concrete.cta-button';
import {Theme} from  '@bit/bit.marketing.theme.theme-provider';

export const withTheme = () => (
    <Theme>
            <CtaButton>Cta button</CtaButton>
    </Theme>
);

and added it to my existing button component. when I run bit build, I get the following exception:

⡋⠁ isolating component - concrete/cta-buttonconcrete/cta-button/cta-button.story.tsx:2:25 - error TS2307: Cannot find module '@bit/bit.marketing.concrete.cta-button'.

2 import {CtaButton} from '@bit/bit.marketing.concrete.cta-button';
                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Found 1 error.

error: bit failed to build bit.marketing/concrete/cta-button@0.0.4 with the following exception:
Command failed with exit code 2 (ENOENT): /Users/oded/code/base-components/.git/bit/components/compilers/react-typescript/bit.envs/3.1.43/components/.dependencies/compilers/typescript/bit.envs/3.1.38/node_modules/typescript/bin/tsc --declaration
Error: Command failed with exit code 2 (ENOENT): /Users/oded/code/base-components/.git/bit/components/compilers/react-typescript/bit.envs/3.1.43/components/.dependencies/compilers/typescript/bit.envs/3.1.38/node_modules/typescript/bin/tsc --declaration
    at makeError (/Users/oded/code/base-components/.git/bit/components/compilers/react-typescript/bit.envs/3.1.43/components/.dependencies/compilers/typescript/bit.envs/3.1.38/node_modules/execa/lib/error.js:59:11)
    at handlePromise (/Users/oded/code/base-components/.git/bit/components/compilers/react-typescript/bit.envs/3.1.43/components/.dependencies/compilers/typescript/bit.envs/3.1.38/node_modules/execa/index.js:112:26)
    at process._tickCallback (internal/process/next_tick.js:68:7)

I tried to run bit link and it ran without errors, but it didnt help when I tried to build again.

the required @bit links in the node_modules are present and link back to the source code as expected. It seems like the compiler does not recognize the component in my workspace.

Steps to Reproduce

  1. create 2 components. a and b.
  2. make a dependent on b with a relative import.
  3. export both of them to a bit.dev scope.
  4. change the require in a to use the bit id in bit.dev (@bit)
  5. run bit build

Expected Behavior

the compiler should recognize that both components are in my workspace when I import them using a bit id

Specifications

l0gicgate commented 4 years ago

I believe this is also related to: https://github.com/teambit/envs/issues/2306

GiladShoham commented 4 years ago

@l0gicgate I think the link is wrong, you probably meant to this one: https://github.com/teambit/bit/issues/2306 ?