Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

React Email import works not correctly with Storybook #1737

Open
donni911 opened this issue Oct 17, 2024 · 4 comments
Open

React Email import works not correctly with Storybook #1737

donni911 opened this issue Oct 17, 2024 · 4 comments
Labels
Resolution: Needs More Information More information is needed on this issue Type: Bug Confirmed bug

Comments

@donni911
Copy link

Describe the Bug

I want to create a Storybook with react-email components, but I have an issue.

When I import like:
import { Text } from "@react-email/components"
I receive this Error
SyntaxError: Unexpected string (at @react-email_components.js?v=25ba9bd9:48627:14)
image

When I import like:
import { Text } from "@react-email/text"
All works correctly
image

Used packages:
"@react-email/components": "0.0.25",
"@react-email/render": "1.0.1",
"storybook": "^8.3.5",

Which package is affected (leave empty if unsure)

No response

Link to the code that reproduces this issue

private

To Reproduce

  1. Create a simple component with import any component from @react-email/components.
  2. Create storybook file.
  3. Run a storybook.

Storybook file

import type { Meta, StoryObj } from "@storybook/react";
import { Tag } from "..";

const meta: Meta<typeof Tag> = {
  title: "Components/Tag",
};

export default meta;

type Story = StoryObj<typeof Tag>;

export const DefaultTag: Story = {
  render: () => <Tag>Test Tag</Tag>,
};

Tag file

import { Text } from "@react-email/components";
import React, { ReactNode } from "react";

type Props = {
  children: ReactNode;
  type: TagType;
};

export function Tag({ children, type }: Props) {
  return (
    <Text>
      {children}
    </Text>
  );
}

Expected Behavior

SyntaxError: Unexpected string (at @react-email_components.js?v=25ba9bd9:48627:14)
image

What's your node version? (if relevant)

v20.11.0

@donni911 donni911 added the Type: Bug Confirmed bug label Oct 17, 2024
@jasongoetz
Copy link

@donni911 Thank you for logging this. I'm having the same issue, although I didn't know about your workaround.

@gabrielmfern
Copy link
Collaborator

Can you share the code for this? Try making a minimal project that has the issue you mentioned.

This might also be something on your side, rather than in ours, most likely.

@donni911
Copy link
Author

Can you share the code for this? Try making a minimal project that has the issue you mentioned.

This might also be something on your side, rather than in ours, most likely.

Sorry, I can't share the repository because it's private.
I can show you the components and storybook.
Or you can try to create workspace using code I described above.

@gabrielmfern
Copy link
Collaborator

gabrielmfern commented Nov 15, 2024

@donni911 You don't need to share your private code, you can create a new project with the least amount of code possible that has the same error and then share it here. I won't be able to fix it properly otherwise.

@gabrielmfern gabrielmfern added the Resolution: Needs More Information More information is needed on this issue label Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: Needs More Information More information is needed on this issue Type: Bug Confirmed bug
Projects
None yet
Development

No branches or pull requests

3 participants