@rollup/plugin-terser
Advanced tools
Comparing version 0.4.1 to 0.4.2
@@ -14,2 +14,6 @@ 'use strict'; | ||
const taskInfo = Symbol('taskInfo'); | ||
const freeWorker = Symbol('freeWorker'); | ||
const workerPoolWorkerFlag = 'WorkerPoolWorker'; | ||
/** | ||
@@ -28,3 +32,3 @@ * Duck typing worker context. | ||
function runWorker() { | ||
if (worker_threads.isMainThread || !worker_threads.parentPort) { | ||
if (worker_threads.isMainThread || !worker_threads.parentPort || worker_threads.workerData !== workerPoolWorkerFlag) { | ||
return; | ||
@@ -54,5 +58,2 @@ } | ||
const taskInfo = Symbol('taskInfo'); | ||
const freeWorker = Symbol('freeWorker'); | ||
class WorkerPoolTaskInfo extends async_hooks.AsyncResource { | ||
@@ -108,3 +109,5 @@ constructor(callback) { | ||
addNewWorker() { | ||
const worker = new worker_threads.Worker(this.filePath); | ||
const worker = new worker_threads.Worker(this.filePath, { | ||
workerData: workerPoolWorkerFlag | ||
}); | ||
worker.on('message', (result) => { | ||
@@ -111,0 +114,0 @@ var _a; |
@@ -1,2 +0,2 @@ | ||
import { isMainThread, parentPort, Worker } from 'worker_threads'; | ||
import { isMainThread, parentPort, workerData, Worker } from 'worker_threads'; | ||
import { isObject, hasOwnProperty, merge } from 'smob'; | ||
@@ -10,2 +10,6 @@ import { minify } from 'terser'; | ||
const taskInfo = Symbol('taskInfo'); | ||
const freeWorker = Symbol('freeWorker'); | ||
const workerPoolWorkerFlag = 'WorkerPoolWorker'; | ||
/** | ||
@@ -24,3 +28,3 @@ * Duck typing worker context. | ||
function runWorker() { | ||
if (isMainThread || !parentPort) { | ||
if (isMainThread || !parentPort || workerData !== workerPoolWorkerFlag) { | ||
return; | ||
@@ -50,5 +54,2 @@ } | ||
const taskInfo = Symbol('taskInfo'); | ||
const freeWorker = Symbol('freeWorker'); | ||
class WorkerPoolTaskInfo extends AsyncResource { | ||
@@ -104,3 +105,5 @@ constructor(callback) { | ||
addNewWorker() { | ||
const worker = new Worker(this.filePath); | ||
const worker = new Worker(this.filePath, { | ||
workerData: workerPoolWorkerFlag | ||
}); | ||
worker.on('message', (result) => { | ||
@@ -107,0 +110,0 @@ var _a; |
{ | ||
"name": "@rollup/plugin-terser", | ||
"version": "0.4.1", | ||
"version": "0.4.2", | ||
"publishConfig": { | ||
@@ -5,0 +5,0 @@ "access": "public" |
export const taskInfo = Symbol('taskInfo'); | ||
export const freeWorker = Symbol('freeWorker'); | ||
export const workerPoolWorkerFlag = 'WorkerPoolWorker'; |
@@ -8,3 +8,3 @@ import { AsyncResource } from 'async_hooks'; | ||
import { freeWorker, taskInfo } from './constants'; | ||
import { freeWorker, taskInfo, workerPoolWorkerFlag } from './constants'; | ||
@@ -85,3 +85,5 @@ import type { | ||
private addNewWorker() { | ||
const worker: WorkerWithTaskInfo = new Worker(this.filePath); | ||
const worker: WorkerWithTaskInfo = new Worker(this.filePath, { | ||
workerData: workerPoolWorkerFlag | ||
}); | ||
@@ -88,0 +90,0 @@ worker.on('message', (result) => { |
@@ -1,2 +0,2 @@ | ||
import { isMainThread, parentPort } from 'worker_threads'; | ||
import { isMainThread, parentPort, workerData } from 'worker_threads'; | ||
@@ -7,2 +7,4 @@ import { hasOwnProperty, isObject } from 'smob'; | ||
import { workerPoolWorkerFlag } from './constants'; | ||
import type { WorkerContextSerialized, WorkerOutput } from './type'; | ||
@@ -26,3 +28,3 @@ | ||
export function runWorker() { | ||
if (isMainThread || !parentPort) { | ||
if (isMainThread || !parentPort || workerData !== workerPoolWorkerFlag) { | ||
return; | ||
@@ -29,0 +31,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
28603
731