Module Resolution Setting being weird?
I got this error when attempting to use
state-in-url:
Error:
tsconfig has moduleResolution set to bundler. Using the TS Spec, if that makes a difference.4 Replies
Hi @Zeke. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Based on the knowledge sources provided, there is no explicit information about the specific error you are encountering with the module resolution setting for TypeScript in Wasp, especially regarding the use of the bundler setting and the state-in-url package.
However, there are some related insights:
- Wasp projects use TypeScript and ES Modules, and there have been issues in the past with module resolution, especially around extensions and compatibility with certain module systems. For example, ESNext modules require explicit file extensions in imports, and TypeScript does not rewrite these extensions during emit, which can cause issues if the expected file is not found or if the module system is not configured correctly. This is a known quirk of the TypeScript/ESM ecosystem, not specific to Wasp itself, and is discussed in the context of import paths and module resolution in Wasp projects. The recommendation is to ensure your imports use the correct extensions and that your tsconfig is aligned with your project's module system requirements. Switching to an older module system like CommonJS is not recommended for Wasp projects, as ES Modules are the standard going forward and are required for features like top-level await and compatibility with Vite and Node.js ESM support Look at extension requirements when importing Jobs.
- There is no mention in the sources of the state-in-url package or its compatibility with Wasp or its default TypeScript configuration.
- The error message you are seeing suggests that TypeScript cannot resolve the module under your current moduleResolution setting, even though the type definitions exist. The message itself suggests trying node16, nodenext, or bundler as possible values for moduleResolution, but there is no information in the sources about which of these is best supported or recommended in Wasp.
In summary, the knowledge sources do not contain enough information to provide a definitive answer or solution to your specific module resolution issue with state-in-url in Wasp. You may need to experiment with the moduleResolution setting or consult the documentation for both Wasp and the state-in-url package for further guidance. If you continue to encounter issues, consider reaching out to the Wasp community for more targeted support.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @Zeke, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:
Perhaps try again in 15mins?
@Filip woud you mind answering this one, I feel like you could better answer all the details regarding
tsconfig.jsonHmm, this is weird because you say you do have bundler
Oh, I see, the error is probably coming from
.wasp/out/sdk/wasp/tsconfig.json
@Zeke there's a comment above the module resolution that explains the problem
I'll paste it here:
The short version is: Wasp SDK cannot have module resolution set to bundler because of our dependency on stitches
We have plans to move away from stitches here: https://github.com/wasp-lang/wasp/issues/1565
I've mentioned this Discord thread in the issue to help prioritize it
Now, how can you solve this error for yourself in the immediate future, let me think
I'm guessing the best bet is somehow patching the state-in-url/react-router to work with moduleResolution: node10
Would that work for you @Zeke?
Thanks for the patience btw, I know this is pretty ridiculousohh alrighty no worries. I'll switch to using
nuqs instead, it seems like it'll work just as well