Close Menu
  • Home
  • Altcoin
  • Bitcoin
  • Crypto
  • Forex
  • Online Money
What's Hot

op return – What is the justification for allowing multiple OP_RETURN outputs per transaction in Bitcoin Core v30?

October 4, 2025

Highest Lowest MT4 Indicator – ForexMT4Indicators.com

October 4, 2025

Google Search serving issue in some locales

October 4, 2025
Facebook X (Twitter) Instagram
  • Altcoin
  • Bitcoin
  • Crypto
  • Forex
  • Online Money
Facebook X (Twitter) Instagram
Cointelegraphe
  • Home
  • Altcoin
  • Bitcoin
  • Crypto
  • Forex
  • Online Money
Cointelegraphe
Home»Bitcoin»Webpack issue with tiny-secp256k1 and ECPair
Webpack issue with tiny-secp256k1 and ECPair
Bitcoin

Webpack issue with tiny-secp256k1 and ECPair

adminBy adminJuly 9, 2025No Comments2 Mins Read
Share
Facebook Twitter LinkedIn Pinterest Email


I am developing a browser extension using Webpack v5 and incorporating the bitcoinjs-lib and ecpair libraries to create a Bitcoin wallet. However, I am encountering an error when attempting to load the WebAssembly module.

I would greatly appreciate any guidance or suggestions on how to resolve this issue successfully and instantiate the WebAssembly module in my browser extension.

Error Message:

Webpack issue with tiny-secp256k1 and ECPair

Here are the key details of my setup:

  • I am using Webpack v5 to bundle the application.
  • I have included the bitcoinjs-lib and ecpair libraries as dependencies in my project.
  • Error is occurring when trying to import tiny-secp256k1 and also when passing that instance to ECPairFactory.

enter image description here

My webpack.config.js file:

const path = require("path");
const CopyPlugin = require("copy-webpack-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const { exec } = require("child_process");
const fs = require("fs");

function copyFolderSync(from, to) {
  fs.mkdirSync(to, { recursive: true });
  fs.readdirSync(from).forEach((element) => {
    if (element !== "manifest.json") {
      if (fs.lstatSync(path.join(from, element)).isFile()) {
        fs.copyFileSync(path.join(from, element), path.join(to, element));
      } else {
        copyFolderSync(path.join(from, element), path.join(to, element));
      }
    }
  });
}

module.exports = {
  module: {
    rules: [
      {
        test: /\.scss$/,
        use: ["style-loader", "css-loader", "sass-loader"],
      },
      {
        test: /\.(js|jsx)$/,
        exclude: /node_modules/,
        use: {
          loader: "babel-loader",
          options: {
            presets: ["@babel/preset-env", "@babel/preset-react"],
          },
        },
      },
      {
        test: /\.wasm$/,
        type: "webassembly/async", // or "webassembly/sync"
      },
    ],
  },
  experiments: {
    asyncWebAssembly: true,
  },
  resolve: {
    extensions: [".js", ".jsx"],
    fallback: {
      buffer: require.resolve("buffer"),
      stream: require.resolve("stream-browserify"),
    },
  },
  entry: {
    background: "./app/background.js",
    popup: "./app/popup.js",
  },
  output: {
    path: path.resolve(__dirname, "dist/chrome"),
    filename: "[name].js",
  },
  plugins: [
    new HtmlWebpackPlugin({
      template: "./app/popup.html",
      filename: "popup.html",
      chunks: ["popup"],
    }),
    new CopyPlugin({
      patterns: [
        {
          from: "app",
          to: "",
          globOptions: {
            ignore: [
              "**/background.js",
              "**/popup.js",
              "**/popup.html",
              "**/build-types",
              "**/manifest",
            ],
          },
        },
        {
          from: "ui",
          to: "ui",
        },
      ],
    }),
    {
      apply: (compiler) => {
        compiler.hooks.afterEmit.tap("AfterEmitPlugin", (compilation) => {
          // Run the JavaScript file after the compilation is done
          exec("node development/build/index.js", (error, stdout, stderr) => {
            if (error) {
              console.error(`exec error: ${error}`);
              return;
            }
            // Copy files from the temp folder to other folders
            fs.readdirSync(path.resolve(__dirname, "dist")).forEach((dest) => {
              copyFolderSync("dist/chrome", `dist/${dest}`);
            });
          });
        });
      },
    },
  ],
};



Source link

ECPair Issue tinysecp256k1 Webpack
Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
admin
  • Website

Related Posts

op return – What is the justification for allowing multiple OP_RETURN outputs per transaction in Bitcoin Core v30?

October 4, 2025

Google Search serving issue in some locales

October 4, 2025

XRP’s Next Rally Predicted To Shock Markets

October 2, 2025

FOMC Rate Cuts Loom As Bitcoin Holds Above $109,500 EMA

October 1, 2025
Add A Comment
Leave A Reply Cancel Reply

Top Insights

op return – What is the justification for allowing multiple OP_RETURN outputs per transaction in Bitcoin Core v30?

October 4, 2025

Highest Lowest MT4 Indicator – ForexMT4Indicators.com

October 4, 2025

Google Search serving issue in some locales

October 4, 2025

BTC Nears Record Highs as Total Market Cap Peaks at $4.21T

October 4, 2025
ads

Subscribe to Updates

Get the latest creative news from Cointelegraphe about Crypto, bItcoin and Altcoin.

About Us
About Us

At CoinTelegraphe, we are dedicated to bringing you the latest and most insightful news, analysis, and updates from the dynamic world of cryptocurrency. Our mission is to provide our readers with accurate, timely, and comprehensive information to help them navigate the complexities of the crypto market.

Facebook X (Twitter) Instagram Pinterest YouTube
Top Insights

op return – What is the justification for allowing multiple OP_RETURN outputs per transaction in Bitcoin Core v30?

October 4, 2025

Highest Lowest MT4 Indicator – ForexMT4Indicators.com

October 4, 2025

Google Search serving issue in some locales

October 4, 2025
Get Informed

Subscribe to Updates

Get the latest creative news from Cointelegraphe about Crypto, bItcoin and Altcoin.

Please enable JavaScript in your browser to complete this form.
Loading
  • About us
  • Contact Us
  • Shop
  • Privacy Policy
  • Terms and Conditions
Copyright 2024 Cointelegraphe Design By Horaam Sultan.

Type above and press Enter to search. Press Esc to cancel.