Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempted import error: 'WalletPluginScatter' is not exported #2

Open
DenisCarriere opened this issue Sep 9, 2023 · 4 comments
Open

Comments

@DenisCarriere
Copy link

Looks like some rollup build issue, the wallet-plugin-anchor seems to work fine, but all other plugins not.

Some rollup imports missing

import commonjs from '@rollup/plugin-commonjs'
import nodePolyfills from 'rollup-plugin-polyfill-node'
import resolve from '@rollup/plugin-node-resolve'

❌ error

Attempted import error: 'WalletPluginWombat' is not exported from '@wharfkit/wallet-plugin-wombat' (imported as 'WalletPluginWombat').

Import trace for requested module:
./utils/config.ts
./app/(user-profile)/my-wallets/page.tsx

./utils/config.ts
Attempted import error: 'WalletPluginTokenPocket' is not exported from '@wharfkit/wallet-plugin-tokenpocket' (imported as 'WalletPluginTokenPocket').

Import trace for requested module:
./utils/config.ts
./app/(user-profile)/my-wallets/page.tsx

./utils/config.ts
Attempted import error: 'WalletPluginScatter' is not exported from '@wharfkit/wallet-plugin-scatter' (imported as 'WalletPluginScatter').
@aaroncox
Copy link
Member

@DenisCarriere What does your import look like?

I think we're currently moving away from default exports to only providing named exports, and I'm wondering if that's the issue here.

@DenisCarriere
Copy link
Author

Here is our import, we're not using default exports

import { Chains } from "@wharfkit/common"
import { SessionKit } from "@wharfkit/session"
import { WebRenderer } from "@wharfkit/web-renderer"
import { WalletPluginAnchor } from "@wharfkit/wallet-plugin-anchor"
import { WalletPluginCleos } from "@wharfkit/wallet-plugin-cleos"
import { WalletPluginScatter } from "@wharfkit/wallet-plugin-scatter"
import { WalletPluginWombat } from "@wharfkit/wallet-plugin-wombat"
import { WalletPluginTokenPocket } from "@wharfkit/wallet-plugin-tokenpocket"
import { TransactPluginResourceProvider } from "@wharfkit/transact-plugin-resource-provider";
import { TransactPluginCosigner } from "@wharfkit/transact-plugin-cosigner";

const cosigner = new TransactPluginCosigner({
    actor: 'cpu.pomelo',
    permission: 'cosign',
    privateKey: 'PVT_K1_...',
    contract: 'cpu.pomelo',
    action: 'noop',
})

export function generateKit() {
    return new SessionKit({
        appName: "work.pomelo",
        chains: [Chains.EOS],
        ui: new WebRenderer(),
        walletPlugins: [
            new WalletPluginAnchor(),
            new WalletPluginWombat(),
            new WalletPluginTokenPocket(),
            new WalletPluginScatter(),
            new WalletPluginCleos(),
        ],
    }, {
        transactPlugins: [cosigner],
    });
}

tsconfig.json

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

@aaroncox
Copy link
Member

Alright I'm seeing the same error in a sample nextjs app I just setup - but its still working? When I click the "login" button in the example app, it pops up and Scatter/TokenPocket/Wombat all appear as options and actually work. I do see the warning in the console though.

./app/login.tsx
Attempted import error: 'WalletPluginScatter' is not exported from '@wharfkit/wallet-plugin-scatter' (imported as 'WalletPluginScatter').
./app/login.tsx
Attempted import error: 'WalletPluginTokenPocket' is not exported from '@wharfkit/wallet-plugin-tokenpocket' (imported as 'WalletPluginTokenPocket').
./app/login.tsx
Attempted import error: 'WalletPluginWombat' is not exported from '@wharfkit/wallet-plugin-wombat' (imported as 'WalletPluginWombat').

I dug through the node_modules code and those are being exported properly, and just like Anchor.

I also went through and tested these 3 plugins against Svelte, SvelteKit, and Vue - and didn't see the same issue. So I think this is actually an issue with SWC (the compiler Next uses) and I'm not entirely sure how to resolve this yet.

@DenisCarriere
Copy link
Author

DenisCarriere commented Sep 11, 2023

Yes it still works, but throws these errors in next dev and throws warnings in console

As for resolving it, the @wharfkit/wallet-plugin-anchor works, just need to include the same build configs to the other plugins

This works => https://github.com/wharfkit/wallet-plugin-anchor/blob/master/rollup.config.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants