Skip to content

Commit e00f4b9

Browse files
committed
refactor(repo): centralize package subpaths
1 parent 53d9022 commit e00f4b9

25 files changed

Lines changed: 1103 additions & 76 deletions

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@
2424
"changelog:weekly": "tsx scripts/changelog-weekly.ts",
2525
"sync-schemas": "tsx scripts/sync-schemas.ts",
2626
"sync-schemas:check": "tsx scripts/sync-schemas.ts --check",
27-
"lint": "bun run check:tracked-artifacts && bun run check:workspace-contracts && bun run check:package-cycles && oxlint . && tsx scripts/lint-skills.ts",
27+
"sync:package-subpaths": "node scripts/package-subpaths.mjs --write",
28+
"check:package-subpaths": "node scripts/package-subpaths.mjs",
29+
"lint": "bun run check:tracked-artifacts && bun run check:workspace-contracts && bun run check:package-cycles && bun run check:package-subpaths && oxlint . && tsx scripts/lint-skills.ts",
2830
"lint:skills": "tsx scripts/lint-skills.ts",
2931
"lint:fix": "oxlint --fix .",
3032
"check:tracked-artifacts": "node scripts/check-tracked-artifacts.mjs",
@@ -42,7 +44,7 @@
4244
"player:perf": "bun run --filter @hyperframes/player perf",
4345
"format:check": "oxfmt --check .",
4446
"knip": "knip",
45-
"test:scripts": "node --import tsx --test scripts/check-tracked-artifacts.test.mjs scripts/check-workspace-contracts.test.mjs scripts/check-package-cycles.test.mjs scripts/validate-release-channel.test.mjs scripts/draft-changelog.test.ts scripts/set-version.test.ts scripts/release-prepare.test.ts scripts/cli-options.test.ts scripts/changelog-weekly.test.ts scripts/claude-plugin-compression.test.ts scripts/studio-runtime-smoke.test.mjs scripts/verify-packed-manifests.test.mjs",
47+
"test:scripts": "node --import tsx --test scripts/check-tracked-artifacts.test.mjs scripts/check-workspace-contracts.test.mjs scripts/check-package-cycles.test.mjs scripts/package-subpaths.test.mjs scripts/validate-release-channel.test.mjs scripts/draft-changelog.test.ts scripts/set-version.test.ts scripts/release-prepare.test.ts scripts/cli-options.test.ts scripts/changelog-weekly.test.ts scripts/claude-plugin-compression.test.ts scripts/studio-runtime-smoke.test.mjs scripts/verify-packed-manifests.test.mjs",
4648
"test:skills": "node --test 'skills/**/*.test.mjs'",
4749
"generate:previews": "tsx scripts/generate-template-previews.ts",
4850
"generate:catalog-previews": "tsx scripts/generate-catalog-previews.ts",
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"package": "@hyperframes/aws-lambda",
3+
"subpaths": {
4+
".": {
5+
"source": "./src/index.ts",
6+
"runtime": "./dist/index.js",
7+
"types": "./dist/index.d.ts",
8+
"environments": ["bun", "node"]
9+
},
10+
"./handler": {
11+
"source": "./src/handler.ts",
12+
"runtime": "./dist/handler.js",
13+
"types": "./dist/handler.d.ts",
14+
"environments": ["bun", "node"]
15+
},
16+
"./sdk": {
17+
"source": "./src/sdk/index.ts",
18+
"runtime": "./dist/sdk/index.js",
19+
"types": "./dist/sdk/index.d.ts",
20+
"environments": ["bun", "node"]
21+
},
22+
"./cdk": {
23+
"source": "./src/cdk/index.ts",
24+
"runtime": "./dist/cdk/index.js",
25+
"types": "./dist/cdk/index.d.ts",
26+
"environments": ["bun", "node"]
27+
}
28+
}
29+
}

packages/aws-lambda/package.json

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,46 @@
1717
"types": "./dist/index.d.ts",
1818
"exports": {
1919
".": {
20-
"import": "./dist/index.js",
21-
"types": "./dist/index.d.ts"
20+
"bun": "./src/index.ts",
21+
"import": "./src/index.ts",
22+
"types": "./src/index.ts"
2223
},
2324
"./handler": {
24-
"import": "./dist/handler.js",
25-
"types": "./dist/handler.d.ts"
25+
"bun": "./src/handler.ts",
26+
"import": "./src/handler.ts",
27+
"types": "./src/handler.ts"
2628
},
2729
"./sdk": {
28-
"import": "./dist/sdk/index.js",
29-
"types": "./dist/sdk/index.d.ts"
30+
"bun": "./src/sdk/index.ts",
31+
"import": "./src/sdk/index.ts",
32+
"types": "./src/sdk/index.ts"
3033
},
3134
"./cdk": {
32-
"import": "./dist/cdk/index.js",
33-
"types": "./dist/cdk/index.d.ts"
35+
"bun": "./src/cdk/index.ts",
36+
"import": "./src/cdk/index.ts",
37+
"types": "./src/cdk/index.ts"
3438
}
3539
},
3640
"publishConfig": {
3741
"access": "public",
42+
"exports": {
43+
".": {
44+
"import": "./dist/index.js",
45+
"types": "./dist/index.d.ts"
46+
},
47+
"./handler": {
48+
"import": "./dist/handler.js",
49+
"types": "./dist/handler.d.ts"
50+
},
51+
"./sdk": {
52+
"import": "./dist/sdk/index.js",
53+
"types": "./dist/sdk/index.d.ts"
54+
},
55+
"./cdk": {
56+
"import": "./dist/cdk/index.js",
57+
"types": "./dist/cdk/index.d.ts"
58+
}
59+
},
3860
"registry": "https://registry.npmjs.org/"
3961
},
4062
"scripts": {

packages/cli/tsup.config.ts

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { defineConfig } from "tsup";
22
import { resolve } from "node:path";
33
import { readFileSync } from "node:fs";
4+
import { sourceAliases } from "../../scripts/package-subpaths.mjs";
45

56
const pkg = JSON.parse(readFileSync(new URL("./package.json", import.meta.url), "utf-8")) as {
67
version: string;
@@ -79,27 +80,12 @@ var __dirname = __hf_dirname(__filename);`,
7980
},
8081
esbuildOptions(options) {
8182
options.alias = {
82-
"@hyperframes/producer": resolve(__dirname, "../producer/src/index.ts"),
83-
// esbuild's alias map treats `@hyperframes/producer` as a file path
84-
// and would otherwise resolve `@hyperframes/producer/distributed`
85-
// to `../producer/src/index.ts/distributed` (treating the file as a
86-
// directory). Adding an explicit alias for every subpath we import
87-
// avoids the prefix-substitution misfire.
88-
"@hyperframes/producer/distributed": resolve(__dirname, "../producer/src/distributed.ts"),
89-
// Same reason: the lambda CLI imports `@hyperframes/aws-lambda/sdk`,
90-
// which would resolve to `../aws-lambda/src/index.ts/sdk` without
91-
// an explicit subpath alias. The SDK subpath has its own barrel.
92-
"@hyperframes/aws-lambda/sdk": resolve(__dirname, "../aws-lambda/src/sdk/index.ts"),
93-
// Same for the GCP adapter's SDK subpath barrel.
94-
"@hyperframes/gcp-cloud-run/sdk": resolve(__dirname, "../gcp-cloud-run/src/sdk/index.ts"),
95-
// hf#677 follow-up: the shader-blend worker imports from
96-
// `@hyperframes/engine/shader-transitions` (subpath export) — a
97-
// standalone TS file with zero internal imports that survives the
98-
// worker_thread loader boundary.
99-
"@hyperframes/engine/shader-transitions": resolve(
100-
__dirname,
101-
"../engine/src/utils/shaderTransitions.ts",
102-
),
83+
// Exact subpaths are generated from the same contracts as package
84+
// exports, avoiding esbuild's root-alias prefix substitution trap.
85+
...sourceAliases(resolve(__dirname, "../producer"), [".", "./distributed"]),
86+
...sourceAliases(resolve(__dirname, "../aws-lambda"), ["./sdk"]),
87+
...sourceAliases(resolve(__dirname, "../gcp-cloud-run"), ["./sdk"]),
88+
...sourceAliases(resolve(__dirname, "../engine"), [".", "./shader-transitions"]),
10389
};
10490
options.loader = { ...options.loader, ".browser.js": "text" };
10591
},

0 commit comments

Comments
 (0)