thread-stream 1.0.0 → 1.0.1

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.
@@ -1,4 +1,5 @@
1
1
  name: CI
2
+
2
3
  on:
3
4
  push:
4
5
  paths-ignore:
@@ -8,35 +9,53 @@ on:
8
9
  paths-ignore:
9
10
  - 'docs/**'
10
11
  - '*.md'
12
+
13
+ # This allows a subsequently queued workflow run to interrupt previous runs
14
+ concurrency:
15
+ group: "${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}"
16
+ cancel-in-progress: true
17
+
11
18
  jobs:
19
+ dependency-review:
20
+ name: Dependency Review
21
+ if: github.event_name == 'pull_request'
22
+ runs-on: ubuntu-latest
23
+ permissions:
24
+ contents: read
25
+ steps:
26
+ - name: Check out repo
27
+ uses: actions/checkout@v3
28
+ with:
29
+ persist-credentials: false
30
+
31
+ - name: Dependency review
32
+ uses: actions/dependency-review-action@v1
33
+
12
34
  test:
35
+ name: Test
13
36
  runs-on: ${{ matrix.os }}
14
-
15
37
  permissions:
16
38
  contents: read
17
-
18
39
  strategy:
19
40
  matrix:
20
41
  node-version: [14, 16, 18]
21
42
  os: [macos-latest, ubuntu-latest, windows-latest]
22
-
23
43
  steps:
44
+ - name: Check out repo
45
+ uses: actions/checkout@v3
46
+ with:
47
+ persist-credentials: false
24
48
 
25
- - uses: actions/checkout@v3
26
-
27
- - name: Use Node.js
49
+ - name: Setup Node ${{ matrix.node-version }}
28
50
  uses: actions/setup-node@v3
29
51
  with:
30
52
  node-version: ${{ matrix.node-version }}
31
53
 
32
- - name: Install
33
- run: |
34
- npm install --ignore-scripts
54
+ - name: Install dependencies
55
+ run: npm i --ignore-scripts
35
56
 
36
57
  - name: Run tests
37
- shell: bash
38
- run: |
39
- npm run test:ci
58
+ run: npm run test:ci
40
59
 
41
60
  - name: Coveralls Parallel
42
61
  uses: coverallsapp/github-action@1.1.3
@@ -56,11 +75,15 @@ jobs:
56
75
  parallel-finished: true
57
76
 
58
77
  automerge:
78
+ name: Automerge Dependabot PRs
79
+ if: >
80
+ github.event_name == 'pull_request' &&
81
+ github.event.pull_request.user.login == 'dependabot[bot]'
59
82
  needs: test
60
- runs-on: ubuntu-latest
61
83
  permissions:
62
84
  pull-requests: write
63
85
  contents: write
86
+ runs-on: ubuntu-latest
64
87
  steps:
65
88
  - uses: fastify/github-action-merge-dependabot@v3
66
89
  with:
@@ -23,7 +23,7 @@ jobs:
23
23
  with:
24
24
  node-version: ${{ matrix.node-version }}
25
25
  - name: Use pnpm
26
- uses: pnpm/action-setup@v2.2.1
26
+ uses: pnpm/action-setup@v2.2.2
27
27
  with:
28
28
  version: ^6.0.0
29
29
  - name: Install dependancies
@@ -51,6 +51,7 @@ jobs:
51
51
  yarn set version berry
52
52
  echo "nodeLinker: pnp" >> .yarnrc.yml
53
53
  echo "pnpMode: loose" >> .yarnrc.yml
54
+ echo "pnpEnableEsmLoader: false" >> .yarnrc.yml
54
55
  yarn add -D pino-elasticsearch@^6.0.0
55
56
  yarn install
56
57
  env:
package/README.md CHANGED
@@ -1,7 +1,6 @@
1
1
  # thread-stream
2
2
  [![npm version](https://img.shields.io/npm/v/thread-stream)](https://www.npmjs.com/package/thread-stream)
3
3
  [![Build Status](https://img.shields.io/github/workflow/status/pinojs/thread-stream/CI)](https://github.com/pinojs/thread-stream/actions)
4
- [![Known Vulnerabilities](https://snyk.io/test/github/pinojs/thread-stream/badge.svg)](https://snyk.io/test/github/pinojs/thread-stream)
5
4
  [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://standardjs.com/)
6
5
 
7
6
  A streaming way to send data to a Node.js Worker Thread.
package/lib/worker.js CHANGED
@@ -32,12 +32,6 @@ async function start () {
32
32
  } else {
33
33
  fn = (await realImport(filename))
34
34
  }
35
-
36
- // Depending on how the default export is performed, and on how the code is
37
- // transpiled, we may find cases of two nested "default" objects.
38
- // See https://github.com/pinojs/pino/issues/1243#issuecomment-982774762
39
- if (typeof fn === 'object') fn = fn.default
40
- if (typeof fn === 'object') fn = fn.default
41
35
  } catch (error) {
42
36
  // A yarn user that tries to start a ThreadStream for an external module
43
37
  // provides a filename pointing to a zip file.
@@ -54,6 +48,13 @@ async function start () {
54
48
  throw error
55
49
  }
56
50
  }
51
+
52
+ // Depending on how the default export is performed, and on how the code is
53
+ // transpiled, we may find cases of two nested "default" objects.
54
+ // See https://github.com/pinojs/pino/issues/1243#issuecomment-982774762
55
+ if (typeof fn === 'object') fn = fn.default
56
+ if (typeof fn === 'object') fn = fn.default
57
+
57
58
  destination = await fn(workerData.workerData)
58
59
 
59
60
  destination.on('error', function (err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "thread-stream",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "A streaming way to send data to a Node.js Worker Thread",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -8,12 +8,12 @@
8
8
  "real-require": "^0.1.0"
9
9
  },
10
10
  "devDependencies": {
11
- "@types/node": "^17.0.37",
11
+ "@types/node": "^18.0.0",
12
12
  "@types/tap": "^15.0.0",
13
13
  "desm": "^1.3.0",
14
14
  "fastbench": "^1.0.1",
15
15
  "husky": "^8.0.1",
16
- "sonic-boom": "^2.8.0",
16
+ "sonic-boom": "^3.0.0",
17
17
  "standard": "^17.0.0",
18
18
  "tap": "^16.2.0",
19
19
  "ts-node": "^10.8.0",
@@ -54,3 +54,27 @@ test('yarn module resolution for directories with special characters', { skip: !
54
54
 
55
55
  t.equal(strings, 'hello world\nsomething else\n')
56
56
  })
57
+
58
+ test('yarn module resolution for typescript commonjs modules', { skip: !isYarnPnp }, async t => {
59
+ t.plan(3)
60
+
61
+ const { port1, port2 } = new MessageChannel()
62
+ const stream = new ThreadStream({
63
+ filename: join(__dirname, 'ts-commonjs-default-export.zip', 'worker.js'),
64
+ workerData: { port: port1 },
65
+ workerOpts: {
66
+ transferList: [port1]
67
+ },
68
+ sync: false
69
+ })
70
+ t.teardown(() => {
71
+ stream.end()
72
+ })
73
+
74
+ t.ok(stream.write('hello world\n'))
75
+ t.ok(stream.write('something else\n'))
76
+
77
+ const [strings] = await once(port2, 'message')
78
+
79
+ t.equal(strings, 'hello world\nsomething else\n')
80
+ })