-
Notifications
You must be signed in to change notification settings - Fork 612
publish Node.js module compatible ESM (.mjs) artifacts #3622
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
Comments
HI @JamesKyburz thanks for bringing this up, one of the many solutions is indeed to rename the files, the team is already aware of this and working on a solution. Will keep you posted. |
@ajredniwja Thanks, I have quite a long exclude list when deploying lambdas the keep the size down :) Some of them are - '!./**/node_modules/typescript'
- '!./**/node_modules/@types'
- '!./**/node_modules/@aws-sdk/**/dist-es'
- '!./**/node_modules/@aws-sdk/**/dist-types'
- '!./**/CHANGELOG.md'
- '!./**/LICENSE*'
- '!./**/README.md' |
Even without the file name extensions the use of the The |
Can we get an update on this? The follow very basic example fails despite aws docs mentioning ESM in several places
|
I'm also interested in when this can be rectified |
@ajredniwja can we get some kind of update? |
bump |
It would be helpful for us as well to get an update/resolution on this soon; thanks! |
Ditto, a response would be really appreciated. Thank you! |
same |
The community is eager for a fix |
Can the community do something to help fix this? What are the next steps? |
Also interested, thanks! |
I'm also interested in getting an eta for this one! |
Please, I need this fix too. |
+1 hope this gets fixed asap |
A good start would be making sure all relative imports use file extensions |
Please build and host your esm dist. I can recommend a CDN service called CloudFront. Then dog food it, no build tools especially with flagship clients, <javascript type="module">
import { initializeApp } from "https://www.gstatic.com/firebasejs/9.9.3/firebase-app.js";
const firebaseConfig = {}
const app = initializeApp(firebaseConfig);
</javascript> |
Oh wow they are actually resolving now, at least the ones i just tried, haven't tried again with node build tools. <!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<!--
JSPM Generator Import Map
Edit URL: https://generator.jspm.io/#U2VhYGDhD80rySzJSU1hcEgsL9YtTsnWT87JTM0r0U3OT8/LLMnXzUxJBSmp1C0oyi8DcoocjPUMLQz0DDB0ZGfmpRZnFuuCVOXrFmem5yXmZOalE6cep6piY5gUAOgTvPexAA
-->
<script type="importmap">
{
"imports": {
"@aws-sdk/client-cognito-identity-provider": "https://ga.jspm.io/npm:@aws-sdk/[email protected]/dist-es/index.js",
"@aws-sdk/client-kinesis-video": "https://ga.jspm.io/npm:@aws-sdk/[email protected]/dist-es/index.js",
"@aws-sdk/client-kinesis-video-signaling": "https://ga.jspm.io/npm:@aws-sdk/[email protected]/dist-es/index.js",
"@aws-sdk/client-s3": "https://ga.jspm.io/npm:@aws-sdk/[email protected]/dist-es/index.js"
},
"scopes": {
"https://ga.jspm.io/": {
"@aws-crypto/crc32": "https://ga.jspm.io/npm:@aws-crypto/[email protected]/build/index.js",
"@aws-crypto/crc32c": "https://ga.jspm.io/npm:@aws-crypto/[email protected]/build/index.js",
"@aws-crypto/util": "https://ga.jspm.io/npm:@aws-crypto/[email protected]/build/index.js",
"@aws-sdk/client-sso": "https://ga.jspm.io/npm:@aws-sdk/[email protected]/dist-es/index.js",
"@aws-sdk/client-sts": "https://ga.jspm.io/npm:@aws-sdk/[email protected]/dist-es/index.js",
"@aws-sdk/config-resolver": "https://ga.jspm.io/npm:@aws-sdk/[email protected]/dist-es/index.js",
"@aws-sdk/credential-provider-env": "https://ga.jspm.io/npm:@aws-sdk/[email protected]/dist-es/index.js",
"@aws-sdk/credential-provider-imds": "https://ga.jspm.io/npm:@aws-sdk/[email protected]/dist-es/index.js",
"@aws-sdk/credential-provider-ini": "https://ga.jspm.io/npm:@aws-sdk/[email protected]/dist-es/index.js",
"@aws-sdk/credential-provider-node": "https://ga.jspm.io/npm:@aws-sdk/[email protected]/dist-es/index.js",
"@aws-sdk/credential-provider-process": "https://ga.jspm.io/npm:@aws-sdk/[email protected]/dist-es/index.js",
"@aws-sdk/credential-provider-sso": "https://ga.jspm.io/npm:@aws-sdk/[email protected]/dist-es/index.js",
"@aws-sdk/credential-provider-web-identity": "https://ga.jspm.io/npm:@aws-sdk/[email protected]/dist-es/index.js",
"@aws-sdk/eventstream-codec": "https://ga.jspm.io/npm:@aws-sdk/[email protected]/dist-es/index.js",
"@aws-sdk/eventstream-serde-config-resolver": "https://ga.jspm.io/npm:@aws-sdk/[email protected]/dist-es/index.js",
"@aws-sdk/eventstream-serde-node": "https://ga.jspm.io/npm:@aws-sdk/[email protected]/dist-es/index.js",
"@aws-sdk/eventstream-serde-universal": "https://ga.jspm.io/npm:@aws-sdk/[email protected]/dist-es/index.js",
"@aws-sdk/hash-node": "https://ga.jspm.io/npm:@aws-sdk/[email protected]/dist-es/index.js",
"@aws-sdk/hash-stream-node": "https://ga.jspm.io/npm:@aws-sdk/[email protected]/dist-es/index.js",
"@aws-sdk/is-array-buffer": "https://ga.jspm.io/npm:@aws-sdk/[email protected]/dist-es/index.js",
"@aws-sdk/middleware-bucket-endpoint": "https://ga.jspm.io/npm:@aws-sdk/[email protected]/dist-es/index.js",
"@aws-sdk/middleware-content-length": "https://ga.jspm.io/npm:@aws-sdk/[email protected]/dist-es/index.js",
"@aws-sdk/middleware-expect-continue": "https://ga.jspm.io/npm:@aws-sdk/[email protected]/dist-es/index.js",
"@aws-sdk/middleware-flexible-checksums": "https://ga.jspm.io/npm:@aws-sdk/[email protected]/dist-es/index.js",
"@aws-sdk/middleware-host-header": "https://ga.jspm.io/npm:@aws-sdk/[email protected]/dist-es/index.js",
"@aws-sdk/middleware-location-constraint": "https://ga.jspm.io/npm:@aws-sdk/[email protected]/dist-es/index.js",
"@aws-sdk/middleware-logger": "https://ga.jspm.io/npm:@aws-sdk/[email protected]/dist-es/index.js",
"@aws-sdk/middleware-recursion-detection": "https://ga.jspm.io/npm:@aws-sdk/[email protected]/dist-es/index.js",
"@aws-sdk/middleware-retry": "https://ga.jspm.io/npm:@aws-sdk/[email protected]/dist-es/index.js",
"@aws-sdk/middleware-sdk-s3": "https://ga.jspm.io/npm:@aws-sdk/[email protected]/dist-es/index.js",
"@aws-sdk/middleware-sdk-sts": "https://ga.jspm.io/npm:@aws-sdk/[email protected]/dist-es/index.js",
"@aws-sdk/middleware-serde": "https://ga.jspm.io/npm:@aws-sdk/[email protected]/dist-es/index.js",
"@aws-sdk/middleware-signing": "https://ga.jspm.io/npm:@aws-sdk/[email protected]/dist-es/index.js",
"@aws-sdk/middleware-ssec": "https://ga.jspm.io/npm:@aws-sdk/[email protected]/dist-es/index.js",
"@aws-sdk/middleware-stack": "https://ga.jspm.io/npm:@aws-sdk/[email protected]/dist-es/index.js",
"@aws-sdk/middleware-user-agent": "https://ga.jspm.io/npm:@aws-sdk/[email protected]/dist-es/index.js",
"@aws-sdk/node-config-provider": "https://ga.jspm.io/npm:@aws-sdk/[email protected]/dist-es/index.js",
"@aws-sdk/node-http-handler": "https://ga.jspm.io/npm:@aws-sdk/[email protected]/dist-es/index.js",
"@aws-sdk/property-provider": "https://ga.jspm.io/npm:@aws-sdk/[email protected]/dist-es/index.js",
"@aws-sdk/protocol-http": "https://ga.jspm.io/npm:@aws-sdk/[email protected]/dist-es/index.js",
"@aws-sdk/querystring-builder": "https://ga.jspm.io/npm:@aws-sdk/[email protected]/dist-es/index.js",
"@aws-sdk/querystring-parser": "https://ga.jspm.io/npm:@aws-sdk/[email protected]/dist-es/index.js",
"@aws-sdk/service-error-classification": "https://ga.jspm.io/npm:@aws-sdk/[email protected]/dist-es/index.js",
"@aws-sdk/shared-ini-file-loader": "https://ga.jspm.io/npm:@aws-sdk/[email protected]/dist-es/index.js",
"@aws-sdk/signature-v4": "https://ga.jspm.io/npm:@aws-sdk/[email protected]/dist-es/index.js",
"@aws-sdk/signature-v4-multi-region": "https://ga.jspm.io/npm:@aws-sdk/[email protected]/dist-es/index.js",
"@aws-sdk/smithy-client": "https://ga.jspm.io/npm:@aws-sdk/[email protected]/dist-es/index.js",
"@aws-sdk/url-parser": "https://ga.jspm.io/npm:@aws-sdk/[email protected]/dist-es/index.js",
"@aws-sdk/util-arn-parser": "https://ga.jspm.io/npm:@aws-sdk/[email protected]/dist-es/index.js",
"@aws-sdk/util-base64-node": "https://ga.jspm.io/npm:@aws-sdk/[email protected]/dist-es/index.js",
"@aws-sdk/util-body-length-node": "https://ga.jspm.io/npm:@aws-sdk/[email protected]/dist-es/index.js",
"@aws-sdk/util-buffer-from": "https://ga.jspm.io/npm:@aws-sdk/[email protected]/dist-es/index.js",
"@aws-sdk/util-config-provider": "https://ga.jspm.io/npm:@aws-sdk/[email protected]/dist-es/index.js",
"@aws-sdk/util-defaults-mode-node": "https://ga.jspm.io/npm:@aws-sdk/[email protected]/dist-es/index.js",
"@aws-sdk/util-hex-encoding": "https://ga.jspm.io/npm:@aws-sdk/[email protected]/dist-es/index.js",
"@aws-sdk/util-middleware": "https://ga.jspm.io/npm:@aws-sdk/[email protected]/dist-es/index.js",
"@aws-sdk/util-stream-node": "https://ga.jspm.io/npm:@aws-sdk/[email protected]/dist-es/index.js",
"@aws-sdk/util-uri-escape": "https://ga.jspm.io/npm:@aws-sdk/[email protected]/dist-es/index.js",
"@aws-sdk/util-user-agent-node": "https://ga.jspm.io/npm:@aws-sdk/[email protected]/dist-es/index.js",
"@aws-sdk/util-utf8-browser": "https://ga.jspm.io/npm:@aws-sdk/[email protected]/dist-es/index.js",
"@aws-sdk/util-utf8-node": "https://ga.jspm.io/npm:@aws-sdk/[email protected]/dist-es/index.js",
"@aws-sdk/util-waiter": "https://ga.jspm.io/npm:@aws-sdk/[email protected]/dist-es/index.js",
"@aws-sdk/xml-builder": "https://ga.jspm.io/npm:@aws-sdk/[email protected]/dist-es/index.js",
"buffer": "https://ga.jspm.io/npm:@jspm/[email protected]/nodelibs/browser/buffer.js",
"child_process": "https://ga.jspm.io/npm:@jspm/[email protected]/nodelibs/browser/child_process.js",
"crypto": "https://ga.jspm.io/npm:@jspm/[email protected]/nodelibs/browser/crypto.js",
"entities": "https://ga.jspm.io/npm:[email protected]/lib/dev.index.js",
"fast-xml-parser": "https://ga.jspm.io/npm:[email protected]/src/parser.js",
"fs": "https://ga.jspm.io/npm:@jspm/[email protected]/nodelibs/browser/fs.js",
"http": "https://ga.jspm.io/npm:@jspm/[email protected]/nodelibs/browser/http.js",
"http2": "https://ga.jspm.io/npm:@jspm/[email protected]/nodelibs/browser/http2.js",
"https": "https://ga.jspm.io/npm:@jspm/[email protected]/nodelibs/browser/https.js",
"os": "https://ga.jspm.io/npm:@jspm/[email protected]/nodelibs/browser/os.js",
"path": "https://ga.jspm.io/npm:@jspm/[email protected]/nodelibs/browser/path.js",
"process": "https://ga.jspm.io/npm:@jspm/[email protected]/nodelibs/browser/process.js",
"stream": "https://ga.jspm.io/npm:@jspm/[email protected]/nodelibs/browser/stream.js",
"tslib": "https://ga.jspm.io/npm:[email protected]/tslib.es6.js",
"url": "https://ga.jspm.io/npm:@jspm/[email protected]/nodelibs/browser/url.js",
"util": "https://ga.jspm.io/npm:@jspm/[email protected]/nodelibs/browser/util.js",
"uuid": "https://ga.jspm.io/npm:[email protected]/dist/esm-browser/index.js"
},
"https://ga.jspm.io/npm:@aws-crypto/[email protected]/": {
"tslib": "https://ga.jspm.io/npm:[email protected]/tslib.es6.js"
},
"https://ga.jspm.io/npm:@aws-crypto/[email protected]/": {
"tslib": "https://ga.jspm.io/npm:[email protected]/tslib.es6.js"
}
}
}
</script>
<!-- ES Module Shims: Import maps polyfill for modules browsers without import maps support (all except Chrome 89+) -->
<script async src="https://ga.jspm.io/npm:[email protected]/dist/es-module-shims.js" crossorigin="anonymous"></script>
<script type="module">
import * as SdkClientCognitoIdentityProvider from "@aws-sdk/client-cognito-identity-provider";
import * as SdkClientKinesisVideo from "@aws-sdk/client-kinesis-video";
import * as SdkClientKinesisVideoSignaling from "@aws-sdk/client-kinesis-video-signaling";
import * as SdkClientS3 from "@aws-sdk/client-s3";
// Write main module code here, or as a separate file with a "src" attribute on the module script.
console.log(SdkClientCognitoIdentityProvider, SdkClientKinesisVideo, SdkClientKinesisVideoSignaling, SdkClientS3);
</script>
</body>
</html> |
One way forward would be to
|
Any news on this as Lambda Node 20 is probably coming soon? |
jest would probably have to be fixed too for this to be pushed forward? |
Any news? |
bump!!! |
Any news? |
1 similar comment
Any news? |
Hi everyone, I apologize for not seeing this issue sooner. ES node distribution is not offered since our ES distribution is for bundlers only. Thanks, |
This issue has not received a response in 1 week. If you still think there is a problem, please leave a comment to avoid the issue from automatically closing. |
I don't understand this statement:
I followed this issue because I had trouble building my application with your SDK when I wanted to use ESM everywhere in a serverless (Lambda) microservice. I punted on building a ESM target for Lambda due to this issue. I've moved on and I only upload CommonJS to Lambda now. It's a shame as no one wants to read mangled CommonJS code and ESM would be so much more elegant when troubleshooting a Lambda application. Please take all the feedback in this thread as a request for something better than what is currently offered. |
I see two feature requests in this issue: 1 - host a CDN distribution of the AWS SDK in the ESM format on a CDN called CloudFrontWe don't plan to do this. We recommend using a web bundler to incorporate the AWS SDK into your application by downloading it from NPM. 2 - provide a Node.js ESM (MJS) distributionWe are not opposed to this, however it will be a large undertaking and it is not currently a planned project. Although there is a lot of engagement on this issue, it is mostly bumps and plus-ones. I would like to hear more about specific use cases, which could help increase the priority of this request. So far, I only see one reason provided, that of having easier-to-read code for troubleshooting on AWS Lambda. For some context, we currently prioritize the CJS distribution for use in Node.js because |
@RanVaknin Thanks for the clarification, that makes sense. It does mean though when not using a bundler a lot of files need to be deleted that aren't used. i.e dist-es :) I understand changing tsconfig to confirm to node compatible ESM would require a lot of work! |
@kuhe while I understand the reluctance to do a large rewrite of the codebase, there are other ways to solve this issue: 1. Custom transformer while Typescript itself does not have first-class support for appending extensions to the output, this could be solved with a custom transformer that simply appends the While not tested, based on what I could glean from the project setup and the outputs of the Potential downsides:
2. Monkey patch the existing build If the build times/backwards compatibility is an issue, monkey patching the existing 3. Rollup Or just use rollup for the build process, which can already do this, and would be backwards compatible with both cjs and browser esm. The project already uses vite in some places, so this wouldn't really be an extra dependency. In case any of these sound like a viable solution, I'm open to help with this. |
@kuhe frameworks like rails prefer using using importmaps https://guides.rubyonrails.org/working_with_javascript_in_rails.html this can also apply to any non node.js backend that don't have nodejs stack |
Describe the bug
The
dist-es
code published to NPM is never run when no bundler is used.Your environment
SDK version number
@aws-sdk/<all I think>@3.94.0
Is the issue in the browser/Node.js/ReactNative?
No
Details of the browser/Node.js/ReactNative version
Paste output of
npx envinfo --browsers
ornode -v
orreact-native -v
LTS
version of nodeNow using node v16.15.0 (npm v8.5.5)
Steps to reproduce
Observed behavior
The code shipped in
dist-es
doesn't work in Node either because it's non standard (for example file extensions are missing).Adding the
exports
field to package.json +index.mjs
would work if the dist-es code was compatible with node.Expected behavior
Using this module with vanilla node runs the ESM code.
Screenshots
If applicable, add screenshots to help explain your problem.
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: