Skip to content

Extract and validate Next.js build configuration in apps/dashboard #341

Description

@Lakes41

Background

The apps/dashboard Next.js app fails with multiple module resolution errors during the build step:

Module not found: Can't resolve './schemas/dashboard.js'

These errors point to issues upstream in packages/env, but also suggest that apps/dashboard's Next.js configuration may not be optimally handling monorepo imports or TypeScript paths.

Problem

  1. Unclear path resolution: apps/dashboard may not have jsconfig.json or tsconfig.json properly configured for monorepo imports
  2. No path aliases: Hardcoded relative imports (../../packages/env) are error-prone
  3. TypeScript/Next.js mismatch: Next.js may not be respecting the workspace tsconfig.base.json or custom paths
  4. No documentation: It's unclear how the dashboard is intended to import from packages

Expected Outcome

  • apps/dashboard/tsconfig.json properly configured for Next.js 14 and monorepo structure
  • Path aliases (e.g., @guildpass/*) defined for clean imports
  • Clear import strategy documented
  • Dashboard builds successfully and imports all required packages

Suggested Implementation

  1. Review and update apps/dashboard/tsconfig.json:

    {
      "extends": "../../tsconfig.base.json",
      "compilerOptions": {
        "lib": [
          "dom",
          "dom.iterable",
          "esnext"
        ],
        "jsx": "preserve",
        "incremental": true,
        "paths": {
          "@guildpass/*": [
            "../../packages/*"
          ]
        }
      },
      "include": [
        "next-env.d.ts",
        "**/*.ts",
        "**/*.tsx"
      ],
      "exclude": [
        "node_modules"
      ]
    }
  2. Update imports in apps/dashboard/ to use path aliases:

    // Before
    import { validateEnv } from '../../packages/env/dist/index';
    
    // After
    import { validateEnv } from '@guildpass/env';
  3. Verify apps/dashboard/package.json includes proper Next.js dependencies (next, react, react-dom at appropriate versions)

  4. Add apps/dashboard/.env.local (if needed) with any required environment variables

  5. Update Next.js build configuration in apps/dashboard/next.config.js if needed:

    /** @type {import('next').NextConfig} */
    const nextConfig = {
      transpilePackages: ['@guildpass/env', '@guildpass/integration-client'],
    };
    module.exports = nextConfig;

    This ensures monorepo packages are transpiled by Next.js.

  6. Test build:

    pnpm build -r --filter apps/dashboard
  7. Document in apps/dashboard/README.md:

    ## Setup
    
    ### Path Aliases
    The dashboard uses path aliases for clean imports:
    - `@guildpass/env``../../packages/env`
    - `@guildpass/integration-client``../../packages/integration-client`
    
    ### Building
    The build process:
    1. Builds all upstream packages (`packages/env`, etc.)
    2. Transpiles monorepo packages via Next.js
    3. Outputs to `.next/`

Acceptance Criteria

  • apps/dashboard/tsconfig.json extends tsconfig.base.json and defines path aliases
  • next.config.js includes transpilePackages for monorepo packages
  • All imports of @guildpass/* in the dashboard use path aliases (no relative imports)
  • pnpm build -r --filter apps/dashboard succeeds
  • No "Module not found" errors for package imports
  • Types from imported packages are properly resolved
  • Dashboard README documents path aliases and build process

Affected Files/Directories

  • apps/dashboard/tsconfig.json
  • apps/dashboard/next.config.js
  • apps/dashboard/package.json (verify dependencies)
  • apps/dashboard/app/**/*.tsx (update imports to use aliases)
  • apps/dashboard/README.md (document)

Metadata

Metadata

Labels

Third CampaignOfficial FWC26 campaign issue — eligible for campaign scoring and rewardsadvancedAdvanced difficulty tasks requiring significant domain knowledge and implementation effortbuildUser interface or user experience improvements and design worktype-safetyTypeScript type system improvements and strict type enforcement

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions