[kbn/optimizer] require fsevents on macos (#67147)

This commit is contained in:
Spencer 2020-05-21 02:20:14 -07:00 committed by GitHub
parent 9e39a13a76
commit ffe7341f27
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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),