Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

When getTimings is exposed from rollup output the info. #1685

Merged
merged 3 commits into from
Jan 1, 2021
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/api/export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ async function _export({
queue.addSave(save(message.url, message.status, message.type, message.body));
});

return new Promise((res, rej) => {
return new Promise<void>((res, rej) => {
queue.setCallback('onDone', () => {
proc.kill();
res();
Expand Down
13 changes: 12 additions & 1 deletion src/core/create_compilers/RollupCompiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ const INJECT_STYLES_ID = 'inject_styles.js';

let rollup: any;

function printTimings(timings: {[event: string]: [number, number, number]}) {
for (const [key, info] of Object.entries(timings)) {
console.info(`${key} took ${info[0].toFixed(0)}ms`);
}
}

const inject_styles = `
export default function(files) {
return Promise.all(files.map(function(file) { return new Promise(function(fulfil, reject) {
Expand Down Expand Up @@ -319,7 +325,9 @@ export default class RollupCompiler {
try {
const bundle = await rollup.rollup(config);
await bundle.write(config.output);

if (bundle.getTimings != null) {
printTimings(bundle.getTimings());
}
return new RollupResult(Date.now() - start, this, sourcemap);
} catch (err) {
// flush warnings
Expand Down Expand Up @@ -373,6 +381,9 @@ export default class RollupCompiler {
break;

case 'BUNDLE_END':
if (event.result.getTimings != null) {
printTimings(event.result.getTimings());
}
cb(null, new RollupResult(Date.now() - this._start, this, sourcemap));
break;

Expand Down