From 4462d8b05d3aba37c865cf53e09b3199cf051a92 Mon Sep 17 00:00:00 2001 From: dcodeIO Date: Thu, 8 Dec 2016 00:56:09 +0100 Subject: [PATCH] Attempt to hide require('fs') from webpack, see #527 --- README.md | 26 +++++++++++++------------- src/util.js | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index afc73d38a..7eca2d360 100644 --- a/README.md +++ b/README.md @@ -284,19 +284,19 @@ Documentation ### Data type recommendations -| Value type | protobuf Type | Size / Notes -|--------------------------|---------------|----------------------------------------------------------------------------------- -| Unsigned 32 bit integers | uint32 | 1 to 5 bytes. -| Signed 32 bit integers | sint32 | 1 to 5 bytes. Do not use int32 (always encodes negative values as 10 bytes). -| Unsigned 52 bit integers | uint64 | 1 to 10 bytes. -| Signed 52 bit integers | sint64 | 1 to 10 bytes. Do not use int64 (always encodes negative values as 10 bytes). -| Unsigned 64 bit integers | uint64 | Use with long.js. 1 to 10 bytes. -| Signed 64 bit integers | sint64 | Use with long.js. 1 to 10 bytes. Do not use int64 (always encodes negative values as 10 bytes). -| 32 bit precision floats | float | 4 bytes. -| 64 bit precision floats | double | 8 bytes. Use float if 32 bits of precision are enough. -| Boolean values | bool | 1 byte. -| Strings | string | 1 byte + utf8 byte length. -| Buffers | bytes | 1 byte + byte length. +| Value type | protobuf Type | Size / Notes +|---------------------|---------------|----------------------------------------------------------------------------------- +| Unsigned 32 bit int | uint32 | 1 to 5 bytes. +| Signed 32 bit int | sint32 | 1 to 5 bytes. Do not use int32 (always encodes negative values as 10 bytes). +| Unsigned 52 bit int | uint64 | 1 to 10 bytes. +| Signed 52 bit int | sint64 | 1 to 10 bytes. Do not use int64 (always encodes negative values as 10 bytes). +| Unsigned 64 bit int | uint64 | Use with long.js. 1 to 10 bytes. +| Signed 64 bit int | sint64 | Use with long.js. 1 to 10 bytes. Do not use int64 (always encodes negative values as 10 bytes). +| 32 bit float | float | 4 bytes. +| 64 bit float | double | 8 bytes. Use float if 32 bits of precision are enough. +| Boolean values | bool | 1 byte. +| Strings | string | 1 to 5 bytes + utf8 byte length. +| Buffers | bytes | 1 to 5 bytes + byte length. Command line ------------ diff --git a/src/util.js b/src/util.js index 1c5f7eb89..ca596bce0 100644 --- a/src/util.js +++ b/src/util.js @@ -98,7 +98,7 @@ util.asPromise = asPromise; function fetch(path, callback) { if (!callback) return asPromise(fetch, util, path); - var fs; try { fs = require("fs"); } catch (e) {} // eslint-disable-line no-empty + var fs; try { fs = Function('r', 'return r("fs")')(require); } catch (e) { } // eslint-disable-line no-new-func, no-empty if (fs && fs.readFile) return fs.readFile(path, "utf8", callback); var xhr = new XMLHttpRequest();