envs icon indicating copy to clipboard operation
envs copied to clipboard

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

Open odedre opened this issue 6 years ago • 2 comments

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/[email protected] 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

  • Bit version: 14.7.4
  • Node version: v10.15.3
  • yarn version: 1.13.0
  • Platform: macos
  • Compiler / Tester (include version): bit.envs/compilers/[email protected]

odedre avatar Feb 10 '20 19:02 odedre

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

l0gicgate avatar Apr 14 '20 20:04 l0gicgate

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

GiladShoham avatar Apr 19 '20 07:04 GiladShoham