Skip to content

Commit

Permalink
[kbn/optimizer] require fsevents on macos (#67147)
Browse files Browse the repository at this point in the history
  • Loading branch information
Spencer authored and spalger committed May 21, 2020
1 parent f3a6655 commit 2146082
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions packages/kbn-optimizer/src/run_optimizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,26 @@ export type OptimizerUpdate = Update<OptimizerEvent, OptimizerState>;
export type OptimizerUpdate$ = Rx.Observable<OptimizerUpdate>;

export function runOptimizer(config: OptimizerConfig) {
return Rx.defer(async () => ({
startTime: Date.now(),
cacheKey: await getOptimizerCacheKey(config),
})).pipe(
return Rx.defer(async () => {
if (process.platform === 'darwin') {
try {
require.resolve('fsevents');
} catch (error) {
if (error.code === 'MODULE_NOT_FOUND') {
throw new Error(
'`fsevents` module is not installed, most likely because you need to follow the instructions at https://github.com/nodejs/node-gyp/blob/master/macOS_Catalina.md and re-bootstrap Kibana'
);
}

throw error;
}
}

return {
startTime: Date.now(),
cacheKey: await getOptimizerCacheKey(config),
};
}).pipe(
mergeMap(({ startTime, cacheKey }) => {
const bundleCacheEvent$ = getBundleCacheEvent$(config, cacheKey).pipe(
observeOn(Rx.asyncScheduler),
Expand Down

0 comments on commit 2146082

Please sign in to comment.