feat: export winston's stock npm levels alongside the custom defaults#140
Merged
feat: export winston's stock npm levels alongside the custom defaults#140
Conversation
Adds `winstonDefaultLevels` / `winstonDefaultLevelColors` so consumers can opt back into winston's built-in npm level set via `loggerOptions.levels` without reaching into `winston.config.npm`. Colours register automatically on first use, mirroring the existing behaviour for `defaultLevels`. Also exposes `defaultLevelColors` for parity. https://claude.ai/code/session_01Ap9pEtBBrZBzqmwtZb3gzr
- rollup CJS output now uses interop:'auto', so default imports of yamlify-object (whose CJS build sets exports.default + __esModule but no module.exports = fn) are unwrapped at the call site instead of throwing TypeError: yamlifyObject is not a function. Only the CJS bundle was affected; the .mjs build resolved through yamlify-object's `import` condition correctly already. - Re-add per-module subpath entries to the dist package.json's `exports` field via tstoolkit config, so deep-imports like `@makerx/node-winston/serialize-error` resolve again instead of hitting ERR_PACKAGE_PATH_NOT_EXPORTED. Restores the v1.2-and-earlier shape that the v1.3 modernify lost when it added a single-`.` exports field. Validated by attw across node10/node16-cjs/node16-esm/bundler. https://claude.ai/code/session_01Ap9pEtBBrZBzqmwtZb3gzr
Drop the per-module `exports` map: v2 ships a single `.` entry, so deep imports like `@makerx/node-winston/serialize-error` are intentionally unsupported. Every public format, helper and type is re-exported from the root entry. The `./serialize-error` subpath specifically has no replacement — `serialize-error` is now a peer dependency, so consumers who want the underlying serializer should import it from that package directly rather than through us. The yamlify-object CJS interop fix in rollup.config.ts (interop:'auto') stays — that's an unrelated runtime bug. https://claude.ai/code/session_01Ap9pEtBBrZBzqmwtZb3gzr
CI's `npm run audit` was failing on GHSA-qx2v-qp2m-jg93 (PostCSS XSS in CSS Stringify Output) — pulled in transitively via vitest → vite → postcss@8.5.9. Pin postcss to ^8.5.10 via npm `overrides` so we get the patched version without waiting on a vitest/vite release. postcss is dev-only here (we don't process CSS); the override just keeps the audit job green. https://claude.ai/code/session_01Ap9pEtBBrZBzqmwtZb3gzr
- Split the serialize-error breaking change into two precise bullets: the wire-format shape change (now includes name/cause/own-props/ circular-ref handling via the serialize-error peer dep) and the logger-level promotion (errors are now serialised on every transport, not just inside the Console's format.json — custom transports that expected an Error instance need to read the plain object now). - Drop "omit/redact handling" from the omitPaths bullet; redact didn't exist in v1 so the wording was anachronistic. - Surface redactPaths as a drop-in replacement for any hand-rolled redaction in v1 loggerOptions.format / custom transports — calls out that, like omitPaths, it applies at the logger level across every transport. - Add a new-functionality bullet for mapAuditLevelForOtel (was documented in its own section but missing from the migration list). - Tighten the serializeErrorFormat new-functionality bullet to focus on the standalone format / pluggable serializer; the behaviour change now lives in the breaking-changes section where it belongs. https://claude.ai/code/session_01Ap9pEtBBrZBzqmwtZb3gzr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
feat— AddswinstonDefaultLevels/winstonDefaultLevelColorsso consumers can opt back into winston's built-in npm level set vialoggerOptions.levelswithout reaching intowinston.config.npm. Colours register automatically on first use, mirroring the existing behaviour fordefaultLevels. Also exposesdefaultLevelColorsfor parity, and adds aWinstonDefaultLoggertype alias.fix(cjs)— Rollup's CJS output now usesinterop: 'auto'. Default imports ofyamlify-object(whose CJS build setsexports.default = fn+__esModule: truewith nomodule.exports = fnshim) were being emitted asvar yamlifyObject = require('yamlify-object')and then called directly, throwingTypeError: yamlifyObject is not a functionfor CJS consumers. Withinterop: 'auto', Rollup emits a runtime__esModulecheck and unwraps.defaultat the call site. The.mjsbuild was unaffected — it resolved throughyamlify-object'simportcondition correctly already. Verified end-to-end with a Node smoke test ofrequire('./dist/index.js')+createLogger({ consoleFormat: 'pretty' }).docs— Documents in the v1 → v2 migration notes that submodule deep-imports (e.g.@makerx/node-winston/redact-format) are intentionally not part of v2's surface — every public format/helper/type is re-exported from the root entry. The./serialize-errorsubpath specifically has no replacement:serialize-erroris now a peer dependency, so consumers wanting the underlying serializer should import it from that package directly rather than through us.fix(audit)— Pins transitivepostcssto^8.5.10via npmoverridesto clear GHSA-qx2v-qp2m-jg93 (XSS in CSS Stringify Output, pulled in through vitest → vite → postcss@8.5.9). postcss is dev-only here.Test plan
npm test— all 46 tests pass (existing suite + new tests coveringwinstonDefaultLevelsexports and method shape, plus a@ts-expect-errorconfirmingauditis rejected on the winston-default-typed logger)npm run lint/npm run check-types— cleannpm run build—attwreports 🟢 across node10 / node16 (CJS) / node16 (ESM) / bundlernpm run audit—🤝 All good!(postcss override applied, lockfile rehydrates cleanly vianpm ci)require('./dist/index.js')+createLogger({ consoleFormat: 'pretty' }).info(...)no longer throws on yamlifyimport { yamlify } from './dist/pretty-console-format.mjs'still workshttps://claude.ai/code/session_01Ap9pEtBBrZBzqmwtZb3gzr