Skip to content

workerData export not available when using ES Modules #25765

New issue

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

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

Already on GitHub? # to your account

Closed
GeorgeTaveras1231 opened this issue Jan 28, 2019 · 1 comment
Closed

workerData export not available when using ES Modules #25765

GeorgeTaveras1231 opened this issue Jan 28, 2019 · 1 comment
Assignees
Labels
esm Issues and PRs related to the ECMAScript Modules implementation. worker Issues and PRs related to Worker support.

Comments

@GeorgeTaveras1231
Copy link

  • Version: v11.8.0
  • Platform: Darwin NY-GTaverasMBA 17.7.0 Darwin Kernel Version 17.7.0: Thu Jun 21 22:53:14 PDT 2018; root:xnu-4570.71.2~1/RELEASE_X86_64 x86_64
  • Subsystem: worker_threads

The following code produces this error:

ERROR:

import { workerData } from 'worker_threads';
         ^^^^^^^^^^
SyntaxError: The requested module 'worker_threads' does not provide an export named 'workerData'

main.mjs:

import { Worker } from 'worker_threads';

const worker = new Worker('./worker.js', { workerData: 'Hello from main thread' });

worker.mjs:

import { workerData } from 'worker_threads';

console.log(workerData);

COMMAND:
node --experimental-modules main.mjs

@addaleax addaleax added esm Issues and PRs related to the ECMAScript Modules implementation. worker Issues and PRs related to Worker support. labels Jan 28, 2019
@addaleax addaleax self-assigned this Jan 28, 2019
addaleax added a commit to addaleax/node that referenced this issue Jan 28, 2019
@addaleax
Copy link
Member

#25768 should address this

targos pushed a commit that referenced this issue Jan 30, 2019
Fixes: #25765

PR-URL: #25768
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
esm Issues and PRs related to the ECMAScript Modules implementation. worker Issues and PRs related to Worker support.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants