Skip to content

Commit d664fc3

Browse files
authored
fix: use threadId from worker_threads instead of workerId from workerData (#90)
1 parent 6a10569 commit d664fc3

File tree

3 files changed

+7
-14
lines changed

3 files changed

+7
-14
lines changed

turbopack/crates/turbopack-node/js/src/transforms/postcss.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ declare const __turbopack_external_require__: (
55
) => any
66

77
import type { Processor } from 'postcss'
8+
import { workerData } from 'worker_threads'
89

910
// @ts-ignore
1011
import postcss from '@vercel/turbopack/postcss'
@@ -133,8 +134,7 @@ export default async function transform(
133134
}
134135
}
135136

136-
// @ts-ignore
137-
if (typeof self !== 'undefined' && self.workerData && self.workerData.binding) {
137+
if (workerData && workerData.binding) {
138138
// @ts-ignore
139139
const { run } = require('../web_worker/evaluate')
140140
run(async () => {

turbopack/crates/turbopack-node/js/src/transforms/webpack-loaders.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
} from './transforms'
1818
import fs from 'fs'
1919
import path from 'path'
20+
import { workerData } from 'worker_threads'
2021

2122
export type IpcInfoMessage =
2223
| {
@@ -509,8 +510,7 @@ const transform = (
509510

510511
export { transform as default }
511512

512-
// @ts-ignore
513-
if (typeof self !== 'undefined' && self.workerData && self.workerData.binding) {
513+
if (workerData && workerData.binding) {
514514
// @ts-ignore
515515
const { run } = require('../web_worker/evaluate')
516516
run(async () => {

turbopack/crates/turbopack-node/js/src/web_worker/evaluate.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,13 @@ import {
66
} from '../worker_thread/taskChannel'
77
import { structuredError } from '../error'
88
import type { Channel } from '../types'
9+
import { workerData, threadId as workerId } from 'worker_threads'
910

10-
export type Self = DedicatedWorkerGlobalScope & {
11-
workerData: {
12-
workerId: number
13-
cwd: string
14-
binding: Binding
15-
}
16-
}
11+
export type Self = DedicatedWorkerGlobalScope
1712

1813
export declare const self: Self
19-
// @ts-ignore
20-
const { workerId } = self.workerData
2114

22-
let binding: Binding = self.workerData.binding
15+
let binding: Binding = workerData.binding
2316

2417
binding.workerCreated(workerId)
2518

0 commit comments

Comments
 (0)