Speckle viewer moving objects :S

Hi community,
I have a little issue with the Speckle viewer

  • Objective: Uploading a model from Sketchup 2024 to Speckle with Sketch up Connector 3.0.1 and viewing it with @speckle/viewer": “2.18.16” in our web app.

  • Issue: The model looks fine I upload it to speckle, with the Sketchup Connector 3.0.1, I open it in Speckle the model still looks fine, I copy the model id in our web app where we use the @speckle/viewer": “2.18.16” and all objects jump to the origin, individually

  • Example:
    Sketchup:


    Speckle Web:

    @Speckle/viewer": “2.18.16”:

  • Speckle link: (https://app.speckle.systems/projects/3043c3077d/models/b84dcc2f1b)

Ps: Please help me get the lady out of the fridge, she must be freezing :frowning:

Hi @bobo0025,

New connectors has different approach to handle components (instancing) which we call them proxies. @alex implemented a way to handle them at some point. My guess is that you might be living in quite old viewer version without proxy support. I believe thats way the lady is freezing :cold_face:

Hi @bobo0025

@oguzhan is right about this. The first thing you should do is update to the latest viewer version. In case you worry about breaking changes, we also have a migration guide which you can check

Let us know how it goes!

Cheers

1 Like

Hey, let me jump in here, I am working with Botond.

Based on your advice, we are trying to use the latest version of @speckle/viewer, but we are encountering a persistent issue when trying to use @2.23.15 within a Nuxt 2 (@2.17.2) project, specifically in the production build.

Environment:

  • Nuxt: 2.17.2
  • Nuxt Target: server
  • Key Dependencies:
    • @speckle/viewer: ^2.23.15
    • true-myth: ^8.5.1
  • Build System: Nuxt 2’s default Webpack 4

Problem: The application works correctly in development mode (yarn run dev), but the production build (yarn run build + yarn start or deployed in Docker) throws a runtime error: TypeError: i.default is not a function. This error occurs when instantiating the viewer (new Viewer(...)) inside our component.

Required Build Configuration (nuxt.config.js):
To get the build (yarn run build) to even complete successfully, I found the following configuration necessary:

build: {
    sourcemap: { server: true, client: true }, 
    transpile: ["@speckle/viewer", "@speckle/shared", "true-myth"],
    extend(config, { isDev, isClient }) {
      config.resolve.alias = config.resolve.alias || {};

      // Needed by @speckle/objectloader
      config.resolve.alias["#lodash"] = "lodash";
      
      // Needed by @speckle/shared for build to pass
      // This alias allows the build to complete but seems to cause the runtime error
      try {
        config.resolve.alias['true-myth/maybe'] = require.resolve('true-myth');
        config.resolve.alias['true-myth/result'] = require.resolve('true-myth');
      } catch (e) {
        console.error("Could not resolve 'true-myth'.", e);
      }
    }
  }

Without the true-myth alias pointing to the main package, the build fails with Dependencies were not found: true-myth/maybe....

The Runtime Error & Sourcemap Issues:

With the above configuration, the build passes, but running the production code results in TypeError: i.default is not a function when new Viewer() is called. This strongly suggests a CJS/ESM interop issue related to how dependencies (likely true-myth via the alias) are bundled/minified in production.

Debugging this is hampered because browser sourcemaps aren’t working correctly.

  • We forced sourcemap generation using config.devtool = 'source-map' in build.extend, and .map files are generated.
  • The //# sourceMappingURL=... comment exists in the served JS files.
  • However, testing with yarn start across Chrome, Incognito, and Safari, the browser does not make any network request for the .map files (DevTools settings are confirmed correct).
  • The stack trace only maps the error origin to our component (SpeckleViewer.vue:188) but shows minified internal calls (index.js:..., asyncToGenerator.js:...).

Troubleshooting Steps Tried:

  • Transpiling: Added @speckle/viewer, @speckle/shared, true-myth. (Required)
  • Aliases:
    • Added #lodash. (Required)
    • Added true-myth/* pointing to require.resolve('true-myth'). (Required for build, but likely causes runtime error).
    • Tried removing true-myth alias → Build fails (“Dependencies not found”).
    • Tried aliasing true-myth/* to specific dist/es/*.js files (using path.resolve) → Build fails (same resolution error as .mjs attempt during dev, suggests resolve issues). Correction based on previous attempts - the final attempt was aliasing to dist/cjs/*.cjs using path.resolve, which did build successfully but still resulted in the same runtime error.
    • Tried aliasing true-myth/* to specific dist/cjs/*.cjs files (using path.resolve) → Build passed, but still resulted in the same runtime error.
  • Sourcemaps: Forced devtool: 'source-map' (and others like nosources-source-map) which generated maps, but browser doesn’t load them. Verified sourceMappingURL comment exists and looks correct. Verified DevTools settings and tried multiple browsers/incognito.
  • Cache: Performed aggressive cache clearing (node_modules, .nuxt, yarn.lock, yarn cache clean).

Request:

Given this persistent runtime error seemingly caused by the necessary build configuration for true-myth, could you provide guidance on:

  1. The recommended way to configure Nuxt 2 (Webpack 4) builds to correctly handle @speckle/viewer and its dependencies like true-myth?
  2. Any known issues or workarounds for this TypeError: i.default is not a function in production, potentially related to the true-myth alias or CJS/ESM interop?
  3. Any insights into why the sourcemaps might not be loading correctly in the browser?

Any help or pointers would be greatly appreciated!

1 Like

Just to provide a bit more context: we have many models live, and currently, all of them are being displayed incorrectly, which essentially renders them unusable.

Shouldn’t there have been a notification indicating that recent changes would break backward compatibility?

Hi @Adam_Mezovari, sounds like a very bad case of frontend dependency hell. The people who’d be able to answer this question (@fabians / @MikeTasset / @Andrew_Wallace ) are heads down with a tight deadline.

I know this asking for something extra from you, after a big bout of head scratching, but would it be easy for you to set up a minimal reproduction repository with nuxt2 & co?

Hi Dimitrie, the reproduction repo is here:

2 Likes

I can reproduce the problem. I can’t get to the bottom of it though, it’s very annoying.

I’ve even tried migrating you to nuxt3, via nuxt bridge, but gave up - again, other things are cracking.

Things seem to be coming from true-myth being required by @speckle/shared. I’ve tried forcing the usage of an older version (5.x.x) as they instruct in their readme, but then other things started cracking.

You might need to wait for one of our resident js experts to poke at this.

2 Likes

Thank you for giving it a try—I’m looking forward to hearing the experts’ input.

Do you have an idea of when they might be able to take a look? As mentioned, it’s quite urgent on our end.

@Adam_Mezovari
I’ve investigated the reproduction repo, and the issue isn’t only with true-myth, cause I used yarn resolutions to pin @speckle/shared to an older version without true-myth and the same error was thrown. There also may be a problem with the fact that the Viewer is built as ESM and does not have a CommonJS build.

At the end of the day, the root of the problem is that your build process & stack is very outdated. Webpack 5 came out half a decade ago, and you’re trying to consume @speckle/viewer on Webpack 4. Nuxt 3 also came out a few years ago and Nuxt 2 is beyond End-of-Life and is no longer receiving any updates.

Supporting legacy environments & builds is not only a hassle, but also sometimes prevents us from relying on modern tools & development approaches in the JavaScript ecosystem, so I’d want to avoid having to start supporting Webpack 4 here.

You may have some luck swapping out Webpack 4 for Vite in your project, I remember something about Nuxt 2 (or Nuxt bridge?) having some kind of Vite support.

2 Likes