Skip to content

Commit

Permalink
fix: fsevents integration (#4312)
Browse files Browse the repository at this point in the history
* fix: fsevents integration

* refactor: convert to async function
  • Loading branch information
dnalborczyk committed Dec 22, 2021
1 parent 83af3aa commit 48f0e31
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
5 changes: 4 additions & 1 deletion rollup.config.ts
Expand Up @@ -70,7 +70,10 @@ const nodePlugins = [
json(),
conditionalFsEventsImport(),
string({ include: '**/*.md' }),
commonjs({ include: 'node_modules/**' }),
commonjs({
ignoreTryCatch: false,
include: 'node_modules/**'
}),
typescript()
];

Expand Down
14 changes: 6 additions & 8 deletions src/watch/fsevents-importer.ts
@@ -1,16 +1,14 @@
let fsEvents: unknown;
let fsEventsImportError: Error | undefined;

export function loadFsEvents(): Promise<void> {
export async function loadFsEvents(): Promise<void> {
const moduleName = 'fsevents';

return import(moduleName)
.then(namespace => {
fsEvents = namespace.default;
})
.catch(err => {
fsEventsImportError = err;
});
try {
({ default: fsEvents } = await import(moduleName));
} catch (err: any) {
fsEventsImportError = err;
}
}

// A call to this function will be injected into the chokidar code
Expand Down

0 comments on commit 48f0e31

Please sign in to comment.