spacebudz / lucid

Lucid is a library, which allows you to create Cardano transactions and off-chain code for your Plutus contracts in JavaScript, Deno and Node.js.
https://lucid.spacebudz.io
MIT License
336 stars 133 forks source link

Issue with Lucid Initialization in Chrome Extension #210

Closed Varagos closed 11 months ago

Varagos commented 11 months ago

I'm encountering an issue when trying to initialize Lucid in my Chrome Extension. The relevant code can be found in src/pages/Popup/Popup.jsx.

// code snippet
async function lucidConnect() {
  const projectId = 'YOUR_PROJECT_ID_HERE'; // Replace with your Project ID
  const lucid = await Lucid.new(
    new Blockfrost('https://cardano-preview.blockfrost.io/api/v0', projectId),
    'Preview'
  );
  console.log('Lucid', lucid);
}

To reproduce the issue, please follow these steps:

  1. Clone the repository from here .
  2. Run npm install to install the dependencies.
  3. Run npm start.
  4. Load the extension on Chrome by accessing chrome://extensions/, checking Developer mode, clicking on Load unpacked extension, and selecting the build folder.
  5. Right-click on the loaded extension, and click Inspect Pop-up to view the extension logs and the error of interest.

Please make sure to replace 'YOUR_PROJECT_ID_HERE' with your actual project ID in the code snippet.

I suspect this issue may be related to webpack configuration. I have added the options mentioned in the documentation: webpack.config.js

experiments: {
    asyncWebAssembly: true,
    topLevelAwait: true,
    layers: true // optional, with some bundlers/frameworks it doesn't work without
  }

Any insights into this possibility or help in resolving the issue would be greatly appreciated. Thank you!