diff --git a/.changeset/static-imports-already-loaded.md b/.changeset/static-imports-already-loaded.md new file mode 100644 index 0000000..d079125 --- /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 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/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`, )