Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/static-imports-already-loaded.md
Original file line number Diff line number Diff line change
@@ -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.
6 changes: 4 additions & 2 deletions packages/intent/src/commands/support.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down
14 changes: 4 additions & 10 deletions packages/intent/src/commands/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -280,11 +282,7 @@ function applyFrontmatterFixes(plans: Array<FrontmatterFixPlan>): void {
)
}

async function applySetVersion(
plans: Array<SetVersionPlan>,
version: string,
): Promise<void> {
const { parseDocument } = await import('yaml')
function applySetVersion(plans: Array<SetVersionPlan>, version: string): void {
const root = repairRoot()
const changes: Array<FileChange> = []

Expand Down Expand Up @@ -433,10 +431,6 @@ async function runValidateCommandInternal(
additionalDirs: Array<string> = [],
exampleSummaries?: Map<string, string>,
): Promise<void> {
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.
Expand Down Expand Up @@ -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`,
)
Expand Down
Loading