-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make winston more ESM friendly #2006
Conversation
@miguelcobain Thanks for your contribution. For non-ESM modules, with your changes, will we still be able to to e.g. |
This should be a non-breaking change for anyone using regular commonjs modules. You can certainly use that import syntax if you use some kind of transpilation step (e.g Babel or Typescript), but ultimately, those tools transpile to regular commonJS I think this change should be non-breaking. Essentially, we're just making it easier for cjs-module-lexer to detect the commonJS named exports, thus improving the esm interoperability. We're just removing some indirection in this PR. Basically, instead of doing: const winston = exports;
winston.version = 123; we're doing the same in a more direct and equivalent way: exports.version = 123; My main question is if things like |
Fair enough. I'm okay with trying this, and we can always update if any other users have issues. |
i tillegg: - fjernet --experimental-modules flagget siden Dockerfile nå kjører med node:16 - bumpet prom api og client pga deprecation warning: ``` (node:22932) [DEP0152] DeprecationWarning: Custom PerformanceEntry accessors are deprecated. Please use the detail property. at PerformanceObserver.<anonymous> (/Users/g161400/dev/git/ditt-nav-arbeidsgiver/server/node_modules/prom-client/lib/metrics/gc.js:42:38) ``` re: - https://github.com/winstonjs/winston/releases/tag/v3.4.0 - winstonjs/winston#2006
i tillegg: - fjernet --experimental-modules flagget siden Dockerfile nå kjører med node:16 - bumpet prom api og client pga deprecation warning: ``` (node:22932) [DEP0152] DeprecationWarning: Custom PerformanceEntry accessors are deprecated. Please use the detail property. at PerformanceObserver.<anonymous> (.../node_modules/prom-client/lib/metrics/gc.js:42:38) ``` re: - https://github.com/winstonjs/winston/releases/tag/v3.4.0 - winstonjs/winston#2006
This PR should make winston friendlier to ESM module named exports.
Basically, with ESM modules, we can't do this:
and instead have to do this:
This is a great blog post that explains the issue: https://simonplend.com/node-js-now-supports-named-imports-from-commonjs-modules-but-what-does-that-mean/