Skip to content

issue-245: fix CommonJS interoperability in tsc-multi and shim files #258

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

CharlieGreenman
Copy link

Copy link

changeset-bot bot commented Jul 25, 2025

⚠️ No Changeset found

Latest commit: 8cfb0a1

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@CharlieGreenman
Copy link
Author

I wasn't quite able to get this deployed and I'm not certain this works. If would like I will close

Copy link
Member

@seratch seratch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much for sending this. As mentioned at one of the comments, this should be good to go, but we need more tests and add automated tests under https://github.com/openai/openai-agents-js/tree/main/integration-tests; I will work on it later this week. If you're willing to help us complete these too, it'd be appreciated.

@@ -1,6 +1,6 @@
{
"targets": [
{ "extname": ".js", "module": "es2022", "moduleResolution": "node" },
{ "extname": ".js", "module": "commonjs", "moduleResolution": "node" },
Copy link
Member

@seratch seratch Jul 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for changing this. This change looks reasonable, but we need to verify these before merging the change:

I will spend time on this later this week soon.

@CharlieGreenman
Copy link
Author

CharlieGreenman commented Jul 28, 2025

@seratch sure, feel to work on and close this pull request whenever. Unfortunately. I'm not sure if I will be able to work on in a timely fashion. This is no longer blocking me(was able to work around albeit took time) so no rush. You have my thanks

Co-authored-by: Kazuhiro Sera <[email protected]>
@vrtnis
Copy link
Contributor

vrtnis commented Aug 4, 2025

hey @seratch! quick note up front: thanks to @CharlieGreenman for the import.meta shim idea, it’s folded in here.

on the Lambda side: the node 22 runtime still ships without automatic module-syntax detection. i do not believe there is a public commitment from aws to change that e.g. see aws-lambda-base-images#233. NODE_OPTIONS=--experimental-require-module is ignored, and the original Compute blog post hasn’t been updated since launch.

so here we’re still hitting two gaps that need addressing. (1) build artifacts: we need both the ESM and CJS outputs, properly wired via the exports field, so environments like lambda and jest can safely require() the SDK without breaking compatibility for existing ESM consumers.

(2) there’s runtime safety. I think the sdk's shims must avoid unguarded access to import.meta so that CJS environments don’t crash when executing runtime code like loadEnv().

Given everything that needs to land here, I think a fresh PR is the cleanest path forward. I’m putting one together to handle both the dual-build setup and the shim guard. (and would include integration tests that cover import, require, and execution inside the relevant Lamda runtime). I'll have it wrapped up tmrw for review.

@seratch
Copy link
Member

seratch commented Aug 4, 2025

Thanks for the inputs. I believe the direction should be good to go, but I just don't have time to do thorough testing right now. Any inputs / suggestions / contributions for this would be greatly appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants