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

"Module not found" errors on next.js #24

Closed
qcho opened this issue Oct 13, 2023 · 3 comments
Closed

"Module not found" errors on next.js #24

qcho opened this issue Oct 13, 2023 · 3 comments

Comments

@qcho
Copy link

qcho commented Oct 13, 2023

I had to downgrade to 0.11.0 because the library was asking me to install all the peer dependencies.

Tried with pnpm and npm. Same error.

./node_modules/.pnpm/@decs+typeschema@0.11.7_valibot@0.17.0/node_modules/@decs/typeschema/dist/deepkit-KEFZXADV.mjs:2:0
Module not found: Can't resolve '@deepkit/type'

https://nextjs.org/docs/messages/module-not-found

Import trace for requested module:
./node_modules/.pnpm/@decs+typeschema@0.11.7_valibot@0.17.0/node_modules/@decs/typeschema/dist/index.mjs
./src/server/routers/auth/login.ts
./src/server/routers/auth.ts
./src/server/index.ts
./src/app/api/trpc/[trpc]/route.ts

It seems there is an error where the _valibot variant is calling for the other deps.

@qcho qcho changed the title v0.12 is broken Versions after v0.11.0 are broken Oct 13, 2023
@decs decs changed the title Versions after v0.11.0 are broken "Module not found" errors on next.js Oct 13, 2023
@decs
Copy link
Owner

decs commented Oct 13, 2023

thanks for the flag! indeed I was able to repro when using typeschema on next.js. downgrading didn't work either, so I'll need to look into how next.js handles dynamic imports and optional peer dependencies. likely, we'll need a fix similar to how I've done on Vite a couple weeks ago: vitejs/vite#14489. I'll prioritize unblocking this

decs added a commit that referenced this issue Oct 13, 2023
@decs
Copy link
Owner

decs commented Oct 13, 2023

found the root cause! it was due to webpack, the bundle used by Next.js. we're now using webpackIgnore on the external imports to mark them as external (8fa8b33) and I also added a check in our CI to avoid future regressions

the fix is out on v0.12.1. thanks a lot for reporting!

@decs decs closed this as completed Oct 13, 2023
@qcho
Copy link
Author

qcho commented Oct 15, 2023

Great work! Thanks @decs ^_^

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