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

ESM exports broken in module environment #1437

Open
DanielOrtel opened this issue Oct 22, 2024 · 0 comments
Open

ESM exports broken in module environment #1437

DanielOrtel opened this issue Oct 22, 2024 · 0 comments

Comments

@DanielOrtel
Copy link

DanielOrtel commented Oct 22, 2024

When running in an ESM environment, shared-ini-file-loader(that I know of, but it's possible other packages are outputting incorrect ESM code as well) provides a broken entryfile, resulting in an error with build processes which are strict about this thing in general:

✘ [ERROR] No matching export in "../../node_modules/@smithy/shared-ini-file-loader/dist-es/index.js" for import "getSSOTokenFromFile"

    ../../node_modules/@aws-sdk/credential-provider-sso/dist-es/resolveSSOCredentials.js:4:9:
      4 │ import { getSSOTokenFromFile } from "@smithy/shared-ini-file-loader";

The reason for this is that in ESM, file extensions are mandatory, but the build process doesn't append these for the dist-es build. This is what the current @smithy/shared-ini-file-loader/dist-es/index.js looks like:

export * from "./getHomeDir";
export * from "./getProfileName";
export * from "./getSSOTokenFilepath";
export * from "./getSSOTokenFromFile";
export * from "./loadSharedConfigFiles";
export * from "./loadSsoSessionData";
export * from "./parseKnownFiles";
export * from "./types";

Manually adding the .js file extensions in my own node_modules folder fixes this, so this is 100% the issue for the build error. Correct ESM output should be:

export * from "./getHomeDir.js";
export * from "./getProfileName.js";
export * from "./getSSOTokenFilepath.js";
export * from "./getSSOTokenFromFile.js";
export * from "./loadSharedConfigFiles.js";
export * from "./loadSsoSessionData.js";
export * from "./parseKnownFiles.js";
export * from "./types.js";

Edit: may be an issue with the bundler, since running with a simple node command works, but to err on the side of caution, the es export should still contain the proper extensions.

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

No branches or pull requests

1 participant