KeyringController icon indicating copy to clipboard operation
KeyringController copied to clipboard

Document what is needed to use this library in Webpack

Open mcmire opened this issue 2 years ago • 2 comments

Although we use Browserify, many people use Webpack, so we should document how to use this library with Webpack.

mcmire avatar Feb 22 '23 17:02 mcmire

According to #198, you may need:

resolve: {
  extensions: ['.ts', '.js'],
  fallback: {
    stream: require.resolve('stream-browserify'),
    buffer: require.resolve('buffer'),
    crypto: require.resolve('crypto-browserify'),
    global: require.resolve('globalthis'),
    process: require.resolve('process')
  }
},
plugins: [
  new CopyWebpackPlugin({
    patterns: [
      {
        from: 'node_modules/webextension-polyfill/dist/browser-polyfill.js'
      }
    ]
  }),
  new webpack.ProvidePlugin({
    global: require.resolve('globalthis')
  }),
  new webpack.ProvidePlugin({
    process: require.resolve('process')
  })
]

We should investigate whether this is truly the minimal set of configuration needed or whether we can make this simpler.

mcmire avatar Feb 22 '23 17:02 mcmire

@mcmire Since I have fixed instantiating keyring controller, his methods don't work correctly. Ex. in service worker environment Im trying to call createNewVaultAndKeychain(), documentation says that this method creates 1 new random account so under the hood @scure/bip39 lib's methods getting called and this gives another error:

image

Error's entry point is in /@metamask/browser-passworder/dist/index.js image

Any idea or recommendations how can I completely setup keyring controller?

ko1ebayev avatar Feb 24 '23 12:02 ko1ebayev