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

checking for node runtimes does not work in serverless.ts #788

Closed
JacobWithACapitalJ opened this issue Apr 20, 2021 · 2 comments
Closed
Labels
awaiting reply Awaiting for a reply from the OP

Comments

@JacobWithACapitalJ
Copy link

JacobWithACapitalJ commented Apr 20, 2021

Bug Report

Description

when using a Typescript file for serverless configuration, the feature described in PR doesn't seem to check for Node runtimes.

Example serverless.ts:

const common = getCommonConfig();

const slsConfig: Serverless = {
  org: common.org,
  app: common.app,

  service: "test-service",

  plugins: {
    // @ts-expect-error: invalid type, remove comment once fixed
    localPath: "../.serverless_plugins",
    modules: [
      "serverless-offline",
      "serverless-python-requirements",
      "serverless-webpack",
    ],
  },

  provider: {
    ...common.provider,

   runtime: common.node.runtime,

  custom: {
    webpack: common.custom.webpack,
    pythonRequirements: { dockerizePip: true },
  },

  package: {
    individually: true,
  },

  functions: {
    nodetest: {
      handler: "src/functions/nodetest/handler.default",
    },
    pytest: {
      runtime: "python3.8",
      handler: "src/functions/pytest/handler.pytest",
    },
  },
};

export = slsConfig;

This results in webpack trying to run on the src/functions/pytest/handler.py file (using serverless invoke local -f pytest):

Serverless: Bundling with Webpack...
asset src/functions/pytest/handler.js 1.14 KiB [emitted] (name: src/functions/pytest/handler) 1 related asset
./src/functions/pytest/handler.py 310 bytes [built] [code generated] [1 error]

ERROR in ./src/functions/pytest/handler.py 4:0
Module parse failed: Unexpected token (4:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| 
| 
> def pytest(event, context):
|     body = {
|         "message": "Your function executed successfully!",

Expected:

serverless-webpack should identify that the function does not have a node runtime and skip webpack compilation.

(Note: common is simply another typescript file with some of our common configurations used across multiple services)

Additional Data

  • Serverless-Webpack 5.4.1:
  • Webpack 5.23.0:
  • Serverless Framework 2.30.3:
  • Operating System macOS Catalina 10.15.7 19H15 x86_64:
@j0k3r
Copy link
Member

j0k3r commented May 6, 2021

I'm wondering if this could be fixed by #808

@j0k3r
Copy link
Member

j0k3r commented Jun 10, 2021

Could you test again using the 5.5.1? Thanks 🙏

@j0k3r j0k3r added the awaiting reply Awaiting for a reply from the OP label Jun 10, 2021
@j0k3r j0k3r closed this as completed Mar 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting reply Awaiting for a reply from the OP
Projects
None yet
Development

No branches or pull requests

2 participants