feat: support multiple import styles from JS and TS; add morgan types #165
+409
−121
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.
This updates the three @elastic/ecs-*-format packages to support the following
import styles from JS and TS code:
const { ecsFormat } = require('@elastic/ecs-pino-format);
in JS and TS.The preferred import style for JS code using CommonJS.
import { ecsFormat } from '@elastic/ecs-pino-format';
in JS and TS.ES module (ESM) import style. This is the preferred style for TypeScript
code and for JS developers using ESM.
const ecsFormat = require('@elastic/ecs-pino-format');
in JS.The old, deprecated import method. Still supported for backward compat.
import ecsFormat from '@elastic/ecs-pino-format';
in JS and TS.This works, but is deprecated. Prefer style (2).
import * as EcsPinoFormat from '@elastic/ecs-pino-format';
in TS.One must then use
EcsPinoFormat.ecsFormat()
.Note that this excludes support for this TS-only style:
import escFormat = require('@elastic/ecs-pino-format');
This also adds types for ecs-morgan-format, based on #119 and #90.
I'd had an earlier start on this in #96.
Replaces: #96
Closes: #90
Closes: #119
The functional part of this diff is this in each index.js file:
plus the new morgan/index.d.ts file. The rest of the diff is tests, style updates,
and a
npm run test:skip-slow
convenience for dev. Note that I added exhaustivetests just for ecs-pino-format. I thought it overkill to add "import-styles.test.js"
for the other packages as well.