Closed sgraphics closed 1 week ago
After I tried to ignore this error I get some other error. What might be the cause? Would appreciate any help! Cc. @guybedford
Uncaught TypeError: Failed to resolve module specifier "quick-format-unescaped". Relative references must start with either "/", "./", or "../".
I managed to make some progress on this in
Main issues were:
Buffer
and global
needed to be set from their importsWith that it seems like it might be working now. Let me know if you need any further help.
This is great, I now have the entire web3auth stack operational except for one library @web3auth/coinbase-adapter
. Apparently it is doing import i from "@coinbase/wallet-sdk"
but "i is not a constructor". I think it should instead do import { CoinbaseWalletSDK as i } from "@coinbase/wallet-sdk"
Thanks for checking so quickly and yea you are right it does not immediately show. Only when actually using new await CoinbaseAdapter().init() does it use the invalid constructor. Is this in scope?
<script type="module">
import CoreNodelibsBuffer from "@jspm/core/nodelibs/buffer";
window.global = window;
window.Buffer = CoreNodelibsBuffer.Buffer;
</script>
<script type="module">
import { CoinbaseAdapter } from "@web3auth/coinbase-adapter";
const adapter = new CoinbaseAdapter({ clientId : "BPi5PB_UiIZ-cPz1GtV5i1I2iOSOHuimiXBI0e-Oe_u6X3oVAbCiAZOTEBtTXw4tsluTITPqA8zMsfxIKMjiqNQ" }); //taken from https://web3auth.io/docs/sdk/pnp/web/adapters/coinbase#helper-sdks-menu example
await adapter.init(); //Error here!
</script>
Okay, so the above is actually an interop problem, which strictly speaking is a bug in this file:
https://unpkg.com/@web3auth/coinbase-adapter@9.0.2/dist/lib.cjs/coinbaseAdapter.js
In the above it does this:
var CoinbaseWalletSDK = require('@coinbase/wallet-sdk');
// later on
new CoinbaseWalletSDK(...)
when the file at @coinbase/wallet-sdk
is https://unpkg.com/@coinbase/wallet-sdk@4.1.0/dist/index.js and looks like:
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CoinbaseWalletSDK = void 0;
// Copyright (c) 2018-2024 Coinbase, Inc. <https://www.coinbase.com/>
const CoinbaseWalletSDK_1 = require("./CoinbaseWalletSDK");
exports.default = CoinbaseWalletSDK_1.CoinbaseWalletSDK;
var CoinbaseWalletSDK_2 = require("./CoinbaseWalletSDK");
Object.defineProperty(exports, "CoinbaseWalletSDK", { enumerable: true, get: function () { return CoinbaseWalletSDK_2.CoinbaseWalletSDK; } });
which therefore has the shape module.exports === { default: CoinbaseWalletSDK, CoinbaseWalletSDK }
.
So the fix would be for the consumer to change their code to instead do:
var { CoinbaseWalletSDK } = require('@coinbase/wallet-sdk');
or if they are concerned about interop issues to something like:
var CoinbaseWalletSDK = require('@coinbase/wallet-sdk');
if (CoinbaseWalletSDK.CoinbaseWalletSDK)
CoinbaseWalletSDK = CoinbaseWalletSDK.CoinbaseWalletSDK;
I would therefore advise posting an issue to the original repo about this further. If there is no desire to change on their side then we can potentially look into solving this through JSPM-side overrides, but usually we try to avoid that whenever possible.
Let me know if you need any further help at all.
And if they are transpiling ES modules, their transpilation isn't applying the __esModule
interop pattern correctly where it is supposed to output: var CoinbaseWalletSDK = require('@coinbase/wallet-sdk').__esModule ? require('@coinbase/wallet-sdk').default : require('@coinbase/wallet-sdk');
kind of thing.
Bug fixed in https://github.com/Web3Auth/web3auth-web/issues/1967
Thanks for information, all good now.
Was adding
@web3auth/wallet-connect-v2-adapter
but got"The requested module 'pino' does not provide an export named 'levels'"
The error seems to be originating from @walletconnect package logger@2.1.2 dependency.
Is there something I can do to fix it myself?