fix: restore native browser ESM imports - #2495
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Castiron custom code✅ No new custom-code files detected. 32 mixed files remain; 0 existing customizations changed. Compared 32 existing customizations unchanged
A changed generated baseline means this report cannot reliably identify which handwritten lines changed. Inspect the custom-code diffDownload the exact patch produced by this run (requires repository access): gh run download 33042968288 --repo openai/openai-node \
--name castiron-custom-code-33042968288-1 --dir /tmp/castiron-custom-code-33042968288-1
git apply --stat /tmp/castiron-custom-code-33042968288-1/custom-code.patch
cat /tmp/castiron-custom-code-33042968288-1/custom-code.patchOr reproduce it from an SDK checkout containing the vendored reporter: git fetch --no-tags origin 76b73a9c73aafe11c60a425a82898705f1db966d a3f004f24006473347c532b7cebd495277853dc1
python3 scripts/castiron/custom_code_report.py report \
--base 76b73a9c73aafe11c60a425a82898705f1db966d \
--head a3f004f24006473347c532b7cebd495277853dc1 --fetch --require-head-hash --public \
--out /tmp/castiron-custom-code-a3f004f24006
cat /tmp/castiron-custom-code-a3f004f24006/custom-code.patchThis is the current full custom patch for mixed files, not an attribution of only the handwritten lines changed by this PR. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a3f004f240
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const statePath = path.join(distDir, 'internal/auth/x509-transport-state.mjs'); | ||
| const relativeStatePath = path.relative(path.dirname(file), statePath).split(path.sep).join('/'); | ||
| const stateSpecifier = relativeStatePath.startsWith('.') ? relativeStatePath : `./${relativeStatePath}`; | ||
| const transformed = code.replaceAll(/from (['"])#x509-transport-state\1/g, `from '${stateSpecifier}'`); |
There was a problem hiding this comment.
Add a native-browser regression for the rewritten imports
This packaging fix rewrites the private package import and introduces runtime selection between browser and CommonJS state, but the commit adds no focused regression exercising the built public SDK in a native browser. A future compiler or postprocessor change could therefore reintroduce the unresolved #x509-transport-state specifier—or break the shim-dependent fallback—without any test failing; add a public-entrypoint browser test that fails against the parent revision and passes with this rewrite.
AGENTS.md reference: AGENTS.md:L18-L21
Useful? React with 👍 / 👎.
Changes being requested
Fixes #2494.
process,module, andexportsshims.This is intentionally the production-only release fix. Expanded browser and bundler regression coverage will follow separately.
Additional context & links
Verified locally:
process,module, andexportsshims.pnpm build,pnpm lint,pnpm exec tsc, and 196 focused authentication/browser-security tests pass.