-
Bug ReportUnable to reproduce the basic react example from https://codesandbox.io/s/react-elcg7i?file=/src/Perspective.js:0-1467 in the Remix framework (https://remix.run) Minimal Reproduction here: https://github.com/Senjai/remix-perspective-issues Copying over from the readme I wrote on my repro repository This is a wip reproduction of an issue with getting perspective working within remix. This repo attempts to recreate https://codesandbox.io/s/react-elcg7i?file=/src/Perspective.js in Remix. Related issues: #2181, #2183. I've looked at the NextJS example as well. This seems challenging since Remix explicitly doesn't want to open up its compiler so far that I can tell, but importing the perspective library without the fully qualified path (e.g. import "@finos/perspective") seems to attempt to load the node-specific code, which errors out on not being able to find the stoppable module. Either adding stoppable as a dependency, setting the build target to neutral, or loading the fully qualified url "@finos/perspective/dist/esm/perspective.js" triggers errors related to using import/export outside of a module. I'm a bit stuck. As a last resort of course we could probably pull these files in via CDN or the like instead of using the bunlder, but that seems off. To reproduce the errors: Error using the qualified path:
Error using the regular import yields the stoppable module not found issue. Adding it as a dependency brings us back to the module issues. Steps to Reproduce:Clone https://github.com/Senjai/remix-perspective-issues On your own: Expected Result:A rendered perspective table Actual Result:Not being able to kick off the relevant server process on latest version of all packages involved. Environment:MacOSX, Dependencies listed here: https://github.com/Senjai/remix-perspective-issues/blob/main/package.json, Node 19. Additional Context:I know there's been a few random issues like this but no actual repro, hopefully this helps. I know that this might be a Remix problem, but because I've seen others struggle with something pertinent to this I thought I'd also add it here, such that the context is visible. I've also asked some folks on the remix end as well. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
I see a lot of es module related stuff on the "gotchas" page https://remix.run/docs/en/main/pages/gotchas#importing-esm-packages |
Beta Was this translation helpful? Give feedback.
-
@Senjai Remix is a server-side framework, you're trying to import a module written for the browser (Perspective). I am not a Remix expert but I imagine you're going to need to do something similar to this next.js example which defers loading the perspective libraries until runtime so the server-side react compiler does not try to import them. |
Beta Was this translation helpful? Give feedback.
-
Your understanding is incorrect, there is no "way" to make this work except as described in my response above. Re: your ESM compilation error is completely unrelated - it is because you are importing a random file in the perspective source tree |
Beta Was this translation helpful? Give feedback.
@Senjai Remix is a server-side framework, you're trying to import a module written for the browser (Perspective). I am not a Remix expert but I imagine you're going to need to do something similar to this next.js example which defers loading the perspective libraries until runtime so the server-side react compiler does not try to import them.