Skip to content

Commit

Permalink
refactor: make fs/zlib optional for browsers
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
retrixe committed Apr 29, 2024
1 parent b1ce5d0 commit ec74b09
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions nbt.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
'use strict';

const fs = require('fs');
const zlib = require('zlib');
let fs;
try { fs = require('fs'); } catch (e) { /* Not running on Node.js */ }
let zlib;
try { zlib = require('zlib'); } catch (e) { /* Not running on Node.js */ }

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

Expand Down

0 comments on commit ec74b09

Please sign in to comment.