Git Product home page Git Product logo

Comments (16)

dpiatek avatar dpiatek commented on June 14, 2024 1

thanks @awachat. I've setup a fresh nextjs app, but could not reproduce the error. Any chance you could provide a full stack trace? The error suggests some issue with module resolution, but as far as I can tell you are importing the correct (.mjs, which the default) pacakge. Perhaps something went wrong when you installed the package? I'd try removing node_modules and installing again.

As a side note, I noticed you are not passing a clientId to the constructor. When authenticating with the API_KEY, you'll need to do:

new Spaces({ key: "ABLY_API_KEY", clientId: "a client id" })

You can read about what a clientId is for Ably here https://ably.com/docs/realtime/authentication?lang=javascript#identified-clients

(noticed this is missing in our docs currently)

from spaces.

dpiatek avatar dpiatek commented on June 14, 2024 1

hey @awachat sorry to hear that. Happy to screen share, will chat with Daria to arrange

from spaces.

awachat avatar awachat commented on June 14, 2024 1

I am trying to investigate if it has to do something with server sider rendering. I tried to use dynamic import, but no luck. The dynamic import throws another error (type mistmatch)

const Spaces = dynamic(() => import('@ably-labs/spaces'));

Also, @dpiatek I am use the page router of nextjs along with auth0. Auth0 checks the session on the servers, and if the user is not logged in, then redirect to login page.

Thanks.

from spaces.

dpiatek avatar dpiatek commented on June 14, 2024 1

The interesting thing in that error @awachat is that the missing import (for Cursors) is lacking the JS extension and, looking at our compiled code, it differs from other imports:

Screenshot 2023-06-19 at 16 59 24

Perhaps the way bundling is resolved in your application requires the correct extension, if so, we should be able to amend on our side to make this work (will give it a try tomorrow morning).

from spaces.

dpiatek avatar dpiatek commented on June 14, 2024 1

hey @awachat yes, of course, you've mentioned before. I'm still not quite sure which part of next's config causes this issue, but I amended now the internal imports for this to work. Have a go with 0.0.10. And many thanks for your help in testing the lib :)

from spaces.

awachat avatar awachat commented on June 14, 2024 1

Thanks a ton @dpiatek. It's working now. I will get started adding some cool features you and your team built. Let me know if you have any example of using ably for document collaboration with comments.

from spaces.

dpiatek avatar dpiatek commented on June 14, 2024

hey @awachat, thanks for trying out the SDK. I can look into this for you. Could you please post how are you importing the library and what are you passing to Spaces (basically what's cut-off on the screenshot)?

Moreover, to confirm versions – you are using next 13.4.6 and node 20.3?

from spaces.

awachat avatar awachat commented on June 14, 2024

@dpiatek I am using "next": "^13.4.6", "react": "^18.2.0" and node v19.6.1. Let me know if this is helpful.

image

PS: I removed the API Key to take the screenshot. I pasted the api key from the dashboard as a string here.

from spaces.

awachat avatar awachat commented on June 14, 2024

@dpiatek I removed node_modules .next, deleted package.json. Reinstalled all the packages. Yet no luck. I'm getting the same error.

Should we get on a call, and do a screenshare to figure the root cause. Let me know what do you think?

Update:
Screenshot 2023-06-19 at 8 59 57 PM

from spaces.

awachat avatar awachat commented on June 14, 2024

I read about this a little today. It looks like the when js extension is not specified - it defaults to commonjs instead of es module.

from spaces.

dpiatek avatar dpiatek commented on June 14, 2024

hey @awachat I've just cut release 0.0.9 could you give it a try?

from spaces.

awachat avatar awachat commented on June 14, 2024

@dpiatek Now I got this error. I followed the demo example.

image image

from spaces.

dpiatek avatar dpiatek commented on June 14, 2024

hey @awachat it looks like now next.js thinks Ably is a CommonJS module - could you post your tsconfig please?

from spaces.

awachat avatar awachat commented on June 14, 2024

@dpiatek here you go.

{
  "compilerOptions": {
    "lib": [
      "dom",
      "dom.iterable",
      "esnext"
    ],
    "allowJs": true,
    "skipLibCheck": true,
    "strict": false,
    "forceConsistentCasingInFileNames": true,
    "noEmit": true,
    "incremental": true,
    "esModuleInterop": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "jsx": "preserve",
    "paths": {
      "@/*": [
        "./*"
      ]
    }
  },
  "include": [
    "next-env.d.ts",
    "**/*.ts",
    "**/*.tsx"
  ],
  "exclude": [
    "node_modules"
  ]
}

from spaces.

dpiatek avatar dpiatek commented on June 14, 2024

the config looks good @awachat :( I wonder if this could be a problem with SSR? Is the breaking component a use client component or imported via dynamic ?

from spaces.

awachat avatar awachat commented on June 14, 2024

I'm using page router. It's not added dynamically. This error happen at the compile time.

from spaces.

Related Issues (7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.