d3 / d3-request

A convenient alternative to XMLHttpRequest.
BSD 3-Clause "New" or "Revised" License
110 stars 54 forks source link

Electron compatibility #31

Open nathansalwen opened 6 years ago

nathansalwen commented 6 years ago

I am not sure if this is an electron issue or a d3 issue (or maybe just user error). However, since it works with an older version of d3 but not the latest, I am routing it here. I do not know

d3 version 4.12 (d3-request 1.0.6) does not work well with electron. In particular, I cannot access local files by relative address, for example d3.csv("data.csv")

I found that, if I comment line 3 in d3-request/builds/d3-request.node.js //var XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest; it uses the built-in electron XMLHttpRequest and then works.

When I run an earlier version of d3 (version 3.5.17), which does not have any d3-request module, this issue does not occur and d3.csv("data.csv") succeed

Thank you for the packages.

index.html: `<!DOCTYPE html>

`

package.json (works): { "name": "simple", "version": "0.1.0", "main": "./main.js", "scripts": { "start": "electron .", "binary": { "module_name": "simple", "module_path": "./lib/binding/", "host": "localhost" } }, "dependencies": { "electron-prebuilt": "", "electron-debug": "", "d3": "^3.5.6" } }

package.json (fails): { "name": "simple", "version": "0.1.0", "main": "./main.js", "scripts": { "start": "electron .", "binary": { "module_name": "simple", "module_path": "./lib/binding/", "host": "localhost" } }, "dependencies": { "electron-prebuilt": "", "electron-debug": "", "d3": "" } }

dbrezack commented 6 years ago

This is currently an issue with node-XMLHttpRequest a version bump in the module should fix this issues but I don't think the guys over there have added it to the latest version yet.

Same issue will occur with WebPack.

@mbostock Would you like a separate issue created for this ?

See for reference https://github.com/driverdan/node-XMLHttpRequest/issues/152