feat(extensions): nativescript.commands map — per-command lazy loading for extensions - #6102
Draft
edusperoni wants to merge 5 commits into
Draft
feat(extensions): nativescript.commands map — per-command lazy loading for extensions#6102edusperoni wants to merge 5 commits into
edusperoni wants to merge 5 commits into
Conversation
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
edusperoni
force-pushed
the
feat/define-command
branch
from
July 30, 2026 01:39
b15734b to
863f964
Compare
edusperoni
force-pushed
the
feat/extension-manifests
branch
from
July 30, 2026 01:41
220e027 to
02d6f7c
Compare
edusperoni
force-pushed
the
feat/define-command
branch
from
July 30, 2026 01:44
863f964 to
74caa8f
Compare
edusperoni
force-pushed
the
feat/extension-manifests
branch
from
July 30, 2026 01:44
02d6f7c to
d8a8fcf
Compare
edusperoni
force-pushed
the
feat/define-command
branch
from
July 30, 2026 02:27
74caa8f to
cafa737
Compare
edusperoni
force-pushed
the
feat/extension-manifests
branch
from
July 30, 2026 02:28
d8a8fcf to
e0c671c
Compare
…s map An extension whose package.json declares nativescript.commands as a map of command name to module path is no longer require()d at startup. Each entry is registered with injector.requireCommand against the module's absolute path, so a command's implementation loads only when that command is first resolved, and the CLI stops paying every installed extension's load cost on every invocation. Entries are validated: a command name or module path that is not a non-empty string is warned about and skipped, and a name already claimed by another extension is reported as a warning naming both extensions rather than propagating the injector's "require'd twice" failure. The legacy array shape (and a missing commands key) keeps today's behavior verbatim - eager require of the extension main plus the extensions.require-time-registration deprecation report. Both shapes now feed IExtensionData.commands and the npm install suggestion for unknown commands.
A manifest entry may now point at a module that exports a defineCommand definition instead of registering itself on load: the deferred loader adapts and registers the export under the manifest key. The override also lands on a parent record the entry just created, because dispatch resolves the hierarchical parent before any child module has loaded and the dispatcher only comes into existence once a child registers. Also cross-links the authoring guides from dependency-injection.md.
… seam The service takes $injector as a constructor dependency instead of the module-level import, so manifest registration and the definition-aware loaders target the instance that resolved it. Tests assert on their own per-test injector; the process-wide injector is swapped only because legacy-shape fixture modules register through the published global surface at load, and that seam is labeled as such. extensions.md no longer teaches the global-injector patterns: the legacy array path and self-registering modules are described under their deprecation framing without runnable samples.
Registry operations go through the narrow subsystem contract; the full facade stays only for container-record operations (has, provider registration). First consumer of the per-face tokens.
edusperoni
force-pushed
the
feat/define-command
branch
from
July 30, 2026 02:51
cafa737 to
a1ba0ef
Compare
edusperoni
force-pushed
the
feat/extension-manifests
branch
from
July 30, 2026 02:52
e0c671c to
10aaa87
Compare
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.
PR Checklist
What is the current behavior?
Every installed extension is eagerly
require()d on every CLI invocation, before the command is even known — the extension's whole module tree loads so its top-level side effects can register commands againstglobal.$injector.nativescript.commandsin an extension's package.json is astring[]used only to suggest installs for unknown commands. Two extensions claiming the same command name crash at startup.What is the new behavior?
nativescript.commandsalso accepts a map of command name → module path, which becomes authoritative:defineCommanddefinition — the deferred loader adapts and registers the export under the manifest key, including the subtle hierarchical case where dispatch resolves the parent dispatcher before any child module has loaded.settlePromisesisolation preserved).|*default-command short-form behavior.IExtensionDatagainscommands?: string[].extensions.md;dependency-injection.mdnow cross-links all three API guides.12 new tests (lazy registration, eager-path preservation, malformed/conflict handling, both suggestion shapes, pure-definition modules incl. the parent-first case). Full stacked suite: 111 files, 1628 passed / 38 skipped; yok oracle, public-API test, and compat fixtures untouched.