Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix dynamic imports for rollup #121

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
155 changes: 119 additions & 36 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,39 +15,122 @@ const format = exports.format = require('./format');
*/
exports.levels = require('./levels');

/*
* @api private
* method {function} exposeFormat
* Exposes a sub-format on the main format object
* as a lazy-loaded getter.
*/
function exposeFormat(name, path) {
path = path || name;
Object.defineProperty(format, name, {
get() {
return require(`./${path}.js`);
},
configurable: true
});
}

//
// Setup all transports as lazy-loaded getters.
//
exposeFormat('align');
exposeFormat('errors');
exposeFormat('cli');
exposeFormat('combine');
exposeFormat('colorize');
exposeFormat('json');
exposeFormat('label');
exposeFormat('logstash');
exposeFormat('metadata');
exposeFormat('ms');
exposeFormat('padLevels', 'pad-levels');
exposeFormat('prettyPrint', 'pretty-print');
exposeFormat('printf');
exposeFormat('simple');
exposeFormat('splat');
exposeFormat('timestamp');
exposeFormat('uncolorize');

Object.defineProperty(format, 'align', {
get() {
return require('./align');
},
configurable: true
});

Object.defineProperty(format, 'errors', {
get() {
return require('./errors');
},
configurable: true
});

Object.defineProperty(format, 'cli', {
get() {
return require('./cli');
},
configurable: true
});

Object.defineProperty(format, 'combine', {
get() {
return require('./combine');
},
configurable: true
});

Object.defineProperty(format, 'colorize', {
get() {
return require('./colorize');
},
configurable: true
});

Object.defineProperty(format, 'json', {
get() {
return require('./json');
},
configurable: true
});

Object.defineProperty(format, 'label', {
get() {
return require('./label');
},
configurable: true
});

Object.defineProperty(format, 'logstash', {
get() {
return require('./logstash');
},
configurable: true
});

Object.defineProperty(format, 'metadata', {
get() {
return require('./metadata');
},
configurable: true
});

Object.defineProperty(format, 'ms', {
get() {
return require('./ms');
},
configurable: true
});

Object.defineProperty(format, 'padLevels', {
get() {
return require('./pad-levels');
},
configurable: true
});

Object.defineProperty(format, 'prettyPrint', {
get() {
return require('./pretty-print');
},
configurable: true
});

Object.defineProperty(format, 'printf', {
get() {
return require('./printf');
},
configurable: true
});

Object.defineProperty(format, 'simple', {
get() {
return require('./simple');
},
configurable: true
});

Object.defineProperty(format, 'splat', {
get() {
return require('./splat');
},
configurable: true
});

Object.defineProperty(format, 'timestamp' ,{
get() {
return require('./timestamp');
},
configurable: true
});

Object.defineProperty(format, 'uncolorize', {
get() {
return require('./uncolorize');
},
configurable: true
});