Skip to content
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

Avoid ESM failures when AWS V4 signing is unused #176

Merged
merged 1 commit into from
Aug 21, 2024

Conversation

mdlavin
Copy link
Member

@mdlavin mdlavin commented Aug 21, 2024

Alpha does not work well in a non-ESM because Axios, upstream, adopted ESM in their "unsafe" published source files. This sort of failure is common when adopting the latest Alpha version:

/Users/mattlavin/Projects/graphql-tools-cli/node_modules/@lifeomic/alpha/src/interceptors/aws-v4-signature.js:11
const buildURL_js_1 = __importDefault(require("axios/unsafe/helpers/buildURL.js"));
                                      ^

Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/mattlavin/Projects/graphql-tools-cli/node_modules/axios/lib/helpers/buildURL.js from /Users/mattlavin/Projects/graphql-tools-cli/node_modules/@lifeomic/alpha/src/interceptors/aws-v4-signature.js not supported.

Luckily, the only place that "unsafe" (aka ESM) modules are imported is in the AWS V4 signing support and that is very infrequently used. By making this change, it reduces the failure to only modules that use AWS V4 (nearly nobody and they must already have to deal with it)

This change doesn't avoid the problem completely, but it significantly reduces the impact.

Copy link
Member

@shawnzhu shawnzhu left a comment

Choose a reason for hiding this comment

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

great fix.

Have you trying to upgrade Alpha for repos already?

@mdlavin
Copy link
Member Author

mdlavin commented Aug 21, 2024

How did you discover this problem?

I have run into some variation of the failure in the description every time I try to adopt the latest Alpha in a project. I was finally sick of the problem and wanted a better fix. The error message was pretty helpful at pointing out the problem. I went through a couple different solutions before I ended on this as "best for now"

@mdlavin mdlavin merged commit 8876494 into master Aug 21, 2024
6 checks passed
@mdlavin mdlavin deleted the reduce-failures-when-on-commonjs branch August 21, 2024 20:54
@mdlavin
Copy link
Member Author

mdlavin commented Aug 21, 2024

Have you trying to upgrade Alpha for repos already?

As soon as this as this builds, I'm going to put up a fix to an internal project and I'll add you to the PR

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.

2 participants