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

Misleading error related to TypeScript configuration #1185

Open
lsalazarm99 opened this issue Jun 28, 2022 · 1 comment
Open

Misleading error related to TypeScript configuration #1185

lsalazarm99 opened this issue Jun 28, 2022 · 1 comment

Comments

@lsalazarm99
Copy link

This is a Bug Report

Description

For bug reports:

  • What went wrong? A misleading error message is being shown when there is an error in the TypeScript configuration file. I think the problem is here. It's assuming any error related to that require is because the dependency is missing. This makes you think you have to install the ts-node package as a dependency and not as a development dependecy (as it should be), but that was not the problem. I had to read the value of the catched error in order to realize that it was a problem with my TypeScript configuration file.
  • What did you expect should have happened? I was expecting a correct error message.
  • What was the config you used? Any incorrect TypeScript configuration is valid to reproduce the error.
  • What stacktrace or error message from your provider did you see?

For feature proposals:

  • What is the use case that should be solved. The more detail you describe this in the easier it is to understand for us.
  • If there is additional config how would it look

Similar or dependent issue(s):

Additional Data

  • Serverless-Webpack Version you're using: 5.7.1
  • Webpack version you're using: 5.73.0
  • Serverless Framework Version you're using: 3.19.0
  • Operating System: 5.15.49-1-MANJARO
  • Stack Trace (if available):
@vicary
Copy link
Member

vicary commented Jul 3, 2022

@lsalazarm99 I believe you have seen a few incorrect tsconfig.json already, would you mind making a PR for this?

I could imagine starting with something like the following, and then build unit tests around it.

      try {
        require('ts-node/register');
      } catch (e) {
        if (e.code === "MODULE_NOT_FOUND") {
          throw new Error('If you want to use TypeScript with serverless-webpack, please add "ts-node" as dependency.');
        } else {
          throw e;
        }
      }

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