nextra icon indicating copy to clipboard operation
nextra copied to clipboard

make `nextra-theme-docs` ESM compatible

Open dimaMachina opened this issue 3 years ago • 6 comments

currently it has ESM issues, we use a patch to make it works 😅

https://github.com/dotansimha/graphql-yoga/blob/48794374dfd4a0f9b0544ab092194055dbc7ca6d/patches/nextra-theme-docs%2B2.0.0-beta.29.patch

dimaMachina avatar Sep 19 '22 16:09 dimaMachina

🦋 Changeset detected

Latest commit: 5221229ebe735140a516a31de05749761b1ae0f0

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

changeset-bot[bot] avatar Sep 19 '22 16:09 changeset-bot[bot]

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
nextra-theme-docs-dev ✅ Ready (Inspect) Visit Preview Sep 19, 2022 at 4:16PM (UTC)
1 Ignored Deployment
Name Status Preview Updated
nextra ⬜️ Ignored (Inspect) Sep 19, 2022 at 4:16PM (UTC)

vercel[bot] avatar Sep 19 '22 16:09 vercel[bot]

@shuding needs your help, these changes fix ESM issues but in examples/swr-site in dev and prod there are some hydration problems

@promer94 maybe you have some thoughts also?

dev

image

prod

image

I tried a lot of things but nothing helps, but in an applied patch on our website (graphql-yoga) there are no one hydration problems, I guess it goes from pnpm and its dependenciesMeta

image

dimaMachina avatar Sep 19 '22 21:09 dimaMachina

Could you explain more about what is ESM issues. It would be batter if we could know more about the original problem

Current changes seems to make it harder for user to create their own theme.
import head from 'next/head.js' is really wired syntax. normally you dont need to add file extension for bare specifiers https://nodejs.org/api/esm.html#mandatory-file-extensions

Also, does the blog-themes have the same ESM issues ?

promer94 avatar Sep 20 '22 06:09 promer94

@promer94

both nextra-theme-docs and nextra-theme-blog are ESM packages but they misses "type": "module" in their package.json's

if you add "type": "module" in swr example and nextra-theme-docs, your app will be no longer works due misses .js extension in next/head, next/router and next/link

image

dimaMachina avatar Sep 20 '22 09:09 dimaMachina

I have two problems.

Although nextra-theme-docs itself is esm, it depends on next which is not esm. should we add "type": "modules" in this case ?

swr example is a applicatioon, is it necessary to add "type": "modules" for applications ?

promer94 avatar Sep 21 '22 12:09 promer94

swr example is a applicatioon, is it necessary to add "type": "modules" for applications ?

It up to you specify or not, both are fine with/without

Although nextra-theme-docs itself is esm, it depends on next which is not esm. should we add "type": "modules" in this case ?

The problem was on our side, our package with components reexport all things from nextra-theme-docs but we also specified type: module in our package.json after removing it all things works without errors

dimaMachina avatar Sep 23 '22 01:09 dimaMachina