Skip to content

TypeError: cig is not a function #5

@sleeyax

Description

@sleeyax

Installed the library, ran a very basic example and got the error TypeError: cig is not a function.

Runtime

If you run the following code you can see that the default export is actually an object, not the cig function itself:

import cig, { z } from "cigs";

console.log(cig);
> node dist/index.js

{ default: [Getter], z: [Getter] }

So it appears that there's something wrong with the default export.

Compile time

I checked the compiled JS source files and the export looks like this:

var src_default = cig;
export {
  src_default as default,
  z3 as z
};

You'd expect that tsup would just add export default src_default at compile time but for some reason it doesn't...


Related issue: egoist/tsup#985

I'm not sure how you want to continue with this.

The easy work-around is to simply export cig as a named export:

// src/index.ts:19
export { z, cig };

and import it as such:

import { cig, z } from "cigs";

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions