Skip to content

fix(addon): harden add-on entry point resolution - #1278

Closed
jycouet wants to merge 1 commit into
1225-alternativefrom
fix/1233-review
Closed

fix(addon): harden add-on entry point resolution#1278
jycouet wants to merge 1 commit into
1225-alternativefrom
fix/1233-review

Conversation

@jycouet

@jycouet jycouet commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Builds on #1233. Same direction (detect the real failure instead of proxying it via dependencies), with the resolution path tightened.

  • Try ./sv then .. A module-not-found on ./sv currently throws before . is attempted, so a package whose ./sv file is missing from the tarball fails even when . loads fine. The docs already promise this fallback.
  • Stop rejecting valid exports shapes. A bare string ("exports": "./dist/index.mjs"), a conditions-only object, and an absent exports (resolved via main) are all importable but were failing the pre-check. exports is now only consulted to decide whether to probe ./sv, never to reject.
  • Better diagnosis. CJS entries report MODULE_NOT_FOUND without the ERR_ prefix, so the unbundled-deps hint never fired for them. Node's message is kept so the missing module is named, and the "no default export" case no longer throws an error with an empty bullet.

Also documents that sv provides @sveltejs/sv-utils, so an add-on may leave it unbundled at the cost of tracking whatever version sv ships. Nothing verifies it, by design.

Tests cover each exports shape, the ./sv. fallback, both module-not-found codes, and the missing-default case.

Known limitations, not addressed here

Add-ons unpack into sv's own node_modules, so Node resolves upward and an unbundled dependency that happens to sit next to sv loads silently. file: add-ons resolve their own node_modules through the symlink, so the local dev loop cannot reproduce the published failure at all. Both are inherent to the install layout rather than to this change, and a lazily-imported missing dep still surfaces during apply rather than during download.

Try `./sv` then `.` as documented, instead of bailing on the first
failure. Stop rejecting valid `exports` shapes (bare string, conditions
only, absent) before attempting an import, handle the CJS
`MODULE_NOT_FOUND` code, and keep Node's message so the missing module
is named.

Document that `sv` provides `@sveltejs/sv-utils` and that leaving it
unbundled couples the add-on to whatever version `sv` ships.
@pkg-svelte-dev

Copy link
Copy Markdown

Install the latest version of sv from a0a8bd3:

pnx https://pkg.svelte.dev/sv/c/a0a8bd3966b02ca235a0a0e8ce445fe9aea71847 create

Open in pkg.svelte.dev: https://pkg.svelte.dev/repos/cli/pr/1278

@changeset-bot

changeset-bot Bot commented Aug 16, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: a0a8bd3

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@svelte-docs-bot

Copy link
Copy Markdown

@jycouet jycouet closed this Aug 16, 2026
@jycouet
jycouet deleted the fix/1233-review branch August 16, 2026 18:09
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