tiny-invariant icon indicating copy to clipboard operation
tiny-invariant copied to clipboard

Fails to import as default in serverless env.

Open amir-ziaei opened this issue 2 years ago • 1 comments

I have a ts serverless repo with the following tsconfig.json:

{
  "compilerOptions": {
    "strict": true,
    "preserveConstEnums": true,
    "strictNullChecks": true,
    "sourceMap": true,
    "allowJs": true,
    "target": "es5",
    "outDir": ".build",
    "moduleResolution": "node",
    "lib": ["es2015"],
    "rootDir": ".",
    "baseUrl": ".",
    "paths": {
      "test-utils/*": ["tests/utils/*"],
      "~/*": ["src/*"]
    },
    "resolveJsonModule": true
  }
}

When I import tiny-invariant with its default import (import invariant from 'tiny-invariant') , my serverless crashes:

TypeError: (0 , tiny_invariant_1.default) is not a function

But if I import it using named import (import * as invariant from 'tiny-invariant'), it works fine except now my vscode starts complaining:

This expression is not callable.
  Type 'typeof import(".../node_modules/tiny-invariant/dist/tiny-invariant")' has no call signatures.ts(2349)

Is there something wrong with my configuration?

amir-ziaei avatar Nov 14 '22 09:11 amir-ziaei

I'm having the same problem with a similar setup, is there any update on this?

ngregrichardson avatar Aug 06 '23 02:08 ngregrichardson