Background
I am trying to use dgraph-js-http in a Svelte application.
Error
The initial error I was facing was:
Uncaught ReferenceError: buffer is not defined
<anonymous> http://localhost:5000/build/bundle.js:6947
I'm including this as maybe my solution to this was not the best, and that hopefully there is a way to solve both this issue, and the current blocker issue.
However, after a trial-and-error approach (see below for the various things I've tried) I'm now stuck.
Current error
After solving the above error, I am now blocked on this error:
Uncaught ReferenceError: define is not defined
Attempts to resolve
None of the following have worked.
- Add
<script src="https://bundle.run/stream@0.0.2"></script>to index.html - Run
npm install stream - Add
import * as Stream from "stream"to the App.svelte file - Add
import * as Stream from "stream"to the stores.js file - Add
preferBuiltins:truetorollup.config.js - Add
npm install --save-dev rollup-plugin-node-polyfills - Add
preferBuiltins:falsetorollup.config.js. This resolved prior errors and resulted in the new error of:Uncaught ReferenceError: define is not defined - Add
npm install --save define. This, now results in the current blocker:
Uncaught ReferenceError: exports is not defined