Skip to content

Commit 5f3cb8c

Browse files
committed
fix(iocraft+test): bundled-node_modules fallback + drop dist/cli.js → dist/index.js
### iocraft loader: bundled-node_modules fallback (3 + 5 + 4 = 12 tests) The `@socketaddon/iocraft` package's `index.mjs` already had two fallback paths for finding the platform-specific `.node` binary: - direct check at `<build-out>/socketaddon-iocraft-<platformId>/iocraft.node` - pnpm-virtual-store reconstruction back to the same sibling layout Both assume a sibling-package layout (`socketaddon-iocraft-darwin-arm64` next to `socketaddon-iocraft`). On this branch, package-builder emits the binary as a *bundled* dep instead, at: `<build-out>/socketaddon-iocraft/node_modules/@socketaddon/iocraft-darwin-arm64/iocraft.node` That's where pnpm leaves the optionalDependency when it's installed into the file: package's local node_modules but not lifted into the consumer's `.pnpm` store (a known pnpm behavior for `file:` deps that declare optionalDependencies). Add a bundled-path fallback after the sibling-path check. Test: - iocraft-new-features.test.mts: 26/26 (was 23/26) - iocraft-properties.test.mts: 5 previously-failing tests now pass - AnalyticsRenderer / AuditLogRenderer / ThreatFeedRenderer: 4 previously-failing tests now pass ### paths.test.mts: dist/cli.js → dist/index.js (1 test) `getBinCliPath()` returns `dist/index.js` (renamed from `dist/cli.js` in the unified-build refactor — see comment at src/constants/paths.mts:41). Test still asserted the old `cli.js` form; update to expect `dist/index.js`. ### Result socket-cli's full test suite: 5248/5248 passing (was 5235/5248).
1 parent 29551cc commit 5f3cb8c

2 files changed

Lines changed: 23 additions & 1 deletion

File tree

packages/cli/test/unit/constants/paths.test.mts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,9 @@ describe('paths constants', () => {
142142

143143
it('getBinCliPath returns path to CLI entry point', () => {
144144
const result = getBinCliPath()
145-
expect(result).toContain('cli.js')
145+
// The bundle entry is `dist/index.js` (was `dist/cli.js` before
146+
// the unified-build rename in src/constants/paths.mts).
147+
expect(result).toContain('dist/index.js')
146148
})
147149

148150
it('getDistPath returns distPath', () => {

packages/package-builder/templates/socketaddon-main/index.mjs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,30 @@ function loadNativeAddon() {
106106
}
107107

108108
if (buildOutDir) {
109+
// First: look for a sibling-package-style layout
110+
// `socketaddon-iocraft-<platformId>/iocraft.node` next to the
111+
// main package.
109112
const siblingPath = join(buildOutDir, `socketaddon-iocraft-${platformId}`, 'iocraft.node')
110113
if (existsSync(siblingPath)) {
111114
return require(siblingPath)
112115
}
116+
// Second: look inside the main package's bundled
117+
// `node_modules/@socketaddon/iocraft-<platformId>/iocraft.node`.
118+
// This is where pnpm leaves the optionalDependency when it's
119+
// installed into the file: package's local node_modules but
120+
// not lifted into the consumer's .pnpm store (which happens
121+
// for `file:` deps that declare optionalDependencies).
122+
const bundledPath = join(
123+
buildOutDir,
124+
'socketaddon-iocraft',
125+
'node_modules',
126+
'@socketaddon',
127+
`iocraft-${platformId}`,
128+
'iocraft.node',
129+
)
130+
if (existsSync(bundledPath)) {
131+
return require(bundledPath)
132+
}
113133
}
114134

115135
throw new Error('Not in development build structure')

0 commit comments

Comments
 (0)