Skip to content

Commit

Permalink
chore: add comments about __dirname and glob import
Browse files Browse the repository at this point in the history
  • Loading branch information
haoqunjiang committed Oct 17, 2023
1 parent 63925ea commit 621f0b5
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions utils/getLanguage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<repositoryRoot>/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)
Expand Down

0 comments on commit 621f0b5

Please sign in to comment.