How do I use `tslog` (esm)
I honestly don't understand es modules that well. I know how it's intded to work but never really understood the interop modes with typescript and other bundlers. I'm trying to use
tslog
which is exported as an es moudle but when I do a standard import and try to use it, I get logger.ts:6 Uncaught TypeError: _tslog.Logger is not a constructor
. Any ideas on what I should be doing?10 Replies
Just doing
also tried
import * as tslog from 'tslog'
Some ESM stuff is happening, heres the full trace
Is tslog's package.json a proper ESM module? (i.e parsable by the native node resolver)
Otherwise, if it's relying on webpack fallback (like a hybrid), we would need to add it into the ESM resolver list, or we need to create a new configuration feature for ppl to pass down these ESM modules....
Since there're modules that is compiled as ESM, but they didnt' fix their package.json to denote they are ESM...
I do see
"type": "module",
when I look through my node_modules
https://github.com/fullstack-build/tslog/blob/master/package.json#L16I misread the err you got - it's a runtime err
Yep, im honestly not even sure what to do to debug
try doing this:
Empty object
GitHub
Usage with parcel? · Issue #239 · fullstack-build/tslog
Hello, I get the error @parcel/core: node_modules/tslog/dist/browser/index.js does not export 'Logger' when building a bare parcel webextension project at the latest versions. Here is a rep...
Plasmo uses parcel right?
Adding
to my package.json worked
I looked through the open issues but not the closed one, my bad!