rollup#RollupWatcherEvent TypeScript Examples

The following examples show how to use rollup#RollupWatcherEvent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: buildTask.ts    From Cromwell with MIT License 6 votes vote down vote up
onRollupEventShort = (done?: (success: boolean) => void) => (event: RollupWatcherEvent) => {
    requireDevDeps();
    switch (event.code) {
        case 'ERROR':
            handleError(event.error, true);
            done?.(false);
            break;

        case 'BUNDLE_START':
            stderr('wait  - compiling...');
            break;

        case 'BUNDLE_END':
            break;

        case 'END':
            done?.(true);
    }
}
Example #2
Source File: buildTask.ts    From Cromwell with MIT License 5 votes vote down vote up
onRollupEvent = (done?: (success: boolean) => void) => (event: RollupWatcherEvent) => {
    requireDevDeps();

    let input = (event as any)?.input;
    switch (event.code) {
        case 'ERROR':
            handleError(event.error, true);
            done?.(false);
            break;

        case 'BUNDLE_START':
            if (typeof input !== 'string') {
                input = Array.isArray(input)
                    ? input.join(', ')
                    : Object.keys(input as Record<string, string>)
                        .map(key => (input as Record<string, string>)[key])
                        .join(', ');
            }
            stderr(
                cyan(`bundles ${bold(input)}${bold(event.output.map(relativeId).join(', '))}...`)
            );
            break;

        case 'BUNDLE_END':
            stderr(
                green(
                    `created ${bold(event.output.map(relativeId).join(', '))} in ${bold(
                        ms(event.duration)
                    )}`
                )
            );
            if (event.result && event.result.getTimings) {
                printTimings(event.result.getTimings());
            }
            break;

        case 'END':
            stderr(`\n[${dateTime()}] waiting for changes...`);
            done?.(true);
    }
}