Skip to content

examples project fails without pre-building workspace packages #358

@guesung

Description

@guesung

Problem

examples:vite fails without pre-building workspace packages.

@react-simplikit/mobile's exports in package.json points to ./dist/index.js, which doesn't exist until the package is built.

[commonjs--resolver] Failed to resolve entry for package "@react-simplikit/mobile".
The package may have incorrect main/module/exports specified in its package.json.

Both Vite and Next.js resolve exports strictly and require the built output to exist.

Possible Solutions

  1. Root scripts with pre-build — e.g. "example:vite": "yarn build && yarn workspace with-vite dev". Simple but rebuilds every time.
  2. Vite alias / Next.js transpilePackages to source — Configure alias or transpilation to point directly to src/index.ts. Avoids build step but couples the example to source structure.
  3. Monorepo tooling (Turborepo, etc.) — Manages dependency graph so packages are built before dependents. Proper solution but may be overkill for current scale.
  4. Conditional exports for development — Add a development condition in exports pointing to source, used only in dev.

Reproduction

# Clean state (no dist/)
rm -rf packages/mobile/dist packages/core/dist

# execute vite server
yarn example:vite

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions