Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Requiring just decoder is broken #33

Closed
brianchirls opened this issue Apr 21, 2016 · 5 comments
Closed

Requiring just decoder is broken #33

brianchirls opened this issue Apr 21, 2016 · 5 comments

Comments

@brianchirls
Copy link

brianchirls commented Apr 21, 2016

Until of the newest version (1.1.19) released today, I was able to require just the decoder portion of the code (using webpack), like this:

const decode = require('msgpack-lite/lib/decode').decode;

This worked great, because I didn't need to unnecessarily load the encoding code into the client, which was only decoding. It looks like now the decoder requires the entire repo (as of this commit 189b604), which causes two problems:

  1. I now have to load the encoding scripts, which I don't really need and
  2. It causes a circular dependency, which is screwing up webpack.

Is it possible to revert this change and find another way to accomplish whatever you were trying to do in that commit?

Thanks! (And thanks for writing/maintaining this repo in the first place!)

@kawanet
Copy link
Owner

kawanet commented Apr 22, 2016

Reproduced it. It looks critical. I'll fix it (2) soon.

$ webpack lib/browser.js dist/msgpack.webpack.js 
Hash: dcd507d9eaf8af75033c
Version: webpack 1.13.0
Time: 455ms
             Asset    Size  Chunks             Chunk Names
msgpack.webpack.js  105 kB       0  [emitted]  main
   [0] ./lib/browser.js 297 bytes {0} [built]
   [1] ./lib/encode.js 229 bytes {0} [built]
   [2] ./lib/encode-buffer.js 2.29 kB {0} [built]
   [7] ./lib/codec.js 89 bytes {0} [built]
   [8] ./lib/ext.js 1.93 kB {0} [built]
   [9] ./lib/ext-buffer.js 203 bytes {0} [built]
  [10] ./lib/ext-preset.js 4.57 kB {0} [built] [1 error]
  [11] ./lib/read-core.js 468 bytes {0} [built]
  [12] ./lib/read-format.js 4.3 kB {0} [built]
  [14] ./lib/buffer-lite.js 3.04 kB {0} [built]
  [15] ./lib/buffer-shortage.js 160 bytes {0} [built]
  [16] ./lib/read-token.js 3.52 kB {0} [built]
  [17] ./lib/write-core.js 391 bytes {0} [built]
  [18] ./lib/write-type.js 6.83 kB {0} [built]
  [19] ./lib/write-token.js 5.35 kB {0} [built]
  [20] ./lib/write-uint8.js 263 bytes {0} [built]
  [21] ./lib/decode.js 228 bytes {0} [built]
  [22] ./lib/decode-buffer.js 1.64 kB {0} [built]
  [23] ./lib/encoder.js 580 bytes {0} [built]
  [25] ./lib/decoder.js 621 bytes {0} [built]
    + 6 hidden modules

ERROR in ./lib/ext-preset.js
Module not found: Error: a dependency to an entry point is not allowed
 @ ./lib/ext-preset.js 5:14-28

Commit 189b604 was made for a problem on IE with browserify.

@kawanet
Copy link
Owner

kawanet commented Apr 22, 2016

Error: a dependency to an entry point is not allowed seems another error than you mentioned.

2: It causes a circular dependency, which is screwing up webpack.

I hope the commit e934f55 fixes the problem.

Let me know the steps for me to reproduce the "circular dependency" problem, if you still have.

1: I now have to load the encoding scripts, which I don't really need and

It now requests less modules.

@brianchirls
Copy link
Author

Thanks for the quick patch. This fixes the circular reference problem and webpack now builds properly.

But it still includes both encode and decode, even if you only require one. webpack can't know in advance whether the encode function will actually run, so it just scans for any call to require with a static string path inside it and includes whatever's in that path. Presets for encode and decode would have to exist in separate files.

If #34 is going to cover this part, then I guess we can close this one.

@kawanet
Copy link
Owner

kawanet commented Apr 22, 2016

Presets for encode and decode would have to exist in separate files.

Right. I'm trying it but have not finished it yet. Thanks for your feedbacks, anyway.

@kawanet kawanet closed this as completed Apr 22, 2016
@brianchirls
Copy link
Author

Great. Your work is appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants