Skip to content

fix(exports): add a default condition so non-svelte resolvers work - #8

Merged
HaydenBruin merged 1 commit into
mainfrom
fix/exports-default-condition
Aug 25, 2026
Merged

fix(exports): add a default condition so non-svelte resolvers work#8
HaydenBruin merged 1 commit into
mainfrom
fix/exports-default-condition

Conversation

@HaydenBruin

Copy link
Copy Markdown
Contributor

vite dev failed with:

Failed to resolve import "@engineio/ui/components/ui/input/index.js"

Cause

Every subpath declared only types and svelte conditions:

node --conditions=svelte  →  resolves
node                      →  ERR_PACKAGE_PATH_NOT_EXPORTED

Which is exactly why this passed every check and still broke. svelte-check and
vite build apply the svelte condition; Vite's dev-time import-analysis does
not
, so it failed on vite dev only, and only for files inside a workspace
package.

Fix

default added to ., ./components/ui/*, ./components/ui/*/index.js,
./components/brand and ./components/brand/index.js — same target as the
svelte condition, declared last so more specific conditions still win.

Resolution and compilation are separate concerns: the barrels re-export
.svelte files that only a Svelte-aware bundler can compile, but refusing to
resolve is what broke here.

Verified

All six public subpaths resolve both with and without --conditions=svelte, and
the exact failing specifier now resolves in engine/front.

Every subpath declared only `types` and `svelte` conditions, so anything
resolving without the `svelte` condition got ERR_PACKAGE_PATH_NOT_EXPORTED:

  node --conditions=svelte  ->  resolves
  node                      ->  ERR_PACKAGE_PATH_NOT_EXPORTED

That is why this passed every check we ran and still broke the dev server.
svelte-check and `vite build` both apply the svelte condition; Vite's dev-time
import-analysis does not, so the failure surfaced only on `vite dev` and only
for files inside a workspace package — reported as
"Failed to resolve import @engineio/ui/components/ui/input/index.js".

Adds `default` to `.`, `./components/ui/*`, `./components/ui/*/index.js`,
`./components/brand` and `./components/brand/index.js`, pointing at the same
file the svelte condition does, and declared LAST so the more specific
conditions still win where they apply.

The barrels re-export .svelte files, which only a Svelte-aware bundler can
compile — but resolution and compilation are separate concerns, and refusing to
resolve is what broke here. Verified: all six public subpaths now resolve with
and without the condition.

Self-inflicted: the exports map is hand-written rather than generated, and the
`svelte`-only shape is what svelte-package emits for a Svelte-only library where
every consumer is assumed to apply the condition. Vite's own dev server does
not.
@HaydenBruin
HaydenBruin merged commit b541a3f into main Aug 25, 2026
1 check passed
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

Successfully merging this pull request may close these issues.

1 participant