Skip to content

Commit 57ee3ea

Browse files
chore(plans): add samlify-esm-interop
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LFyA5poHwrhAktrnsKrUiQ
1 parent f9a72fb commit 57ee3ea

1 file changed

Lines changed: 45 additions & 0 deletions

File tree

‎plans/samlify-esm-interop.md‎

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
status: done
3+
depends: [saml-login-return-path]
4+
specs:
5+
- specs/api/saml.md
6+
issues: []
7+
pr: null
8+
---
9+
10+
# Plan: samlify ESM/CJS interop in the production build
11+
12+
## Scope
13+
14+
The first signed-in Slack SSO attempt against the live site 500'd:
15+
`Cannot read properties of undefined (reading 'replaceTagsByValue')` in
16+
`dist/saml/config.js`. samlify is CommonJS; under Node's ESM loader,
17+
cjs-module-lexer does not detect `SamlLib` (re-exported through a getter),
18+
so `import * as samlify` leaves it undefined and only `default`
19+
(module.exports) carries it. vitest's interop exposes it as a named export,
20+
which is why all 19 SAML tests passed while production failed.
21+
22+
In: resolve the module from whichever view carries `SamlLib`; verify the
23+
compiled output under plain Node. Out: replacing samlify.
24+
25+
## Implements
26+
27+
- [api/saml.md](../specs/api/saml.md) — no behaviour change; the assertion
28+
pipeline works as specified once the library resolves.
29+
30+
## Approach
31+
32+
`apps/api/src/saml/config.ts`: pick `samlifyNs.default` when it carries
33+
`SamlLib`, else the namespace. Verified with
34+
`node -e "import('./dist/saml/config.js')"` after `npm run build`.
35+
36+
## Validation
37+
38+
- `npm run type-check && npm run lint`; SAML suite 19/19.
39+
- Post-deploy: Slack "Test configuration" completes for a signed-in user.
40+
41+
## Follow-ups
42+
43+
- Tracked as: a build-output smoke test (import the compiled API under plain
44+
Node in CI) would have caught this before release — worth adding to
45+
`ci.yml` after `npm run build`.

0 commit comments

Comments
 (0)