From d702b8fa9e5fff23f821b2e33503a7babfe33a71 Mon Sep 17 00:00:00 2001 From: ladybluenotes Date: Sun, 4 Oct 2026 15:41:45 -0700 Subject: [PATCH 1/2] perf: import already-loaded modules statically --- .changeset/static-imports-already-loaded.md | 5 +++++ packages/intent/src/commands/meta.ts | 2 +- packages/intent/src/commands/support.ts | 6 ++++-- packages/intent/src/commands/validate.ts | 14 ++++---------- 4 files changed, 14 insertions(+), 13 deletions(-) create mode 100644 .changeset/static-imports-already-loaded.md diff --git a/.changeset/static-imports-already-loaded.md b/.changeset/static-imports-already-loaded.md new file mode 100644 index 0000000..af17d93 --- /dev/null +++ b/.changeset/static-imports-already-loaded.md @@ -0,0 +1,5 @@ +--- +'@tanstack/intent': patch +--- + +Make the installed package 16 kB smaller and load one to four fewer files in `intent validate`, `intent meta`, and `intent stale`. Modules that these commands had already loaded are now imported directly instead of through a second, deferred import, so the bundle keeps only the parts of `yaml` that Intent uses; behavior does not change. diff --git a/packages/intent/src/commands/meta.ts b/packages/intent/src/commands/meta.ts index 1090ef9..4144451 100644 --- a/packages/intent/src/commands/meta.ts +++ b/packages/intent/src/commands/meta.ts @@ -1,6 +1,7 @@ import { existsSync, readFileSync, readdirSync } from 'node:fs' import { dirname, join } from 'node:path' import { fail } from '../shared/cli-error.js' +import { parseFrontmatter } from '../shared/utils.js' import { rewriteLoadedSkillMarkdownDestinations } from '../core/markdown.js' export async function runMetaCommand( @@ -40,7 +41,6 @@ export async function runMetaCommand( return } - const { parseFrontmatter } = await import('../shared/utils.js') const entries = readdirSync(metaDir, { withFileTypes: true }) .filter((entry) => entry.isDirectory()) .filter((entry) => existsSync(join(metaDir, entry.name, 'SKILL.md'))) diff --git a/packages/intent/src/commands/support.ts b/packages/intent/src/commands/support.ts index f6a600c..5ae96d9 100644 --- a/packages/intent/src/commands/support.ts +++ b/packages/intent/src/commands/support.ts @@ -4,6 +4,10 @@ import { fileURLToPath } from 'node:url' import { fail } from '../shared/cli-error.js' import { resolveProjectContext } from '../core/project-context.js' import { createIntentFsCache } from '../discovery/fs-cache.js' +import { + findWorkspacePackages, + findWorkspaceRoot, +} from '../setup/workspace-patterns.js' import type { IntentCoreOptions } from '../core/index.js' import type { IntentFsCache } from '../discovery/fs-cache.js' import type { @@ -192,8 +196,6 @@ export async function resolveStaleTargets( } } - const { findWorkspaceRoot, findWorkspacePackages } = - await import('../setup/workspace-patterns.js') const workspaceRoot = findWorkspaceRoot(resolvedRoot) if (workspaceRoot) { const packageDirs = findWorkspacePackages(workspaceRoot) diff --git a/packages/intent/src/commands/validate.ts b/packages/intent/src/commands/validate.ts index 14796bc..197caff 100644 --- a/packages/intent/src/commands/validate.ts +++ b/packages/intent/src/commands/validate.ts @@ -6,7 +6,9 @@ import { statSync, } from 'node:fs' import { basename, dirname, join, relative, resolve } from 'node:path' +import { parseDocument, parse as parseYaml } from 'yaml' import { fail, isCliFailure } from '../shared/cli-error.js' +import { readScalarField } from '../shared/utils.js' import { resolveProjectContext } from '../core/project-context.js' import { findWorkspacePackages } from '../setup/workspace-patterns.js' import { createIntentFsCache } from '../discovery/fs-cache.js' @@ -280,11 +282,7 @@ function applyFrontmatterFixes(plans: Array): void { ) } -async function applySetVersion( - plans: Array, - version: string, -): Promise { - const { parseDocument } = await import('yaml') +function applySetVersion(plans: Array, version: string): void { const root = repairRoot() const changes: Array = [] @@ -433,10 +431,6 @@ async function runValidateCommandInternal( additionalDirs: Array = [], exampleSummaries?: Map, ): Promise { - const [{ parse: parseYaml }, { readScalarField }] = await Promise.all([ - import('yaml'), - import('../shared/utils.js'), - ]) const { findSkillFiles } = createIntentFsCache() // Explicit directories are validated in one run, so a caller with several // skills roots gets every error in one report and one summary. @@ -845,7 +839,7 @@ async function runValidateCommandInternal( console.log(`✅ Fixed ${fixPlans.length} skill files`) } if (willSetVersion) { - await applySetVersion(setVersionPlans, options.setVersion!) + applySetVersion(setVersionPlans, options.setVersion!) console.log( `✅ Set library_version to "${options.setVersion}" on ${setVersionPlans.length} skill files`, ) From 36cba8d314945cfe84855c06cb21d1995f01d79f Mon Sep 17 00:00:00 2001 From: ladybluenotes Date: Sun, 4 Oct 2026 15:53:06 -0700 Subject: [PATCH 2/2] chore: keep the lazy utils import in meta --- .changeset/static-imports-already-loaded.md | 2 +- packages/intent/src/commands/meta.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.changeset/static-imports-already-loaded.md b/.changeset/static-imports-already-loaded.md index af17d93..d079125 100644 --- a/.changeset/static-imports-already-loaded.md +++ b/.changeset/static-imports-already-loaded.md @@ -2,4 +2,4 @@ '@tanstack/intent': patch --- -Make the installed package 16 kB smaller and load one to four fewer files in `intent validate`, `intent meta`, and `intent stale`. Modules that these commands had already loaded are now imported directly instead of through a second, deferred import, so the bundle keeps only the parts of `yaml` that Intent uses; behavior does not change. +Make the installed package 16 kB smaller and load fewer files in each command. `intent validate` and `intent stale` imported modules a second time through a deferred import, although the same files had already loaded them. Those modules are now imported directly, so the bundle keeps only the parts of `yaml` that Intent uses; behavior does not change. diff --git a/packages/intent/src/commands/meta.ts b/packages/intent/src/commands/meta.ts index 4144451..1090ef9 100644 --- a/packages/intent/src/commands/meta.ts +++ b/packages/intent/src/commands/meta.ts @@ -1,7 +1,6 @@ import { existsSync, readFileSync, readdirSync } from 'node:fs' import { dirname, join } from 'node:path' import { fail } from '../shared/cli-error.js' -import { parseFrontmatter } from '../shared/utils.js' import { rewriteLoadedSkillMarkdownDestinations } from '../core/markdown.js' export async function runMetaCommand( @@ -41,6 +40,7 @@ export async function runMetaCommand( return } + const { parseFrontmatter } = await import('../shared/utils.js') const entries = readdirSync(metaDir, { withFileTypes: true }) .filter((entry) => entry.isDirectory()) .filter((entry) => existsSync(join(metaDir, entry.name, 'SKILL.md')))