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
339 stars 139 forks source link

This import assertion requires the loader to be "json" instead: #199

Open hgextracts opened 1 year ago

hgextracts commented 1 year ago

hello i was curious about deno fresh framework and decided i would try to use lucid in this environment. i am still learning so maybe i did something wrong but from i can tell the error is coming from the library itself when trying to load blockfrost.ts

✘ [ERROR] The file "https://deno.land/x/lucid@0.10.6/package.json" was loaded with the "js" loader

https://deno.land/x/lucid@0.10.6/src/core/core.ts:3:24:
  3 │ import packageJson from "../../package.json" assert { type: "json" };
    ╵                         ~~~~~~~~~~~~~~~~~~~~

This import assertion requires the loader to be "json" instead:

https://deno.land/x/lucid@0.10.6/src/core/core.ts:3:54:
  3 │ import packageJson from "../../package.json" assert { type: "json" };
    ╵                                                       ~~~~~~~~~~~~

You need to either reconfigure esbuild to ensure that the loader for this file is "json" or you need to remove this import assertion.

here is my component for reference


  import {
  h,
  Component,
} from "https://unpkg.com/preact@latest/dist/preact.module.js";
import { Blockfrost, Lucid } from "https://deno.land/x/lucid@0.10.6/mod.ts";

class WalletConnector extends Component {
  lucid: any;

  async connectWallet() {
    this.lucid = await Lucid.new(
      new Blockfrost(
        "**********************",
        "**********************"
      ),
      "Preprod"
    );

    const api = await window.cardano.nami.enable();
    this.lucid.selectWallet(api);
  }

  render() {
    return (
      <button onClick={this.connectWallet.bind(this)}>Connect Wallet</button>
    );
  }
}

export default WalletConnector;