fix(addon): harden add-on entry point resolution - #1278
Closed
jycouet wants to merge 1 commit into
Closed
Conversation
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.
|
Install the latest version of pnx https://pkg.svelte.dev/sv/c/a0a8bd3966b02ca235a0a0e8ce445fe9aea71847 createOpen in |
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Builds on #1233. Same direction (detect the real failure instead of proxying it via
dependencies), with the resolution path tightened../svthen.. A module-not-found on./svcurrently throws before.is attempted, so a package whose./svfile is missing from the tarball fails even when.loads fine. The docs already promise this fallback.exportsshapes. A bare string ("exports": "./dist/index.mjs"), a conditions-only object, and an absentexports(resolved viamain) are all importable but were failing the pre-check.exportsis now only consulted to decide whether to probe./sv, never to reject.MODULE_NOT_FOUNDwithout theERR_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
svprovides@sveltejs/sv-utils, so an add-on may leave it unbundled at the cost of tracking whatever versionsvships. Nothing verifies it, by design.Tests cover each
exportsshape, the./sv→.fallback, both module-not-found codes, and the missing-default case.Known limitations, not addressed here
Add-ons unpack into
sv's ownnode_modules, so Node resolves upward and an unbundled dependency that happens to sit next tosvloads silently.file:add-ons resolve their ownnode_modulesthrough 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.