Skip to content

regression: can't import ?modulePath from inside ?modulePath #862

@ThaUnknown

Description

@ThaUnknown

Describe the bug

case: worker spawns a different worker

this doesn't work, the 2nd's worker's code is instead inlined in the first worker's code

example code:

// main.ts
import { Worker } from 'node:worker_threads'
import worker1 from './worker1.ts?modulePath'
new Worker(worker1)
// worker1.ts
import { Worker } from 'node:worker_threads'
import worker2 from './worker2.ts?modulePath'
globalThis.test = '42'
new Worker(worker2)
// worker2.ts
console.log(globalThis.test) // '42', should be undefined

having multiple ?modulePath imports inside main.ts however works...

new URL('./worker2.ts', import.meta.url) also does not work

Electron-Vite Version

5.0.0

Last Working Electron-Vite Version

4.0.0

Electron Version

38.0.0

Vite Version

7.3.0

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions