lukeed / klona

A tiny (240B to 501B) and fast utility to "deep clone" Objects, Arrays, Dates, RegExps, and more!
MIT License
1.62k stars 43 forks source link

klona is not a function #25

Closed joeosburn closed 4 years ago

joeosburn commented 4 years ago

Hey Luke,

Myself and a coworker have been running into an issue with klona. When we attempt to use klona with CommonJS, such as the following:

const klona = require('klona');
....
const dup = klona(data);

We get the error: klona is not a function.

All other requires seem to be working and I've tried deconstructing the require as well. Any idea what the issue might be?

lukeed commented 4 years ago

Hey, klona is a named export.

const { klona } = require('klona');
// Or
import { klona } from 'klona';
joeosburn commented 4 years ago

Thanks. I've tried:

const { klona } = require('klona');

And I get the exact same error. When I log the value of klona this way, it's undefined.

edit: I updated to the latest version of klona and that solved it. Thanks!

lukeed commented 4 years ago

Ah I was going to say, there's no way you're using 2.x then

The named export was the breaking change from 1.x to 2.x. Your intellisense might not like 1.x but that's part of the reason for the named export.

Closing since you got it working. Thanks!