cramforce/splittable

Add support for requires of JSON

Closed this issue ยท 8 comments

While running splittable on my file, I get this error:

> splittable src/index.js


assert.js:85
  throw new assert.AssertionError({
  ^
AssertionError: Target node with node_modules/diffie-hellman/lib/primes.json key should exist
    at TopologicalSort.addEdge (/home/darshak/Code/mangabot/node_modules/topological-sort/build.js:26:9)
    at /home/darshak/Code/mangabot/node_modules/splittable/splittable.js:220:14
    at Array.forEach (native)
    at /home/darshak/Code/mangabot/node_modules/splittable/splittable.js:219:17
    at Array.forEach (native)
    at Readable.<anonymous> (/home/darshak/Code/mangabot/node_modules/splittable/splittable.js:218:31)
    at emitNone (events.js:91:20)
    at Readable.emit (events.js:185:7)
    at endReadableNT (/home/darshak/Code/mangabot/node_modules/readable-stream/lib/_stream_readable.js:926:12)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickCallback (internal/process/next_tick.js:98:9)

Running Node.js 6.9.1.

Could this be because it is a JSON file? I took a quick peek at splittable.js, and saw that the maybeAddDotJs() function adds .js to anything that does not end with .js, and the resulting string is pushed into topo as a node.

Please advise.

Fixed this a minute ago in #27.

Uh-oh! Same error in 2.1.1.

Any chance you post a sample project like https://github.com/garthenweb/splittable-test

At the very least 2.1.1. should have more debug output in the error message now.

Sure. Give me a moment.

Here: https://github.com/dar5hak/splittable-test

I figured that the dependency causing the error is Telegraf, so I added just that, and was able to reproduce it.

npm run split runs splittable on index.js.

Ah, this is a different error. I'll see whether support for JSON inputs can be added easily.

This works now. Unfortunately telegraf still fails due to circular dependencies which are not and cannot be supported in splittable.

Typically it is possible to get rid of them if one controls the dependencies.

Awesome! Thank you! ๐Ÿ˜ƒ