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

How to compile worker_threads #25

Closed
Winexcel opened this issue Jun 19, 2019 · 2 comments
Closed

How to compile worker_threads #25

Winexcel opened this issue Jun 19, 2019 · 2 comments

Comments

@Winexcel
Copy link

Hi, I'm using bytenode, this is a reallly great stuff for protection your code, but i have a problem, the problem is that i can't compile my source project with worker_threads. If i compile it, when i run my project i get this error:

TypeError [ERR_WORKER_UNSUPPORTED_EXTENSION]: The worker script extension must be ".js" or ".mjs". Received ".jsc"

How can I solve the error?
Great thanks in advance.

@OsamaAbbas
Copy link
Collaborator

Right now, you cannot compile the worker script that will be sent to the new Worker(filename) function. The API now has "Stability: 1 - Experimental" index, so it's better to wait before working on a fix.

However, you can still protect your software logic. Maybe like this:

'use strict';

const bytenode = require('bytenode');
const { Worker, isMainThread } = require('worker_threads');

if (isMainThread) {
  console.log('Inside the main thread..');
  new Worker(__filename);
  // here too you can require some protected '.jsc' files
} else {
  console.log('Inside the worker..');
  console.log(isMainThread);
  require('./protected-script.jsc');
}

@lumix99
Copy link

lumix99 commented Jun 17, 2022

but now is stable!

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