From 621f0b5f3c4dd1f4d886d82f1a13ac18c1519a4e Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Tue, 17 Oct 2023 15:06:17 +0800 Subject: [PATCH] chore: add comments about __dirname and glob import --- utils/getLanguage.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/utils/getLanguage.ts b/utils/getLanguage.ts index fffccc20..a8b6e5a1 100644 --- a/utils/getLanguage.ts +++ b/utils/getLanguage.ts @@ -57,6 +57,10 @@ function getLocale() { export default function getLanguage() { const locale = getLocale() + + // Note here __dirname would not be transpiled, + // so it refers to the __dirname of the file `/outfile.cjs` + // TODO: use glob import once https://github.com/evanw/esbuild/issues/3320 is fixed const localesRoot = path.resolve(__dirname, 'locales') const languageFilePath = path.resolve(localesRoot, `${locale}.json`) const doesLanguageExist = fs.existsSync(languageFilePath) -- 2.39.5