Skip to content

ReferenceError: process is not defined when using Shapediver #2858

Closed

Description

@sebastian-meckovski

What is the location of your example repository?

https://github.com/sebastian-meckovski/hydrogen-shapediver-test

Which package or tool is having this issue?

Shapediver

What version of that package or tool are you using?

3.9.6

What version of Remix are you using?

Remix: 2.16.1
Hydrogen: 2025.1.3

Steps to Reproduce

  • scaffold project
    npm create @shopify/hydrogen@latest

  • Install Shapediver NPM package
    npm i @shapediver/viewer.session

  • Paste this code snippet to products page inside Product component. This should only run on client side:

  useEffect(() => {
    const init = async () => {
      try {
        const {createSession} = await import('@shapediver/viewer.session');

        const session = await createSession({
          ticket: 'ticketId',
          modelViewUrl: 'modelViewUrl',
        });
      } catch (error) {
        console.error('Error initializing the session or viewport:', error);
      }
    };
    init();
  }, []);

Expected Behavior

It should attempt to create a session in the client, this can be checked in the browser dev tools console:

Initializing session...
_index.tsx:21 Powered by:
   _____  __                         ____   _                   
  / ___/ / /_   ____ _ ____   ___   / __ \ (_)_   __ ___   _____
  \__ \ / __ \ / __ '// __ \ / _ \ / / / // /| | / // _ \ / ___/
 ___/ // / / // /_/ // /_/ //  __// /_/ // / | |/ //  __// /    
/____//_/ /_/ \__,_// .___/ \___//_____//_/  |___/ \___//_/     
                   /_/                                          
ShapeDiver Viewer 3, Version 3.9.6
Visit us at https://shapediver.com/ and find out more!

_index.tsx:25 Session created: SessionApi {}

Actual Behavior

When CreateSession is invoked, the following error appears in the browser dev tools console:

Image

Important notes:

  • This was not happening on hydrogen version 2025.1.2 and remix 2.15.3. Code from this repository works as expected
  • The older version is deployed here. Can be tested by clicking the settings cog next to the picture. As a result a 3D model should appear instead of an image.
  • I also tried to reproduce it in simple Remix + Vite template in this branch. Shapediver works as expected there
  • This is a follow up from this issue as it might be related. The original issue was resolved by doing dynamic imports and tweaking vite.config.ts
  • Shapediver should only run on client side, it should never be run on the server side at all

Activity

  1. self-assigned this
    on Apr 14, 2025
  2. juanpprieto commented on Apr 15, 2025

    @juanpprieto
    Contributor

    Could be related to #2863

  3. blittle commented on Apr 15, 2025

    @blittle
    Contributor

    I think it is related. I tried it out locally. @sebastian-meckovski you can fix it manually if you don't want to wait for us to release by updating your vite config to match resolve.conditions here: https://github.com/Shopify/hydrogen/pull/2863/files#diff-22cb6dc8944213fc0eef63fc06af4f67967c07392c1c6efe4adef1eb1a4be8e8R49

  4. sebastian-meckovski commented on Apr 15, 2025

    @sebastian-meckovski
    Author

    This has solved the problem, thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions