Skip to content

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

Open

Description

@odedre

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

  • Bit version: 14.7.4
  • Node version: v10.15.3
  • yarn version: 1.13.0
  • Platform: macos
  • Compiler / Tester (include version): bit.envs/compilers/react-typescript@3.1.43

Activity

  1. l0gicgate commented on Apr 14, 2020

    @l0gicgate
  2. GiladShoham commented on Apr 19, 2020

    @GiladShoham
    Member

    @l0gicgate I think the link is wrong, you probably meant to this one:
    teambit/bit#2306 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

type/bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions