@contember/logger 2.2.0-alpha.11 → 2.2.0-alpha.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { describe, expect, test } from 'bun:test'
|
|
2
|
+
import { fileURLToPath } from 'node:url'
|
|
3
|
+
|
|
4
|
+
// chalk stays external so the bundler cannot see whether it is side-effect free, as with chalk 4 (CommonJS)
|
|
5
|
+
const bundle = async (fixture: string): Promise<string> => {
|
|
6
|
+
const result = await Bun.build({
|
|
7
|
+
entrypoints: [fileURLToPath(new URL(`./fixtures/${fixture}`, import.meta.url))],
|
|
8
|
+
target: 'node',
|
|
9
|
+
external: ['chalk'],
|
|
10
|
+
})
|
|
11
|
+
expect(result.success).toBe(true)
|
|
12
|
+
return await result.outputs[0].text()
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
describe('tree shaking', () => {
|
|
16
|
+
test('a bundle without the pretty print handler does not import chalk', async () => {
|
|
17
|
+
const code = await bundle('jsonHandlerConsumer.ts')
|
|
18
|
+
expect(code).toContain('JsonStreamLoggerHandler')
|
|
19
|
+
expect(code).not.toContain('chalk')
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
test('a bundle with the pretty print handler imports chalk', async () => {
|
|
23
|
+
const code = await bundle('prettyPrintHandlerConsumer.ts')
|
|
24
|
+
expect(code).toContain('PrettyPrintLoggerHandler')
|
|
25
|
+
expect(code).toContain('chalk')
|
|
26
|
+
})
|
|
27
|
+
})
|