feat: add importMetaUrl to DevframeDefinition for dependency resolution - #261
Merged
Conversation
Add an optional `importMetaUrl` field to `DevframeDefinition` (strongly recommended, `importMetaUrl: import.meta.url`) that gives the host a resolution base rooted in the tool's own dependency graph. - Remote assets: `importMetaUrl` becomes the default `resolveFrom` for any remote `StaticAssetsSource` the devframe hosts (its `cli.distDir` and every `ctx.views.hostStatic` call). The rule lives in one funnel — `resolveStaticAssetsSource` gains a `defaultResolveFrom` argument, applied only when a source omits `resolveFrom`; an explicit per-source value still wins and an explicit `null` still opts out of the installed-copy lookup. - Services: adapters and the hub install path resolve declared service packages from `importMetaUrl`, so a plugin can ship a service package as its own dependency without asking users to install it. The field is optional for backward compatibility. First-party plugins now declare it once and drop their redundant per-asset `resolveFrom`; examples and the definition/client-assets/services docs model the recommended pattern. Created with the help of an agent.
✅ Deploy Preview for devfra ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
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.
What
Adds an optional
importMetaUrlfield toDevframeDefinition(strongly recommended —importMetaUrl: import.meta.url) that gives the host a resolution base rooted in the tool's own dependency graph, so a plugin can ship companion packages (its built-SPA--assetspackage, a service package) as its own dependencies without asking users to install anything extra.Why
Plugins were repeating
resolveFrom: import.meta.urlon every remote-assets block, and service resolution leaned on the declaringpackageNameresolved from the consuming app'scwd. A single definition-levelimportMetaUrlexpresses the intent once and covers both remote assets and service loading.How
importMetaUrlis the defaultresolveFromfor any remoteStaticAssetsSourcethe devframe hosts (itscli.distDirand everyctx.views.hostStaticcall). The precedence rule lives in a single funnel:resolveStaticAssetsSourcegains adefaultResolveFromargument, applied only when a source omitsresolveFrom— an explicit per-source value still wins, and an explicitresolveFrom: nullstill opts out of the installed-copy lookup.importMetaUrl.DevframeNodeContextsurface.importMetaUrlonce and drop their now-redundant per-assetresolveFrom; examples and thedevframe-definition/client-assets/servicesdocs model the recommended pattern.Verification
pnpm lint,pnpm knip,pnpm test(1204 passed),pnpm typecheck, andpnpm buildall pass. tsnapi API snapshots regenerated for the three changed surfaces.This PR was created with the help of an agent.