Closed ivan-aksamentov closed 1 year ago
Have also encountered this. It might be more helpful to export an entry point into the package's main source code and let the consuming application about module bundling, rather than exporting a fully bundled and minified version.
It's a little tricky, but more than happy to discuss and pursue enhancements around this.
Right now, each extension
and platform
project is published independently w/ a UMD target.
We can add CommonJS and Source, but ESM has to wait for WebPack v5, or we need to maintain a separate Rollup config.
@ohif/viewer
is a bit special in that our monorepo setup has us building everything from source to create the bundle (UMD), or PWA output
The bundle, published as @ohif/viewer
has two top level named exports:
App
, the React component of the viewer.installViewer
, a convenience method that takes App
's props (our config object), a container to render to, and a callbackI think this above issue could be our package builds, or react-cornerstone-viewport
/ react-vtkjs-viewport
, accidentally bundling react
. LayoutManager
would be using the react-cornerstone-viewport
that is a dependency of @ohif/extension-cornerstone
We should, at a minimum:
There is an in-progress PR to shift LayoutManager
into the Viewer
project, as it doesn't make a ton of sense as a reusable UI component.
That's my brain dump
Right now, each extension and platform project is published independently w/ a UMD target. We can add CommonJS and Source, but ESM has to wait for WebPack v5, or we need to maintain a separate Rollup config.
Yeah it's a bit of a pain now, having been through it with some of my own packages. Didn't know if there was a specific technical reason for exporting it that way, or logistical.
I think this above issue could be our package builds, or react-cornerstone-viewport / react-vtkjs-viewport, accidentally bundling react. LayoutManager would be using the react-cornerstone-viewport that is a dependency of @ohif/extension-cornerstone
The issue isn't unique to @ohif/viewer
. cornerstoneWADOImageLoader
doesn't provide an ESM entry point either, which makes debugging (and even learning about the inner-workings) a bit of a pain. I've been able to get around the issue a little by cloning the repos into my development environment and importing from the source, but obviously not an ideal solution to deploy.
We don't have great visibility into how our packages are being consumed; so we optimize our use cases, and then wait for individuals to pipe up that it would be great if we also supported X.
Because we primarily touch the extension/platform packages through the monorepo, we don't feel the pain points of minified UMD consumption as keenly as others. I'm more than happy to review PRs for any OHIF
or Cornerstonejs
org repository packages that add ESM, Commonjs, and unminified variants. I can even provide some rough guidance.
All of this is "on my list" to do, but it's not at the top.
It's not super opaque, but our priorities are driven by grants, consultants contributing client work, developers addressing community needs to increase the appeal of the platform, and fly-by-the-night crusaders popping in a quick fix/enhancement.
Completely understand. Thanks so much for taking the time to answer.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
👟 💨 🤖
I'm going to keep this open for now. We're cleaning up our UMD and package usage near future to address issues like this. I'll post back after we've made changes to get feedback on if this has been resolved.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
I am encountering the same error when I attempt to render the OHIF viewer within a React component.
componentDidMount() {
var Viewer = window.OHIFViewer.App;
var app = React.createElement(Viewer, ohifViewerConfig, null);
ReactDOM.render(app, document.getElementById('viewer'));
}
Interestingly if I use the installViewer
exported function ,I am able to render the viewer correctly. However my application requires the DOM element that the viewer is attached to, to be created and removed multiple times. This causes another error implying installViewer
can only be called once per page. I went down the route of using the App
object for this reason but cannot proceed because of the Invalid hook call error.
Perhaps there is a way to call installViewer
multiple times per page? Or otherwise do you see a fix for this issue in the near future?
Perhaps there is a way to call
installViewer
multiple times per page? Or otherwise do you see a fix for this issue in the near future?
I was able to use installViewer
multiple times by editing the following Cornerstone code in the minified file.
https://github.com/cornerstonejs/cornerstoneWADOImageLoader/blob/2420f321946b9c08442a7f82ed85155e1e9fec96/src/imageLoader/webWorkerManager.js#L153
Instead of throwing an exception, I logged the warning to the console and returned out of the function.
Using the App
object would have encountered the same problem.
Thank you for your past contributions and for raising this issue related to legacy versions of our OHIF Viewer. Your time and effort have been invaluable in helping us improve the product.
We wanted to update you that our development focus has shifted to OHIF Viewer v3, which is now available for testing on viewer-dev.ohif.org
. This site is deployed from our master
branch and incorporates new features, optimizations, and bug fixes. If you're still using viewer.ohif.org
, it's worth noting that this is deployed from our release
branch and may not have the latest updates. You can read more about our branching strategies here.
Given the move to Version 3, we are closing older issues that pertain to Versions 1 and 2, as we are no longer providing support for those versions. If you find that the issue you've raised is still relevant in Version 3, we encourage you to reopen this issue or create a new one for proper triage.
Thank you for your understanding and continued support.
Bug Report
Describe the Bug
After upgrading to the latest versions of @ohif packages our app crashes with:
the full text of the decoded error:
What steps can we follow to reproduce the bug?
After upgrading from
to
In both cases
Here is what I know so far:
@ohif/i18n
andreact-i18next
functionality from@ohif/ui
completely the same error now appears in@ohif/ui
(stack trace is readable up to theLayoutManager
.@ohif
packages only provide minified versions, so I cannot tell where the error happens exactly)That's all information I've got so far. How can I debug this?