Skip to content
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

Add ability to use WebWorkerRpcDriver on vite and nextjs examples #3730

Closed
cmdcolin opened this issue May 26, 2023 · 3 comments · Fixed by GMOD/jbrowse-react-linear-genome-view-vite-demo#1
Labels
enhancement New feature or request

Comments

@cmdcolin
Copy link
Collaborator

Currently our vite/nextjs examples are not enabled to do web worker rpc. It may be valuable to create examples of this but there are hurdles to each

For nextjs, the component tries to get rendered server side, and it gets confused by importing directly from '@jbrowse/react-linear-genome-view/esm/makeWorkerInstance' (which has esm export statement, which the server side does not like, it prefers the commonjs)

For vite, it gives a lot of odd errors related to MIME type. I found that adding the filename extension could help with this. Alternative code

At least for vite dev mode, haven't tried production, can get closer to working with this

const state = createViewState({
      assembly,
      tracks,
      makeWorkerInstance: function makeWorkerInstance() {
        return new Worker(
          new URL(
            "@jbrowse/react-linear-genome-view/esm/rpcWorker.js", // actual rpcWorker with file extension, has proper mime type
            import.meta.url
          ),
          { type: "module" } // needed since it uses import
        );
      },
      defaultSession,
      configuration: {
        rpc: {
          defaultDriver: "WebWorkerRpcDriver",
        },
      },
    });
@cmdcolin cmdcolin added the bug Something isn't working label May 26, 2023
@cmdcolin
Copy link
Collaborator Author

note that the above still goes into an infinite loading state on the tracks and maybe throws (err insufficiet resources? it loads a lot of js to the client...)

image

@cmdcolin cmdcolin added enhancement New feature or request and removed bug Something isn't working labels May 26, 2023
@cmdcolin
Copy link
Collaborator Author

possibly the vanillajs example too if possible

@cmdcolin
Copy link
Collaborator Author

cmdcolin commented May 1, 2024

this has now been deployed across the embedded demos for both app (nextjs and vite) and lgv (nextjs and vite) demos

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
1 participant