teambit / envs

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

Missing default export from dists #150

Open KutnerUri opened 4 years ago

KutnerUri commented 4 years ago

I noticed my component failing render in the bit.dev playground.

Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.

Investigating a little further, I found that the default export was missing (undefined). It only happens when using the package directly through node_modules, as it keeps working in my local project, and also as relative-link dependencies in other components.

As a workaround, I changed the default export to be a named export, which solved the problem.

Steps to Reproduce

This version of the component still have the problem: bit.evangelist/marketing/comment-carousel@1.1.0

  1. create a new react-app
  2. yarn add @bit/bit.evangelist.marketing.comment-carousel@1.1.0 @bit/bit.evangelist.content.bit-testimonials node-sass
  3. Consume the package at app.tsx:
import React from 'react';
import { bitTestimonials } from '@bit/bit.evangelist.content.bit-testimonials';
import CommentCarousel from '@bit/bit.evangelist.marketing.comment-carousel';

export default function App() {
  return <CommentCarousel content={bitTestimonials} />;
}

--> runtime error: JSX element type 'CommentCarousel' does not have any construct or call signatures.

Expected Behavior

A clear and concise description of what you expected to happen.

Screenshots, exceptions and logs

If applicable, add screenshots, exceptions, and logs to help explain your problem.

Specifications

Additional context

Add any other context about the problem here.