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

Not possible to import a React client component in Next.JS via esm.sh #804

Open
OrangeTimes opened this issue Feb 29, 2024 · 0 comments
Open

Comments

@OrangeTimes
Copy link

Considering I publish the next React client component to private registry and use locally hosted esm.sh

'use client'
import React, { useState } from 'react';
import AllComponents from './src/components/AllComponents';

const Page: React.FC = (props: any) => {
const [counter, setCounter] = useState(0)
return (


<button onClick={() => setCounter(state=> state + 1)}>{counter}
);
}
export default Page;

When using esm.sh there is no way to specify 'use client' in the top of the module declaration to correctly render them in a SSR framework like Next.js (because it tries to render as a server component)

My top-level declaration looks like this in esm.sh
/* esm.sh - esbuild bundle(avatar-page@1.0.26) es2022 production */
import si,{useState as ii}from"/stable/react@18.2.0/es2022/react.mjs";var Zs={exports:{}},i={};var n;function ri(){if(n)return i;n=1;var

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

1 participant