Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function require(path: string) {
if (path === '') {
throw new Error('Cannot import an empty path');
}
const usedPath = manager.getPresetAliasedPath(path);
const bfsModule = BrowserFS.BFSRequire(usedPath);
if (path === 'os') {
const os = require('os-browserify');
os.homedir = () => '/home/sandbox';
return os;
}
if (bfsModule) {
return bfsModule;
}
if (path === 'module') {
return class NodeModule {
filename = undefined;
id = undefined;
loaded = false;
static _resolveFilename(toPath: string, module) {
if (module.filename == null) {
throw new Error('Module has no filename');
function require(path: string) {
if (path === '') {
throw new Error('Cannot import an empty path');
}
const usedPath = manager.getPresetAliasedPath(path);
const bfsModule = BrowserFS.BFSRequire(usedPath);
if (path === 'os') {
const os = require('os-browserify');
os.homedir = () => '/home/sandbox';
return os;
}
if (bfsModule) {
return bfsModule;
}
if (path === 'module') {
return class NodeModule {
filename = undefined;
id = undefined;
loaded = false;
static _resolveFilename(toPath: string, module) {
if (module.filename == null) {
throw new Error('Module has no filename');
if (path === 'tty') {
return {
isatty () {
return false
}
}
}
if (path === 'util') {
return require('util')
}
if (path === 'os') {
const os = require('os-browserify')
os.homedir = () => '/home/sandbox'
return os
}
const module = BrowserFS.BFSRequire(path)
if (module) {
return module
}
if (IGNORED_MODULES.indexOf(path) > -1) {
return {}
}
const fs = BrowserFS.BFSRequire('fs')
return evaluateFromPath(
fs,
BrowserFS.BFSRequire,
if (path === 'tty') {
return {
isatty() {
return false;
},
};
}
if (path === 'util') {
return require('util');
}
if (path === 'os') {
const os = require('os-browserify');
os.homedir = () => '/home/sandbox';
return os;
}
const module = BrowserFS.BFSRequire(path);
if (module) {
return module;
}
if (IGNORED_MODULES.indexOf(path) > -1) {
return {};
}
const fs = BrowserFS.BFSRequire('fs');
return evaluateFromPath(
fs,
BrowserFS.BFSRequire,