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

[@mantine/core] <Title> renders <element> with vite build #366

Closed
hauptrolle opened this issue Nov 1, 2021 · 4 comments
Closed

[@mantine/core] <Title> renders <element> with vite build #366

hauptrolle opened this issue Nov 1, 2021 · 4 comments

Comments

@hauptrolle
Copy link

Hello Guys,

first of all, thank your for this awesome library 👏

I have found an issue with the <Title> component from @mantine/core when using it together with Vite.

In the development mode everything works fine, but after building the app the Title components gets rendered as <element> instead of h1. You can find an example repo here

@rtivital
Copy link
Member

rtivital commented Nov 1, 2021

Hi @hauptrolle, here is our output esm code for Title component:

const Title = forwardRef((_a, ref) => {
  var _b = _a, { className, order = 1, children, align, style, sx } = _b, others = __objRest(_b, ["className", "order", "children", "align", "style", "sx"]);
  if (![1, 2, 3, 4, 5, 6].includes(order)) {
    return null;
  }
  const element = `h${order}`;
  const { classes, cx } = useStyles({ element }, { sx, name: "Title" });
  const styles = __spreadValues({}, style);
  if (align) {
    styles.textAlign = align;
  }
  const { mergedStyles, rest } = useExtractedMargins({ others, style: styles });
  return React.createElement(element, __spreadValues({
    className: cx(classes.root, className),
    style: mergedStyles,
    ref
  }, rest), children);
});

It looks correct to me – we do not use element as a string here. I do not think that there is something that we can do on our side to fix it as it seems to be a bug in Vite bundler.

@rtivital
Copy link
Member

rtivital commented Nov 1, 2021

I think this issue contains details – vitejs/vite#5441

@rtivital
Copy link
Member

rtivital commented Nov 1, 2021

Alright, I've released a patch that fixes this issue, update to 3.1.2 and Title will render correct element.

@rtivital rtivital closed this as completed Nov 1, 2021
@hauptrolle
Copy link
Author

Wow! Thank you so much for your fast response!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants