npm i import-locals
import locals from "import-locals";
const locals = require("import-locals"); // ES5 usage
locals.export("request/lib/cookies", "RequestJar");
locals.export("request/lib/cookies", "CookieJar");
locals.export("request/lib/cookies", "CookieJar", "LocalJar");
import { RequestJar, CookieJar, LocalJar } from "request/lib/cookies"; // ES6 works
const { RequestJar, CookieJar, LocalJar } = require("request/lib/cookies");
// you can access internal GlobalPatcher
global.locals.separator = "\n\n";
global.locals.unpatch();
global.locals.compile.call(module, content, filename);
export(request: String, variable: String, name: String = variable);
-
request
- module name or path -
variable
- name of variable (or function, class, etc) to export -
name
- name to use for export, by default the same asvariable
/* Usage example */
patcher.export("request/lib/cookies", "RequestJar");
patcher.export("request/lib/cookies", "CookieJar", "LocalJar");
import { RequestJar, LocalJar } from "request/lib/cookies";
unexport(request: String, variable: String = null, name: String = variable);
-
request
- module name or path -
variable
- ifnull
unexports all variables -
name
- name used for export, by default the same asvariable
/* Usage example */
patcher.unexport("request/lib/cookies", "RequestJar");
patcher.unexport("request/lib/cookies", "CookieJar", "LocalJar");
patcher.unexport("request/lib/cookies");
var foo = ["bar"];
// this module adds:
exports["foo"] = foo;
Released under MIT license