Meteor bundler issue with thirdweb

I wanted to integrate the thirdweb library in a Meteor app today.

According to their Quickstart Docs, it uses the following import:

import { ThirdwebProvider, ConnectButton } from "thirdweb/react";

This works fine in their Next.js app, but not in my Meteor app. Meteor cannot resolve the thirdweb/react path, although WebStorm can navigate to it without any issues. I only get the error from Meteor’s bundler (and also in the client).

The package.json in the node_modules folder has this export entry:

"exports": {
    ".": {
      "types": "./dist/types/exports/thirdweb.d.ts",
      "import": "./dist/esm/exports/thirdweb.js",
      "default": "./dist/cjs/exports/thirdweb.js"
    },
   ...
    "./react": {
      "types": "./dist/types/exports/react.d.ts",
      "import": "./dist/esm/exports/react.js",
      "react-native": "./dist/esm/exports/react.native.js",
      "default": "./dist/cjs/exports/react.js"
    },
...
    "./package.json": "./package.json"
  },

This looks fine to me.

What might be the issue why Meteor cannot find the component, though?

It’s the first time I am facing such a situation.

(I also noticed that I am getting a different error when pointing my import into the node_modules folder directly. In this case, I am getting the error that forwardRef cannot be found. But this might be unrelated.)

I also tried their previous release 4.x now. In this release, they used several packages:

However, this doesn’t work either. It tries to include additional packages (thirdweb/pay and thirdweb/utils), but if even I install the thirdweb package again, these references cannot be found. This seems to be the same issue as mentioned above.

Update: Importing it like this

import { ThirdwebProvider } from '../../../node_modules/thirdweb/dist/esm/exports/react.js';

works.

However, I am still wondering why a simple thirdweb/react fails?

Meteor doesn’t support the package.json exports field. I actually just opened a PR yesterday to add it.

5 Likes

@zodern Thank you so much, that was super fast, highy appreciated! Would be cool if support for these type of package could be down-ported to Meteor 2 as well. We’re working on the Meteor 3 upgrade, but this will take a while. Our code-base is pretty huge.

This part of Meteor is mostly the same between Meteor 2 and 3, so it shouldn’t take much effort for someone to backport it to Meteor 2 once it has been released. I might do it if I have the time and Meteor is interested in making a new Meteor 2 release.

1 Like

Thanks for the info. Would be awesome.