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

feat(Next.JS): Support server-side Next.JS usage #220

Open thaddeusdiamond opened 10 months ago

thaddeusdiamond commented 10 months ago

Next.JS disallows relative imports since 12.0.1 (see https://nextjs.org/docs/messages/middleware-relative-urls for more information). So, we need to sniff out if we are in the NEXTJS environment and if so, use the fallback URL.

This should resolve: https://github.com/spacebudz/lucid/issues/174

[ Testing: deno task build ]

thaddeusdiamond commented 10 months ago

Hold on this is now not working... it was before. Investigating.

thaddeusdiamond commented 10 months ago

@alessandrokonrad this change works when I build it off of 0.9.8 (as you recommended in the original ticket), but not off of 0.10.7. Any reason why that would be? How do you want to address this, publishing an npm patch called 0.9.8-nextjs?

Rithista commented 2 months ago

@thaddeusdiamond Followup on this PR, tested this PR in a test/production app and works as indended. Would strongly recommend this gets merged, otherwise other next users will fall into the rabbit hole of why certain .wasm functions break and its tricky to debug without going into the module code. Next is now more heavily server-side than before so I expect more users to run into this issue.