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

TypeError: cig is not a function #5

Open
sleeyax opened this issue Sep 14, 2024 · 0 comments
Open

TypeError: cig is not a function #5

sleeyax opened this issue Sep 14, 2024 · 0 comments

Comments

@sleeyax
Copy link

sleeyax commented Sep 14, 2024

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";
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

1 participant