antfu-collective / local-pkg

Get information on local packages.
MIT License
144 stars 15 forks source link

importModule does not work with @vitest/coverage-c8@0.29.8 #7

Closed dteoh closed 1 year ago

dteoh commented 1 year ago

Describe the bug

I'm not sure which repo is ultimately responsible for this issue, so let me report this here.

I suddenly started running into TypeError: coverageModule.getProvider is not a function when trying to generate coverage with vitest. Let me just skip straight to the investigation results.

It seems like importModule only considers an import to be ESM if the exported object has a truthy __esModule property. Reference: https://github.com/antfu/local-pkg/blob/main/index.mjs#L20

When I look at the code and dumped the module object during debugging, the module object was found, but the default export doesn't have that property. Reference: https://unpkg.com/browse/@vitest/coverage-c8@0.29.8/dist/index.js

After downgrading @vitest/coverage-c8 to 0.29.7 it works again.

Reproduction

I hope my explanation is enough.

System Info

System:
    OS: macOS 12.6.2
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 20.13 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 18.15.0 - ~/.asdf/installs/nodejs/18.15.0/bin/node
    npm: 9.5.0 - ~/.asdf/plugins/nodejs/shims/npm
  Browsers:
    Chrome: 111.0.5563.146
    Firefox: 111.0.1
    Safari: 16.3
    Safari Technology Preview: 16.4

Used Package Manager

pnpm

Validations