-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
ReferenceError: document is not defined #5243
Comments
Sorry, I think it is a configuration problem on my side. It seems to work with create-react-app. I am closing this because of this. |
I get the same error again and in a similar situation, so I think it is real. This time I have more information. We use Browser window contentsDevTools consolereact-plotly.js errorsOur code's errorsplotly.js errorsI will try to reproduce this issue in a Thank you. |
@silviubogan could you investigate if probe-image-size depends on plotly.js/src/traces/image/helpers.js Line 11 in e62219a
|
In our code, the issue is that these instructions (just them, as I verified), when not commented out, produce the error related to the const LoadableBasicPlotly = loadable.lib(() =>
import('plotly.js/lib/index-basic'),
);
const LoadableCartesianPlotly = loadable.lib(() =>
import('plotly.js/lib/index-cartesian'),
);
const LoadableGeoPlotly = loadable.lib(() => import('plotly.js/lib/index-geo'));
const LoadableGl3dPlotly = loadable.lib(() =>
import('plotly.js/lib/index-gl3d'),
);
const LoadableGl2dPlotly = loadable.lib(() =>
import('plotly.js/lib/index-gl2d'),
);
const LoadableMapboxPlotly = loadable.lib(() =>
import('plotly.js/lib/index-mapbox'),
);
const LoadableFinancePlotly = loadable.lib(() =>
import('plotly.js/lib/index-finance'),
); I still do not understand how I start investigating the probe-image-size library now, if nothing else more important intervenes. Thank you! |
The it('should return content-length', async function () {
responder = function (req, res) {
res.writeHead(200, { 'Content-Length': 1234 });
res.end(GIF1x1);
};
let size = await probe(url);
assert.strictEqual(size.width, 1);
assert.strictEqual(size.height, 1);
assert.strictEqual(size.length, 1234);
assert.strictEqual(size.mime, 'image/gif');
}); (via this link) But its internal functions are easy to use and extend. If time allows me to do this, I can try to use it for your use cases. |
I could be way off the mark here but the |
Yes, more precisely we use razzle with SSR. I hope that SSR is supported. Thank you. |
Unfortunately, pure-Javascript SSR is not officially supported at this time and I'm not aware of anyone having successfully done it unofficially, due to this exact issue. Plotly.js relies extensively on browser APIs which are generally not available or hard to emulate on the server short of running a full in memory browser like we do in the Kaleido project. |
PTAL and help me solve this issue. Is it an issue in
|
It seems that after commenting all the other loadable.lib calls in the message above, from these remaining two: const LoadableBasicPlotly = loadable.lib(() =>
import('plotly.js/lib/index-basic'),
);
const LoadableCartesianPlotly = loadable.lib(() =>
import('plotly.js/lib/index-cartesian'),
); the first one alone does not produce the error with Thank you. |
@silviubogan would you mind testing if the issue was resolved after #5388? |
@archmoj Thank you for the notification. I am pleased to know you have worked on this. I will try to find time in the following week. |
See #5377 (comment) |
@archmoj The error related to the module |
Thanks for testing this out. |
This dependency makes it impossible to use plotly.js in the browser because image-size uses fs module which is not available in browsers. I do not know how does react-plotly.js adapt to this dependency but I guess they have this issue too.
Related to: #5119.
Reproducible example
create-react-app
.plotly.js@1.57.1
and use it as a dynamic import with@loadable/component
.yarn start
in the project directory.Screenshot
Expected output
The app runs well without terminal or browser errors.
Actual output
Error inside browser window:
Update
The essence of this issue is here: #5243 (comment)
The text was updated successfully, but these errors were encountered: