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

"Warning: Skipping wrapping for Function" when using Typescript function files #729

Open
benzittlau opened this issue Sep 22, 2023 · 1 comment

Comments

@benzittlau
Copy link

I'm attempting to use Typescript with serverless and hit an issue with the dashboard plugin when I changed my function file from a .js extension to .ts. After this change I would see the following error when attempting to invoke my function or deploy it:

Warning: Skipping wrapping for Function: <Your Function Name Here>

This appears to be due to the check on line 38 in the wrapUtils.js file:

const shouldWrapFunction = (ctx, functionConfig) => {
const runtime = functionConfig.runtime
? functionConfig.runtime
: ctx.sls.service.provider.runtime || 'nodejs14.x';
if (runtime.includes('python')) {
return true;
}
if (runtime.includes('nodejs')) {
const handlerPath = functionConfig.handler.split('.').slice(0, -1).join('.');
if (fs.existsSync(path.join(ctx.sls.config.servicePath, `${handlerPath}.js`))) {
return true;
}
if (fs.existsSync(path.join(ctx.sls.config.servicePath, `${handlerPath}.mjs`))) {
return false;
}
}
return false;
};

Effectively if a node runtime is declared in the configuration file the function's file must have a .js extension or the dashboard plugin will skip wrapping the function. Consequently if the file is a typescript file with a .ts extension it won't be wrapped.

It's possible this plugin isn't intended to support typescript functions, but I wasn't able to find an explicit reference in documentation so I've created this issue in case it's intended that the plugin should support functions in Typescript files.

@petegleeson
Copy link

Running into this as well using the serverless-esbuild plugin. I had a look into the zip when this warning is printed and the main difference is the serverless sdk isn't automatically included. I found some explanation of what this SDK is and how to include it when using a bundler https://www.serverless.com/framework/docs/guides/sdk/nodejs

I think the main consequence is that instrumentation isn't automatic. Would like the warning to better describe the tradeoffs though.

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

2 participants