dormd / rich-logger-decorator

Rich Logger Typescript Decorator for Easy Coding & Debugging
https://medium.com/@dormoshe/rich-typescript-logger-decorator-for-easy-coding-fc2ff73684c6
MIT License
99 stars 19 forks source link

commonjs es6 module resolution #2

Open ngmariusz opened 7 years ago

ngmariusz commented 7 years ago

Hi, How you make it work with

       // tsconfig.json
        "module": "commonjs",
        "target": "es6",

?

dormd commented 7 years ago

There are some problems with this configurations?

chetmurphy commented 7 years ago

My understanding is that node module must in the commonjs format - not es6 or esnext.

I get the error: rich-logger-decorator\src\index.ts:1 ({"Object.":function(module,exports,require,dirname,filename,global,jest){export * from './interfaces'; for the keyword 'export'.

mrosack commented 7 years ago

I'm having problems using the library as well... import { ClassLogger } from "rich-logger-decorator"; gives me the error Cannot find module 'rich-logger-decorator' on compilation, and import { ClassLogger } from "rich-logger-decorator/dist/src"; gives the same error @chetmurphy mentions above at runtime.

dormd commented 7 years ago

This error may be appeared when the npm isn't installed. Please add a plunker

mrosack commented 7 years ago

Sure, here's a fresh angular cli project where i just try to add ClassLogger and it doesn't work. I think you need to compile your module to commonjs so it'll work with webpack (but I'm not an expert on these things).

https://github.com/mrosack/rich-logger-decorator-test

marvelsrp commented 7 years ago

+1 Not work import library. Cannot find module 'rich-logger-decorator'.

nelisbijl commented 7 years ago

changing main in package.json does the trick: "main": "dist/src/index.js",

Roustalski commented 6 years ago

I have resolved the above mentioned issues, but I also changed the log output. I opened a PR.

Details: https://github.com/Roustalski/rich-logger-decorator/blob/master/README.md