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

feat: add support for serverless v4 and typescript #1806

Merged
merged 15 commits into from
Jul 31, 2024

Conversation

DorianMazur
Copy link
Collaborator

@DorianMazur DorianMazur commented Jul 18, 2024

Description

When using Serverless v4 with TypeScript, the following error occurs:

✖ Unhandled exception in handler 'hello'.
✖ Error: Cannot find module 'index'
Require stack:
- /Users/dorianmazur/Documents/simple-serverless4-offline-example/node_modules/serverless-offline/src/lambda/handler-runner/in-process-runner/aws-lambda-ric/UserFunction.js
Runtime.ImportModuleError: Error: Cannot find module 'index'
Require stack:
- /Users/dorianmazur/Documents/simple-serverless4-offline-example/node_modules/serverless-offline/src/lambda/handler-runner/in-process-runner/aws-lambda-ric/UserFunction.js
    at _loadUserApp (/Users/dorianmazur/Documents/simple-serverless4-offline-example/node_modules/serverless-offline/src/lambda/handler-runner/in-process-runner/aws-lambda-ric/UserFunction.js:310:15)
    at async module.exports.load (/Users/dorianmazur/Documents/simple-serverless4-offline-example/node_modules/serverless-offline/src/lambda/handler-runner/in-process-runner/aws-lambda-ric/UserFunction.js:341:21)
    at async InProcessRunner.run (file:///Users/dorianmazur/Documents/simple-serverless4-offline-example/node_modules/serverless-offline/src/lambda/handler-runner/in-process-runner/InProcessRunner.js:41:21)
    at async MessagePort.<anonymous> (file:///Users/dorianmazur/Documents/simple-serverless4-offline-example/node_modules/serverless-offline/src/lambda/handler-runner/worker-thread-runner/workerThreadHelper.js:24:14)
✖ Error: Cannot find module 'index'
Require stack:
- /Users/dorianmazur/Documents/simple-serverless4-offline-example/node_modules/serverless-offline/src/lambda/handler-runner/in-process-runner/aws-lambda-ric/UserFunction.js

You can reproduce this issue with the repository https://github.com/NicoHinderling/simple-serverless4-offline-example/tree/main
Fixes #1800

Motivation and Context

Serverless v4 supports TypeScript out of the box. To resolve the module loading issue, I have updated the UserFunction file and integrated tsx to execute TypeScript files.

How Has This Been Tested?

Unit tests and manually tested the helloTypescript endpoint locally using the test suite located at tests/manual/nodejs

@DorianMazur DorianMazur changed the title [WIP] feat: add support for serverless v4 and typescript feat: add support for serverless v4 and typescript Jul 31, 2024
@DorianMazur DorianMazur marked this pull request as ready for review July 31, 2024 15:58
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.

Serverless V4 Support
1 participant