Last active
July 3, 2024 02:00
-
-
Save jdalton/57ea855c036f28be6235884d96f69b8d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
const fs = require('fs') | |
const path = require('path') | |
const zlib = require('zlib') | |
require.extensions['.gz'] = | |
require.extensions['.js.gz'] = (module, filename) => { | |
if (path.extname(filename.slice(0, -3)) === '.js') { | |
let content = zlib.unzipSync(fs.readFileSync(filename)).toString() | |
content = content.charCodeAt(0) === 0xFEFF ? content.slice(1) : content | |
module._compile(content, filename) | |
} | |
} | |
require.extensions['.js'] = ((func) => (module, filename) => { | |
const gz = filename + '.gz' | |
return fs.existsSync(gz) ? require.extensions['.gz'](module, gz) : func(module, filename) | |
})(require.extensions['.js']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment