Skip to content

Commit ec74b09

Browse files
committed
refactor: make fs/zlib optional for browsers
This allows users to shrink bundle sizes by marking them as externals. I would prefer to do away with these entirely to shrink the library, but I've only opted to do this much for now.
1 parent b1ce5d0 commit ec74b09

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

nbt.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
'use strict';
22

3-
const fs = require('fs');
4-
const zlib = require('zlib');
3+
let fs;
4+
try { fs = require('fs'); } catch (e) { /* Not running on Node.js */ }
5+
let zlib;
6+
try { zlib = require('zlib'); } catch (e) { /* Not running on Node.js */ }
57

68
const Tag = require('./lib/base_tag');
79

0 commit comments

Comments
 (0)