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

Feedback: using _app.mdx vs _app.tsx is weird and more error prone #1632

Closed
transitive-bullshit opened this issue Mar 13, 2023 · 7 comments
Closed
Milestone

Comments

@transitive-bullshit
Copy link

I got my use case working with _app.tsx, but after #1448, the guidance and console logs tell you to use _app.mdx.

This feels really weird to me as an end user. I tried using _app.mdx and kept running into weird transpilation issues, and all existing docs and examples from the greater Next.js ecosystem use _app.tsx.

For context, I'm not using mdx at all for https://sklearn.vercel.app (solely md).

My recommendation would be to find a way to have _app.tsx / _document.tsx be the default methods for injecting custom JS/TS.

@dimaMachina
Copy link
Collaborator

Please provide your reproduction of weird behavior with _app.mdx

@transitive-bullshit
Copy link
Author

This is not a bug report; rather just general feedback.

As for a repro:

git clone git@github.com:transitive-bullshit/scikit-learn-ts.git
cd scikit-learn-ts
git checkout d3adcf4bccd8010d4edae6e7bc487d545f7c46ff # current HEAD
pnpm i
cd docs
pnpm build # builds fine with pages/_app.tsx
mv pages/_app.tsx pages/_app.mdx
pnpm build # obfuscated error with the mdx version

CleanShot 2023-03-13 at 12 26 18@2x

@dimaMachina
Copy link
Collaborator

dimaMachina commented Mar 13, 2023

You can't just declare variables (you must to use export /export default with declaration) in mdx files, take a look of a working example of how you need to export your App https://github.com/shuding/nextra/blob/main/docs/pages/_app.mdx

@transitive-bullshit
Copy link
Author

transitive-bullshit commented Mar 13, 2023

Thanks @B2o5T. Removing the TS types from the mdx file makes the build work.

My original feedback still stands, however. I'd greatly prefer to use _app.tsx / _document.tsx for editor support / familiarity / tooling / existing code / typescript support / copying code from examples / etc.

Really appreciate the quick response btw – thanks for all your hard work! 🙏 💕

@dimaMachina
Copy link
Collaborator

We'll try to improve it in Nextra 3

@dimaMachina dimaMachina mentioned this issue Mar 13, 2023
20 tasks
@transitive-bullshit
Copy link
Author

Thanks @B2o5T 🙏

@prisis
Copy link
Contributor

prisis commented May 17, 2023

One more point to allow _app.tsx would be for example https://github.com/dequelabs/axe-core with the current _app.mdx, i can not use it.

Repository owner locked as spam and limited conversation to collaborators May 17, 2023
@dimaMachina dimaMachina added this to the 3.0 milestone Sep 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants