-
Notifications
You must be signed in to change notification settings - Fork 59
ES module support #44
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
So cracking open the latest // If still not loaded, try .js, .mjs, and .cjs in that order.
// Files ending with .js are loaded as ES modules when the nearest parent package.json
// file contains a top-level field "type" with a value of "module".
// https://nodejs.org/api/packages.html#packages_type
const loaded =
(pjHasModule && _tryAwaitImport(lambdaStylePath, ".js")) ||
_tryAwaitImport(lambdaStylePath, ".mjs") ||
_tryRequireFile(lambdaStylePath, ".cjs"); so it looks to have been added, but hasn't made it up to this repo yet? |
It's now more than halfway through June. Is there any update on this issue? It's pretty critical not to be able to use ES modules in 2022. |
Same here, we need this asap. |
Within ES modules (type is module inside package.json), if you try to either: ``` require('file') require('file.js') ``` it does not allow that as imports should be used within ES modules. The only way to use require() is to explicitly require `.cjs` file which explicitly insidicates that path is a CommonJS file, not ESM: ``` require('file.cjs') ``` This change allows to require .cjs files when a user function is being searched. I would imagine eventually this library would need to fully support ES modules as per aws#44 however this diff will allow people to use lambdas within ES modules if they have .cjs lambda files.
Don't want to repeat the same request but it would be great it to get some response from maintainers |
This is fixed in #70. |
https://aws.amazon.com/about-aws/whats-new/2022/01/aws-lambda-es-modules-top-level-await-node-js-14/
Also; is this maintained? Last commit Nov 3 2021, open issues and outstanding PRs.
The text was updated successfully, but these errors were encountered: