Skip to content

Commit

Permalink
[7.x] [kbn/optimizer] require fsevents on macos (#67147) (#67158)
Browse files Browse the repository at this point in the history
  • Loading branch information
Spencer authored May 21, 2020
1 parent d705691 commit 69d0875
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 69d0875

Please sign in to comment.