From c8eb4adfa43237e42b3153049d0cccee757d9789 Mon Sep 17 00:00:00 2001 From: Jan Amann Date: Tue, 19 Nov 2024 09:16:22 +0100 Subject: [PATCH] fix: Use `fs.watch` instead of `chokidar` --- examples/example-app-router/messages/de.json | 1 - packages/next-intl/package.json | 1 - .../src/plugin/createMessagesDeclaration.tsx | 11 +++++------ pnpm-lock.yaml | 3 --- 4 files changed, 5 insertions(+), 11 deletions(-) diff --git a/examples/example-app-router/messages/de.json b/examples/example-app-router/messages/de.json index 7533cf4eb..b96e77e7c 100644 --- a/examples/example-app-router/messages/de.json +++ b/examples/example-app-router/messages/de.json @@ -15,7 +15,6 @@ "locale": "{locale, select, de {πŸ‡©πŸ‡ͺ Deutsch} en {πŸ‡ΊπŸ‡Έ English} other {Unbekannt}}" }, "Manifest": { - "description": "", "name": "" }, "Navigation": { diff --git a/packages/next-intl/package.json b/packages/next-intl/package.json index 90e13d691..12965a07e 100644 --- a/packages/next-intl/package.json +++ b/packages/next-intl/package.json @@ -111,7 +111,6 @@ ], "dependencies": { "@formatjs/intl-localematcher": "^0.5.4", - "chokidar": "^4.0.1", "negotiator": "^1.0.0", "use-intl": "workspace:^" }, diff --git a/packages/next-intl/src/plugin/createMessagesDeclaration.tsx b/packages/next-intl/src/plugin/createMessagesDeclaration.tsx index fc1162727..eaa7468ca 100644 --- a/packages/next-intl/src/plugin/createMessagesDeclaration.tsx +++ b/packages/next-intl/src/plugin/createMessagesDeclaration.tsx @@ -1,6 +1,5 @@ import fs from 'fs'; import path from 'path'; -import {watch} from 'chokidar'; import {throwError} from './utils.tsx'; function runOnce(fn: () => void) { @@ -44,14 +43,14 @@ export default function createMessagesDeclaration(messagesPath: string) { } function startWatching(messagesPath: string) { - const watcher = watch(messagesPath); - - watcher.on('change', () => { - compileDeclaration(messagesPath, true); + const watcher = fs.watch(messagesPath, (eventType) => { + if (eventType === 'change') { + compileDeclaration(messagesPath, true); + } }); process.on('exit', () => { - void watcher.close(); + watcher.close(); }); } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index acc223139..babc4dc6c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -766,9 +766,6 @@ importers: '@formatjs/intl-localematcher': specifier: ^0.5.4 version: 0.5.5 - chokidar: - specifier: ^4.0.1 - version: 4.0.1 negotiator: specifier: ^1.0.0 version: 1.0.0