Skip to content

nest does not work in production bundle #361

@max-ae

Description

@max-ae

I am facing the following issue: I have a common dictionary, and would like to reference some keys in smaller dictionaries. See attached code.

This works fine in vite dev server, however, does not work in the production bundle (vite build && vite preview) - the strings do not get rendered.

Common content:

import { type Dictionary, t } from "intlayer";

const commonContent = {
  content: {
    period: {
      daily: t({ de: "Täglich", en: "Daily" }),
      monthly: t({ de: "Monatlich", en: "Monthly" }),
      weekly: t({ de: "Wöchentlich", en: "Weekly" }),
    },
    startPage: t({ de: "Startseite", en: "Start Page" }),
    submit: t({ de: "Absenden", en: "Submit" }),
  },
  key: "common",
} satisfies Dictionary;

export default commonContent;

concrete content:

import { type Dictionary, nest, t } from "intlayer";

const dashboardContent = {
  content: {
      period: nest("common", "period"),
      submit: nest("common", "submit"),
    },
  },
  key: "dashboard",
} satisfies Dictionary;

export default dashboardContent;

usage:

  const dashboard = useIntlayer("dashboard");

What works is this, but this goes against the purpose of the nesting function

import { type Dictionary, nest, t } from "intlayer";
import commonContent from "../content/common.content";

const dashboardContent = {
  content: {
      period: commonContent.content.period,
      submit: commonContent.content.submit,
    },
  },
  key: "dashboard",
} satisfies Dictionary;

export default dashboardContent;

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingbundlingRelated to the way intlayer is bundled on application (Next.js, Vite.js, Nuxt.js, etc)

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions