-
Notifications
You must be signed in to change notification settings - Fork 3
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
.range is not a function #103
Comments
You need to use import parallel from "parallel-es" You find an example here using commonjs. I had to release a new version as it seemed that webpack did not export the default export for some reason. This seems to be fixed with a newer webpack version. So just install the latest version and you find the api documentation here Besides, the webpack plugin does not yet work with node.js. So you can use webpack but you don't have to for parallel.es (but you can not use any variables from the outer scope). |
I forgot to mention that I tried I updated to 0.1.18 that you released a few hours ago and
But it sounds like the webpack compiling isn't suppose to work yet with node.js. Here is a nice summary of the difference between node.js webpack config and a browser config: http://stackoverflow.com/a/43202748/1884101 What needs to happen to get it to work with node.js? Also, in node.js, does that mean I can't pass external functions to the function I want to run in parallel? This section in the docs I'm not clear on: https://github.com/MichaReiser/parallel.es#referenced-functions-variables-and-imports. Can I manually do what webpack does? I want to pass in a few lodash functions to the function I want to parallelize. Could I just pass the functions in as arguments? Thanks |
Using it with webpack is a little bit more complicated for the moment. Just require your module. There is no need to use webpack in a node project. If you intend to use webpack, you need to copy the node-slave.parallel file from node_modules/parallel-es/dist into your dist folder, e.g. by using the copy plugin of WebPack. However, I suggest you for the moment to just use plain require (or import with babel or TypeScript and compiling down to commonjs style).
No, you can't at the moment. Passing in the functions will not be sufficient as lodash makes heavily use of closures that are, and cannot, be supported. There needs to be a transpilation step that includes the used functions. But I never got time to work on supporting node properly. |
@MichaReiser Ok, maybe I made it more complicated than I needed to. Just require functions. That's fine. I ran into other problems that are more appropriate for a different ticket. Thank you. |
…llel into distilled folder Based on this thread: MichaReiser/parallel.es#103 (comment) 5103 (By the way, I intentionally committing the /dist/ folder so people can see how it works)
For reference for other people, here is a node.js repo that uses typescript compilation and webpack. This works: import parallel from "parallel-es"
parallel.range(0, 10)
.map(value => value * value)
.subscribe((subresult, taskIndex) => console.log(`The result of the task ${taskIndex} is`, subresult))
.then(result => console.log(result))
// output:
// The result of the task 6 is [ 36 ]
// The result of the task 8 is [ 64 ]
// The result of the task 3 is [ 9 ]
// The result of the task 9 is [ 81 ]
// The result of the task 7 is [ 49 ]
// The result of the task 1 is [ 1 ]
// The result of the task 4 is [ 16 ]
// The result of the task 0 is [ 0 ]
// The result of the task 5 is [ 25 ]
// The result of the task 2 is [ 4 ]
// [ 0, 1, 4, 9, 16, 25, 36, 49, 64, 81 ] Here I'm copying the plugins: [
new CopyWebpackPlugin([
{from: './node_modules/parallel-es/dist/node-slave.parallel.js'},
]),
], |
I've got an example repo where I'm trying to get some simple examples working. I'm using webpack in a node environment. I would like to include
lodash
functions in some of the parallel processing but right now I'm just trying to get the simplest example working.Here is the function:
https://github.com/jefffriesen/parallel-es-node-example/blob/master/src/parallel-range.ts
Here is the error:
parallel
is importing something. I can see it here:Any suggestions?
The text was updated successfully, but these errors were encountered: