Skip to content

feat: add importMetaUrl to DevframeDefinition for dependency resolution - #261

Merged
antfu merged 1 commit into
mainfrom
feat/definition-import-meta-url
Aug 19, 2026
Merged

feat: add importMetaUrl to DevframeDefinition for dependency resolution#261
antfu merged 1 commit into
mainfrom
feat/definition-import-meta-url

Conversation

@antfubot

Copy link
Copy Markdown
Collaborator

What

Adds 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, so a plugin can ship companion packages (its built-SPA --assets package, a service package) as its own dependencies without asking users to install anything extra.

Why

Plugins were repeating resolveFrom: import.meta.url on every remote-assets block, and service resolution leaned on the declaring packageName resolved from the consuming app's cwd. A single definition-level importMetaUrl expresses the intent once and covers both remote assets and service loading.

How

  • Remote assetsimportMetaUrl is the default resolveFrom for any remote StaticAssetsSource the devframe hosts (its cli.distDir and every ctx.views.hostStatic call). The precedence rule lives in a single funnel: resolveStaticAssetsSource gains a defaultResolveFrom argument, applied only when a source omits resolveFrom — an explicit per-source value still wins, and an explicit resolveFrom: null still opts out of the installed-copy lookup.
  • Services — the standalone adapters and the hub install path now resolve declared service packages from importMetaUrl.
  • The field is optional for backward compatibility. It is an internal plumbing detail on the host context, not part of the public DevframeNodeContext surface.
  • First-party plugins declare importMetaUrl once and drop their now-redundant per-asset resolveFrom; examples and the devframe-definition / client-assets / services docs model the recommended pattern.

Verification

pnpm lint, pnpm knip, pnpm test (1204 passed), pnpm typecheck, and pnpm build all pass. tsnapi API snapshots regenerated for the three changed surfaces.

This PR was created with the help of an agent.

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.
@netlify

netlify Bot commented Aug 19, 2026

Copy link
Copy Markdown

Deploy Preview for devfra ready!

Name Link
🔨 Latest commit a038159
🔍 Latest deploy log https://app.netlify.com/projects/devfra/deploys/6a84f3352a67a50008f52c72
😎 Deploy Preview https://deploy-preview-261--devfra.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@antfu
antfu merged commit 162e616 into main Aug 19, 2026
12 checks passed
@antfu
antfu deleted the feat/definition-import-meta-url branch August 19, 2026 00: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.

2 participants