-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrequire.macro.js
More file actions
32 lines (27 loc) · 895 Bytes
/
require.macro.js
File metadata and controls
32 lines (27 loc) · 895 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const { macroify } = require("./dist/main");
const { paramCase } = require("param-case");
// Function that provides underling macro objects
function macroFactory(opts) {
var importName = opts.importName;
return {
// Default import : can be used to create a storage
// Named imports : can be used to macroify any installed Node module
obj:
importName === "default"
? function (v) {
return v;
}
: require(paramCase(importName)),
// Other options:
allowAssignments: true,
preventOverride: true,
thisConverter: undefined,
};
}
// General macroify settings (console log related)
const macroifyOpts = {
packageName: "macroify/require.macro",
consoleLogs: Boolean(process.env.MACROIFY_LOGS),
};
// macroify/require.macro preset
module.exports = macroify(macroFactory, macroifyOpts);