Fork me on GitHub
#cljs-dev
<
2017-02-17
>
mhuebert01:02:02

@dnolen hmm that doesn’t seem to be the problem.. Adding this top-level expr (println [js/__dirname (contains? (set (.keys js/Object js/global)) “__dirname”)]) outputs [nil true]

mhuebert01:02:40

however I still have to try without using cljsbuild or figwheel

dnolen14:02:53

hrm that’s a pretty strange result

chris-andrews17:02:00

I’m testing out the node modules support in clojurescript 1.9.473 and I'm having an issue using the d3 module from npm I'm using the example from https://clojurescript.org/guides/javascript-modules verbatim except I've added {"d3": "4.5.0"} as a dependency to package.json (and installed it) and I added the line var d3 = require("d3"); to the npm_stuff.js file after the other require statments. When I try to build the project I get the error:

ERROR: JSC_COMMONJS_MODULE_LOAD_ERROR. Failed to load module "d3" at .../jsfresh/src/libs/npm_stuff.js line 3 : 9

Exception in thread "main" java.lang.IllegalStateException: Cannot build without root node being specified, compiling: ...

chris-andrews17:02:37

Any ideas why this would happen?

chris-andrews17:02:42

I tried it with the externs from cljsjs included the same way as the react externs were and get the same error

dnolen17:02:40

it just sounds like you missed a step or something about d3 makes it not get picked up

dnolen17:02:06

the JS modules stuff is very experimental so you need to expect to have to debug and investigate these kinds of issues on your own

dnolen17:02:11

and report and submit patches etc.

chris-andrews17:02:46

ok I’ll see if I can figure anything else out. will get a report together if I can narrow this down at all

chris-andrews17:02:56

thanks for commenting

dnolen18:02:14

once you rule out a misstep

dnolen18:02:31

then something about how get all the inputs isn’t working right

dnolen18:02:51

make something minimal that demonstrates the problem and maybe somebody will take a look

chris-andrews18:02:57

will do. so far trying other npm libraries and this seems specific to d3. doesn’t happen with lodash or jquery

dnolen18:02:59

ok then that’s information we didn’t have before

dnolen18:02:21

if you know JS you can examine how we get the inputs

dnolen18:02:46

cljs.build.api/node-inputs invokes a JS script that calls module-deps a NPM lib for figuring this out

chris-andrews18:02:04

ok I’ll dig around with that

dnolen18:02:41

likely we can’t find the main for d3

dnolen18:02:44

or something like that

chris-andrews18:02:21

yeah, the main for d3 is build/d3.node.js

chris-andrews18:02:57

maybe the extra dot causes a bug in module-deps

chris-andrews18:02:26

I’ll try a few more libs and see if I can find any patterns

dnolen18:02:24

@anmonteiro does this sound like something obvious to you? ^

dnolen18:02:34

I’d be surprised if the problem was module-deps

anmonteiro18:02:09

I think that there’s just not enough information to start pointing fingers

anmonteiro18:02:37

I would be really surprised if the dots in the d3 main were the problem for example

anmonteiro18:02:57

just looks like there’s a file missing from the foreign-libs entry

anmonteiro18:02:19

@dnolen I feel like a minimal repro (even with d3) would be helpful

chris-andrews18:02:50

ok, will try to put together a minimal example for you

chris-andrews18:02:04

so far have also found a problem with http://socket.io

chris-andrews18:02:17

other libs I’ve tried from the most popular list on npm don’t seem to have the same issues

anmonteiro18:02:18

trying d3 now

anmonteiro18:02:17

@dnolen @chris-andrews I suppose the problem with d3 is that it’s doing fancy dynamic stuff with the exports

'use strict';

Object.defineProperty(exports, '__esModule', { value: true });
var d3Voronoi = require('d3-voronoi');
var d3Zoom = require('d3-zoom');

var version = "4.5.0";

exports.version = version;
Object.keys(d3Voronoi).forEach(function (key) { exports[key] = d3Voronoi[key]; });
Object.keys(d3Zoom).forEach(function (key) { exports[key] = d3Zoom[key]; });
Object.defineProperty(exports, "event", {get: function() { return d3Selection.event; }});

anmonteiro18:02:43

I don’t think that’s going to work

anmonteiro18:02:38

the alternative will be requiring d3/index, but that doesn’t work with the current CLJS compiler because we need to bump Closure to have the ES6 import feature: https://github.com/d3/d3/blob/master/index.js

chris-andrews19:02:26

@anmonteiro interesting & looks like that’s the issue

dnolen21:02:48

@anmonteiro I think pprint patch needs a rebase?

anmonteiro21:02:03

let me check it out

anmonteiro21:02:56

@dnolen thanks for the heads up. just attached a rebased patch