serverless / serverless-plugin-typescript

Serverless plugin for zero-config Typescript support
MIT License
781 stars 222 forks source link

[BUG] This plugin borks something with package artifacts #287

Open darylteo opened 1 year ago

darylteo commented 1 year ago

I'm using the package.artifact functionality for a different function that is not typescript. But enabling this plugin borked packaging of other functions using package.artifact.

I'm not sure how else to describe it so here's a video.

https://imgur.com/DnztNvA

From this it seems that it mangles a path library, or maybe changes the state of the serverless options which causes problems down the chain of plugins.

Even if I move the artifact to the place it tries to look at (in the .build directory), it then tries to inside .serverless instead.

https://imgur.com/jlk7k5w

Incredibly annoying, hope I can find a workaround for this.

Reproduction Repro here. https://github.com/darylteo/serverless-plugin-typescript-bug-repro

Does it have something to do with the outDir and rootDir in tsconfig?

darylteo commented 1 year ago

Or is it related to these lines mutating the serverless service?

    if (!this.originalServicePath) {
      // Save original service path and functions
      this.originalServicePath = this.serverless.config.servicePath
      // Fake service path so that serverless will know what to zip
      this.serverless.config.servicePath = path.join(this.originalServicePath, BUILD_FOLDER)
    }

https://github.com/serverless/serverless-plugin-typescript/blob/a1098de63f4f36b7ece330f53b9384f7de2bdafa/src/index.ts#L173

darylteo commented 1 year ago

Okay i should be able to workaround this with serverless compose since the change is limited only to the service.

Complicates things a bit but I think it's workable. Just noisy because I would to set up separate services which creates separate stacks, and also set up vars, envs, and plugins between services.

This is also less ideal because Serverless Compose does not currently support running multiple services under the same serverless-offline instance. https://github.com/dherault/serverless-offline/issues/1386