Skip to content

Commit d4f845c

Browse files
committed
Change how module is required
1 parent aff0ef7 commit d4f845c

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

custom.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
'use strict'
2+
3+
// See `index.js` for an alternative to this file
4+
module.exports = require('./src')

index.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
11
'use strict'
22

3-
module.exports = require('./src')
3+
const setup = require('./src')
4+
5+
// Logging setup is automatically performed by `node -r log-process-errors` or
6+
// `require('log-process-errors')`.
7+
// It encourages using `node -r` to prevent from adding this helper in the
8+
// source code. This is beneficial in the following use cases:
9+
// - when using it for debugging purpose only
10+
// - discouraging libraries from shipping this code, as it mutates global
11+
// environment. This could lead to unexpected side-effects when requiring
12+
// the library, and to conflicts between libraries.
13+
// Also it ensures this code is called as early as possible, to make sure early
14+
// events are caught.
15+
// To either defer the call or to pass options, one must use instead
16+
// `require('log-process-errors/custom')(options)`
17+
setup()

0 commit comments

Comments
 (0)