Help me understand imports #3090
mfcochauxlaberge
started this conversation in
Help Wanted
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm new to Nitro and the whole unjs ecosystem. If find it interesting enough to want to dig a little, understand how it works, write solid code with it, and maybe one day even contribute.
Lately I've had a hard time with auto imports. They worked out of the box and I was able to follow the guide and make a small app. But once I went deeper, I felt like I hit a brick wall.
See, there's no documentation at all for testing and a lot of the auto import magic isn't explained and hard to disable. From what I found online I should just build my app and run it on some random port. That would be fine for e2e tests, but I want to make small and fast little tests for each individual endpoints. I made so progress in that direction, but:
middleware
directory to build the app programmatically. Maybe there's a better way for works good enough for me.The issue I have is imports. Even when auto imports disabled, I cannot simply run a test because for some reason the test environment isn't configured with all the magic.
In general, it's hard to see how imports are managed. I guess it's all done by
unimport
? I wonder whyendpoint.ts
works butendpoint.test.ts
(which importsendpoint.ts
) fails miserably and complains about undefined functions inendpoint.ts
.By better understanding the setup, I want to fix the test environment myself, then share my story and help improve Nitro.
Right now with auto imports disabled, and the error I get is that the
#nitro-internal-virtual/storage
module cannot be found. But that module is mentioned deep down innitropack
. Why would the output ofnitropack
still use that magic?My question is: how can I understand imports? Can someone point me in the right direction?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions