Skip to content

Commit 4462d8b

Browse files
committed
Attempt to hide require('fs') from webpack, see #527
1 parent 98a58d4 commit 4462d8b

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

README.md

+13-13
Original file line numberDiff line numberDiff line change
@@ -284,19 +284,19 @@ Documentation
284284

285285
### Data type recommendations
286286

287-
| Value type | protobuf Type | Size / Notes
288-
|--------------------------|---------------|-----------------------------------------------------------------------------------
289-
| Unsigned 32 bit integers | uint32 | 1 to 5 bytes.
290-
| Signed 32 bit integers | sint32 | 1 to 5 bytes. Do not use int32 (always encodes negative values as 10 bytes).
291-
| Unsigned 52 bit integers | uint64 | 1 to 10 bytes.
292-
| Signed 52 bit integers | sint64 | 1 to 10 bytes. Do not use int64 (always encodes negative values as 10 bytes).
293-
| Unsigned 64 bit integers | uint64 | Use with long.js. 1 to 10 bytes.
294-
| Signed 64 bit integers | sint64 | Use with long.js. 1 to 10 bytes. Do not use int64 (always encodes negative values as 10 bytes).
295-
| 32 bit precision floats | float | 4 bytes.
296-
| 64 bit precision floats | double | 8 bytes. Use float if 32 bits of precision are enough.
297-
| Boolean values | bool | 1 byte.
298-
| Strings | string | 1 byte + utf8 byte length.
299-
| Buffers | bytes | 1 byte + byte length.
287+
| Value type | protobuf Type | Size / Notes
288+
|---------------------|---------------|-----------------------------------------------------------------------------------
289+
| Unsigned 32 bit int | uint32 | 1 to 5 bytes.
290+
| Signed 32 bit int | sint32 | 1 to 5 bytes. Do not use int32 (always encodes negative values as 10 bytes).
291+
| Unsigned 52 bit int | uint64 | 1 to 10 bytes.
292+
| Signed 52 bit int | sint64 | 1 to 10 bytes. Do not use int64 (always encodes negative values as 10 bytes).
293+
| Unsigned 64 bit int | uint64 | Use with long.js. 1 to 10 bytes.
294+
| Signed 64 bit int | sint64 | Use with long.js. 1 to 10 bytes. Do not use int64 (always encodes negative values as 10 bytes).
295+
| 32 bit float | float | 4 bytes.
296+
| 64 bit float | double | 8 bytes. Use float if 32 bits of precision are enough.
297+
| Boolean values | bool | 1 byte.
298+
| Strings | string | 1 to 5 bytes + utf8 byte length.
299+
| Buffers | bytes | 1 to 5 bytes + byte length.
300300

301301
Command line
302302
------------

src/util.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ util.asPromise = asPromise;
9898
function fetch(path, callback) {
9999
if (!callback)
100100
return asPromise(fetch, util, path);
101-
var fs; try { fs = require("fs"); } catch (e) {} // eslint-disable-line no-empty
101+
var fs; try { fs = Function('r', 'return r("fs")')(require); } catch (e) { } // eslint-disable-line no-new-func, no-empty
102102
if (fs && fs.readFile)
103103
return fs.readFile(path, "utf8", callback);
104104
var xhr = new XMLHttpRequest();

0 commit comments

Comments
 (0)