Coder Social home page Coder Social logo

browser support? about bip39 HOT 9 CLOSED

bitcoinjs avatar bitcoinjs commented on May 24, 2024
browser support?

from bip39.

Comments (9)

NullVoxPopuli avatar NullVoxPopuli commented on May 24, 2024 1

I have safe-buffer, which looking at the index.js inside safe-buffer, "it" is trying to require buffer which isn't in my node_modules.

This also confirms that cjs is the correct transform. thanks.

from bip39.

junderw avatar junderw commented on May 24, 2024 1

@thatsbrandon This question is better asked on a webpack forum/issue.

I do remember faintly that latest webpack requires some extra configuration to include Buffer.

from bip39.

Red3nzo avatar Red3nzo commented on May 24, 2024 1

@junderw Thank you! I ended up looking into this extra configuration for Buffer in webpack & I found the solution which was to create my own resolve.fallback polyfill. I got my extension to compile a run without an issue

from bip39.

dcousens avatar dcousens commented on May 24, 2024

@NullVoxPopuli what issues are you experiencing specifically?
This project does work if you use browserify or web-pack or the like.

from bip39.

NullVoxPopuli avatar NullVoxPopuli commented on May 24, 2024

I'm actually trying not to use browserify (feels hacky), webpack (personal vendetta), and am using rollup and broccoli.

if I just try to load the module directly: node_modules/bip39/index.js I get this error when my app boots (breaking all the things / not even rendering a page):

Could not find module `safe-buffer` imported from `(require)`

(same error happens when I try an amd transform on it)

if I do a common-js transform on it, my app loads, and then I get this error when I import the module:

Error: Could not find module `buffer` imported from `bip39`
TypeError: Cannot read property 'exports' of undefined

I have a unit test that file that only has:

import * as bip from 'bip39';
console.log(bip);

from bip39.

dcousens avatar dcousens commented on May 24, 2024

@NullVoxPopuli this isn't an issue of this module.

We have safe-buffer listed as a dependency in our package.json:

"safe-buffer": "^5.0.1",

The tools are what you need to fix 👍

from bip39.

dcousens avatar dcousens commented on May 24, 2024

@NullVoxPopuli you'll need to add Buffer to your bundling setup.

OOI, why do you think browserify is "hacky"?

from bip39.

Red3nzo avatar Red3nzo commented on May 24, 2024

@dcousens Do you have any links as to where I can add Buffer to my webpack build, I'm, new to webpack?

from bip39.

NullVoxPopuli avatar NullVoxPopuli commented on May 24, 2024

@dcousens the problem is that browserify "does what it needs to" to make "the build work" giving no cares for bundle size. polyfill node builtins bloats the output JS a ton.

Here is a < 100 line version of bip39(ish), using native browser APIs: https://github.com/NullVoxPopuli/emberclear/blob/31c2807ade0f09da1ace435b0a90267c3b2bddd3/client/web/addons/crypto/addon/workers/crypto/utils/mnemonic.ts

(ish) = I haven't tested against bip39, and don't need to for that specific app

from bip39.

Related Issues (20)

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.