Skip to content

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

@JacobWithACapitalJ

Description

@JacobWithACapitalJ

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:

Metadata

Metadata

Assignees

No one assigned

    Labels

    awaiting replyAwaiting for a reply from the OP

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions