planttheidea/micro-memoize

Import error for common js compiler module type

Closed this issue · 1 comments

I get this error when trying to execute jest unit tests.

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

Import syntax used in codebase

import memoize from 'micro-memoize';

Typescript compiler configured to use CommonJs module for unit tests. I looked what is defined here

image

And seems export for cjs file is defined correctly.

I have created a simple repo to reproduce an error: https://github.com/r0ss0neri/memoise-import-example

steps are simple:

  • clone and install deps
  • just run app.component.spec

Thanks for advice.

As I expected issue is not with library, I enabled esModuleInterop. Now imports are working correctly even for other libraries like lodash