Skip to content

armgit / Ix

Public Imported from GitHub
0

Understand any codebase instantly. System intelligence for codebases, built for humans and AI.

perf(release): stop shipping the build toolchain in the release tarball (#338)

KageBinaryac1347346936
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index dc68f513..36a4e282 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -193,6 +193,51 @@ jobs:
npm run build
npm version "$VERSION" --no-git-tag-version --allow-same-version
+ # Drop the build toolchain before anything reads node_modules. `npm run
+ # build` above has already consumed it, and every later step only copies
+ # or scans files, so nothing downstream needs it.
+ #
+ # --omit=dev keeps `dependencies` AND `optionalDependencies`, so all 27
+ # tree-sitter grammars (13 required + 14 optional) survive — they are
+ # genuine runtime deps and the parser is useless without them. Only
+ # devDependencies go.
+ #
+ # This also tightens the SBOM below for `ix-cli`, which until now described
+ # the build toolchain as shipped content. Note the SBOM still scans only
+ # `ix-cli`; core-ingestion's runtime tree is shipped but not catalogued.
+ - name: Prune dev dependencies before packaging
+ run: |
+ # `|| true`: this step runs under `bash -eo pipefail`, so a non-zero du
+ # anywhere in the pipeline would abort the whole release. Reporting a
+ # size is not worth that, and the `:-?` fallbacks below only mean
+ # something if the failure is allowed to reach them.
+ size() { du -sm "$1" 2>/dev/null | cut -f1 | head -1 || true; }
+ before_cli=$(size ix-cli/node_modules)
+ before_ing=$(size core-ingestion/node_modules)
+ (cd ix-cli && npm prune --omit=dev)
+ (cd core-ingestion && npm prune --omit=dev)
+ echo "ix-cli/node_modules: ${before_cli:-?} MB -> $(size ix-cli/node_modules) MB"
+ echo "core-ingestion/node_modules: ${before_ing:-?} MB -> $(size core-ingestion/node_modules) MB"
+
+ # The CLI must still start from the pruned tree, or the tarball ships
+ # broken. `--version` only resolves the eager import graph, so it
+ # proves nothing about core-ingestion: the CLI reaches that through a
+ # dynamic import in ingestion-loader.ts and would fail first on a
+ # user's `ix map`, long after this step went green.
+ #
+ # So actually parse something. A grammar dropped by mistake makes
+ # parseFile return null here rather than at a user's first ingest.
+ # (parse-worker.js is deliberately not imported — it throws by design
+ # unless it is running inside a worker thread.)
+ node ix-cli/dist/cli/main.js --version
+ node --input-type=module -e "
+ const { parseFile } = await import('./core-ingestion/dist/index.js');
+ await import('./core-ingestion/dist/patch-builder.js');
+ const result = parseFile('smoke.ts', 'export const smoke = 1;\n');
+ if (!result) throw new Error('core-ingestion parsed nothing from the pruned tree');
+ console.log('core-ingestion parses from the pruned tree');
+ "
+
# The compass job does not run on PR dry-runs, so the artifact is legitimately
# absent there. continue-on-error covers only that case; a real release
# asserts the bundle is present in the packaging step below.
diff --git a/ix-cli/package.json b/ix-cli/package.json
index 54eb2aa0..a08f8ba5 100644
--- a/ix-cli/package.json
+++ b/ix-cli/package.json
@@ -16,7 +16,7 @@
"node": ">=22.0.0"
},
"scripts": {
- "build": "node scripts/build-core-ingestion.mjs && node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\" && tsc",
+ "build": "node scripts/build-core-ingestion.mjs && node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\" && tsc -p tsconfig.build.json",
"test": "node scripts/build-core-ingestion.mjs && vitest run && node test/parser.smoke.mjs",
"test:unit": "vitest run",
"test:coverage": "vitest run --coverage",
diff --git a/ix-cli/tsconfig.build.json b/ix-cli/tsconfig.build.json
new file mode 100644
index 00000000..e63c158d
--- /dev/null
+++ b/ix-cli/tsconfig.build.json
@@ -0,0 +1,13 @@
+{
+ // Build-only config: same settings as tsconfig.json, minus the tests.
+ //
+ // tsconfig.json deliberately still includes them so `npm run typecheck`
+ // covers test files. But emitting them is a different matter: tsc would write
+ // every src/**/__tests__ file into dist/, the Package step copies dist/
+ // wholesale into the release tarball, and the result is ~35 shipped modules
+ // importing vitest — inside a tree from which the release workflow's
+ // `npm prune --omit=dev` has just removed vitest. It also made the SBOM
+ // describe test-only imports as shipped content.
+ "extends": "./tsconfig.json",
+ "exclude": ["src/**/__tests__/**", "src/**/*.test.ts"]
+}
diff --git a/ix-cli/tsconfig.json b/ix-cli/tsconfig.json
index c3cdc34c..5d35c696 100644
--- a/ix-cli/tsconfig.json
+++ b/ix-cli/tsconfig.json
@@ -10,5 +10,7 @@
"declaration": true,
"skipLibCheck": true
},
+ // Covers tests too, so `npm run typecheck` keeps checking them.
+ // The shipped build uses tsconfig.build.json, which excludes them from dist.
"include": ["src"]
}