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

Improve Deno Fresh Documentation with Deno Workspace Examples #2740

Open
akshit-vadodariya-st8 opened this issue Oct 29, 2024 · 3 comments
Open

Comments

@akshit-vadodariya-st8
Copy link

Description:

The current Deno Fresh documentation is a great starting point, but additional guidance on integrating Deno workspaces into Fresh projects would be beneficial. Many developers are facing challenges when trying to manage dependencies and organize code within their Fresh applications using workspaces.

Specific Suggestions:

  1. Dedicated Workspace Guide:

    • A comprehensive guide explaining the benefits of using workspaces with Fresh.
    • Step-by-step instructions on setting up a workspace in a Fresh project.
    • Clear examples demonstrating how to organize code, manage dependencies, and share code between islands and the main app.
  2. Expanded API Reference:

    • More detailed explanations of how Fresh components interact with workspaces.
    • Specific examples illustrating how to import and use modules from workspace members within islands and routes.
  3. Real-world Example Projects:

    • Open-source examples showcasing well-structured Fresh projects using workspaces.
    • Examples demonstrating best practices for organizing code, managing dependencies, and testing within a workspace.

Benefits:

  • Improved Developer Experience: Clear and concise documentation will help developers quickly understand and adopt workspaces in their Fresh projects.
  • Enhanced Project Organization: Workspaces provide a structured way to manage code, making projects more maintainable and scalable.
  • Simplified Dependency Management: Workspaces streamline dependency management, reducing potential conflicts and improving build times.
  • Increased Community Adoption: By addressing a common pain point, this improvement will encourage more developers to use Deno Fresh and contribute to its ecosystem.

I'm eager to contribute to the documentation by providing code examples, writing tutorials, or reviewing pull requests.

Context

@marvinhagemeister
Copy link
Collaborator

I'm eager to contribute to the documentation by providing code examples, writing tutorials, or reviewing pull requests.

Go for it 👍

@wderezin
Copy link

Steps to get fresh working as a sub - workspace. For example, if fresh was installed in frontend/:

  1. Move the following configuration from the fresh frontend/deno.json to the project root deno.json workspace:
  • imports
  • compilerOptions
  • nodeModulesDir and change from true to "auto"
  1. Add the following:
import * as React from "preact/compat";

To the following files

  • frontend/islands/Counter.tsx
  • frontend/components/Button.tsx

@shanipribadi
Copy link

shanipribadi commented Nov 2, 2024

I managed to get fresh 2.0-alpha working with workspace as well,
with slight differences from @wderezin suggestions

  1. imports => only need the preact import to be on root deno.json (I'm assuming because of the preact compilerOptions
  2. compilerOptions => moved to root deno.json
  3. nodeModulesDir => "none". using "auto" works only if I symlink the root node_modules dir to the subdirectory
  4. preact/compat import is not needed

example repo here: https://github.com/shanipribadi/spikefresh
the web repo is generated using `deno run -Ar jsr:@fresh/[email protected]

the store package has drizzle orm implementation that works as well in a workspace and is imported from the fresh package, although with a bit of a hack for the tests (drizzle-kit/api didn't work, so I had to write a Deno.Command wrapper to execute drizzle-kit cli for migration during tests). also had to use npm:dotenv for drizzle.config.ts, but on the main app/lib I can use @std/env instead.

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

4 participants