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
Using puppeteer branch as a node module #391
Comments
I've made some progress... the following are the changed parts (from
Observations:
Here are the files I'm referring to above: File
File
Aside from the above observations, the main issue is that you cannot seem to define a
This is a major downside IMHO... kinda defeats the purpose of using this as a node module (with all the benefits and convenience that brings). Is there any way that this could be done? Not only is it not convenient to force the callback into a separate file, but it also seems to be the case that a simple comment line will break everything, e.g. as follows, making it impractical for development purposes:
|
Hi @drmrbrewer Thank you for providing us with your insights and I'm sorry for the late reply. First of all, sorry for the mess with information on how to use exactly the new export server version. There were some changes that still aren't correctly described in the README section. We will improve this one. I've looked at your code and analyzed it and here are the answers to your questions:
The first major change is that the
Yes, some additional async code was added along the way.
We wanted to add more flexibility when it comes for users to specify any Highcharts code, which includes
Yes, you are right. That's an issue. For now I simply changed it to use absolute path but ofc. will correct it to make it work better.
It seems that the sun icon is blocked by the not same origin error even in the official demo (
To include the
Sure, you will find the Also, here I explained the
The reason why function related options can only be passed that way is because later in the code they are inserted directly in the stringified template that is used when creating a page through Puppeteer headless instance. As for your other observations:
I will take a look at this one and provide suggested corrections. It seems that the code snippet doesn't mention about the necessity of the default options for the
Yes, you are right. Unfortunately, the Puppeteer version still isn't available on the npm registry. For now you can use it as a downloaded repo or by referencing by commit (or with a local path). Here is the newest commit for you: 70e1d04. Finally, here is a snippet of your code that I’ve prepared for you. It will correctly export a chart to the
Once again, thank you for your insights and suggestions. We'll constantly upgrade, fix and optimize Puppeteer branch, so any further suggestions are welcome. And ofc. In case of any further questions, feel free to contact us. |
Thanks for the reply, @PaulDalek !
You will see that I already tried this approach in my updated code above. Did I do it wrong there? It doesn't seem to work. If there is no way to load dependencies like this (easily, via the config options) it would make the custom code feature rather limited IMHO because in many cases we will need to rely on other libraries.
But this commit isn't in the puppeteer branch itself? So far as I can see, the latest commit in the puppeteer branch is this one?
So it will never be possible with this library to define a
If this won't be possible, I think it's a problem for me using this as a node module (and possibly for many others in all but the simplest of use cases), and maybe I need to use my own implementation. I did already create a custom node implementation based on puppeteer (it's more like just using puppeteer to take a screen capture of my chart hosted on a remote host... could be any web page really but in my case it's a custom chart generated based on options passed to it via the URL)... it works fine... except that it seems to use more resources (RAM and CPU) than my equivalent native version based on phantomjs, and I hoped that a more native puppeteer implementation like yours would somehow be more efficient. But not being able to use |
Hi @drmrbrewer
Yes, this commit is on another branch, not yet merged into the Puppeteer branch, although it should be soon.
I’ve tried your approach and it worked for me. The changes regarding adding the function
We didn't change that behavior compared to the old solution (based on the PhantomJS). We can take a look at it and consider if we can make it work for a node module usage.
Yes, to be honest it is a challenge for us too now, as the Puppeteer based solution turned out to be more demanding than the PhantomJS one. Right now it is not very performant. There's definitely still room for improvement here and we will delve into optimizing it. |
I think that this would (if at all possible) make the library far more powerful and flexible when used as a node module. Thanks for considering. |
For what it's worth, we got the puppeteer branch installed with |
@ff0041 thanks, very helpful! |
@PaulDalek what official demo is that? I'm trying to reproduce this problem in a simple demo, so that I can either fix it or report it, because I'm seeing it in my current phantomjs implementation for some symbols which I'm fetching from highcharts. I wonder if it relates to the new bot protection that seems to be in place across highcharts.com? |
#391 (comment)
Any ideas? |
It has been solved with this PR: #408 Now, using The readme section has been updated to reflect those changes: https://github.com/highcharts/node-export-server/tree/enhancement/puppeteer#using-as-a-nodejs-module For now, these changes are available on GitHub, but they will be available on NPM after the next minor release. I'm closing this issue but please feel free to ask in case you find anything unclear. |
I have the same problem as @ndubel
The only way to WA the issue, is to manually delete the |
@ronenl did you try with the latest version of the branch? |
@jakubSzuminski Yes I did, but getting the same problem |
I posted here and was advised that I should be using the puppeteer branch straight away, even though it's not released yet.
But @PaulDalek @cvasseng I'm seriously confused about how (or even whether it's possible) to use the new puppeteer branch as a node module. The README in this branch still seems to be referring to the phantomjs version for the node module part? Despite my best efforts, I cannot get it to work.
I think (but am not sure) that the only way to load the puppeteer branch via the package.json is to refer to a specific commit (or is it?), like so:
Then in my node app I'm using the following function as a GET route for an
express
app. I am deliberately showing use of aMyChart
function/class for providing functionality relating to the chart generation (ideally providing theoptions
and also thecallback
) because that is the model I want to use in practice. Please check in the code where I've added a "NOTE:
" comment about how I'd really like to do things, rather than having to putcustomCode
andcallback
in their own standalone files.File
./lib/lodash.min.js
is just a copy/paste from here.File
./lib/customCode.js
:File
./lib/callback.js
(though really I want the callback to come fromMyChart.onChartLoad()
):But running the app and calling the route, I'm just getting:
Any hints about how to get this to work as a node module?
The text was updated successfully, but these errors were encountered: