Importing bonfida using vite

Hello,

I have a problem when I am trying to import “@bonfida/token-vesting” into my project.
I am using repl.it for development and that it’s using vite.

The line that generates my error is: “import * as streamClient from “@bonfida/token-vesting”;”

And here is the error:


> ReplitReactjsProject@0.0.1 dev /home/runner/vesting-project
> vite

Pre-bundling dependencies:
  react
  react-dom
  @solana/web3.js
  @project-serum/anchor
  buffer
  (...and 1 more)
(this will be run only when your dependencies or config have changed)
✘ [ERROR] No matching export in "browser-external:url" for import "parse"

    node_modules/@bonfida/token-vesting/node_modules/@solana/web3.js/lib/index.esm.js:14:9:
      14 │ import { parse, format } from 'url';
         ╵          ~~~~~

✘ [ERROR] No matching export in "browser-external:url" for import "format"

    node_modules/@bonfida/token-vesting/node_modules/@solana/web3.js/lib/index.esm.js:14:16:
      14 │ import { parse, format } from 'url';
         ╵                 ~~~~~~

✘ [ERROR] No matching export in "browser-external:url" for import "parse"

    node_modules/@bonfida/token-vesting/node_modules/@solana/spl-token/node_modules/@solana/web3.js/lib/index.esm.js:14:9:
      14 │ import { parse, format } from 'url';
         ╵          ~~~~~

✘ [ERROR] No matching export in "browser-external:url" for import "format"

    node_modules/@bonfida/token-vesting/node_modules/@solana/spl-token/node_modules/@solana/web3.js/lib/index.esm.js:14:16:
      14 │ import { parse, format } from 'url';
         ╵                 ~~~~~~

error when starting dev server:
Error: Build failed with 4 errors:
node_modules/@bonfida/token-vesting/node_modules/@solana/spl-token/node_modules/@solana/web3.js/lib/index.esm.js:14:9: ERROR: No matching export in "browser-external:url" for import "parse"
node_modules/@bonfida/token-vesting/node_modules/@solana/spl-token/node_modules/@solana/web3.js/lib/index.esm.js:14:16: ERROR: No matching export in "browser-external:url" for import "format"
node_modules/@bonfida/token-vesting/node_modules/@solana/web3.js/lib/index.esm.js:14:9: ERROR: No matching export in "browser-external:url" for import "parse"
node_modules/@bonfida/token-vesting/node_modules/@solana/web3.js/lib/index.esm.js:14:16: ERROR: No matching export in "browser-external:url" for import "format"
    at failureErrorWithLog (/home/runner/vesting-project/node_modules/vite/node_modules/esbuild/lib/main.js:1602:15)
    at /home/runner/vesting-project/node_modules/vite/node_modules/esbuild/lib/main.js:1248:28
    at runOnEndCallbacks (/home/runner/vesting-project/node_modules/vite/node_modules/esbuild/lib/main.js:1033:63)
    at buildResponseToResult (/home/runner/vesting-project/node_modules/vite/node_modules/esbuild/lib/main.js:1246:7)
    at /home/runner/vesting-project/node_modules/vite/node_modules/esbuild/lib/main.js:1355:14
    at /home/runner/vesting-project/node_modules/vite/node_modules/esbuild/lib/main.js:665:9
    at handleIncomingPacket (/home/runner/vesting-project/node_modules/vite/node_modules/esbuild/lib/main.js:762:9)
    at Socket.readFromStdout (/home/runner/vesting-project/node_modules/vite/node_modules/esbuild/lib/main.js:632:7)
    at Socket.emit (events.js:314:20)
    at addChunk (_stream_readable.js:297:12)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! ReplitReactjsProject@0.0.1 dev: `vite`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the ReplitReactjsProject@0.0.1 dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/runner/.npm/_logs/2022-05-17T17_36_44_641Z-debug.log
exit status 1```


ALSO this is the log:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'run', 'dev' ]
2 info using npm@6.14.16
3 info using node@v12.22.10
4 verbose run-script [ 'predev', 'dev', 'postdev' ]
5 info lifecycle ReplitReactjsProject@0.0.1~predev: ReplitReactjsProject@0.0.1
6 info lifecycle ReplitReactjsProject@0.0.1~dev: ReplitReactjsProject@0.0.1
7 verbose lifecycle ReplitReactjsProject@0.0.1~dev: unsafe-perm in lifecycle true
8 verbose lifecycle ReplitReactjsProject@0.0.1~dev: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/runner/vesting-project/node_modules/.bin:/nix/store/37s4644i36ni7fgb7i13i8l7n60ilclc-pid1/bin:/nix/store/22jj08nss8zvbgk52ikj09ssg6rw84rv-silver-searcher-2.2.0/bin:/nix/store/0pmhap0w9prffjj639ba5786ab71i512-bash/bin:/nix/store/176gh50y24c0lx2bnnmsvf9wazb73php-coreutils-9.0/bin:/nix/store/zaamc32wijqka1mg8w2gr1f6bgvs7yyz-vscode-cpptools-dap-1.3.1/bin:/nix/store/ann2w0blx5vrc8mw1hwnvb37gry6ci9a-replit-python-dap-wrapper-1.0.0/bin:/nix/store/gvzyha79wkr1xazax4fd9nnbj8yp9rv6-node-dap/bin:/nix/store/hhzckydwi442l85smbd512xlwp2qarxv-fluxbox/bin:/nix/store/13sxby28d6x7r98ggggp0gk5al4hdj9f-prybar-nodejs-0.0.0-7d40edb/bin:/nix/store/mav4251if1ahjq5vkpwycyyvnmy459c4-pulseaudio-14.2/bin:/nix/store/2py1rvdx7y7fbi0yffw7dq2bacd15605-rfbproxy-0.0.0-b81eb2f/bin:/nix/store/0b2bvviijkvq2nvm04dbq3lwlq7h742m-tigervnc-1.12.0/bin:/nix/store/7v07bmyfjq0jdnx6xwxlib05na8kksdf-xwininfo-1.1.4/bin:/nix/store/gfvyxpnr8ji58pdhy7ns4zqy57z34aqm-replbox/bin:/home/runner/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
9 verbose lifecycle ReplitReactjsProject@0.0.1~dev: CWD: /home/runner/vesting-project
10 silly lifecycle ReplitReactjsProject@0.0.1~dev: Args: [ '-c', 'vite' ]
11 silly lifecycle ReplitReactjsProject@0.0.1~dev: Returned: code: 1  signal: null
12 info lifecycle ReplitReactjsProject@0.0.1~dev: Failed to exec dev script
13 verbose stack Error: ReplitReactjsProject@0.0.1 dev: `vite`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:314:20)
13 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:314:20)
13 verbose stack     at maybeClose (internal/child_process.js:1022:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:287:5)
14 verbose pkgid ReplitReactjsProject@0.0.1
15 verbose cwd /home/runner/vesting-project
16 verbose Linux 5.13.0-1025-gcp
17 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "dev"
18 verbose node v12.22.10
19 verbose npm  v6.14.16
20 error code ELIFECYCLE
21 error errno 1
22 error ReplitReactjsProject@0.0.1 dev: `vite`
22 error Exit status 1
23 error Failed at the ReplitReactjsProject@0.0.1 dev script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]


Do you guys have any suggestions ? 
Thank you

Could you share more info about your issue? E.g a minimal example so I can reproduce on my end.

https://vesting.bonfida.org/ is built with vite.js and does not have this issue so I suspect the probleme might not be vite.js related.