From: Haoqun Jiang Date: Tue, 17 Oct 2023 07:06:17 +0000 (+0800) Subject: chore: add comments about __dirname and glob import X-Git-Tag: v3.8.0~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=621f0b5f3c4dd1f4d886d82f1a13ac18c1519a4e;p=thirdparty%2Fvuejs%2Fcreate-vue.git chore: add comments about __dirname and glob import --- 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)