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

serialization? #75

Open
yocontra opened this issue Aug 15, 2019 · 4 comments
Open

serialization? #75

yocontra opened this issue Aug 15, 2019 · 4 comments

Comments

@yocontra
Copy link

Stumbled on it by noticing that my regex's were failing, but raises a larger issue:

Screen Shot 2019-08-15 at 12 18 36 PM

There are plenty of non-JSON values used in loader options that currently break when using thread-loader (regex, dates, functions). It seems like an easy solution would be to use a more comprehensive serialization method, or allow users to plug their own in. This will allow thread-loader to work with even more loaders and seems like a quick win.

I think this is the line in question:

const messageBuffer = Buffer.from(JSON.stringify(data), 'utf-8');

Quick glance shows a few libraries that handle this, I'm sure you could either do this internally or find a better one as well:

@rainke
Copy link

rainke commented Mar 3, 2020

yes, the sass-loader I set implementation will get Error

@arcanis
Copy link

arcanis commented Jan 4, 2021

Presumably the right fix is to use the dedicated Node API for complex object serialization:

https://nodejs.org/api/v8.html#v8_serialization_api

@yocontra
Copy link
Author

yocontra commented Jan 4, 2021

@arcanis I think that solution would work well for almost every case - serializing functions isn't a thing and I think it will just need to be noted in the docs + have a nice error message that it isn't supported. I do see functions used in loader configs relatively frequently.

@nyngwang
Copy link

@yocontra I'm sorry to tag you directly. Could you clarify whether the current README is out of date? Specifically, the third rule in below. I want to make sure that each worker will read the options I provided for those loaders, e.g. babel-loader.

Loaders running in a worker pool are limited. Examples:

Loaders cannot emit files.
Loaders cannot use custom loader API (i. e. by plugins).
Loaders cannot access the webpack options.

I also opened a question there, if you could help I will be very grateful: webpack/webpack#18196.

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

4 participants