Skip to content

Conversation

@zastrowm
Copy link
Member

@zastrowm zastrowm commented Dec 4, 2025

Description

Update the package exports to account for CommonJS-style imports (require(...)).

Per my research into #310 via https://nodejs.org/api/packages.html#conditional-exports:

Conditional exports provide a way to map to different paths depending on certain conditions. They are supported for both CommonJS and ES module imports.

...

  • "import" - matches when the package is loaded via import or import(), or via any top-level import or resolve operation by the ECMAScript module loader. Applies regardless of the module format of the target file. Always mutually exclusive with "require".
  • "require" - matches when the package is loaded via require(). The referenced file should be loadable with require() although the condition matches regardless of the module format of the target file. Expected formats include CommonJS, JSON, native addons, and ES modules. Always mutually exclusive with "import".

...

  • "default" - the generic fallback that always matches. Can be a CommonJS or ES module file. This condition should always come last.

Rather than duplicating imports for import and require, we'll juse use default; in the future we can decide if we need specific imports for different modules, but right now we can support both.

I also updated it to put types first, as [the documentation]("default" - the generic fallback that always matches. Can be a CommonJS or ES module file. This condition should always come last.) indicates it should be:

  • "types" - can be used by typing systems to resolve the typing file for the given export. This condition should always be included first.

Notes

  • I also moved the test packages file to a sub folder for better grouping; in the future I hope to also update the integ folder to move them to a sub folder of test

Related Issues

#310

Documentation PR

N/A

Type of Change

Bug fix

Testing

How have you tested the change?

  • I ran npm run check

Checklist

  • I have read the CONTRIBUTING document
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • I have added an appropriate example to the documentation to outline the feature, or no new docs are needed
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Per strands-agents#310 we need to specify exports for common-js format; default is the easiest way to do this
@zastrowm zastrowm added this pull request to the merge queue Dec 4, 2025
Merged via the queue into strands-agents:main with commit a8223b5 Dec 4, 2025
8 checks passed
@zastrowm zastrowm deleted the package_targets branch December 4, 2025 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants