Skip to content

Commit

Permalink
feat: be lazier and don't require unless we need to
Browse files Browse the repository at this point in the history
  • Loading branch information
NullVoxPopuli committed Feb 22, 2022
1 parent c91ae10 commit 5f92b4b
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions index.js
@@ -1,25 +1,34 @@
// @ts-check
'use strict';

const { ember } = require('./configs/ember');
const { nodeCJS, nodeESM, nodeMTS } = require('./configs/node');
const { json } = require('./configs/json');
const { configCreator } = require('./utils');

module.exports = {
// by using getters here we don't force projects to install
// dependencies of each of these configs if they are not needed
configs: {
get ember() {
const { ember } = require('./configs/ember');
const { json } = require('./configs/json');

return configCreator(ember, json);
},
get nodeCJS() {
const { nodeCJS } = require('./configs/node');
const { json } = require('./configs/json');

return configCreator(nodeCJS, json);
},
get node() {
const { nodeESM } = require('./configs/node');
const { json } = require('./configs/json');

return configCreator(nodeESM, json);
},
get nodeTS() {
const { nodeESM, nodeMTS } = require('./configs/node');
const { json } = require('./configs/json');

return configCreator(nodeESM, nodeMTS, json);
},
},
Expand Down

0 comments on commit 5f92b4b

Please sign in to comment.