Skip to content

@simple-module-py/ui exports map ('.', './*') doesn't cover ./components/*, ./layouts/* — vite can't resolve subpath imports from module pages #110

Description

@antosubash

Summary

After successfully booting the API on a fresh sm new scaffold, npm run dev (vite) fails because module-shipped .tsx files can't resolve their @simple-module-py/ui subpath imports. The package's exports map declares only \".\" and \"./*\", neither of which expose paths like ./components/PageShell, ./layouts/AuthenticatedLayout, or ./components/ui/button that the bundled users / dashboard / permissions modules import.

Reproduction

uvx --from simple_module_cli sm new my-app --db sqlite --preset standard -y --no-install
cd my-app
# (after working around #105/#106/#107/#108/#109)
make install
make migrate
cd client_app && npm run dev

Vite output:

Failed to resolve dependency: use-sync-external-store, present in client 'optimizeDeps.include'
Failed to resolve dependency: use-sync-external-store/shim, present in client 'optimizeDeps.include'
Failed to resolve dependency: use-sync-external-store/shim/with-selector, present in client 'optimizeDeps.include'
VITE v6.4.2 ready in 1192 ms
Error: The following dependencies are imported but could not be resolved:
@simple-module-py/ui/components/PageShell (imported by .../site-packages/users/pages/Users/Invite.tsx)
@simple-module-py/ui/layouts/AuthenticatedLayout (imported by .../site-packages/users/pages/Users/Index.tsx)
@simple-module-py/ui/components/ui/badge (imported by .../site-packages/users/components/RolesTab.tsx)
@simple-module-py/ui/components/ui/button (imported by .../site-packages/users/components/RolesTab.tsx)
@simple-module-py/ui/components/ui/card (imported by .../site-packages/users/components/RolesTab.tsx)
@simple-module-py/ui/components/ui/alert-dialog (imported by .../site-packages/users/pages/Users/Edit.tsx)
... (more)

Root cause

client_app/node_modules/@simple-module-py/ui/package.json:

{
"main": "src/index.ts",
"exports": { ".": "...", "./*": "..." },
"files": ["src", "README.md"]
}

The \"./*\" pattern only matches direct children of the package root (one segment). It does not match ./components/PageShell, ./layouts/AuthenticatedLayout, or ./components/ui/badge. Modules import these subpaths today, so Vite gives up.

Related

This is adjacent to (but not the same as) the closed #73, which dealt with module-dir node_modules symlinks and vite aliases. That fix made bare-package resolution find the workspace node_modules, but the resolver then still has to honor the package's exports map — and that map doesn't expose what the modules use.

Suggested fix

Add explicit subpath exports to @simple-module-py/ui (and any sibling packages with the same shape):

{
\"exports\": {\".\": \"./src/index.ts\",\"./components/*\": \"./src/components/*.tsx\",\"./components/ui/*\": \"./src/components/ui/*.tsx\",\"./layouts/*\": \"./src/layouts/*.tsx\",\"./hooks/*\": \"./src/hooks/*.ts\",\"./*\": \"./src/*\" }}

(Exact pattern depends on the actual source layout — a glance at src/components/ui/ should confirm.)

Environment

  • @simple-module-py/ui 0.0.6
  • vite 6.4.2 (resolved by vite ^8.0.0 in scaffold's package.json — separate small surprise)
  • node 20+

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingjavascriptPull requests that update javascript code

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions