[X] This issue is not a question, feature request, RFC, or anything other than a bug report directly related to Gatsby. Please post those things in GitHub Discussions: https://github.com/gatsbyjs/gatsby/discussions
Description
🟢 VALID: import { DISABLED_LOCALE_CODES } from "../constants";
🔴 ERROR (only in gatsby-node file): import { DISABLED_LOCALE_CODES } from "@pkgs-frontend/constants";
Trying to use custom package @pkgs-frontend/constants in pkg-pages/gatsby-node.ts will throw mentioned error. Using the package along the same package pkg-pages but within pages works fine.
import path from "node:path";
import { LOCALES } from "@pkgs-frontend/constants"; // This package would cause the error
import i18nIsoLanguages from "@cospired/i18n-iso-languages";
import i18nIsoCountries from "i18n-iso-countries";
import i18next from "i18next";
import i18nextFsBackend from "i18next-fs-backend";
import type { Actions, GatsbyNode, Page, Reporter } from "gatsby";
import type { Resource } from "i18next";
import type { SetRequired } from "type-fest";
import { REDIRECTS } from "./redirects";
console.log(LOCALES); // <- ReferenceError: Cannot access 'D' before initialization
Preliminary Checks
Description
🟢 VALID:
import { DISABLED_LOCALE_CODES } from "../constants";
🔴 ERROR (only in gatsby-node file):import { DISABLED_LOCALE_CODES } from "@pkgs-frontend/constants";
Trying to use custom package
@pkgs-frontend/constants
in pkg-pages/gatsby-node.ts will throw mentioned error. Using the package along the same packagepkg-pages
but within pages works fine.tsconfig.json of pkgs-frontend constants
Reproduction Link
NA
Steps to Reproduce
Expected Result
Successful build.
Actual Result
Environment
Config Flags
No response