7a09f88d14
When using pnpm / yarnPnP to install next.js, styled-jsx as dependency is not hoisted in the top level node_modules, it will fail when nodejs is trying to resolve `styled-jsx/style` from project directory. Re-export `styled-jsx/style` in next.js and let swc/babel plugin compile the import path it to `next/dist/shared/lib/styled-jsx` Resolves #10149 Closes #21320 Closes #9325 Co-authored-by: Tim Neutkens <6324199+timneutkens@users.noreply.github.com>
40 lines
1.3 KiB
JavaScript
40 lines
1.3 KiB
JavaScript
import _JSXStyle from "next/dist/shared/lib/styled-jsx";
|
|
export default (({ level =1 })=>{
|
|
const Element = `h${level}`;
|
|
return <Element className={"jsx-fca64cc3f069b519" + " " + "root"}>
|
|
|
|
<p className={"jsx-fca64cc3f069b519"}>dynamic element</p>
|
|
|
|
<_JSXStyle id={"fca64cc3f069b519"}>{".root.jsx-fca64cc3f069b519{background:red}"}</_JSXStyle>
|
|
|
|
</Element>;
|
|
});
|
|
export const TestLowerCase = ({ level =1 })=>{
|
|
const element = `h${level}`;
|
|
return <element className={"jsx-fca64cc3f069b519" + " " + "root"}>
|
|
|
|
<p className={"jsx-fca64cc3f069b519"}>dynamic element</p>
|
|
|
|
<_JSXStyle id={"fca64cc3f069b519"}>{".root.jsx-fca64cc3f069b519{background:red}"}</_JSXStyle>
|
|
|
|
</element>;
|
|
};
|
|
const Element2 = 'div';
|
|
export const Test2 = ()=>{
|
|
return <Element2 className="root">
|
|
|
|
<p className={"jsx-fca64cc3f069b519"}>dynamic element</p>
|
|
|
|
<_JSXStyle id={"fca64cc3f069b519"}>{".root.jsx-fca64cc3f069b519{background:red}"}</_JSXStyle>
|
|
|
|
</Element2>;
|
|
};
|
|
export const Test3 = ({ Component ='div' })=>{
|
|
return <Component className={"jsx-f825b24bbab5b83b"}>
|
|
|
|
<p className={"jsx-f825b24bbab5b83b"}>dynamic element</p>
|
|
|
|
<_JSXStyle id={"f825b24bbab5b83b"}>{".root.jsx-f825b24bbab5b83b{background:red}"}</_JSXStyle>
|
|
|
|
</Component>;
|
|
};
|