Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v 1.7.0 isWorkerRuntime not available on ESM #452

Open
beckend opened this issue Dec 7, 2022 · 2 comments
Open

v 1.7.0 isWorkerRuntime not available on ESM #452

beckend opened this issue Dec 7, 2022 · 2 comments

Comments

@beckend
Copy link

beckend commented Dec 7, 2022

{
  "threads": "^1.7.0",
}
❯ cat node_modules/threads/worker.mjs
import WorkerContext from "./dist/worker/index.js"

export const expose = WorkerContext.expose
export const registerSerializer = WorkerContext.registerSerializer
export const Transfer = WorkerContext.Transfer
import { expose, isWorkerRuntime } from 'threads/worker';
                 ^^^^^^^^^^^^^^^
SyntaxError: The requested module 'threads/worker' does not provide an export named 'isWorkerRuntime'
    at ModuleJob._instantiate (node:internal/modules/esm/module_job:123:21)
    at ModuleJob.run (node:internal/modules/esm/module_job:189:5)
    at async Promise.all (index 0)
    at ESMLoader.import (node:internal/modules/esm/loader:530:24)
    at loadESM (node:internal/process/esm_loader:91:5)
    at handleMainPromise (node:internal/modules/run_main:65:12)
@noramass
Copy link

I experience the same issue.
additionally if i try to run the expose method in the worker script without importing it in the main thread, i get this error:

node:internal/event_target:1010
  process.nextTick(() => { throw err; });

Error: expose() called in the master thread.

I experience the same issue with cjs if i put "type": "module" in my package.json

it is impossible for me to remove "type": "module" from my package.json because a plugin in my build chain relies on it so i am at the moment unable to use this package.

@janiago
Copy link

janiago commented Apr 18, 2023

This is fixed in master branch by #419
But we haven't see a new release includes this fix yet. What time is the 1.7.1 release planed to?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants