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

Claudia with Node 14 and ES6 #237

Open
oakleaf opened this issue Jul 12, 2022 · 2 comments
Open

Claudia with Node 14 and ES6 #237

oakleaf opened this issue Jul 12, 2022 · 2 comments

Comments

@oakleaf
Copy link

oakleaf commented Jul 12, 2022

Since Lambda now supports Node14, it makes sense to support ES6 modules? Maybe Im doing something crazy here, but I just installed latest Claudia.js on my macOS M1, it seems to be homebrewed.

  • Expected behaviour:
    Be able to create / use Claudia with ES6 modules/development

  • What actually happens:
    When running "claudia create --region eu-north-1 --handler index.handler", I get errors about not using ES5 structure

Console:

bash-3.2# claudia create --region eu-north-1 --handler index.handler
packaging files npm install -q --no-audit --production
npm WARN config production Use `--omit=dev` instead.

added 223 packages in 1s

3 packages are looking for funding
validating package
Error [ERR_REQUIRE_ESM]: require() of ES Module /private/tmp/MsKutW/hello_world-1.0.0-KAgNGL/package/index.js from /opt/homebrew/lib/node_modules/claudia/src/tasks/validate-package.js not supported.
Instead change the require of index.js in /opt/homebrew/lib/node_modules/claudia/src/tasks/validate-package.js to a dynamic import() which is available in all CommonJS modules.
    at validatePackage (/opt/homebrew/lib/node_modules/claudia/src/tasks/validate-package.js:16:15)
    at /opt/homebrew/lib/node_modules/claudia/src/commands/create.js:370:10
cannot require ./index after clean installation. Check your dependencies.
  • Link to a minimal, executable project that demonstrates the problem:
import { v4 as uuidv4 } from "uuid";

export const handler = async (e) => {
console.log("hello world");
};
  • Steps to install the project:
    In package.js, use "type": "module" to enable ES6 compability

  • Steps to reproduce the problem:
    Create an ES6 project, with "import" instead of "require", with "type": "module" in package.js. Im getting those errors above..

Thanks!

@laspero
Copy link

laspero commented Nov 17, 2022

Claudia needs to provide support for ES Modules in order to provide top level awaits. Without this functionality a different set of tools will be required. Is there any active support for this or should I just move to a different toolkit?

@eross220
Copy link

I had same problem.
are there any updates?

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

3 participants