Carere
Carere13mo ago

Pretty new to Deno, what is the recommended way to create a monorepo-like in Deno ?

Everything is in the question. I tried during the entire week-end to get up & running with monorepo-like setup in Deno. My NodeJS monorepo was pretty simplistic: - app ---- 3 projects inside (front, server, and cli) - packages ---- 1 project inside which is used by all 3 mentioned above I don't have any problem with Deno runtime project (eg. CLI, server, etc), Deno delivers perfectly (it's a real pleasure to work with it on those type of project). The real pain reside in FrontEnd with ViteJS. It seems that ViteJs project need to be in it's own root folder, it cannot be a sub-folder. Also, I would like to keep my NX configuration since it does rely on package.json (really helpful in order to avoid building project if nothing has change in it) So my question is, do I waste time trying to use my former knowledge of monorepo ? Do I need to switch my way of thinking (as I did by not using package.json and node_modules) ? Is there somewhere some resource explaining how to proceed to achieve what I'm trying to do ? PS: Please, try to answer with elaborate responses, don't want to be bash for asking questions as a newbie on a new tech 😅
15 Replies
Deno AI Helper
Deno AI Helper13mo ago
Welcome to the Deno community! 🦕 It's great to hear that you're enjoying working with Deno. Regarding your question about creating a monorepo-like setup in Deno, the documentation doesn't provide a specific guide or recommendation for this. However, I can share some general advice based on the information available in the documentation. Firstly, Deno does not use a node_modules directory or a package.json file by default. Instead, it uses URLs as module specifiers and caches modules globally on your system. This is a significant departure from Node.js and it might require a shift in your thinking when it comes to organizing your projects. However, Deno does support the use of a package.json file for resolving dependencies, as mentioned in the documentation. This could potentially be useful if you want to maintain some aspects of your existing Node.js monorepo setup, such as scripts and dependencies. As for ViteJS, the documentation provides a guide on how to use Vite to scaffold a Vue or React app with Deno. It does mention that the Vite project needs to be in its own root folder, which seems to align with your experience. If you want to keep your NX configuration, you might need to consider how to integrate it with Deno's way of handling modules and dependencies. The documentation doesn't provide specific advice on this, but you could potentially use import maps to manage your dependencies across different projects in your monorepo. In conclusion, while it's possible to create a monorepo-like setup in Deno, it might require some adjustments to your existing setup and practices. It's also worth noting that Deno is still a relatively new platform and some features and best practices are still being developed. I hope this helps! If you have any more
Carere
Carere13mo ago
For those looking for more info about this subject, I ended up using this methodology: https://github.com/neolace-dev/neolace It's a great example how to have a monorepo-like experience with Deno. For the Front-End, you have to stick to Node, but since you're using ViteJs, it's not really a problem. You get the best of both world. Great DX overall, ViteJs for the front end, and deno for server & CLI 😄 Don't hesitate if you have some questions 🙂
GitHub
GitHub - neolace-dev/neolace: The next-generation knowledge graph p...
The next-generation knowledge graph platform. Contribute to neolace-dev/neolace development by creating an account on GitHub.
parkernilson
parkernilson4mo ago
Could you explain the gist of how the monorepo works in this example?
marvinh.
marvinh.4mo ago
FYI: the next version of Deno will ship with official support for workspaces
Necmttn | Craftgen.ai
is there a WIP PR I can subscribe to?
marvinh.
marvinh.4mo ago
The PRs for this have already been merged into main
parkernilson
parkernilson4mo ago
This may be the change that makes me convert to Deno forever ❤️
Necmttn | Craftgen.ai
Oh just saw bunch of workspace feature released with version 1.45 any documentation to get start with it ?
marvinh.
marvinh.4mo ago
we're working on the official release blog post + docs at the moment. The short summary: There is a new workspace key in deno.json where you can add workspace members:
{
"workspace": ["./member-a", "./member-b"]
}
{
"workspace": ["./member-a", "./member-b"]
}
Each workspace member must have its own deno.json config file for node projects, we'll support npm workspaces out of the box too
Necmttn | Craftgen.ai
hmm how is the imports are looks like ?
marvinh.
marvinh.4mo ago
refer to other workspace members in imports the same way you'd do today without workspace support. Deno will detect that it's a workspace member and import it from there
Mark G
Mark G4mo ago
does this mean the LSP will support workspaces too?
marvinh.
marvinh.4mo ago
yes