-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: Support bundlers. * test: Added bundler support test.
- Loading branch information
1 parent
73c851f
commit 514e8ca
Showing
5 changed files
with
50 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
'use strict' | ||
|
||
const { test } = require('tap') | ||
const { join } = require('path') | ||
const { file } = require('./helper') | ||
const ThreadStream = require('..') | ||
|
||
test('bundlers support', function (t) { | ||
t.plan(1) | ||
|
||
globalThis.__bundlerPathsOverrides = { | ||
'thread-stream-worker': join(__dirname, 'custom-worker.js') | ||
} | ||
|
||
const dest = file() | ||
|
||
process.on('uncaughtException', error => { | ||
console.log(error) | ||
}) | ||
|
||
const stream = new ThreadStream({ | ||
filename: join(__dirname, 'to-file.js'), | ||
workerData: { dest }, | ||
sync: true | ||
}) | ||
|
||
stream.worker.removeAllListeners('message') | ||
stream.worker.once('message', message => { | ||
t.equal(message.code, 'CUSTOM-WORKER-CALLED') | ||
}) | ||
|
||
stream.end() | ||
}) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
'use strict' | ||
|
||
const { parentPort } = require('worker_threads') | ||
|
||
parentPort.postMessage({ | ||
code: 'CUSTOM-WORKER-CALLED' | ||
}) | ||
|
||
require('../lib/worker') |