kawanet / msgpack-lite

Fast Pure JavaScript MessagePack Encoder and Decoder / msgpack.org[JavaScript]
https://www.npmjs.com/package/msgpack-lite
MIT License
987 stars 127 forks source link

Circular dependencies #91

Open acoreyj opened 6 years ago

acoreyj commented 6 years ago

These prevent at least Rollup from compiling for web in a way that works

Circular dependency: node_modules/msgpack-lite/lib/bufferish.js -> node_modules/msgpack-lite/lib/bufferish-array.js -> node_modules/msgpack-lite/lib/bufferish.js Circular dependency: node_modules/msgpack-lite/lib/bufferish.js -> node_modules/msgpack-lite/lib/bufferish-array.js -> commonjs-proxy:/Users/Corey/Documents/workspace/mkr/node_modules/msgpack-lite/lib/bufferish.js -> node_modules/msgpack-lite/lib/bufferish.js Circular dependency: node_modules/msgpack-lite/lib/bufferish.js -> node_modules/msgpack-lite/lib/bufferish-buffer.js -> node_modules/msgpack-lite/lib/bufferish.js Circular dependency: node_modules/msgpack-lite/lib/bufferish.js -> node_modules/msgpack-lite/lib/bufferish-uint8array.js -> node_modules/msgpack-lite/lib/bufferish.js Circular dependency: node_modules/msgpack-lite/lib/bufferish.js -> node_modules/msgpack-lite/lib/bufferish-proto.js -> node_modules/msgpack-lite/lib/bufferish.js Circular dependency: node_modules/msgpack-lite/lib/encode.js -> node_modules/msgpack-lite/lib/encode-buffer.js -> node_modules/msgpack-lite/lib/write-core.js -> node_modules/msgpack-lite/lib/ext-packer.js -> node_modules/msgpack-lite/lib/encode.js Circular dependency: node_modules/msgpack-lite/lib/encode.js -> node_modules/msgpack-lite/lib/encode-buffer.js -> node_modules/msgpack-lite/lib/write-core.js -> node_modules/msgpack-lite/lib/ext-packer.js -> commonjs-proxy:/Users/Corey/Documents/workspace/mkr/node_modules/msgpack-lite/lib/encode.js -> node_modules/msgpack-lite/lib/encode.js Circular dependency: node_modules/msgpack-lite/lib/decode.js -> node_modules/msgpack-lite/lib/decode-buffer.js -> node_modules/msgpack-lite/lib/read-core.js -> node_modules/msgpack-lite/lib/ext-unpacker.js -> node_modules/msgpack-lite/lib/decode.js Circular dependency: node_modules/msgpack-lite/lib/decode.js -> node_modules/msgpack-lite/lib/decode-buffer.js -> node_modules/msgpack-lite/lib/read-core.js -> node_modules/msgpack-lite/lib/ext-unpacker.js -> commonjs-proxy:/Users/Corey/Documents/workspace/mkr/node_modules/msgpack-lite/lib/decode.js -> node_modules/msgpack-lite/lib/decode.js

kawanet commented 6 years ago

@acoreyj Let me know the command to reproduce the message above.

I have never faced the problem on compiling it with browserify though.

acoreyj commented 6 years ago

@kawanet

I don't have a simple reproduction setup. Basically if you compile a project with rollup you will see this printout. You can see more about it here and here.

I'm using rollup to build a bundle that requires fortune-indexeddb which requires msgpack-lite.

Yup it does work with browserify, what I ended up doing is creating a browserify bundle of fortune-indexeddb and include that. This may be more of an issue of fortune-indexeddb not including a bundled distribution.

Not sure what would be for you to do other than switching everything to javascript modules.

Although is there a reason that your browser field in the package.json doesn't just point to the bundle in dist?

kawanet commented 6 years ago

Although is there a reason that your browser field in the package.json doesn't just point to the bundle in dist?

No reason but just missing, I guess.

pkit commented 4 years ago

It's simple:

// bufferish-array.js
var Bufferish = require("./bufferish");
// bufferish.js
var BufferArray = exports.Array = require("./bufferish-array");

Here's the circle. Pretty nasty one. Refactoring out all the stuff like var isArray = exports.isArray = require("isarray"); into bufferish-utils.js will probably fix it.