CashScript / cashscript

⚖️ Easily write and interact with Bitcoin Cash smart contracts
https://cashscript.org
MIT License
112 stars 79 forks source link

Allow for config-free usage in browser (e.g. Next.js) #147

Open rkalis opened 1 year ago

rkalis commented 1 year ago

Right now, this is what a Next.js config file has to look like for CashScript to work with it:

/** @type {import('next').NextConfig} */
const nextConfig = {
  reactStrictMode: true,
  webpack: (config, options) => {
    config.experiments = {...config.experiments, topLevelAwait: true };
    config.resolve.alias = {...config.resolve.alias, ...{
        net: false,
        tls: false,
        fs: false,
      }};

    return config
  },
}

module.exports = nextConfig

Ideally we don't require any of this config. So we'll have to find a solution to the fact that CashScript and its dependencies require these Node.js specific modules. @mr-zwets mentioned that @mainnet-pat is also familiar with these issues of trying to run CashScript / electrum-cash in the browser, so maybe he'll have some ideas as well.